trying to train LSTM model with (5,xxx) data stream fe
(5, 17516)
array([[ 3820., 2873., 2369., ..., 18865., 16893., 14242.],
[ 4656., 3820., 2873., ..., 19967., 18865., 16893.],
[ 6210., 4656., 3820., ..., 20223., 19967., 18865.],
[ 8127., 6210., 4656., ..., 20319., 20223., 19967.],
[10844., 8127., 6210., ..., 17246., 20319., 20223.]])
here is the model :
def lstm_model(self, window=5):
self.model = Sequential()
self.model.add(LSTM(4, input_shape=( window, 1)))
self.model.add(Dense(1))
self.model.compile(loss='mean_squared_error', optimizer='adam')
return self.model
here is the fit :
self.history = self.model.fit(
windowed_data , self.data.data,
validation_split=0.2, nb_epoch=55, batch_size=10, verbose=1)
here is the error I'm getting :
ValueError: Error when checking input: expected lstm_6_input to have 3 dimensions, but got array with shape (5, 17516)
What I'm doing wrong ?
This seems to solve it.
w.reshape(w.shape[0], w.shape[1],1)
according to keras docs the input data should be a 3d tensor ie (nb_samples, timesteps, input_dim). this is a good tutorial on how to reshape your data for lstm models.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.