简体   繁体   English

哪个参数配置是 Keras 在为多个 epoch 训练 model 后默认使用预测

[英]Which parameter configuration is Keras using by default for predictions after training a model for multiple epochs

I have a general question about Keras.我有一个关于 Keras 的一般性问题。 When training a Artificial Neural Network (eg a Multi-Layer-Perceptron or a LSTM) with a split of training, validation and test data (eg 70 %, 20 %, 10 %), I would like to know which parameter configuration the trained model is eventually using for predictions?在训练具有训练、验证和测试数据(例如 70%、20%、10%)拆分的人工神经网络(例如多层感知器或 LSTM)时,我想知道训练的参数配置model 最终用于预测?

Here I have an exmaple from a training process with 11 epoch:在这里,我有一个来自 11 个 epoch 的训练过程的示例:

在此处输入图像描述

I could think about 3 possible parameter configurations (surely there are also others):我可以考虑 3 种可能的参数配置(当然还有其他的):

  1. The configuration that led to the lowest error in the training dataset (which would be after the 11th epoch)导致训练数据集中误差最小的配置(将在第 11 个 epoch 之后)
  2. The configuration after the last epoch (which would the after the 11th epoch, as in 1.)最后一个 epoch 之后的配置(这将在第 11 个 epoch 之后,如 1.)
  3. The configuration that led to the lowest error in the validation dataset (which would be after the 3rd epoch)导致验证数据集中误差最小的配置(将在第三个 epoch 之后)

If you just build the model without for example like this:如果您只是构建 model 而没有像这样:

# Build the model and train it

optimizer_adam = tf.keras.optimizers.Adam(lr= 0.001)
model = keras.models.Sequential([
    keras.layers.LSTM(10, return_sequences=True, input_shape=[None, numberOfInputFeatures]),
    keras.layers.LSTM(10, return_sequences=True),
    keras.layers.TimeDistributed(keras.layers.Dense(numberOfOutputNeurons))
    ])
    
    
model.compile(loss="mean_squared_error", optimizer=optimizer_adam, metrics=['mean_absolute_percentage_error'])
history = model.fit(X_train, Y_train, epochs=11, batch_size=10, validation_data=(X_valid, Y_valid))

# Predict the values from the test dataset
Y_pred = model.predict(X_test)

Can you tell me which configuration is used for predicting the values from the test dataset in the line Y_pred = model.predict(X_test) ?您能告诉我使用哪种配置来预测Y_pred = model.predict(X_test)行中的测试数据集的值吗?

It would be the configuration after the last epoch (the 2nd possible configuration that you have mentioned).这将是最后一个时期之后的配置(您提到的第二个可能的配置)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Keras:如果我在训练几个 epoch 后重新编译我的 model 会怎样 - Keras: What if i recompile my model after training few epochs 使用 scikit-learn 训练线性回归 model 后,如何对原始数据集中不存在的新数据点进行预测? - After training the Linear Regression model using scikit-learn , How to do predictions for new data points which are not there in original data set? Keras:错误的训练时期 - Keras: Wrong Number of Training Epochs 训练 model 后无法提取单个预测 - Unable to extract individual predictions after training a model 受过训练的keras模型比预测训练要慢得多 - Trained keras model much slower making its predictions than in training 使用多个输入训练 Keras 模型 - Training Keras model with multiple inputs 在 TF/Keras 中是否可以在 X epochs 之后保存最佳模型? - Is it possible in TF/Keras to save the best model AFTER X epochs? Keras:如果我多次训练 10 个 epoch,是否需要重新加载模型? - Keras: Is there a need to reload the model if I train for 10 epochs multiple times? 使用 python 的多处理并行化 keras 中的模型预测 - Parallelizing model predictions in keras using multiprocessing for python 为什么在多个在线培训时期之后识别率会下降? - Why does recognition rate drop after multiple online training epochs?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM