Rahul Jaikrishna
Rahul Jaikrishna

Reputation: 25

Error while running a CNN-LSTM model: ValueError: Input 0 of layer lstm_13 is incompatible with the layer: expected ndim=3

I am receiving an error while running the below code:

model = tf.keras.Sequential([
    tf.keras.layers.Embedding(vocab_size, embedding_dim, input_length=max_length),
    tf.keras.layers.Conv1D(128, 5, activation='relu'),
    tf.keras.layers.GlobalAveragePooling1D(),
    tf.keras.layers.LSTM(32),
    tf.keras.layers.Dense(6, activation='relu'),
    tf.keras.layers.Dense(2, activation='sigmoid')
   ])

Error:

ValueError: Input 0 of layer lstm_13 is incompatible with the layer: expected ndim=3, found ndim=2. Full shape received: [None, 128]

Upvotes: 0

Views: 179

Answers (1)

Marco Cerliani
Marco Cerliani

Reputation: 22031

change tf.keras.layers.GlobalAveragePooling1D() with tf.keras.layers.AveragePooling1D()

Upvotes: 1

Related Questions