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
4b2abfcf
Commit
4b2abfcf
authored
Oct 09, 2018
by
Kai Chen
Browse files
minor format adjustment
parent
64afdd0a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
18 deletions
+10
-18
mmcv/cnn/__init__.py
mmcv/cnn/__init__.py
+2
-3
mmcv/cnn/vgg.py
mmcv/cnn/vgg.py
+8
-15
No files found.
mmcv/cnn/__init__.py
View file @
4b2abfcf
...
@@ -4,7 +4,6 @@ from .resnet import ResNet, make_res_layer
...
@@ -4,7 +4,6 @@ from .resnet import ResNet, make_res_layer
from
.weight_init
import
xavier_init
,
normal_init
,
uniform_init
,
kaiming_init
from
.weight_init
import
xavier_init
,
normal_init
,
uniform_init
,
kaiming_init
__all__
=
[
__all__
=
[
'AlexNet'
,
'VGG'
,
'make_vgg_layer'
,
'AlexNet'
,
'VGG'
,
'make_vgg_layer'
,
'ResNet'
,
'make_res_layer'
,
'ResNet'
,
'make_res_layer'
,
'xavier_init'
,
'normal_init'
,
'uniform_init'
,
'xavier_init'
,
'normal_init'
,
'uniform_init'
,
'kaiming_init'
'kaiming_init'
]
]
mmcv/cnn/vgg.py
View file @
4b2abfcf
...
@@ -16,15 +16,10 @@ def conv3x3(in_planes, out_planes, dilation=1, bias=False):
...
@@ -16,15 +16,10 @@ def conv3x3(in_planes, out_planes, dilation=1, bias=False):
bias
=
bias
)
bias
=
bias
)
def
make_vgg_layer
(
inplanes
,
def
make_vgg_layer
(
inplanes
,
planes
,
num_blocks
,
dilation
=
1
,
with_bn
=
False
):
planes
,
num_blocks
,
dilation
=
1
,
with_bn
=
False
):
layers
=
[]
layers
=
[]
for
_
in
range
(
num_blocks
):
for
_
in
range
(
num_blocks
):
layers
.
append
(
layers
.
append
(
conv3x3
(
inplanes
,
planes
,
dilation
,
not
with_bn
))
conv3x3
(
inplanes
,
planes
,
dilation
,
not
with_bn
))
if
with_bn
:
if
with_bn
:
layers
.
append
(
nn
.
BatchNorm2d
(
planes
))
layers
.
append
(
nn
.
BatchNorm2d
(
planes
))
layers
.
append
(
nn
.
ReLU
(
inplace
=
True
))
layers
.
append
(
nn
.
ReLU
(
inplace
=
True
))
...
@@ -89,11 +84,11 @@ class VGG(nn.Module):
...
@@ -89,11 +84,11 @@ class VGG(nn.Module):
dilation
=
dilations
[
i
]
dilation
=
dilations
[
i
]
planes
=
64
*
2
**
i
if
i
<
4
else
512
planes
=
64
*
2
**
i
if
i
<
4
else
512
vgg_layer
=
make_vgg_layer
(
vgg_layer
=
make_vgg_layer
(
self
.
inplanes
,
self
.
inplanes
,
planes
,
planes
,
num_blocks
,
num_blocks
,
dilation
=
dilation
,
dilation
=
dilation
,
with_bn
=
with_bn
)
with_bn
=
with_bn
)
self
.
inplanes
=
planes
self
.
inplanes
=
planes
layer_name
=
'layer{}'
.
format
(
i
+
1
)
layer_name
=
'layer{}'
.
format
(
i
+
1
)
self
.
add_module
(
layer_name
,
vgg_layer
)
self
.
add_module
(
layer_name
,
vgg_layer
)
...
@@ -118,9 +113,7 @@ class VGG(nn.Module):
...
@@ -118,9 +113,7 @@ class VGG(nn.Module):
for
m
in
self
.
modules
():
for
m
in
self
.
modules
():
if
isinstance
(
m
,
nn
.
Conv2d
):
if
isinstance
(
m
,
nn
.
Conv2d
):
nn
.
init
.
kaiming_normal_
(
nn
.
init
.
kaiming_normal_
(
m
.
weight
,
m
.
weight
,
mode
=
'fan_out'
,
nonlinearity
=
'relu'
)
mode
=
'fan_out'
,
nonlinearity
=
'relu'
)
if
m
.
bias
is
not
None
:
if
m
.
bias
is
not
None
:
nn
.
init
.
constant_
(
m
.
bias
,
0
)
nn
.
init
.
constant_
(
m
.
bias
,
0
)
elif
isinstance
(
m
,
nn
.
BatchNorm2d
):
elif
isinstance
(
m
,
nn
.
BatchNorm2d
):
...
...
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