本文整理匯總了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]