提交 3c09a57e 编写于 作者: X Xin Pan

fix bias

test=develop
上级 c8c3efad
...@@ -261,21 +261,20 @@ class FC(layers.Layer): ...@@ -261,21 +261,20 @@ class FC(layers.Layer):
attrs={"use_mkldnn": False}) attrs={"use_mkldnn": False})
bias_attr = self._helper.bias_attr bias_attr = self._helper.bias_attr
if not bias_attr: if bias_attr:
return # add bias
size = list(out.shape[1:])
# add bias if not self._built:
size = list(out.shape[1:]) self._b = self._helper.create_parameter(
if not self._built: attr=bias_attr, shape=size, dtype=out.dtype, is_bias=True)
self._b = self._helper.create_parameter( bias_out = self._helper.create_variable_for_type_inference(
attr=bias_attr, shape=size, dtype=out.dtype, is_bias=True) dtype=out.dtype)
bias_out = self._helper.create_variable_for_type_inference( self._helper.append_op(
dtype=out.dtype) type='elementwise_add',
self._helper.append_op( inputs={'X': [out],
type='elementwise_add', 'Y': [self._b]},
inputs={'X': [out], outputs={'Out': [bias_out]},
'Y': [self._b]}, attrs={'axis': 1})
outputs={'Out': [bias_out]}, out = bias_out
attrs={'axis': 1})
# add activation # add activation
return self._helper.append_activation(bias_out) return self._helper.append_activation(out)
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册