在利用keras做lstm时,出现如下问题,不知道该怎么办
from tensorflow import keras
model=keras.models.Sequential([
keras.layers.LSTM(64,input_shape=[5,10],return_sequences=True),
keras.layers.Dropout(0.0001),
keras.layers.LSTM(16,input_shape=[5,10],return_sequences=True),
keras.layers.Dropout(0.0001),
keras.layers.Dense(4,kernel_initializer='uniform',activation='relu'),
keras.layers.Dense(1,kernel_initializer='uniform',activation='relu')
])
X_train的shape是(3309,5,10),y_train的shape是(3309,),以下为报错
ValueError: A target array with shape (3309, 1) was passed for an output of shape (None, 5, 1) while using as loss `mean_squared_error`. This loss expects targets to have the same shape as the output.
你的output shape应该是(None, 1)才对,而不应该是(None, 5, 1)