From 773f2f735c235afcc6ea40ddc2af23fe7a69a2e9 Mon Sep 17 00:00:00 2001 From: fengjiayi Date: Thu, 18 Jan 2018 21:06:51 +0800 Subject: [PATCH] fix errors --- python/paddle/v2/fluid/clip.py | 5 +++-- python/paddle/v2/fluid/layers/ops.py | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/python/paddle/v2/fluid/clip.py b/python/paddle/v2/fluid/clip.py index 7a36df0dabb..d4f025a4af6 100644 --- a/python/paddle/v2/fluid/clip.py +++ b/python/paddle/v2/fluid/clip.py @@ -138,8 +138,7 @@ class GradientClipByGlobalNorm(BaseGradientClipAttr): cls = self.__class__ cls.check_init() - local_norm_var = layers.reduce_sum( - x=layers.pow(x=grad, factor=2), reduce_all=True) + local_norm_var = layers.reduce_sum(input=layers.pow(x=grad, factor=2.0)) layers.sums( input=[local_norm_var, cls.global_norm_var], out=[cls.global_norm_var]) @@ -154,6 +153,8 @@ class GradientClipByGlobalNorm(BaseGradientClipAttr): x=cls.clip_norm_var, y=layers.elementwise_max( x=cls.clip_norm_var, y=cls.global_norm_var)) + assert cls.scale_var.shape == (1L, ) + new_grad = layers.elementwise_mul(x=grad, y=cls.scale_var) return param, new_grad diff --git a/python/paddle/v2/fluid/layers/ops.py b/python/paddle/v2/fluid/layers/ops.py index dd3197fc002..a2055c5d7b8 100644 --- a/python/paddle/v2/fluid/layers/ops.py +++ b/python/paddle/v2/fluid/layers/ops.py @@ -48,7 +48,7 @@ __all__ = [ 'mean', 'mul', 'reshape', 'scale', 'transpose', 'sigmoid_cross_entropy_with_logits', 'elementwise_add', 'elementwise_div', 'elementwise_sub', 'elementwise_mul', 'elementwise_max', 'elementwise_min', - 'clip', 'clip_by_norm', 'sequence_softmax', 'reduce_sum' + 'clip', 'clip_by_norm', 'sequence_softmax' ] + __activations__ for _OP in set(__all__): -- GitLab