diff --git a/python/paddle/fluid/layers/nn.py b/python/paddle/fluid/layers/nn.py index 37ce73827532d4fbaeffc5dc798b0149de371be1..56c37f05ccd6d0f228c96a43cade71ebbe013f7e 100644 --- a/python/paddle/fluid/layers/nn.py +++ b/python/paddle/fluid/layers/nn.py @@ -1518,9 +1518,6 @@ def batch_norm(input, bias = helper.create_parameter( attr=helper.bias_attr, shape=param_shape, dtype=dtype, is_bias=True) - if do_model_average_for_mean_and_var: - do_model_average_for_mean_and_var = None - mean = helper.create_parameter( attr=ParamAttr( name=moving_mean_name, diff --git a/python/paddle/fluid/optimizer.py b/python/paddle/fluid/optimizer.py index 1917b7d044c565d351f0a9de72437571064221b2..36503cac6d5391821b977d90e6b77c4df7e3b564 100644 --- a/python/paddle/fluid/optimizer.py +++ b/python/paddle/fluid/optimizer.py @@ -853,7 +853,8 @@ class ModelAverage(Optimizer): self.params_grads = [] if params_grads is None else params_grads params = {} for param, grad in self.params_grads: - params[param.name] = (param, grad) + if param.do_model_average != False: + params[param.name] = (param, grad) for param in framework.default_main_program().global_block( ).all_parameters(): if param.name not in params and param.do_model_average != False: