您无需调用tuner.get_state()
and tuner.set_state()
。在实例化 aTuner
时,比如说 a RandomSearch
,如示例中所述,
# 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",
)
您需要设置参数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",
)
现在开始搜索,您会发现best params so far
没有改变。此外,tuner.results_summary()
返回所有搜索结果。
在此处查看Tuner
该类的文档。