I'm using LSTM (python/tensorflow) to build a model. We have a time sequence of the input X_train in shape of (, 8). The output is a single value. The model performs very well by setting return_sequence=False.
lstm_model = tf.keras.models.Sequential([
tf.keras.layers.LSTM(32, return_sequences=False,input_shape=(None, 8)),
tf.keras.layers.Dense(1)])
lstm_model.compile(loss="mean_squared_error", optimizer='adam')
history = lstm_model.fit(X_train, y_train, epochs=100,validation_data=(X_valid, y_valid))
However, I want to output a sequence to speed up the predictions. If I set return_sequence=True, the model always predict the mean value of y_train.
Can anyone tell me what's the problem? How to make the model behave as well as in the case of only predicting the last time step?
I tried to set return_sequence=True, and was expecting the model predicts good resuts (at least after a few timesteps) just like in the case wheren return_sequence=False. However, the model always output the mean value of y.