title: pre-trained Word2Vec with LSTM, predict next word in sentence
body: <p>I have a corpus of text. For a preprocessing data I've vectorized all text using gensim Word2Vec.
  I don't understand what I do exactly wrong. For the base I've took this discussion (and good tutorial) <a href="https://stackoverflow.com/questions/42064690/using-pre-trained-word2vec-with-lstm-for-word-generation">predict next word</a>. Code: <a href="https://gist.github.com/maxim5/c35ef2238ae708ccb0e55624e9e0252b" rel="nofollow noreferrer">Source code</a>.</p>
  
  <p>As input I have lines of sentences. I want to take each line, then take word[0] of this line -> predict word[1 ]. Then using word[0] and word[1 ] predict word[3], and so on to the end of line.</p>
  
  <p>In this tutorial each time predicts fix length of words.
  What I do:</p>
  
  <pre><code>def on_epoch_end(epoch, _):
      print('\nGenerating text after epoch: %d' % epoch)
      for sentence in inpt:
          word_first=sentence.split()[0]
          sample = generate_next(word_first, len(sentence))
          print('%s... -&gt; %s' % (word_first, sample))
  </code></pre>
  
  <p>I take first word and use it to generate all next. And as second parameter I give length of sentence (not <code>num_generated=10</code>) as in tutorial. But it doesn't help for me at all. Every time I'm getting output predicted sequence of words with random(in my opinion) length.</p>
  
  <p>What am I doing wrong and how to fix it?</p>