未验证 提交 23b2acb4 编写于 作者: M minghaoBD 提交者: GitHub

fix mbv3 latency error caused by ReLU6 (#884)

上级 15ef0c7d
...@@ -77,7 +77,6 @@ class MobileNetV3(): ...@@ -77,7 +77,6 @@ class MobileNetV3():
if_act=True, if_act=True,
act='hard_swish', act='hard_swish',
name='conv1') name='conv1')
print(conv.shape)
i = 0 i = 0
for layer_cfg in cfg: for layer_cfg in cfg:
conv = self.residual_unit( conv = self.residual_unit(
...@@ -115,8 +114,7 @@ class MobileNetV3(): ...@@ -115,8 +114,7 @@ class MobileNetV3():
act=None, act=None,
param_attr=ParamAttr(name='last_1x1_conv_weights'), param_attr=ParamAttr(name='last_1x1_conv_weights'),
bias_attr=False) bias_attr=False)
#conv = fluid.layers.hard_swish(conv) conv = fluid.layers.hard_swish(conv)
conv = self.hard_swish(conv)
out = fluid.layers.fc(input=conv, out = fluid.layers.fc(input=conv,
size=class_dim, size=class_dim,
param_attr=ParamAttr(name='fc_weights'), param_attr=ParamAttr(name='fc_weights'),
...@@ -162,8 +160,7 @@ class MobileNetV3(): ...@@ -162,8 +160,7 @@ class MobileNetV3():
if act == 'relu': if act == 'relu':
bn = fluid.layers.relu(bn) bn = fluid.layers.relu(bn)
elif act == 'hard_swish': elif act == 'hard_swish':
#bn = fluid.layers.hard_swish(bn) bn = fluid.layers.hard_swish(bn)
bn = self.hard_swish(bn)
return bn return bn
def hard_swish(self, x): def hard_swish(self, x):
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册