是否可以使用ML引擎调优超参数以在本地训练模型?文档只提到了在云中使用超参数调优进行培训(提交作业),而没有提到在本地进行培训。
否则,是否存在另一种常用的超参数调优,将命令参数传递给task.py,如人口普查估计器教程中所述?
https://github.com/GoogleCloudPlatform/cloudml-samples/tree/master/census
发布于 2018-12-03 00:51:27
正如Puneith所说,超参数调优不能在ML-Engine中本地运行。
SciKit优化提供了一个易于使用的包装器,可用于任何模型,包括估计器。只需将运行N个时期的训练的代码放入其自己的函数中,该函数将返回评估1-准确性,1-auroc或损失度量以最小化。
import numpy as np
from skopt import gp_minimize
def train(hyperparam_config):
# set from passed in hyperparameters
learning_rate = hyperparam_config[0]
num_layers = hyperparam_config[2]
# run training
res = estimator.train_and_evaluate()...
return res['loss'] # return metric to minimize
hyperparam_config = [Real(0.0001, 0.01, name="learning_rate"),
Integer(3, 10, name="num_layers")]
res = gp_minimize(train, hyperparam_config)
with open('results.txt', 'w') as wf:
wf.write(str(res))
print(res)
发布于 2018-11-30 08:20:57
您不能在本地执行HPTuning (云ML引擎支持的基于Bayesian Optimization的HPTuning ),因为它是云ML引擎提供的托管服务。还有其他方法来执行超参数调整,例如,Scikit-learn GridSearch,但它们在这项任务中的效率要低得多。
发布于 2018-12-13 20:28:39
https://stackoverflow.com/questions/53547031
复制相似问题