title: How to use sentence vectors from doc2vec in keras Sequntial model for sentence sentiment analysis?
body: <p>Creating doc2vec model</p>
  
  <p>x:List of Sentences(Movie reviews)</p>
  
  <p>length of x =2000</p>
  
  <pre><code>doc2vec_data = []
  for line in x:
  temp = ''.join(str(token) for token in line.lower())
  doc2vec_data.append(temp)
  
  File = open('doc2vec_data.txt', 'w',encoding="utf-8") 
  for item in doc2vec_data:
  File.write("%s\n" % item)
  
  sentences=gensim.models.doc2vec.TaggedLineDocument("doc2vec_data.txt")
  
  d2v =gensim.models.Doc2Vec(sentences, dm=0,window = 5, 
                     size=5,
                     iter = 100, workers=32,dbow_words=1,
                     alpha=2,min_aplha=0.5)
  </code></pre>
  
  <p>Creating Numpy array of vectors:
  as doc2vec model cant be directly used in keras sequential model.</p>
  
  <pre><code>vec=np.array([d2v.infer_vector(item) for item in x])
  </code></pre>
  
  <p>Keras Sequential Model:</p>
  
  <pre><code>model=Sequential()
  model.add(Embedding(2000,128,input_length=vec.shape[1]))
  model.add(LSTM(200,dropout=0.2,recurrent_dropout=0.2))
  model.add(Dense(1,activation='sigmoid'))
  
  model.compile(loss='binary_crossentropy',
        optimizer='rmsprop',
        metrics=['accuracy'])
  </code></pre>
  
  <p>y:sentence labels (0 and 1)</p>
  
  <pre><code>model.fit(vec,y,
    batch_size=32,epochs=8,
    verbose=1)
  </code></pre>
  
  <p>Above code is giving me this error-</p>
  
  <pre><code>InvalidArgumentError                      Traceback (most recent call last)
  ~\Anaconda3\lib\site-packages\tensorflow\python\client\session.py in 
  _do_call(self, fn, *args)
  1349     try:
  -&gt; 1350       return fn(*args)
  1351     except errors.OpError as e:
  
  ~\Anaconda3\lib\site-packages\tensorflow\python\client\session.py in 
  _run_fn(session, feed_dict, fetch_list, target_list, options, run_metadata)
   1328                                    feed_dict, fetch_list, target_list,
  -&gt; 1329                                    status, run_metadata)
   1330 
  
  ~\Anaconda3\lib\site-packages\tensorflow\python\framework\errors_impl.py in 
  __exit__(self, type_arg, value_arg, traceback_arg)
  472             compat.as_text(c_api.TF_Message(self.status.status)),  
  --&gt; 473             c_api.TF_GetCode(self.status.status))
  474     # Delete the underlying status object from memory otherwise it 
  stays alive
  
  InvalidArgumentError: indices[0,0] = -19 is not in [0, 2000)
   [[Node: embedding_1/Gather = Gather[Tindices=DT_INT32, Tparams=DT_FLOAT, 
  validate_indices=true, 
  _device="/job:localhost/replica:0/task:0/device:CPU:0"] 
  (embedding_1/embeddings/read, embedding_1/Cast)]]
  
  During handling of the above exception, another exception occurred:
  
  InvalidArgumentError                      Traceback (most recent call last)
  &lt;ipython-input-34-3d0fc0b22a78&gt; in &lt;module&gt;()
   1 model.fit(vec,y,
    2          batch_size=32,epochs=8,
  ----&gt; 3          verbose=1) 
  
  InvalidArgumentError: indices[0,0] = -19 is not in [0, 2000)
   [[Node: embedding_1/Gather = Gather[Tindices=DT_INT32, Tparams=DT_FLOAT, 
  validate_indices=true, 
  _device="/job:localhost/replica:0/task:0/device:CPU:0"] 
  (embedding_1/embeddings/read, embedding_1/Cast)]]
  </code></pre>
  
  <p>Could someone please tell me what's the error and how do i solve it ?</p>