In a paper, it mentioned: ANN, RNN, and LSTM NN are optimized to contain three hidden layers with 1000 hidden units in each layer.

I would like to model the RNN model in Keras. But my code fails in an error!

My code:



    ValueError                                Traceback (most recent call last)
<ipython-input-49-ff01ce62eb30> in <module>()
      1 model=Sequential()
      2 model.add(SimpleRNN(1000,input_shape=(320,15),activation='relu'))
----> 3 model.add(SimpleRNN(1000))
      4 model.add(SimpleRNN(1000))
      5 model.add(Dense(1600))

ValueError: Input 0 is incompatible with layer simple_rnn_2: expected ndim=3, found ndim=2

How can I code for the RNN model which is optimized to contain three hidden layers with 1000 hidden units in each layer?

Thank you so much


The shape should be 3d array --> (samples, timesteps, features)

It needs to add return_sequences=True in first two RNN layers.

model.add(SimpleRNN(1000,input_shape=(1,320*15),activation='relu', return_sequences=True))
model.add(SimpleRNN(1000, return_sequences=True))
  • $\begingroup$ Why the input_shape is (1,320*15)? If he had 320 timesteps with 15 feature it should be (320,15). $\endgroup$ Oct 2 '18 at 10:00
  • $\begingroup$ It contains 1 timestep and 320*15 features. $\endgroup$ Oct 3 '18 at 11:46
  • 1
    $\begingroup$ Wouldn't it be better if data was window-like? Where each timestep(row) has 15 features. This way the RNN will slide over timesteps. If the data is (1,320*15) there will be no sliding. It's literally as you said: "The shape should be 3d array --> (samples, timesteps, features)" $\endgroup$ Oct 3 '18 at 12:41
  • $\begingroup$ 320 is very large. Is it agreeable as the time step? It is an advantageous point. Thank you! $\endgroup$ Oct 4 '18 at 9:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.