Cloud ML Engine上的超参数调整作业失败,并显示以下错误消息:
Too many hyperparameter tuning metrics were written by Hyperparameter Tuning Trial #...
我该如何解决?
首先检查以确保您确实没有写出太多的评估指标。您是否在EvalSpec中指定了合适的油门?
其次,检查损失度量。培训中的损失度量是否与评估中的损失度量相同?如果是这种情况,您的超参数调整工作就会被培训指标弄糊涂。
最简单的解决方法是定义新的评估指标并使用该指标(在我的示例中为“rmse”)作为hyperparameterTag。
这是一个显示这两个修复的示例:
# create metric for hyperparameter tuning
def my_rmse(labels, predictions):
pred_values = predictions['predictions']
return {'rmse': tf.metrics.root_mean_squared_error(labels, pred_values)}
# Create estimator to train and evaluate
def train_and_evaluate(output_dir):
estimator = tf.estimator.DNNLinearCombinedRegressor(...)
estimator = tf.contrib.estimator.add_metrics(estimator, my_rmse)
train_spec = ...
exporter = ...
eval_spec = tf.estimator.EvalSpec(
input_fn = ...,
start_delay_secs = 60, # start evaluating after N seconds
throttle_secs = 300, # evaluate every N seconds
exporters = exporter)
tf.estimator.train_and_evaluate(estimator, train_spec, eval_spec)