未验证 提交 eb9ae558 编写于 作者: Y Yiqun Liu 提交者: GitHub

Optimize the performance of piecewise_decay. (#29077)

上级 8bbedc23
...@@ -425,16 +425,18 @@ Applies piecewise decay to the initial learning rate. ...@@ -425,16 +425,18 @@ Applies piecewise decay to the initial learning rate.
dtype='float32', dtype='float32',
value=float(boundaries[i]), value=float(boundaries[i]),
force_cpu=True) force_cpu=True)
value_var = tensor.fill_constant(
shape=[1], dtype='float32', value=float(values[i]))
with switch.case(global_step < boundary_val): with switch.case(global_step < boundary_val):
tensor.assign(value_var, lr) tensor.fill_constant(
last_value_var = tensor.fill_constant( shape=[1],
shape=[1], dtype="float32",
dtype='float32', value=float(values[i]),
value=float(values[len(values) - 1])) out=lr)
with switch.default(): with switch.default():
tensor.assign(last_value_var, lr) tensor.fill_constant(
shape=[1],
dtype="float32",
value=float(values[len(values) - 1]),
out=lr)
return lr return lr
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册