diff --git a/python/paddle/fluid/dygraph/nn.py b/python/paddle/fluid/dygraph/nn.py index f02e8b55722f3a5cb19bea05ffa930730f9b4a15..64a195250a70d8b682018770993160a1a1d9b452 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 734383655cf6a85015750ab432c0f6697dd6a9b8..90689c0f3775cdf9697eb3453ad292102a935207 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):