title: InvalidArgumentError: indices[0,0] = -1 is not in [0, 10)
body: <p>It worked well with MLP for binary classification. In LSTM and in convolution however it gives the <code>InvalidArgumentError</code>. </p>
  
  <p>I found that y needs to be reshaped and I did it.
  I tried x with all positive values, and model worked well.
  So what is the problem with negative values?
  The data is given in the code. Any ideas?</p>
  
  <p>The error is like:</p>
  
  <pre><code>---------------------------------------------------------------------------
  InvalidArgumentError                      Traceback (most recent call last)
  /usr/local/src/conda3_runtime/home/envs/DSX-Python35-Spark/lib/python3.5/site-packages/tensorflow/python/client/session.py in _do_call(self, fn, *args)
     1326     try:
  -&gt; 1327       return fn(*args)
     1328     except errors.OpError as e:
  ....
  File "/usr/local/src/conda3_runtime/home/envs/DSX-Python35-Spark/lib/python3.5/site-packages/tensorflow/python/framework/ops.py", line 1204, in __init__
      self._traceback = self._graph._extract_stack()  # pylint: disable=protected-access
  
  InvalidArgumentError (see above for traceback): indices[0,0] = -1 is not in [0, 10)
       [[Node: embedding_11/Gather = Gather[Tindices=DT_INT32, Tparams=DT_FLOAT, validate_indices=true, _device="/job:localhost/replica:0/task:0/cpu:0"](embedding_11/embeddings/read, _arg_embedding_11_input_0_3)]]
  </code></pre>
  
  <p>Code:</p>
  
  <pre><code>from keras.models import Sequential
  from keras.layers import Dense, Embedding
  from keras.layers import LSTM
  
  max_features=10
  maxlen=4
  embedding_size=4
  lstm_output_size = 1
  batch_size = 2
  epochs = 2
  
  x=([[ 0,  6,  1,  0],
         [-1,  0,  0,  1],
         [ 4, -4,  3,  0],
         [-1,  9,  1, -5],
         [-2,  0,  0,  0],
         [ 2,  0,  4,  1],
         [ 4, 10, -4, -4],
         [ 0, 10, -1, -4],
         [ 3, -2,  2,  1],
         [ 0, -1,  0,  0]])
  
  y=([[0, 1, 0, 0, 1, 0, 0, 0, 0, 1]])
  
  x, y = np.array(x), np.array(y)
  y = y.reshape((10, 1))
  
  from sklearn.model_selection import train_test_split
  x_train, x_test, y_train, y_test = train_test_split(x, y, test_size=0.2)
  
  
  print('Build model...')
  model = Sequential()
  model.add(Embedding(max_features, 64, input_length = maxlen ))
  model.add(LSTM(64, activation="sigmoid", return_sequences=True, recurrent_activation="hard_sigmoid"))
  model.add(Dropout(0.25))
  model.add(LSTM(lstm_output_size))
  model.add(Dense(1, activation='sigmoid'))
  
  model.compile(loss='binary_crossentropy',
                optimizer='adam',
                metrics=['accuracy'])
  
  print('Train...')
  model.fit(x_train, y_train,
            batch_size=batch_size,
            epochs=epochs,
            validation_data=(x_test, y_test))
  score, acc = model.evaluate(x_test, y_test,
                              batch_size=batch_size)
  
  print('Test score:', score)
  print('Test accuracy:', acc)
  </code></pre>