Reputation: 11
I tried some stuff with TensorFlow and got this error :
ValueError: Input 0 of layer gru is incompatible with the layer: expected ndim=3, found ndim=2. Full shape received: (None, 3)
How can I fix it ?
Upvotes: 1
Views: 212
Reputation:
I could reproduce your issue with sample code. tf.keras.layers.GRU
expects input A 3D tensor, with shape [batch, timesteps, feature]
Reproduced code
import tensorflow as tf
inputs = tf.random.normal([32, 8])
gru = tf.keras.layers.GRU(4)
output = gru(inputs)
print(output.shape)
Output
ValueError: Input 0 of layer gru_1 is incompatible with the layer: expected ndim=3, found ndim=2. Full shape received: (32, 8)
Working sample code
import tensorflow as tf
inputs = tf.random.normal([32, 10, 8])
gru = tf.keras.layers.GRU(4)
output = gru(inputs)
print(output.shape)
Output
(32, 4)
Upvotes: 1