mirror of https://github.com/open-mmlab/mmcv.git
add more act w.o. inplace opt (#329)
parent
f5be29b2b0
commit
2aa7712cb7
|
@ -140,7 +140,7 @@ class ConvModule(nn.Module):
|
|||
if self.with_activation:
|
||||
act_cfg_ = act_cfg.copy()
|
||||
# nn.Tanh has no 'inplace' argument
|
||||
if act_cfg_['type'] != 'Tanh':
|
||||
if act_cfg_['type'] not in ['Tanh', 'PReLU', 'Sigmoid']:
|
||||
act_cfg_.setdefault('inplace', inplace)
|
||||
self.activate = build_activation_layer(act_cfg_)
|
||||
|
||||
|
|
|
@ -123,6 +123,18 @@ def test_conv_module():
|
|||
output = conv(x)
|
||||
assert output.shape == (1, 8, 256, 256)
|
||||
|
||||
# Sigmoid
|
||||
conv = ConvModule(3, 8, 3, padding=1, act_cfg=dict(type='Sigmoid'))
|
||||
assert isinstance(conv.activate, nn.Sigmoid)
|
||||
output = conv(x)
|
||||
assert output.shape == (1, 8, 256, 256)
|
||||
|
||||
# PReLU
|
||||
conv = ConvModule(3, 8, 3, padding=1, act_cfg=dict(type='PReLU'))
|
||||
assert isinstance(conv.activate, nn.PReLU)
|
||||
output = conv(x)
|
||||
assert output.shape == (1, 8, 256, 256)
|
||||
|
||||
|
||||
def test_bias():
|
||||
# bias: auto, without norm
|
||||
|
|
Loading…
Reference in New Issue