X = train_df.iloc[:,:].values
X = np.reshape(X,(634442,1,134))
K.clear_session()
model=Sequential()
model.add(LSTM(units=5,activation='sigmoid',kernel_initializer='zeros',input_shape=(None,134)))
model.add(Dense(units=1))
from keras.callbacks import ModelCheckpoint, TensorBoard, EarlyStopping
model.compile(optimizer='adam',
loss='mean_squared_error',
metrics=['accuracy'])
checkpointer = ModelCheckpoint(filepath="model.h1",
verbose=0,
save_best_only=True)
earlystopper=EarlyStopping(monitor='val_loss',min_delta=0,patience=1,verbose=1,mode='auto')
tensorboard = TensorBoard(log_dir='./logs',
histogram_freq=0,
write_graph=True,
write_images=True)
hist=model.fit(X,target,
epochs=5,
batch_size=64,
verbose=1,
shuffle=True,
validation_split=0.2,
callbacks=[checkpointer, tensorboard]).history
X_test = test_df.iloc[:,:].values
X_test = np.reshape(X_test,(214200,1,134))
from keras.models import load_model
regressor = load_model('model.h1')
val = regressor.predict(X_test)
我无法理解为什么我的模型会不断预测'nan'值列表,我已经尝试了所有可以在网上找到的东西,例如将优化器更改为'Adam',降低了学习率,增加了批量大小,减少了训练数据的大小,但仍然没有结果。 培训部分-
Train on 507553 samples, validate on 126889 samples
Epoch 1/5
507553/507553 [==============================] - 97s - loss: 1.2959e-04 - acc: 1.9702e-06 - val_loss: 4.0737e-05 - val_acc: 0.0000e+00
Epoch 2/5
507553/507553 [==============================] - 96s - loss: 4.5844e-05 - acc: 1.9702e-06 - val_loss: 4.0756e-05 - val_acc: 0.0000e+00
Epoch 3/5
507553/507553 [==============================] - 96s - loss: 4.5847e-05 - acc: 1.9702e-06 - val_loss: 4.0475e-05 - val_acc: 0.0000e+00
Epoch 4/5
507553/507553 [==============================] - 97s - loss: 4.5856e-05 - acc: 1.9702e-06 - val_loss: 4.0405e-05 - val_acc: 0.0000e+00
Epoch 5/5
507553/507553 [==============================] - 96s - loss: 4.5842e-05 - acc: 1.9702e-06 - val_loss: 4.0428e-05 - val_acc: 0.0000e+00