Answer the question
In order to leave comments, you need to log in
What is the reason for the InvalidArgumentError when adding an LSTM layer?
When adding an LSTM layer to a Keras model, an error occurs:
Traceback (most recent call last):
File "/opt/keras-query-classifier/venv_cpu/lib/python3.8/site-packages/tensorflow/python/framework/ops .py", line 1880, in _create_c_op
c_op = pywrap_tf_session.TF_FinishOperation(op_desc)
tensorflow.python.framework.errors_impl.InvalidArgumentError: Shape must be at least rank 3 but is rank 2 for '{{node BiasAdd}} = BiasAdd[T =DT_FLOAT, data_format="NCHW"](add, bias)' with input shapes: [?,80], [80].
until yesterday it was not, it is observed only on one machine.
here is the code:
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import LSTM, Dense, Activation, Dropout,
from tensorflow.keras.layers import Conv1D
from tensorflow.keras.layers import MaxPooling1D
model = Sequential()
model.add(Embedding(1000, 100, input_length=10))
model.add(Conv1D(filters=100, kernel_size=2, padding='same', activation='relu'))
model.add(Conv1D(filters=100, kernel_size=2, padding='same', activation='relu'))
model.add(MaxPooling1D(pool_size=2) )
model.add(LSTM(20))
Changing environment doesn't help.
Tell me vector, where to look for the problem?
Answer the question
In order to leave comments, you need to log in
In most cases, this error occurs when there are collisions between libraries.
Solution not found. As an option for yourself for the future - back up
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question