title: Predicting next word using the language model tensorflow example
body: <p>The <a href="http://tensorflow.org/tutorials/recurrent/index.md#language_modeling" rel="noreferrer">tensorflow tutorial</a> on language model allows  to compute the probability of sentences :</p>
  
  <pre><code>probabilities = tf.nn.softmax(logits)
  </code></pre>
  
  <p>in the comments below it also specifies a way of predicting the next word instead of probabilities but does not specify how this can be done. So how to output a word instead of probability using this example?</p>
  
  <pre><code>lstm = rnn_cell.BasicLSTMCell(lstm_size)
  # Initial state of the LSTM memory.
  state = tf.zeros([batch_size, lstm.state_size])
  
  loss = 0.0
  for current_batch_of_words in words_in_dataset:
      # The value of state is updated after processing each batch of words.
      output, state = lstm(current_batch_of_words, state)
  
      # The LSTM output can be used to make next word predictions
      logits = tf.matmul(output, softmax_w) + softmax_b
      probabilities = tf.nn.softmax(logits)
      loss += loss_function(probabilities, target_words)
  </code></pre>