From c0f266835b8e693e8b0c7c3f593980aed9b6149f Mon Sep 17 00:00:00 2001 From: littletomatodonkey <2120160898@bit.edu.cn> Date: Thu, 6 May 2021 11:44:44 +0800 Subject: [PATCH] fix l1 decay for inplace (#32718) --- 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 db08955c45..64ce283a63 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