首页 新闻 会员 周边

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

0
悬赏园豆:20 [待解决问题]

代码是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表示计算出的概率最大的词的概率值)代码应该是怎样的?

小白努力码代码的主页 小白努力码代码 | 初学一级 | 园豆:155
提问于:2018-08-07 08:42
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册