【发布时间】:2018-01-09 16:45:16
【问题描述】:
我有一个网络,我正在使用学习率的指数衰减。为此,我正在跟踪一个 'global_step' TF 变量,该变量在处理的每个批次中都增加 1。然而,看起来实际上,它并没有真正得到更新。这是代码。
...
global_step = tf.Variable(0, trainable=False, name='global_step')
starter_learning_rate = 0.01
learning_rate = tf.train.exponential_decay(starter_learning_rate, global_step, 1000, 0.50)
update_ops = tf.get_collection(tf.GraphKeys.UPDATE_OPS)
with tf.control_dependencies(update_ops):
optm = tf.train.AdamOptimizer(learning_rate).minimize(cost, global_step=global_step)
init = tf.global_variables_initializer()
def train(file):
global global_step
for batch in batches:
global_step += 1
...
return loss
...
global_step = 0
for epoch in EPOCHS:
for f in files:
loss = train(f)
函数内部和外部的 global_step 正在更新。但是我的学习率没有改变。当我将摘要附加到我的 TF global_step 变量时,我看到它保持在 0 不变。
这里有什么问题?
【问题讨论】:
标签: python tensorflow neural-network