如何使用LSTM和RNN模型对时间序列预测进行准确比较?
嗨,我目前正在使用LSTM和RNN开发一个用于巴士到达时间预测系统的项目。将比较这两个框架,以预测我在数据集中包含的delay_in_min数据的结果。我需要在开发该项目时遇到的一些问题的帮助。
- 我尝试使用LSTM和RNN的此框架来运行我的数据集。
用于数据预处理
- X.Shape =(315,5,21)
- y.shape =(315,)
- 我将数据分为三个部分(火车:200,验证:50和测试:65) 。
LSTM:
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import *
from tensorflow.keras.callbacks import ModelCheckpoint
from tensorflow.keras.losses import MeanSquaredError
from tensorflow.keras.metrics import RootMeanSquaredError
from tensorflow.keras.optimizers import Adam
model1 = Sequential()
model1.add(InputLayer((5,21)))
model1.add(LSTM(256, activation='relu', return_sequences=True))
model1.add(LSTM(256, activation='relu'))
model1.add(Dense(1))
model1.summary()
cp = ModelCheckpoint('model1/', save_best_only=True)
model1.compile(loss=MeanSquaredError(), optimizer=Adam(learning_rate=0.0001), metrics=[RootMeanSquaredError()])
model1.fit(X_train, y_train, validation_data=(X_val, y_val), epochs=1000, callbacks=[cp])
RNN:
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import *
from tensorflow.keras.callbacks import ModelCheckpoint
from tensorflow.keras.losses import MeanSquaredError
from tensorflow.keras.metrics import RootMeanSquaredError
from tensorflow.keras.optimizers import Adam
model1 = Sequential()
model1.add(InputLayer((5,21)))
model1.add(SimpleRNN(256, activation='relu', return_sequences=True))
model1.add(SimpleRNN(256, activation='relu'))
model1.add(Dense(1))
model1.summary()
cp = ModelCheckpoint('model1/', save_best_only=True)
model1.compile(loss=MeanSquaredError(), optimizer=Adam(learning_rate=0.0001), metrics=[RootMeanSquaredError()])
model1.fit(X_train, y_train, validation_data=(X_val, y_val), epochs=1000, callbacks=[cp])
但是,RMSE指标只能达到2.4580的最低值,并且在某个时候没有发生1000个时期的变化。当我查看预测结果时,某些值距离预期的输出值太远了,该值应该在这三个值之间(0,5和10)。我试图通过增加或减少参数值来更改参数值,但是我不知道我是否可以做到这一点。 为了更清楚,下面是输出的示例:
Epoch 1/1000
6/7 [========================>.....] - ETA: 0s - loss: 8263.2939 - root_mean_squared_error: 90.9027INFO:tensorflow:Assets written to: model1/assets
INFO:tensorflow:Assets written to: model1/assets
WARNING:absl:<keras.layers.recurrent.LSTMCell object at 0x7fa6fa753a10> has the same name 'LSTMCell' as a built-in Keras object. Consider renaming <class 'keras.layers.recurrent.LSTMCell'> to avoid naming conflicts when loading with `tf.keras.models.load_model`. If renaming is not possible, pass the object in the `custom_objects` parameter of the load function.
WARNING:absl:<keras.layers.recurrent.LSTMCell object at 0x7fa6fa381150> has the same name 'LSTMCell' as a built-in Keras object. Consider renaming <class 'keras.layers.recurrent.LSTMCell'> to avoid naming conflicts when loading with `tf.keras.models.load_model`. If renaming is not possible, pass the object in the `custom_objects` parameter of the load function.
7/7 [==============================] - 7s 758ms/step - loss: 7940.8867 - root_mean_squared_error: 89.1117 - val_loss: 331.7596 - val_root_mean_squared_error: 18.2143
Epoch 2/1000
6/7 [========================>.....] - ETA: 0s - loss: 404.0868 - root_mean_squared_error: 20.1019INFO:tensorflow:Assets written to: model1/assets
INFO:tensorflow:Assets written to: model1/assets
WARNING:absl:<keras.layers.recurrent.LSTMCell object at 0x7fa6fa753a10> has the same name 'LSTMCell' as a built-in Keras object. Consider renaming <class 'keras.layers.recurrent.LSTMCell'> to avoid naming conflicts when loading with `tf.keras.models.load_model`. If renaming is not possible, pass the object in the `custom_objects` parameter of the load function.
WARNING:absl:<keras.layers.recurrent.LSTMCell object at 0x7fa6fa381150> has the same name 'LSTMCell' as a built-in Keras object. Consider renaming <class 'keras.layers.recurrent.LSTMCell'> to avoid naming conflicts when loading with `tf.keras.models.load_model`. If renaming is not possible, pass the object in the `custom_objects` parameter of the load function.
7/7 [==============================] - 4s 583ms/step - loss: 390.3654 - root_mean_squared_error: 19.7577 - val_loss: 34.9191 - val_root_mean_squared_error: 5.9092
Epoch 3/1000
7/7 [==============================] - ETA: 0s - loss: 33.4639 - root_mean_squared_error: 5.7848INFO:tensorflow:Assets written to: model1/assets
INFO:tensorflow:Assets written to: model1/assets
WARNING:absl:<keras.layers.recurrent.LSTMCell object at 0x7fa6fa753a10> has the same name 'LSTMCell' as a built-in Keras object. Consider renaming <class 'keras.layers.recurrent.LSTMCell'> to avoid naming conflicts when loading with `tf.keras.models.load_model`. If renaming is not possible, pass the object in the `custom_objects` parameter of the load function.
WARNING:absl:<keras.layers.recurrent.LSTMCell object at 0x7fa6fa381150> has the same name 'LSTMCell' as a built-in Keras object. Consider renaming <class 'keras.layers.recurrent.LSTMCell'> to avoid naming conflicts when loading with `tf.keras.models.load_model`. If renaming is not possible, pass the object in the `custom_objects` parameter of the load function.
7/7 [==============================] - 4s 637ms/step - loss: 33.4639 - root_mean_squared_error: 5.7848 - val_loss: 11.8592 - val_root_mean_squared_error: 3.4437
Epoch 4/1000
6/7 [========================>.....] - ETA: 0s - loss: 20.1906 - root_mean_squared_error: 4.4934INFO:tensorflow:Assets written to: model1/assets
INFO:tensorflow:Assets written to: model1/assets
WARNING:absl:<keras.layers.recurrent.LSTMCell object at 0x7fa6fa753a10> has the same name 'LSTMCell' as a built-in Keras object. Consider renaming <class 'keras.layers.recurrent.LSTMCell'> to avoid naming conflicts when loading with `tf.keras.models.load_model`. If renaming is not possible, pass the object in the `custom_objects` parameter of the load function.
WARNING:absl:<keras.layers.recurrent.LSTMCell object at 0x7fa6fa381150> has the same name 'LSTMCell' as a built-in Keras object. Consider renaming <class 'keras.layers.recurrent.LSTMCell'> to avoid naming conflicts when loading with `tf.keras.models.load_model`. If renaming is not possible, pass the object in the `custom_objects` parameter of the load function.
7/7 [==============================] - 4s 581ms/step - loss: 20.0047 - root_mean_squared_error: 4.4727 - val_loss: 8.8859 - val_root_mean_squared_error: 2.9809
Epoch 5/1000
7/7 [==============================] - ETA: 0s - loss: 14.3730 - root_mean_squared_error: 3.7912INFO:tensorflow:Assets written to: model1/assets
INFO:tensorflow:Assets written to: model1/assets
WARNING:absl:<keras.layers.recurrent.LSTMCell object at 0x7fa6fa753a10> has the same name 'LSTMCell' as a built-in Keras object. Consider renaming <class 'keras.layers.recurrent.LSTMCell'> to avoid naming conflicts when loading with `tf.keras.models.load_model`. If renaming is not possible, pass the object in the `custom_objects` parameter of the load function.
WARNING:absl:<keras.layers.recurrent.LSTMCell object at 0x7fa6fa381150> has the same name 'LSTMCell' as a built-in Keras object. Consider renaming <class 'keras.layers.recurrent.LSTMCell'> to avoid naming conflicts when loading with `tf.keras.models.load_model`. If renaming is not possible, pass the object in the `custom_objects` parameter of the load function.
7/7 [==============================] - 3s 552ms/step - loss: 14.3730 - root_mean_squared_error: 3.7912 - val_loss: 7.1798 - val_root_mean_squared_error: 2.6795
Epoch 6/1000
6/7 [========================>.....] - ETA: 0s - loss: 13.1876 - root_mean_squared_error: 3.6315INFO:tensorflow:Assets written to: model1/assets
INFO:tensorflow:Assets written to: model1/assets
WARNING:absl:<keras.layers.recurrent.LSTMCell object at 0x7fa6fa753a10> has the same name 'LSTMCell' as a built-in Keras object. Consider renaming <class 'keras.layers.recurrent.LSTMCell'> to avoid naming conflicts when loading with `tf.keras.models.load_model`. If renaming is not possible, pass the object in the `custom_objects` parameter of the load function.
WARNING:absl:<keras.layers.recurrent.LSTMCell object at 0x7fa6fa381150> has the same name 'LSTMCell' as a built-in Keras object. Consider renaming <class 'keras.layers.recurrent.LSTMCell'> to avoid naming conflicts when loading with `tf.keras.models.load_model`. If renaming is not possible, pass the object in the `custom_objects` parameter of the load function.
7/7 [==============================] - 4s 709ms/step - loss: 12.8867 - root_mean_squared_error: 3.5898 - val_loss: 5.9226 - val_root_mean_squared_error: 2.4336
Epoch 7/1000
7/7 [==============================] - 0s 64ms/step - loss: 12.3348 - root_mean_squared_error: 3.5121 - val_loss: 6.0180 - val_root_mean_squared_error: 2.4532
Epoch 8/1000
7/7 [==============================] - 0s 59ms/step - loss: 12.2133 - root_mean_squared_error: 3.4948 - val_loss: 7.3143 - val_root_mean_squared_error: 2.7045
Epoch 9/1000
7/7 [==============================] - 0s 52ms/step - loss: 12.1458 - root_mean_squared_error: 3.4851 - val_loss: 5.9605 - val_root_mean_squared_error: 2.4414
Epoch 10/1000
.
.
.
Epoch 991/1000
7/7 [==============================] - 0s 61ms/step - loss: 6.4219 - root_mean_squared_error: 2.5341 - val_loss: 3.4269 - val_root_mean_squared_error: 1.8512
Epoch 992/1000
7/7 [==============================] - 0s 60ms/step - loss: 5.7453 - root_mean_squared_error: 2.3969 - val_loss: 12.1370 - val_root_mean_squared_error: 3.4838
Epoch 993/1000
7/7 [==============================] - 0s 58ms/step - loss: 7.3273 - root_mean_squared_error: 2.7069 - val_loss: 4.5648 - val_root_mean_squared_error: 2.1365
Epoch 994/1000
7/7 [==============================] - 0s 64ms/step - loss: 5.7639 - root_mean_squared_error: 2.4008 - val_loss: 3.5638 - val_root_mean_squared_error: 1.8878
Epoch 995/1000
7/7 [==============================] - 0s 67ms/step - loss: 5.2103 - root_mean_squared_error: 2.2826 - val_loss: 6.0134 - val_root_mean_squared_error: 2.4522
Epoch 996/1000
7/7 [==============================] - 0s 66ms/step - loss: 5.5951 - root_mean_squared_error: 2.3654 - val_loss: 3.3826 - val_root_mean_squared_error: 1.8392
Epoch 997/1000
7/7 [==============================] - 0s 65ms/step - loss: 5.4926 - root_mean_squared_error: 2.3436 - val_loss: 4.6553 - val_root_mean_squared_error: 2.1576
Epoch 998/1000
7/7 [==============================] - 0s 68ms/step - loss: 5.6556 - root_mean_squared_error: 2.3781 - val_loss: 3.2487 - val_root_mean_squared_error: 1.8024
Epoch 999/1000
7/7 [==============================] - 0s 68ms/step - loss: 5.5924 - root_mean_squared_error: 2.3648 - val_loss: 3.1579 - val_root_mean_squared_error: 1.7770
Epoch 1000/1000
7/7 [==============================] - 0s 66ms/step - loss: 6.3305 - root_mean_squared_error: 2.5161 - val_loss: 6.0776 - val_root_mean_squared_error: 2.4653
- 下一步,我不知道如何检索已保存到“/model1”文件的最新RMSE值。从我的理解来看,该编码将在将其与上一个检查点的值进行比较之后,将最佳的RMSE值保存到该文件。我需要此值来比较LSTM和RNN的预测准确性。我有什么办法可以检索它吗?
Hi I am currently developing a project for bus arrival time prediction system using LSTM and RNN. These two framework will be compared for their results of predicting the delay_in_min data that I have included in the dataset. I need help with some problems that I have encountered while developing this project.
- I have try to run my dataset with this framework for both LSTM and RNN.
**This is a part of my dataset:
For data preprocessing
- X.shape = (315, 5, 21)
- y.shape = (315,)
- I split the data into three part(train:200, validation:50 and test:65).
LSTM:
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import *
from tensorflow.keras.callbacks import ModelCheckpoint
from tensorflow.keras.losses import MeanSquaredError
from tensorflow.keras.metrics import RootMeanSquaredError
from tensorflow.keras.optimizers import Adam
model1 = Sequential()
model1.add(InputLayer((5,21)))
model1.add(LSTM(256, activation='relu', return_sequences=True))
model1.add(LSTM(256, activation='relu'))
model1.add(Dense(1))
model1.summary()
cp = ModelCheckpoint('model1/', save_best_only=True)
model1.compile(loss=MeanSquaredError(), optimizer=Adam(learning_rate=0.0001), metrics=[RootMeanSquaredError()])
model1.fit(X_train, y_train, validation_data=(X_val, y_val), epochs=1000, callbacks=[cp])
RNN:
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import *
from tensorflow.keras.callbacks import ModelCheckpoint
from tensorflow.keras.losses import MeanSquaredError
from tensorflow.keras.metrics import RootMeanSquaredError
from tensorflow.keras.optimizers import Adam
model1 = Sequential()
model1.add(InputLayer((5,21)))
model1.add(SimpleRNN(256, activation='relu', return_sequences=True))
model1.add(SimpleRNN(256, activation='relu'))
model1.add(Dense(1))
model1.summary()
cp = ModelCheckpoint('model1/', save_best_only=True)
model1.compile(loss=MeanSquaredError(), optimizer=Adam(learning_rate=0.0001), metrics=[RootMeanSquaredError()])
model1.fit(X_train, y_train, validation_data=(X_val, y_val), epochs=1000, callbacks=[cp])
However, the RMSE metrics could only achieved the lowest value at 2.4580 and there are no changes happens at some point for 1000 epochs. When I look to the results of prediction, some of the value is too far from the expected output value which was supposed to be between this three values(0,5 and 10). I have tried to change the parameter value by increasing or decreasing it but somehow I don't know if I can do that or not.
To make it more clear, below is the example of the output:
Epoch 1/1000
6/7 [========================>.....] - ETA: 0s - loss: 8263.2939 - root_mean_squared_error: 90.9027INFO:tensorflow:Assets written to: model1/assets
INFO:tensorflow:Assets written to: model1/assets
WARNING:absl:<keras.layers.recurrent.LSTMCell object at 0x7fa6fa753a10> has the same name 'LSTMCell' as a built-in Keras object. Consider renaming <class 'keras.layers.recurrent.LSTMCell'> to avoid naming conflicts when loading with `tf.keras.models.load_model`. If renaming is not possible, pass the object in the `custom_objects` parameter of the load function.
WARNING:absl:<keras.layers.recurrent.LSTMCell object at 0x7fa6fa381150> has the same name 'LSTMCell' as a built-in Keras object. Consider renaming <class 'keras.layers.recurrent.LSTMCell'> to avoid naming conflicts when loading with `tf.keras.models.load_model`. If renaming is not possible, pass the object in the `custom_objects` parameter of the load function.
7/7 [==============================] - 7s 758ms/step - loss: 7940.8867 - root_mean_squared_error: 89.1117 - val_loss: 331.7596 - val_root_mean_squared_error: 18.2143
Epoch 2/1000
6/7 [========================>.....] - ETA: 0s - loss: 404.0868 - root_mean_squared_error: 20.1019INFO:tensorflow:Assets written to: model1/assets
INFO:tensorflow:Assets written to: model1/assets
WARNING:absl:<keras.layers.recurrent.LSTMCell object at 0x7fa6fa753a10> has the same name 'LSTMCell' as a built-in Keras object. Consider renaming <class 'keras.layers.recurrent.LSTMCell'> to avoid naming conflicts when loading with `tf.keras.models.load_model`. If renaming is not possible, pass the object in the `custom_objects` parameter of the load function.
WARNING:absl:<keras.layers.recurrent.LSTMCell object at 0x7fa6fa381150> has the same name 'LSTMCell' as a built-in Keras object. Consider renaming <class 'keras.layers.recurrent.LSTMCell'> to avoid naming conflicts when loading with `tf.keras.models.load_model`. If renaming is not possible, pass the object in the `custom_objects` parameter of the load function.
7/7 [==============================] - 4s 583ms/step - loss: 390.3654 - root_mean_squared_error: 19.7577 - val_loss: 34.9191 - val_root_mean_squared_error: 5.9092
Epoch 3/1000
7/7 [==============================] - ETA: 0s - loss: 33.4639 - root_mean_squared_error: 5.7848INFO:tensorflow:Assets written to: model1/assets
INFO:tensorflow:Assets written to: model1/assets
WARNING:absl:<keras.layers.recurrent.LSTMCell object at 0x7fa6fa753a10> has the same name 'LSTMCell' as a built-in Keras object. Consider renaming <class 'keras.layers.recurrent.LSTMCell'> to avoid naming conflicts when loading with `tf.keras.models.load_model`. If renaming is not possible, pass the object in the `custom_objects` parameter of the load function.
WARNING:absl:<keras.layers.recurrent.LSTMCell object at 0x7fa6fa381150> has the same name 'LSTMCell' as a built-in Keras object. Consider renaming <class 'keras.layers.recurrent.LSTMCell'> to avoid naming conflicts when loading with `tf.keras.models.load_model`. If renaming is not possible, pass the object in the `custom_objects` parameter of the load function.
7/7 [==============================] - 4s 637ms/step - loss: 33.4639 - root_mean_squared_error: 5.7848 - val_loss: 11.8592 - val_root_mean_squared_error: 3.4437
Epoch 4/1000
6/7 [========================>.....] - ETA: 0s - loss: 20.1906 - root_mean_squared_error: 4.4934INFO:tensorflow:Assets written to: model1/assets
INFO:tensorflow:Assets written to: model1/assets
WARNING:absl:<keras.layers.recurrent.LSTMCell object at 0x7fa6fa753a10> has the same name 'LSTMCell' as a built-in Keras object. Consider renaming <class 'keras.layers.recurrent.LSTMCell'> to avoid naming conflicts when loading with `tf.keras.models.load_model`. If renaming is not possible, pass the object in the `custom_objects` parameter of the load function.
WARNING:absl:<keras.layers.recurrent.LSTMCell object at 0x7fa6fa381150> has the same name 'LSTMCell' as a built-in Keras object. Consider renaming <class 'keras.layers.recurrent.LSTMCell'> to avoid naming conflicts when loading with `tf.keras.models.load_model`. If renaming is not possible, pass the object in the `custom_objects` parameter of the load function.
7/7 [==============================] - 4s 581ms/step - loss: 20.0047 - root_mean_squared_error: 4.4727 - val_loss: 8.8859 - val_root_mean_squared_error: 2.9809
Epoch 5/1000
7/7 [==============================] - ETA: 0s - loss: 14.3730 - root_mean_squared_error: 3.7912INFO:tensorflow:Assets written to: model1/assets
INFO:tensorflow:Assets written to: model1/assets
WARNING:absl:<keras.layers.recurrent.LSTMCell object at 0x7fa6fa753a10> has the same name 'LSTMCell' as a built-in Keras object. Consider renaming <class 'keras.layers.recurrent.LSTMCell'> to avoid naming conflicts when loading with `tf.keras.models.load_model`. If renaming is not possible, pass the object in the `custom_objects` parameter of the load function.
WARNING:absl:<keras.layers.recurrent.LSTMCell object at 0x7fa6fa381150> has the same name 'LSTMCell' as a built-in Keras object. Consider renaming <class 'keras.layers.recurrent.LSTMCell'> to avoid naming conflicts when loading with `tf.keras.models.load_model`. If renaming is not possible, pass the object in the `custom_objects` parameter of the load function.
7/7 [==============================] - 3s 552ms/step - loss: 14.3730 - root_mean_squared_error: 3.7912 - val_loss: 7.1798 - val_root_mean_squared_error: 2.6795
Epoch 6/1000
6/7 [========================>.....] - ETA: 0s - loss: 13.1876 - root_mean_squared_error: 3.6315INFO:tensorflow:Assets written to: model1/assets
INFO:tensorflow:Assets written to: model1/assets
WARNING:absl:<keras.layers.recurrent.LSTMCell object at 0x7fa6fa753a10> has the same name 'LSTMCell' as a built-in Keras object. Consider renaming <class 'keras.layers.recurrent.LSTMCell'> to avoid naming conflicts when loading with `tf.keras.models.load_model`. If renaming is not possible, pass the object in the `custom_objects` parameter of the load function.
WARNING:absl:<keras.layers.recurrent.LSTMCell object at 0x7fa6fa381150> has the same name 'LSTMCell' as a built-in Keras object. Consider renaming <class 'keras.layers.recurrent.LSTMCell'> to avoid naming conflicts when loading with `tf.keras.models.load_model`. If renaming is not possible, pass the object in the `custom_objects` parameter of the load function.
7/7 [==============================] - 4s 709ms/step - loss: 12.8867 - root_mean_squared_error: 3.5898 - val_loss: 5.9226 - val_root_mean_squared_error: 2.4336
Epoch 7/1000
7/7 [==============================] - 0s 64ms/step - loss: 12.3348 - root_mean_squared_error: 3.5121 - val_loss: 6.0180 - val_root_mean_squared_error: 2.4532
Epoch 8/1000
7/7 [==============================] - 0s 59ms/step - loss: 12.2133 - root_mean_squared_error: 3.4948 - val_loss: 7.3143 - val_root_mean_squared_error: 2.7045
Epoch 9/1000
7/7 [==============================] - 0s 52ms/step - loss: 12.1458 - root_mean_squared_error: 3.4851 - val_loss: 5.9605 - val_root_mean_squared_error: 2.4414
Epoch 10/1000
.
.
.
Epoch 991/1000
7/7 [==============================] - 0s 61ms/step - loss: 6.4219 - root_mean_squared_error: 2.5341 - val_loss: 3.4269 - val_root_mean_squared_error: 1.8512
Epoch 992/1000
7/7 [==============================] - 0s 60ms/step - loss: 5.7453 - root_mean_squared_error: 2.3969 - val_loss: 12.1370 - val_root_mean_squared_error: 3.4838
Epoch 993/1000
7/7 [==============================] - 0s 58ms/step - loss: 7.3273 - root_mean_squared_error: 2.7069 - val_loss: 4.5648 - val_root_mean_squared_error: 2.1365
Epoch 994/1000
7/7 [==============================] - 0s 64ms/step - loss: 5.7639 - root_mean_squared_error: 2.4008 - val_loss: 3.5638 - val_root_mean_squared_error: 1.8878
Epoch 995/1000
7/7 [==============================] - 0s 67ms/step - loss: 5.2103 - root_mean_squared_error: 2.2826 - val_loss: 6.0134 - val_root_mean_squared_error: 2.4522
Epoch 996/1000
7/7 [==============================] - 0s 66ms/step - loss: 5.5951 - root_mean_squared_error: 2.3654 - val_loss: 3.3826 - val_root_mean_squared_error: 1.8392
Epoch 997/1000
7/7 [==============================] - 0s 65ms/step - loss: 5.4926 - root_mean_squared_error: 2.3436 - val_loss: 4.6553 - val_root_mean_squared_error: 2.1576
Epoch 998/1000
7/7 [==============================] - 0s 68ms/step - loss: 5.6556 - root_mean_squared_error: 2.3781 - val_loss: 3.2487 - val_root_mean_squared_error: 1.8024
Epoch 999/1000
7/7 [==============================] - 0s 68ms/step - loss: 5.5924 - root_mean_squared_error: 2.3648 - val_loss: 3.1579 - val_root_mean_squared_error: 1.7770
Epoch 1000/1000
7/7 [==============================] - 0s 66ms/step - loss: 6.3305 - root_mean_squared_error: 2.5161 - val_loss: 6.0776 - val_root_mean_squared_error: 2.4653
- Next, is I don't know how to retrieve the latest RMSE value that have been saved to the '/model1' file. From my understanding, this coding will save the best RMSE value to the that file after compare it with the value at the previous checkpoint. I need this value to compare the accuracy of the prediction made by both LSTM and RNN. Is there any way for me to retrieve it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对于问题的第一部分:如果您的模型“无法完全解决基本问题”,这通常意味着您的模型太简单了。但这也可能有很多原因:
您可以通过发布数据的外观以及如何完成预处理来尝试改善问题。此外,您可以尝试在最后添加一些密集的层,以提高模型的复杂性。
对于问题的第二部分:您可以在培训中添加多个回调。当前,您仅添加回调,这将节省最佳模型。除此之外,您还可以查看在这里例如,将最佳损失值保存到.txt文件,以便您以后可以检索。
For the first part of your question: If your model "can't quite get the underlying problem" this normally means, that your model is too simple. But this can also have a lot of reasons:
You could try to improve your question by posting how your data is looking and how your preprocessing is done. Also you could try to add a few more Dense layers at the end to increase your models complexity.
For the second part of your question: You can add multiple callbacks to your training. Currently you are only adding the callback, which will save the best model. In addition to that you can look here how to create a custom callback, which can, for example, save the best loss value to a .txt file, so that you can retrieve it later.