本文整理汇总了Python中blocks.bricks.base.application方法的典型用法代码示例。如果您正苦于以下问题:Python base.application方法的具体用法?Python base.application怎么用?Python base.application使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类blocks.bricks.base
的用法示例。
在下文中一共展示了base.application方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _allocate
# 需要导入模块: from blocks.bricks import base [as 别名]
# 或者: from blocks.bricks.base import application [as 别名]
def _allocate(self):
self.W_state = shared_floatx_nans((self.dim, 4*self.dim),
name='W_state')
self.W_cell_to_in = shared_floatx_nans((self.dim,),
name='W_cell_to_in')
self.W_cell_to_forget = shared_floatx_nans((self.dim,),
name='W_cell_to_forget')
self.W_cell_to_out = shared_floatx_nans((self.dim,),
name='W_cell_to_out')
# The underscore is required to prevent collision with
# the `initial_state` application method
self.initial_state_ = shared_floatx_zeros((self.dim,),
name="initial_state")
self.initial_cells = shared_floatx_zeros((self.dim,),
name="initial_cells")
add_role(self.W_state, WEIGHT)
add_role(self.W_cell_to_in, WEIGHT)
add_role(self.W_cell_to_forget, WEIGHT)
add_role(self.W_cell_to_out, WEIGHT)
add_role(self.initial_state_, INITIAL_STATE)
add_role(self.initial_cells, INITIAL_STATE)
self.parameters = [
self.W_state, self.W_cell_to_in, self.W_cell_to_forget,
self.W_cell_to_out, self.initial_state_, self.initial_cells]
示例2: _allocate
# 需要导入模块: from blocks.bricks import base [as 别名]
# 或者: from blocks.bricks.base import application [as 别名]
def _allocate(self):
self.W_state = shared_floatx_nans((self.dim, 4.5 * self.dim),
name='W_state')
# The underscore is required to prevent collision with
# the `initial_state` application method
self.initial_state_ = shared_floatx_zeros((self.dim,),
name="initial_state")
self.initial_cells = shared_floatx_zeros((self.num_copies, self.dim),
name="initial_cells")
add_role(self.W_state, WEIGHT)
# add_role(self.initial_state_, INITIAL_STATE)
# add_role(self.initial_cells, INITIAL_STATE)
self.parameters = [self.W_state]
示例3: probs
# 需要导入模块: from blocks.bricks import base [as 别名]
# 或者: from blocks.bricks.base import application [as 别名]
def probs(self, readouts):
return self.softmax.apply(readouts, extra_ndim=readouts.ndim - 2)
# Note: the @application decorator inspects the arguments, and transparently adds args ('application_call')
示例4: initial_states
# 需要导入模块: from blocks.bricks import base [as 别名]
# 或者: from blocks.bricks.base import application [as 别名]
def initial_states(self, batch_size, *args, **kwargs):
# TODO: support dict of outputs for application methods
# to simplify this code.
igru_initial_states = self.readout.initial_igru_outputs(batch_size)
if self.igru_depth == 1:
igru_initial_states_dict = {self.igru_states_name[0]: igru_initial_states}
else:
igru_initial_states_dict = {self.igru_states_name[i]: igru_initial_states[i]
for i in range(self.igru_depth)}
initial_outputs = self.readout.initial_outputs(batch_size)
feedback = self.readout.single_feedback(initial_outputs, batch_size)
if self.trg_dgru_depth == 1:
feedback_dict = {self.feedback_name[0]: feedback, 'readout_feedback': feedback}
else:
feedback_dict = {'readout_feedback': feedback[-1]}
feedback_dict.update({self.feedback_name[i]: feedback[i] for i in range(self.trg_dgru_depth)})
state_dict = dict(
self.transition.initial_states(
batch_size, as_dict=True, *args, **kwargs),
outputs=initial_outputs)
state_dict.update(feedback_dict)
state_dict.update(igru_initial_states_dict)
return [state_dict[state_name]
for state_name in self.generate.states]