From c8c3efad768578fb56bea91092e8ca73b007c290 Mon Sep 17 00:00:00 2001 From: Xin Pan Date: Fri, 18 Jan 2019 17:26:30 +0800 Subject: [PATCH] fix bias test=develop --- python/paddle/fluid/imperative/nn.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/python/paddle/fluid/imperative/nn.py b/python/paddle/fluid/imperative/nn.py index 79986070c23..5384533591c 100644 --- a/python/paddle/fluid/imperative/nn.py +++ b/python/paddle/fluid/imperative/nn.py @@ -221,8 +221,11 @@ class FC(layers.Layer): self._dtype = dtype from ..layer_helper import LayerHelper self._helper = LayerHelper( - 'FC', param_attr=param_attr, act=act, name=name) - self._bias_attr = bias_attr if bias_attr else ParamAttr() + 'FC', + param_attr=param_attr, + bias_attr=bias_attr, + act=act, + name=name) def parameters(self): return [self._w, self._b] @@ -256,14 +259,16 @@ class FC(layers.Layer): inputs={"X": [tmp]}, outputs={"Out": out}, attrs={"use_mkldnn": False}) - if not self._bias_attr: - return out + + bias_attr = self._helper.bias_attr + if not bias_attr: + return # add bias size = list(out.shape[1:]) if not self._built: self._b = self._helper.create_parameter( - attr=self._bias_attr, shape=size, dtype=out.dtype, is_bias=True) + attr=bias_attr, shape=size, dtype=out.dtype, is_bias=True) bias_out = self._helper.create_variable_for_type_inference( dtype=out.dtype) self._helper.append_op( -- GitLab