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
371a2172
Unverified
Commit
371a2172
authored
Mar 20, 2021
by
ZhangShilong
Committed by
GitHub
Mar 20, 2021
Browse files
fix bug of convmodule (#889)
* fix bug of convmodule * fix bug of convmodule * fix unitest * remove assert
parent
97730c23
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
3 deletions
+8
-3
mmcv/cnn/bricks/conv_module.py
mmcv/cnn/bricks/conv_module.py
+6
-1
tests/test_cnn/test_conv_module.py
tests/test_cnn/test_conv_module.py
+2
-2
No files found.
mmcv/cnn/bricks/conv_module.py
View file @
371a2172
...
@@ -146,6 +146,8 @@ class ConvModule(nn.Module):
...
@@ -146,6 +146,8 @@ class ConvModule(nn.Module):
norm_channels
=
in_channels
norm_channels
=
in_channels
self
.
norm_name
,
norm
=
build_norm_layer
(
norm_cfg
,
norm_channels
)
self
.
norm_name
,
norm
=
build_norm_layer
(
norm_cfg
,
norm_channels
)
self
.
add_module
(
self
.
norm_name
,
norm
)
self
.
add_module
(
self
.
norm_name
,
norm
)
else
:
self
.
norm_name
=
None
# build activation layer
# build activation layer
if
self
.
with_activation
:
if
self
.
with_activation
:
...
@@ -162,7 +164,10 @@ class ConvModule(nn.Module):
...
@@ -162,7 +164,10 @@ class ConvModule(nn.Module):
@
property
@
property
def
norm
(
self
):
def
norm
(
self
):
if
self
.
norm_name
:
return
getattr
(
self
,
self
.
norm_name
)
return
getattr
(
self
,
self
.
norm_name
)
else
:
return
None
def
init_weights
(
self
):
def
init_weights
(
self
):
# 1. It is mainly for customized conv layers with their own
# 1. It is mainly for customized conv layers with their own
...
...
tests/test_cnn/test_conv_module.py
View file @
371a2172
...
@@ -75,7 +75,7 @@ def test_conv_module():
...
@@ -75,7 +75,7 @@ def test_conv_module():
assert
conv
.
with_activation
assert
conv
.
with_activation
assert
hasattr
(
conv
,
'activate'
)
assert
hasattr
(
conv
,
'activate'
)
assert
not
conv
.
with_norm
assert
not
conv
.
with_norm
assert
not
hasattr
(
conv
,
'
norm
'
)
assert
conv
.
norm
is
None
x
=
torch
.
rand
(
1
,
3
,
256
,
256
)
x
=
torch
.
rand
(
1
,
3
,
256
,
256
)
output
=
conv
(
x
)
output
=
conv
(
x
)
assert
output
.
shape
==
(
1
,
8
,
255
,
255
)
assert
output
.
shape
==
(
1
,
8
,
255
,
255
)
...
@@ -83,7 +83,7 @@ def test_conv_module():
...
@@ -83,7 +83,7 @@ def test_conv_module():
# conv
# conv
conv
=
ConvModule
(
3
,
8
,
2
,
act_cfg
=
None
)
conv
=
ConvModule
(
3
,
8
,
2
,
act_cfg
=
None
)
assert
not
conv
.
with_norm
assert
not
conv
.
with_norm
assert
not
hasattr
(
conv
,
'
norm
'
)
assert
conv
.
norm
is
None
assert
not
conv
.
with_activation
assert
not
conv
.
with_activation
assert
not
hasattr
(
conv
,
'activate'
)
assert
not
hasattr
(
conv
,
'activate'
)
x
=
torch
.
rand
(
1
,
3
,
256
,
256
)
x
=
torch
.
rand
(
1
,
3
,
256
,
256
)
...
...
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