seq2seq_solution.py 文件源码

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

项目:deep_learning 作者: wecliqued 项目源码 文件源码
def _create_model(self):
        depth = len(self.vocab)+1
        self._create_rnn()
        with tf.name_scope('loss'):
            self.logits = tf.contrib.layers.fully_connected(inputs=self.output, num_outputs=depth, activation_fn=None)
            self.labels = tf.one_hot(self.seq, depth=depth)
            self.loss = tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits(labels=self.labels[:, 1:], logits=self.logits[:, :-1]), name='loss')
        with tf.name_scope('sample'):
            self.sample = tf.multinomial(self.logits[:, -1] / self.temp, 1)[:, 0]
        return self.loss, self.sample, self.in_state, self.out_state
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号