如何知道从 R 完成了多少深度学习时期?
How do know how many deep learning epochs were done, from R?
h2o.deeplearning()
的提前停止功能默认开启。但是,从 R 中,我如何知道它是否确实提前停止,以及它停止了多少个 epoch?我试过这个:
model = h2o.deeplearning(...)
print(model)
它告诉我关于层、MSE、R2 等的信息,但没有关于多少个 epoch 的信息 运行。
Over on Flow 我可以看到信息(例如,x 轴在 "Scoring History - Deviance" 图表或评分历史 table 中停止的位置)。
如果您的模型名为 m
,则仅获取训练的 epoch 数:last(m@model$scoring_history$epochs)
要查看还有哪些其他信息(实际上就是您在 Flow 界面中可以看到的所有信息)以及如何访问这些信息,请使用 str(m)
另请注意此命令:summary(m)
除了 print(m)
显示的内容外,它还添加了此部分(对于深度学习模型):
Scoring History:
timestamp duration training_speed epochs iterations samples training_MSE training_deviance training_r2
1 2016-04-14 11:35:46 0.000 sec 0.00000 0 0.000000
2 2016-04-14 11:35:52 5.218 sec 15139 rows/sec 10.00000 1 77150.000000 0.00000 0.00000 0.07884
...
7 2016-04-14 11:36:18 31.346 sec 25056 rows/sec 100.00000 10 771500.000000 0.00000 0.00000 0.72245
即您可以通过查看最后一行来查看 epoch 总数。
顺便说一句,这与应用于数据 frame 的 h2o summary()
命令不同;在这种情况下,它的行为类似于 R 的内置汇总函数,并显示数据框中每一列的统计信息。
我非常有信心地说 Darren Cook 的答案只有在 overwrite_with_best_model=FALSE
时才有效。无论如何,这个参数默认设置为 TRUE
,因此之前的答案可能会产生误导,因为您可以部分找到 here。您可以在以下输出中检查我的意思,使用 h2o.grid
调整网络并按照 Darren 的建议使用 m@model$scoring_history
。
epochs validation_classification_error
0.00000 0.46562
1.43150 0.50000
100.31780 0.46562
如您所见,如果 overwrite_with_best_model=TRUE
函数在最后一次迭代中保存了最佳模型,因此 Darren 的解总是对应于最大轮数。假设您正在调整模型,我推荐以下解决方案:
epochsList = m@model$scoring_history$epochs
bestEpochIndex = which.min(m@model$scoring_history$validation_classification_error)
bestEpoch = epochsList[bestEpochIndex]
print(sprintf("The best epoch is: %d", bestEpoch))
h2o.deeplearning()
的提前停止功能默认开启。但是,从 R 中,我如何知道它是否确实提前停止,以及它停止了多少个 epoch?我试过这个:
model = h2o.deeplearning(...)
print(model)
它告诉我关于层、MSE、R2 等的信息,但没有关于多少个 epoch 的信息 运行。
Over on Flow 我可以看到信息(例如,x 轴在 "Scoring History - Deviance" 图表或评分历史 table 中停止的位置)。
如果您的模型名为 m
,则仅获取训练的 epoch 数:last(m@model$scoring_history$epochs)
要查看还有哪些其他信息(实际上就是您在 Flow 界面中可以看到的所有信息)以及如何访问这些信息,请使用 str(m)
另请注意此命令:summary(m)
除了 print(m)
显示的内容外,它还添加了此部分(对于深度学习模型):
Scoring History:
timestamp duration training_speed epochs iterations samples training_MSE training_deviance training_r2
1 2016-04-14 11:35:46 0.000 sec 0.00000 0 0.000000
2 2016-04-14 11:35:52 5.218 sec 15139 rows/sec 10.00000 1 77150.000000 0.00000 0.00000 0.07884
...
7 2016-04-14 11:36:18 31.346 sec 25056 rows/sec 100.00000 10 771500.000000 0.00000 0.00000 0.72245
即您可以通过查看最后一行来查看 epoch 总数。
顺便说一句,这与应用于数据 frame 的 h2o summary()
命令不同;在这种情况下,它的行为类似于 R 的内置汇总函数,并显示数据框中每一列的统计信息。
我非常有信心地说 Darren Cook 的答案只有在 overwrite_with_best_model=FALSE
时才有效。无论如何,这个参数默认设置为 TRUE
,因此之前的答案可能会产生误导,因为您可以部分找到 here。您可以在以下输出中检查我的意思,使用 h2o.grid
调整网络并按照 Darren 的建议使用 m@model$scoring_history
。
epochs validation_classification_error
0.00000 0.46562
1.43150 0.50000
100.31780 0.46562
如您所见,如果 overwrite_with_best_model=TRUE
函数在最后一次迭代中保存了最佳模型,因此 Darren 的解总是对应于最大轮数。假设您正在调整模型,我推荐以下解决方案:
epochsList = m@model$scoring_history$epochs
bestEpochIndex = which.min(m@model$scoring_history$validation_classification_error)
bestEpoch = epochsList[bestEpochIndex]
print(sprintf("The best epoch is: %d", bestEpoch))