【问题标题】:How to tune hyperparameters using custom model evaluation algorithm?如何使用自定义模型评估算法调整超参数?
【发布时间】:2018-12-17 01:29:17
【问题描述】:

在我的模型评估算法中,我想获得验证数据的模型预测,并应用一种算法,该算法基于验证数据和预测来建模和模仿一些真实世界的场景。

在我的场景中,评估算法不仅依赖于真实的目标值 (y_true) 和预测 (y_pred),还依赖于输入验证数据 (X) 以输出最终的模型分数。因此,我似乎无法为我的用例使用带有自定义指标的估算器。

实现评估/评分算法对我来说是微不足道的,但是如何将评估算法的输出传递回 ML Engine 的超参数调整任务,以便它可以真正优化超参数并在超参数结束时输出最佳超参数值调优任务?

【问题讨论】:

    标签: google-cloud-ml


    【解决方案1】:

    实现评估/评分算法后,使用 hypertune 包写出数字:

    import hypertune
    hpt = hypertune.HyperTune()
    
    # every time you evaluate, write out the evaluation metric
    eval_output_value = your_evaluation_algo(...)    
    hpt.report_hyperparameter_tuning_metric(
        hyperparameter_metric_tag='mymetric',
        metric_value=eval_output_value,
        global_step=0)
    

    然后,将上面的 metric_tag 指定为 CMLE 的评估指标。

    您可以使用 PyPI 安装 hypertune:

       pip install cloudml-hypertune
    

    在你的 trainer 包的 setup.py 中,确保指定 hypertune 包:

     install_requires=[
          ..., # other dependencies
          'cloudml-hypertune',  # Required for hyperparameter tuning.
      ],
    

    有关使用 scikit-learn 的示例,请参阅 https://github.com/GoogleCloudPlatform/training-data-analyst/tree/master/blogs/sklearn/babyweight,因此不能依赖 TensorFlow 的 Estimator API 来写出评估指标。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-08-04
      • 2021-04-25
      • 2013-01-02
      • 2018-07-24
      • 2011-02-12
      • 2011-12-25
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多