I'm trying to create a model for a two layer SimpleRNN model using Keras library in Python. I don't really understand how the keras model layers work, so I don't quite understand how to get the result I want or how to fix the error I'm receiving.
The first SimpleRNN layer needs to be 64 dimensions and output the state sequence, whereas the second one has to have the 64 dimensions and output the final state.
I currently have:
import tensorflow.keras.models as models
import tensorflow.keras.layers as layers
model_simple_rnn = models.Sequential([
layers.Embedding(100,64, name='embedding'),
layers.SimpleRNN(64, name='simpleRNN1'),
layers.SimpleRNN(64, name='simpleRNN2'),
layers.Dense(1, activation='sigmoid', name='dense'),
], name='SIMPLERNN')
I'm getting the following error:
ValueError: Input 0 of layer simple_rnn_1 is incompatible with the layer: expected ndim=3, found ndim=2. Full shape received: (None, 64)
I need to have the following output:
Model: "SIMPLERNN"
_________________________________________________________________
Layer (type) Output Shape Param #
=================================================================
embedding (Embedding) (None, None, 100) 1000000
_________________________________________________________________
simpleRNN1 (SimpleRNN) (None, None, 64) 10560
_________________________________________________________________
simpleRNN2 (SimpleRNN) (None, 64) 8256
_________________________________________________________________
dense (Dense) (None, 1) 65
=================================================================
Total params: 1,018,881
Trainable params: 1,018,881
Non-trainable params: 0