提交 c8c3efad 编写于 作者: X Xin Pan

fix bias

test=develop
上级 d1ac5675
...@@ -221,8 +221,11 @@ class FC(layers.Layer): ...@@ -221,8 +221,11 @@ class FC(layers.Layer):
self._dtype = dtype self._dtype = dtype
from ..layer_helper import LayerHelper from ..layer_helper import LayerHelper
self._helper = LayerHelper( self._helper = LayerHelper(
'FC', param_attr=param_attr, act=act, name=name) 'FC',
self._bias_attr = bias_attr if bias_attr else ParamAttr() param_attr=param_attr,
bias_attr=bias_attr,
act=act,
name=name)
def parameters(self): def parameters(self):
return [self._w, self._b] return [self._w, self._b]
...@@ -256,14 +259,16 @@ class FC(layers.Layer): ...@@ -256,14 +259,16 @@ class FC(layers.Layer):
inputs={"X": [tmp]}, inputs={"X": [tmp]},
outputs={"Out": out}, outputs={"Out": out},
attrs={"use_mkldnn": False}) attrs={"use_mkldnn": False})
if not self._bias_attr:
return out bias_attr = self._helper.bias_attr
if not bias_attr:
return
# add bias # add bias
size = list(out.shape[1:]) size = list(out.shape[1:])
if not self._built: if not self._built:
self._b = self._helper.create_parameter( 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( bias_out = self._helper.create_variable_for_type_inference(
dtype=out.dtype) dtype=out.dtype)
self._helper.append_op( self._helper.append_op(
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册