从 RNN 的第一个 Epoch 开始,损失值被输出为 nan。
纪元 1/100 9787/9787 [===============================] - 22s 2ms/step - loss: nan
我已经对数据进行了标准化。
..., [9.78344703e-01], [1.00000000e+00], [9.94293976e-01]]])我的 X_train 示例(大小为 (9787,60,1) 的 float64)
-
array([6.59848480e-04, 6.98212803e-04, 6.90540626e-04, ..., 1.00000000e+00, 9.94293976e-01, 9.95909540e-01])我的 y_train 示例(float64 大小 (9787,))
我的循环神经网络:
# Initialising the RNN
regressor = Sequential()
# Adding the first LSTM layer and some Dropout regularisation
regressor.add(LSTM(units = 50, return_sequences = True, input_shape =
(X_train.shape[1], 1)))
regressor.add(Dropout(0.2))
# Adding a second LSTM layer and some Dropout regularisation
regressor.add(LSTM(units = 50, return_sequences = True))
regressor.add(Dropout(0.2))
# Adding a third LSTM layer and some Dropout regularisation
regressor.add(LSTM(units = 50, return_sequences = True))
regressor.add(Dropout(0.2))
# Adding a fourth LSTM layer and some Dropout regularisation
regressor.add(LSTM(units = 50))
regressor.add(Dropout(0.2))
# Adding the output layer
regressor.add(Dense(units = 1))
# Compiling the RNN
regressor.compile(optimizer = 'adam', loss = 'mean_squared_error')
# Fitting the RNN to the Training set
regressor.fit(X_train, y_train, epochs = 100, batch_size = 32)