Den*_*nan 1 deep-learning keras tensorflow keras-tuner
我目前正在免费的 Google Colab 实例上使用 Keras Tuner 切换更大的搜索空间。由于使用限制,我的搜索运行将在完成之前中断。我想定期保存搜索进度,以应对这些中断,并在 Colab 资源再次可用时从上一个检查点恢复。我找到了有关如何保存运行中的特定模型的文档,但我想保存搜索的整个状态,包括已经尝试过的内容和这些实验的结果。
我可以直接调用Tuner.get_state(),保存结果,然后从上次中断的地方继续吗Tuner.set_state()?或者还有别的办法吗?
您无需致电tuner.get_state()和tuner.set_state()。在实例化 a 时Tuner,例如示例RandomSearch中提到的a ,
# While creating the tuner for the first time
tuner = RandomSearch(
build_model,
objective="val_accuracy",
max_trials=3,
executions_per_trial=2,
directory="my_dir",
project_name="helloworld",
)
Run Code Online (Sandbox Code Playgroud)
您需要设置参数directory和project_name。检查点保存在此目录中。您可以将此目录另存为 ZIP 文件并使用 files.download().
当您获得新的 Colab 实例时,解压缩该存档并恢复my_dir目录。再次实例化一个Tuner,
# While loading the Tuner
tuner = RandomSearch(
build_model,
objective="val_accuracy",
max_trials=3,
executions_per_trial=2,
directory="my_dir", # <----- Use the directory as you did earlier
overwrite=False, # <-------
project_name="helloworld",
)
Run Code Online (Sandbox Code Playgroud)
现在开始搜索,您会发现best params so far没有改变。还,tuner.results_summary() returns all search results.
Tuner请参阅此处该类的文档。
| 归档时间: |
|
| 查看次数: |
2637 次 |
| 最近记录: |