當前位置: 首頁>>代碼示例>>Python>>正文


Python utils.shared_floatx_zeros方法代碼示例

本文整理匯總了Python中blocks.utils.shared_floatx_zeros方法的典型用法代碼示例。如果您正苦於以下問題:Python utils.shared_floatx_zeros方法的具體用法?Python utils.shared_floatx_zeros怎麽用?Python utils.shared_floatx_zeros使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在blocks.utils的用法示例。


在下文中一共展示了utils.shared_floatx_zeros方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _allocate

# 需要導入模塊: from blocks import utils [as 別名]
# 或者: from blocks.utils import shared_floatx_zeros [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] 
開發者ID:tombosc,項目名稱:dict_based_learning,代碼行數:27,代碼來源:stuff.py

示例2: initial_states

# 需要導入模塊: from blocks import utils [as 別名]
# 或者: from blocks.utils import shared_floatx_zeros [as 別名]
def initial_states(self, batch_size):
        initial_h1 = self.rnn1.initial_states(batch_size)
        initial_h2 = self.rnn2.initial_states(batch_size)
        initial_h3 = self.rnn3.initial_states(batch_size)

        last_h1 = shared_floatx_zeros((batch_size, self.rnn_h_dim))
        last_h2 = shared_floatx_zeros((batch_size, self.rnn_h_dim))
        last_h3 = shared_floatx_zeros((batch_size, self.rnn_h_dim))

        # Defining for all
        initial_k = tensor.zeros(
            (batch_size, self.attention_size), dtype=floatX)
        last_k = shared_floatx_zeros((batch_size, self.attention_size))

        # Trainable initial state for w. Why not for k?
        initial_w = tensor.repeat(self.initial_w[None, :], batch_size, 0)

        last_w = shared_floatx_zeros((batch_size, self.encoded_input_dim))

        return initial_h1, last_h1, initial_h2, last_h2, initial_h3, last_h3, \
            initial_w, last_w, initial_k, last_k 
開發者ID:fizerkhan,項目名稱:mimicry.ai,代碼行數:23,代碼來源:model.py

示例3: _allocate

# 需要導入模塊: from blocks import utils [as 別名]
# 或者: from blocks.utils import shared_floatx_zeros [as 別名]
def _allocate(self):
        """In addition to the GRU parameters ``state_to_state`` and 
        ``state_to_gates``, add the initial state if the search
        strategy is "constant".
        """
        self.parameters.append(shared_floatx_nans((self.dim, self.dim),
                               name='state_to_state'))
        self.parameters.append(shared_floatx_nans((self.dim, 2 * self.dim),
                               name='state_to_gates'))
        for i in range(2):
            if self.parameters[i]:
                add_role(self.parameters[i], WEIGHT)
        if self.init_strategy == 'constant':
            self.parameters.append(shared_floatx_zeros((self.dim,),
                                                       name="initial_state"))
            add_role(self.parameters[2], INITIAL_STATE) 
開發者ID:ucam-smt,項目名稱:sgnmt,代碼行數:18,代碼來源:decoder.py

示例4: _allocate

# 需要導入模塊: from blocks import utils [as 別名]
# 或者: from blocks.utils import shared_floatx_zeros [as 別名]
def _allocate(self):
        self.W_ss = shared_floatx_nans((self.dim, 4*self.dim), name='W_ss')
        self.W_is = shared_floatx_nans((self.dim,), name='W_is')
        # The underscore is required to prevent collision with
        # the `initial_state` application method
        self.initial_state_ = shared_floatx_zeros((self.dim,),
                                                  name="initial_state")
        add_role(self.W_ss, WEIGHT)
        add_role(self.W_is, WEIGHT)
        add_role(self.initial_state_, INITIAL_STATE)

        self.parameters = [
            self.W_ss, self.W_is, self.initial_state_] 
開發者ID:aalitaiga,項目名稱:Generative-models,代碼行數:15,代碼來源:pixelRNN.py

示例5: _allocate

