Trying to create a generator for a LSTM and am running into an error during the.fit_generator(), after I run it the error is
ValueError: Error when checking input: expected lstm_3_input to have 3 dimensions, but got array with shape (1, 5)
and I'm not really sure how to reshape the data when it is in a generator.
n_features=1
series=train_temp.reshape((len(train_temp),n_features))
generator=TimeseriesGenerator(train_temp,train_temp,length=5,batch_size=1)
model = Sequential()
model.add( LSTM(200, activation='relu', input_shape=(5, 1)))
model.add(Dense(1))
model.compile(optimizer='adam', loss='mse')
model.fit_generator(generator, epochs=90,steps_per_epoch=2)
Try printing the shape of input vectors being generated by TimeseriesGenerator
and compare it with input shape of your LSTM layer
. Looking at the exception i guess your input shape should be (5, ) and not (5, 1)
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.