I have a problem with the connection between the convolution layer and the lstm layer. The data is in the form (75.5), where there are 75 time points x5 data points for each time step. I want to do a convolution on (75x5), get new collapsed (75x5) data and transfer this data to the lstm layer. However, this does not work, because the output form of the convolution layer has a number of filters that I do not need. And therefore, the output form of the convolution layer is (1.75.5), and the input signal required for the lstm layer is (75.5). How can I take the first filter.
model = Sequential() model.add(Convolution2D(1, 5,5,border_mode='same',input_shape=(1,75, 5))) model.add(Activation('relu')) model.add(LSTM(75, return_sequences=False, input_shape=(75, 5))) model.add(Dropout(0.5)) model.add(Dense(1)) model.compile(loss='mse', optimizer='rmsprop')
And here is this error:
File "/usr/local/lib/python3.4/dist-packages/keras/layers/recurrent.py", line 378, in __init__ super(LSTM, self).__init__(**kwargs) File "/usr/local/lib/python3.4/dist-packages/keras/layers/recurrent.py", line 97, in __init__ super(Recurrent, self).__init__(**kwargs) File "/usr/local/lib/python3.4/dist-packages/keras/layers/core.py", line 43, in __init__ self.set_input_shape((None,) + tuple(kwargs['input_shape'])) File "/usr/local/lib/python3.4/dist-packages/keras/layers/core.py", line 138, in set_input_shape ', was provided with input shape ' + str(input_shape)) Exception: Invalid input shape - Layer expects input ndim=3, was provided with input shape (None, 1, 75, 5)