如何在 tensorflow.estimator 中获得全局步骤?

How can I get global step in tensorflow.estimator?

有谁知道,如何在估算器定义中获取全局步数?
当优化器创建时,我需要它来调整学习率。
就像下面的例子:

def estimator_fn(features, labels, mode):
  if mode == tf.estimator.ModeKeys.TRAIN:
    optimizer=xxx(learning_rate=GLOBAL_STEP*some process)

tf.train.get_global_step 有效吗?

你也可以使用这个:

if mode == tf.estimator.ModeKeys.TRAIN:
   global_step = tf.train.get_or_create_global_step()
   learning_rate = learning_rate_fn(global_step)

其中 learning_rate_fn 是一个可以修改学习率的函数。

有关详细信息,请查看 here