我得到了错误Input 0 is incompatible with layer lstm_16: expected ndim=3, found ndim=2,代码如下:
#Step 6: Initialize the RNN
regressor = Sequential()
#Step 7: Adding the LSTM layers and some Dropout regularization
#Dropout regularization: drops out unnecessary data, so we are not shifting huge amounts of data through the network
#Adding the first LSTM layer and some Dropout regularization
#units - dimensionality in output space
regressor.add(LSTM(units = 50, return_sequences = True, input_shape = (X_train.shape[1], 1)))
#Adding the second LSTM layer and some Dropout regulariation
regressor.add(LSTM(units = 25, return_sequences = True))
regressor.add(Dropout(0.2))
#Adding a third LSTM layer and some Dropout regularization
regressor.add(LSTM(units = 12, return_sequences = True))
regressor.add(Dropout(0.2))
#Adding a fourth LSTM layer and some Dropout regularization
regressor.add(LSTM(units = 6))
regressor.add(Dropout(0.2))
#Step 8: Adding the output layer
regressor.add(Dense(units = 1))X_train的尺寸为(114, 1, 216) (在I computer X_train.shape时生成)。为什么我会得到这个错误?
发布于 2020-04-27 01:28:49
在这里,您将在第一个LSTM层的input_shape中传递两个值。
(samples, time_steps, nfeatures)的LSTM需要和输入的形状,您的图层输入必须具有此形状。
https://stackoverflow.com/questions/58741673
复制相似问题