I am new to Keras and I am trying to train an LSTM network with the following parameters, however, I get the following error
InvalidArgumentError: indices[120,2] = -1 is not in [0, 10)
[[node sequential_3/embedding_3/embedding_lookup (defined at <ipython-input-65-50ea16cb11fb>:5) ]] [Op:__inference_train_function_13886]
Errors may have originated from an input operation.
Input Source operations connected to node sequential_3/embedding_3/embedding_lookup:
sequential_3/embedding_3/embedding_lookup/12643 (defined at /home/jpandeinge/anaconda3/lib/python3.7/contextlib.py:112)
Function call stack:
train_function
Here is a snippet of my code;
# The next step is to split training and testing data. For this we will use sklearn function train_test_split().
features_train, features_test, labels_train, labels_test = train_test_split(features, labels, test_size=0.2)
# features and labels shape
features_train.shape, features_test.shape, labels_train.shape, labels_test.shape
((180568, 82), (45143, 82), (180568,), (45143,))
model = Sequential()
model.add(Embedding(10, 82, input_length=180568))
model.add(LSTM(10, return_sequences=True, input_shape=features_train))
model.add(Activation('sigmoid'))
model.add(Dropout(0.2))
model.build()
model.compile(loss = 'binary_crossentropy', optimizer='adam', metrics = ['accuracy'])
model.summary()
Model: "sequential_3"
_________________________________________________________________
Layer (type) Output Shape Param #
=================================================================
embedding_3 (Embedding) (None, 180568, 82) 820
_________________________________________________________________
lstm_3 (LSTM) (None, 180568, 10) 3720
_________________________________________________________________
activation_3 (Activation) (None, 180568, 10) 0
_________________________________________________________________
dropout_3 (Dropout) (None, 180568, 10) 0
=================================================================
Total params: 4,540
Trainable params: 4,540
Non-trainable params: 0
________________________
history = model.fit(features_train,
labels_train,
epochs=10,
batch_size=128)