Tensorflow提供了一个将指数衰减自动应用于学习率张量的操作: tf.train.exponential_decay
。有关其使用示例,请参见MNIST卷积模型示例中的此行 。然后使用上面的@mrry的建议将此变量作为您选择的优化程序的learning_rate参数提供。
要看的关键摘录是:
# Optimizer: set up a variable that's incremented once per batch and
# controls the learning rate decay.
batch = tf.Variable(0)
learning_rate = tf.train.exponential_decay(
0.01, # Base learning rate.
batch * BATCH_SIZE, # Current index into the dataset.
train_size, # Decay step.
0.95, # Decay rate.
staircase=True)
# Use simple momentum for the optimization.
optimizer = tf.train.MomentumOptimizer(learning_rate,
0.9).minimize(loss,
global_step=batch)
请注意global_step=batch
参数以使其最小化。这告诉优化器在每次训练时为您有用地增加“ batch”参数。
0
我正在使用TensorFlow训练神经网络。这就是我初始化
GradientDescentOptimizer
:这里的问题是,我不知道如何为学习率或衰减值设置更新规则。
在这里如何使用自适应学习率?