How to input flattened layer into LSTM or GRU

3,390 views
Skip to first unread message

CD

unread,
Apr 22, 2016, 3:46:55 PM4/22/16
to Keras-users
I have a working model with some convolutional (et al) layers. I am flattening (Flatten layer) and feeding to a fully connected (Dense) layer. I would now like to feed the flattened layer into an LSTM or GRU, but the dimensions are wrong resulting in:

Exception: Input 0 is incompatible with layer lstm_1: expected ndim=3, found ndim=2

I know the input shape for the LSTM wants a different ordering (i.e. to include the time dimension). 

I am not clear on how to reshape the data to pipe into the LSTM successfully from my Dense or Flatten layer.

Thanks in advance for any help,
CD


p.nec...@gmail.com

unread,
Apr 25, 2016, 8:02:46 AM4/25/16
to Keras-users
Doesn't reshape(1,dim) work?
http://keras.io/layers/core/#reshape

CD

unread,
Apr 26, 2016, 11:25:17 AM4/26/16
to Keras-users
Thanks
That did it
.. "duh" comes to mind...
Reply all
Reply to author
Forward
0 new messages