From a7c6bf771c493cc9031975ceabcb126ef9ed1188 Mon Sep 17 00:00:00 2001 From: wanghaoshuang Date: Wed, 11 Apr 2018 09:53:56 +0800 Subject: [PATCH] Change do_model_average_for_mean_and_var to boolean in batch_normal. --- python/paddle/fluid/layers/nn.py | 3 --- python/paddle/fluid/optimizer.py | 3 ++- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/python/paddle/fluid/layers/nn.py b/python/paddle/fluid/layers/nn.py index 37ce7382753..56c37f05ccd 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 1917b7d044c..36503cac6d5 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: -- GitLab