关于RNN(LSTM)的代码有点地方不明白
代码是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表示计算出的概率最大的词的概率值)代码应该是怎样的?