Unverified Commit 2aa7712c authored by Jerry Jiarui XU's avatar Jerry Jiarui XU Committed by GitHub
Browse files

add more act w.o. inplace opt (#329)

parent f5be29b2
...@@ -140,7 +140,7 @@ class ConvModule(nn.Module): ...@@ -140,7 +140,7 @@ class ConvModule(nn.Module):
if self.with_activation: if self.with_activation:
act_cfg_ = act_cfg.copy() act_cfg_ = act_cfg.copy()
# nn.Tanh has no 'inplace' argument # 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) act_cfg_.setdefault('inplace', inplace)
self.activate = build_activation_layer(act_cfg_) self.activate = build_activation_layer(act_cfg_)
......
...@@ -123,6 +123,18 @@ def test_conv_module(): ...@@ -123,6 +123,18 @@ def test_conv_module():
output = conv(x) output = conv(x)
assert output.shape == (1, 8, 256, 256) 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(): def test_bias():
# bias: auto, without norm # 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