小编Jul*_*rry的帖子

如何让 Google Cloud AI Platform 在训练期间检测 `tf.summary.scalar` 调用?

(注意:我也在这里问过这个问题)

问题

我一直在尝试让 Google Cloud 的 AI 平台显示在 AI 平台上训练的 Keras 模型的准确性。我配置了超参数调整,hptuning_config.yaml它工作正常。但是,我无法让 AI 平台tf.summary.scalar在训练期间接听电话。

文档

我一直在关注以下文档页面:

1.超参数调优概述

2.使用超参数调优

根据[1]

AI Platform Training 如何获取您的指标 您可能会注意到,本文档中没有关于将您的超参数指标传递给 AI Platform Training 训练服务的说明。这是因为该服务会监控由您的训练应用程序生成的 TensorFlow 摘要事件并检索指标。”

根据[2],生成此类 Tensorflow 摘要事件的一种方法是创建一个回调类,如下所示:

class MyMetricCallback(tf.keras.callbacks.Callback):

    def on_epoch_end(self, epoch, logs=None):
        tf.summary.scalar('metric1', logs['RootMeanSquaredError'], epoch)
Run Code Online (Sandbox Code Playgroud)

我的代码

所以在我的代码中我包括:

# hptuning_config.yaml

trainingInput:
  hyperparameters:
    goal: MAXIMIZE
    maxTrials: 4
    maxParallelTrials: 2
    hyperparameterMetricTag: val_accuracy
    params:
    - parameterName: learning_rate
      type: DOUBLE
      minValue: 0.001
      maxValue: 0.01
      scaleType: UNIT_LOG_SCALE …
Run Code Online (Sandbox Code Playgroud)

google-cloud-platform keras tensorflow google-cloud-ml gcp-ai-platform-training

7
推荐指数
1
解决办法
356
查看次数