From aca53535e07a1209bcdd9f84992e0dd3bef4bf4e Mon Sep 17 00:00:00 2001 From: Hongyu Liu <43953930+phlrain@users.noreply.github.com> Date: Thu, 30 May 2019 16:24:14 +0800 Subject: [PATCH] fix bug; test=develop (#17733) --- python/paddle/fluid/dygraph/nn.py | 10 +++++----- python/paddle/fluid/layers/math_op_patch.py | 9 +++++++-- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/python/paddle/fluid/dygraph/nn.py b/python/paddle/fluid/dygraph/nn.py index f02e8b55722..64a195250a7 100644 --- a/python/paddle/fluid/dygraph/nn.py +++ b/python/paddle/fluid/dygraph/nn.py @@ -1461,8 +1461,8 @@ class GRUUnit(layers.Layer): sigmoid=1, tanh=2, relu=3, ) - activation = activation_dict[activation] - gate_activation = activation_dict[gate_activation] + self.activation = activation_dict[activation] + self.gate_activation = activation_dict[gate_activation] self._dtype = dtype size = size // 3 @@ -1494,8 +1494,8 @@ class GRUUnit(layers.Layer): 'Hidden': updated_hidden, }, attrs={ - 'activation': 2, # tanh - 'gate_activation': 1, # sigmoid + 'activation': self.activation, + 'gate_activation': self.gate_activation, }) return updated_hidden, reset_hidden_pre, gate @@ -2053,7 +2053,7 @@ class Conv2DTranspose(layers.Layer): self._filter_size = [filter_size_h, filter_size_w] else: self._filter_size = utils.convert_to_list( - self._output_size, 2, 'conv2d_transpose.filter_size') + self._filter_size, 2, 'conv2d_transpose.filter_size') if self._output_size is None: self._output_size = [] diff --git a/python/paddle/fluid/layers/math_op_patch.py b/python/paddle/fluid/layers/math_op_patch.py index 734383655cf..90689c0f377 100644 --- a/python/paddle/fluid/layers/math_op_patch.py +++ b/python/paddle/fluid/layers/math_op_patch.py @@ -42,7 +42,9 @@ def monkey_patch_variable(): 'shape': shape, 'value': value, 'force_cpu': force_init_on_cpu() - }) + }, + stop_gradient=True) + var.stop_gradient = True return var def create_scalar(block, value, dtype): @@ -68,7 +70,10 @@ def monkey_patch_variable(): 'value': value, 'input_dim_idx': batch_dim, 'output_dim_idx': batch_dim - }) + }, + stop_gradient=True) + + var.stop_gradient = True return var def astype(self, dtype): -- GitLab