From 6b9f1d343eac40d71b5275071a9e47a04546a356 Mon Sep 17 00:00:00 2001 From: guosheng Date: Mon, 29 Jan 2018 10:33:41 +0800 Subject: [PATCH] Make weight normalization adapt to the up-to-date code --- python/paddle/v2/fluid/layer_helper.py | 4 ++-- python/paddle/v2/fluid/param_attr.py | 7 +++++-- python/paddle/v2/fluid/tests/test_weight_normalization.py | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/python/paddle/v2/fluid/layer_helper.py b/python/paddle/v2/fluid/layer_helper.py index cc4822735aa..2119ca12c8d 100644 --- a/python/paddle/v2/fluid/layer_helper.py +++ b/python/paddle/v2/fluid/layer_helper.py @@ -226,8 +226,8 @@ class LayerHelper(object): scale = elementwise_div( x=g, y=norm) # The shapes of g and norm are the same. # Currently, elementwise_mul only support broadcast when the shape - # of y is a subset of x. Thus, we should reshape y to squeeze to - # achive it. + # of y is a subset of the shape of x. Thus, we reshape y to squeeze + # to achive the subset. w = elementwise_mul( x=v, y=scale if dim is None else reshape( diff --git a/python/paddle/v2/fluid/param_attr.py b/python/paddle/v2/fluid/param_attr.py index 1218e71ca10..fc566b8a248 100644 --- a/python/paddle/v2/fluid/param_attr.py +++ b/python/paddle/v2/fluid/param_attr.py @@ -15,7 +15,10 @@ from initializer import Initializer, Xavier, Constant from regularizer import WeightDecayRegularizer -__all__ = ['ParamAttr'] +__all__ = [ + 'ParamAttr', + 'WeightNormParamAttr', +] class ParamAttr(object): @@ -92,7 +95,7 @@ class WeightNormParamAttr(ParamAttr): """ # List to record the parameters reparameterized by weight normalization. # If these parameters are treated as Variable rather than Parameter, - # it can be used to discriminate these parameters and help to serialize + # it can be used to discriminate these parameters and help to serialize # these paramters for inference. params_with_weight_norm = [] diff --git a/python/paddle/v2/fluid/tests/test_weight_normalization.py b/python/paddle/v2/fluid/tests/test_weight_normalization.py index 200b5b9dc06..1ac54ea3050 100644 --- a/python/paddle/v2/fluid/tests/test_weight_normalization.py +++ b/python/paddle/v2/fluid/tests/test_weight_normalization.py @@ -52,7 +52,7 @@ class TestWeightNormalization(unittest.TestCase): def run_program(self): outputs = [] places = [core.CPUPlace()] - if core.is_compile_gpu(): + if core.is_compiled_with_cuda(): places.append(core.CUDAPlace(0)) for place in places: self.set_inputs(place) -- GitLab