refine optimier function (#19886)

test=developt
expand_as_op_1
chengduo 6 years ago committed by GitHub
parent 93364b45c1
commit ae31faaa87
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -491,6 +491,10 @@ class Optimizer(object):
else:
assert (isinstance(callbacks, list))
program = loss.block.program
assert len(loss.shape) == 1 and loss.shape[0] == 1, \
"The loss.shape should be (1L,), but the current loss.shape is {}. " \
"Maybe that you should call fluid.layers.mean to process the current loss.".format(
loss.shape)
with program_guard(program, startup_program):
params_grads = append_backward(loss, parameter_list,
no_grad_set, callbacks)

Loading…
Cancel
Save