# 需要導入模塊: from blocks import utils [as 別名]
# 或者: from blocks.utils import shared_floatx_zeros [as 別名]
def _allocate(self):
        self.initial_w = shared_floatx_zeros(
            (self.encoded_input_dim,), name="initial_w")

        add_role(self.initial_w, INITIAL_STATE) 
開發者ID:fizerkhan,項目名稱:mimicry.ai,代碼行數:7,代碼來源:model.py

示例6: _allocate

# 需要導入模塊: from blocks import utils [as 別名]
# 或者: from blocks.utils import shared_floatx_zeros [as 別名]
def _allocate(self):
        self.params.append(shared_floatx_nans((self.dim, self.dim),
                           name='state_to_state'))
        self.params.append(shared_floatx_nans((self.dim, 2 * self.dim),
                           name='state_to_gates'))
        self.params.append(shared_floatx_zeros((self.dim,),
                           name="initial_state"))
        for i in range(2):
            if self.params[i]:
                add_role(self.params[i], WEIGHT)
        add_role(self.params[2], INITIAL_STATE) 
開發者ID:jiangnanhugo,項目名稱:lmkit,代碼行數:13,代碼來源:bricks.py

示例7: _allocate

# 需要導入模塊: from blocks import utils [as 別名]
# 或者: from blocks.utils import shared_floatx_zeros [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] 
開發者ID:mohammadpz,項目名稱:Associative_LSTM,代碼行數:16,代碼來源:bricks.py

示例8: _allocate

# 需要導入模塊: from blocks import utils [as 別名]
# 或者: from blocks.utils import shared_floatx_zeros [as 別名]
def _allocate(self):
        self.initial_w = shared_floatx_zeros(
            (self.num_letters,), name="initial_w")

        add_role(self.initial_w, INITIAL_STATE) 
開發者ID:sotelo,項目名稱:scribe,代碼行數:7,代碼來源:model.py

示例9: initial_states

# 需要導入模塊: from blocks import utils [as 別名]
# 或者: from blocks.utils import shared_floatx_zeros [as 別名]
def initial_states(self, batch_size):
        initial_h1 = self.cell1.initial_states(batch_size)
        initial_kappa = shared_floatx_zeros((batch_size, self.att_size))
        initial_w = tensor.repeat(self.initial_w[None, :], batch_size, 0)
        last_h1 = shared_floatx_zeros((batch_size, self.rec_h_dim))
        last_w = shared_floatx_zeros((batch_size, self.num_letters))
        use_last_states = shared(numpy.asarray(0., dtype=floatX))

        return initial_h1, initial_kappa, initial_w, \
            last_h1, last_w, use_last_states 
開發者ID:sotelo,項目名稱:scribe,代碼行數:12,代碼來源:model.py

示例10: compile

# 需要導入模塊: from blocks import utils [as 別名]
# 或者: from blocks.utils import shared_floatx_zeros [as 別名]
def compile(self):
        """Do not add any more tasks after this function is called.
        Compiles the state update and logprobs theano functions for
        this bucket.
        """
        self.n_tasks = len(self.tasks)
        self.n_finished = 0
        self.all_attended = shared_floatx_zeros((1, 1, 1))
        self.all_masks = shared_floatx_zeros((1, 1))
        self.src_indices = T.ivector()
        givens = self._construct_givens()
        self._compile_next_state_computer(givens)
        self._compile_logprobs_computer(givens) 
開發者ID:ucam-smt,項目名稱:sgnmt,代碼行數:15,代碼來源:batch_decode.py

示例11: _push_allocation_config

# 需要導入模塊: from blocks import utils [as 別名]
# 或者: from blocks.utils import shared_floatx_zeros [as 別名]
def _push_allocation_config(self):
        """Sets the dimensions of rnn inputs. """
        self.rnn_inputs = {name: shared_floatx_zeros(
                                            self.transition.get_dim(name))
                              for name in self.transition.apply.sequences 
                              if name != 'mask'} 
開發者ID:ucam-smt,項目名稱:sgnmt,代碼行數:8,代碼來源:encoder.py


注:本文中的blocks.utils.shared_floatx_zeros方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。