Optimize the performance of piecewise_decay. (#29077)

musl/disable_test_yolov3_temporarily
Yiqun Liu 5 years ago committed by GitHub
parent 8bbedc2371
commit eb9ae55849
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -425,16 +425,18 @@ Applies piecewise decay to the initial learning rate.
dtype='float32',
value=float(boundaries[i]),
force_cpu=True)
value_var = tensor.fill_constant(
shape=[1], dtype='float32', value=float(values[i]))
with switch.case(global_step < boundary_val):
tensor.assign(value_var, lr)
last_value_var = tensor.fill_constant(
shape=[1],
dtype='float32',
value=float(values[len(values) - 1]))
tensor.fill_constant(
shape=[1],
dtype="float32",
value=float(values[i]),
out=lr)
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

Loading…
Cancel
Save