Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
MMCV
Commits
2aa7712c
Unverified
Commit
2aa7712c
authored
Jun 10, 2020
by
Jerry Jiarui XU
Committed by
GitHub
Jun 10, 2020
Browse files
add more act w.o. inplace opt (#329)
parent
f5be29b2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
1 deletion
+13
-1
mmcv/cnn/bricks/conv_module.py
mmcv/cnn/bricks/conv_module.py
+1
-1
tests/test_cnn/test_conv_module.py
tests/test_cnn/test_conv_module.py
+12
-0
No files found.
mmcv/cnn/bricks/conv_module.py
View file @
2aa7712c
...
@@ -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_
)
...
...
tests/test_cnn/test_conv_module.py
View file @
2aa7712c
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment