Этот ответ основан на ответе SimonC.Вы можете добавить слой Flatten.В зависимости от вашей цели, он может иметь различные способы
def model():
model = Sequential()
model.add(Dense(128, input_shape = (LSTM_WINDOW_SIZE,1)))
model.add(LSTM(units=5,
return_sequences=True))
model.add(Dense(1, activation = 'linear'))
model.add(Flatten())
model.add(Dense(1))
return model
LSTM_WINDOW_SIZE = 5
model3 = model()
model3.summary()
или (переместить слой Flatten
перед слоем Dense
)
def model():
model = Sequential()
model.add(Dense(128, input_shape = (LSTM_WINDOW_SIZE,1)))
model.add(LSTM(units=5,
return_sequences=True))
model.add(Flatten())
model.add(Dense(1, activation = 'linear'))
model.add(Dense(1)) # redundant for this model, just for illustration
return model
LSTM_WINDOW_SIZE = 5
model3 = model()
model3.summary()