【问题标题】:How to set hyperparameter (learning_rate) schedule in TensorFlow?如何在 TensorFlow 中设置超参数(learning_rate)计划?
【发布时间】:2017-12-19 23:26:35
【问题描述】:

在 TensorFlow 中调度超参数的方法是什么?

也就是说,为了可重复性,我想使用建议的学习率计划 {0: 0.1, 1: 1., 100: 0.01, 150: 0.001} 来实现 ResNet(你说出一个),或者启用权重仅在最初的几个初始时期后衰减。

例如,tensorpack 提供如下选项:

ScheduledHyperParamSetter('learning_rate', [(1, 0.1), (82, 0.01), (123, 0.001), (300, 0.0002)])

如何在原生 TF 中做到这一点?

【问题讨论】:

    标签: tensorflow hyperparameters


    【解决方案1】:

    好吧,没那么难

        schedule = {1: 0.1, 2: 0.2, 3: 0.3, 4: 0.4, 100: 0.01, 150: 0.001}
        schedule = sorted(config.lr_schedule.items(), key=lambda x: x[0])
    
        boundaries = [num_train_iter * int(x[0]) for x in schedule]
        rates = [x[1] for x in schedule]
        rates = rates[:1] + rates  # 
        assert len(boundaries) + 1 == len(rates)
    
        learning_rate = tf.train.piecewise_constant(tf.cast(global_step, tf.int32), boundaries, rates)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-10-22
      • 2018-10-04
      • 1970-01-01
      • 1970-01-01
      • 2012-10-27
      • 2021-07-09
      • 2011-05-14
      相关资源
      最近更新 更多