关于RNN(LSTM)的代码有点地方不明白

weixin_38097791 2018-08-07 08:42:26
代码是tensorflow的,lstm model, 想问问这一段的output和logits到底是什么?是指生成一个词的概率还是生成一个句子中所有词的概率? outputs = [] state = self._initial_state with tf.variable_scope("RNN"): for time_step in range(num_steps): if time_step > 0: tf.get_variable_scope().reuse_variables() (cell_output, state) = cell(inputs[:, time_step, :], state) #inputs[:, time_step, :]的shape是(batch_size, size) outputs.append(cell_output) output = tf.reshape(tf.concat(outputs, 1), [-1, size]) softmax_w = tf.get_variable("softmax_w", [size, vocab_size]) softmax_b = tf.get_variable("softmax_b", [vocab_size]) logits = tf.matmul(output, softmax_w) + softmax_b self._final_state = state mean_absolute_error(output, tf.reshape(self._targets, [-1])) if not is_training: self._prob = tf.nn.softmax(logits) return   还有就是,如果我想要一个predict list=[p1,p2,p3,...](pi表示计算出的概率最大的词的概率值)代码应该是怎样的?
...全文
28 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

476

社区成员

发帖
与我相关
我的任务
社区描述
其他技术讨论专区
其他 技术论坛(原bbs)
社区管理员
  • 其他技术讨论专区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