mirror of https://github.com/open-mmlab/mmcv.git
fix building ConvModule with Tanh activation (#309)
* fix: tanh has not inplace * feat: add ConvModule with Tanhpull/313/head
parent
213156cebb
commit
efecf7d1fe
|
@ -139,7 +139,9 @@ class ConvModule(nn.Module):
|
|||
# build activation layer
|
||||
if self.with_activation:
|
||||
act_cfg_ = act_cfg.copy()
|
||||
act_cfg_.setdefault('inplace', inplace)
|
||||
# nn.Tanh has no 'inplace' argument
|
||||
if act_cfg_['type'] != 'Tanh':
|
||||
act_cfg_.setdefault('inplace', inplace)
|
||||
self.activate = build_activation_layer(act_cfg_)
|
||||
|
||||
# Use msra init by default
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue