Unverified Commit efecf7d1 authored by Harry's avatar Harry Committed by GitHub
Browse files

fix building ConvModule with Tanh activation (#309)

* fix: tanh has not inplace

* feat: add ConvModule with Tanh
parent 213156ce
......@@ -139,6 +139,8 @@ class ConvModule(nn.Module):
# build activation layer
if self.with_activation:
act_cfg_ = act_cfg.copy()
# nn.Tanh has no 'inplace' argument
if act_cfg_['type'] != 'Tanh':
act_cfg_.setdefault('inplace', inplace)
self.activate = build_activation_layer(act_cfg_)
......
......@@ -117,6 +117,12 @@ def test_conv_module():
output = conv(x)
assert output.shape == (1, 8, 256, 256)
# tanh
conv = ConvModule(3, 8, 3, padding=1, act_cfg=dict(type='Tanh'))
assert isinstance(conv.activate, nn.Tanh)
output = conv(x)
assert output.shape == (1, 8, 256, 256)
def test_bias():
# bias: auto, without norm
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment