seq2seq.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:deep_learning 作者: wecliqued 项目源码 文件源码
def _create_cell(self, seq, no_stacked_cells):
        """
        Creates GRU cell
        :param seq: placeholder of the input batch
        :return: cell and placeholder for its internal state
        """
        batch_size = tf.shape(seq)[0]

        ##########################################################################################################
        #
        # TODO: Create a stacked MultiRNNCell from GRU cells
        #       First, you have to use tf.contrib.rnn.GRUCell() to construct cells
        #       Since around May 2017, there is new way of constructing MultiRNNCell and you need to create
        #       one cell for each layer. Old code snippets that used [cell * no_stacked_cells] that you can
        #       find online might not work with the latest Tensorflow
        #
        #       After construction GRUCell objects, use it to construct tf.contrib.rnn.MultiRNNCell().
        #
        # YOUR CODE BEGIN
        #
        ##########################################################################################################

        cell = None # you

        ##########################################################################################################
        #
        # YOUR CODE END
        #
        ##########################################################################################################

        multi_cell_zero_state = cell.zero_state(batch_size, tf.float32)
        in_state_shape = tuple([None, self.hidden_size] for _ in range(no_stacked_cells))
        in_state = tuple(tf.placeholder_with_default(cell_zero_state, [None, self.hidden_size], name='in_state') for cell_zero_state in multi_cell_zero_state)

        return cell, in_state
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号