From efdb0a7d41a0d35c5274d2bc49d47cd18dc98971 Mon Sep 17 00:00:00 2001 From: littletomatodonkey <2120160898@bit.edu.cn> Date: Thu, 6 May 2021 11:44:18 +0800 Subject: [PATCH] fix l1 decay for inplace (#32717) --- python/paddle/fluid/regularizer.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/python/paddle/fluid/regularizer.py b/python/paddle/fluid/regularizer.py index db08955c455..64ce283a63c 100644 --- a/python/paddle/fluid/regularizer.py +++ b/python/paddle/fluid/regularizer.py @@ -326,19 +326,21 @@ class L1DecayRegularizer(WeightDecayRegularizer): assert isinstance(block, framework.Block) if framework.in_dygraph_mode(): + sign = block.create_var(dtype=param.dtype, shape=param.shape) decay = block.create_var(dtype=param.dtype, shape=param.shape) else: + sign = block.create_var( + dtype=param.dtype, shape=param.shape, lod_level=param.lod_level) decay = block.create_var( dtype=param.dtype, shape=param.shape, lod_level=param.lod_level) # Append sign op - block.append_op( - type='sign', inputs={"X": param}, outputs={"Out": decay}) + block.append_op(type='sign', inputs={"X": param}, outputs={"Out": sign}) # Append scale op to the output of sign op block.append_op( type='scale', - inputs={"X": decay}, + inputs={"X": sign}, outputs={"Out": decay}, attrs={"scale": self._regularization_coeff}) -- GitLab