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
afa55d8b
Unverified
Commit
afa55d8b
authored
Oct 09, 2018
by
yl-1993
Committed by
GitHub
Oct 09, 2018
Browse files
Merge branch 'cnn' into cnn
parents
f63f2a97
9af1a2b0
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
3 deletions
+45
-3
mmcv/cnn/__init__.py
mmcv/cnn/__init__.py
+6
-3
mmcv/cnn/weight_init.py
mmcv/cnn/weight_init.py
+39
-0
No files found.
mmcv/cnn/__init__.py
View file @
afa55d8b
from
.alexnet
import
AlexNet
from
.alexnet
import
AlexNet
from
.vgg
import
VGG
,
make_vgg_layer
from
.vgg
import
VGG
,
make_vgg_layer
from
.resnet
import
ResNet
,
make_res_layer
from
.resnet
import
ResNet
,
make_res_layer
from
.weight_init
import
xavier_init
,
normal_init
,
uniform_init
,
kaiming_init
__all__
=
[
'AlexNet'
,
__all__
=
[
'VGG'
,
'make_vgg_layer'
,
'AlexNet'
,
'VGG'
,
'make_vgg_layer'
,
'ResNet'
,
'make_res_layer'
]
'ResNet'
,
'make_res_layer'
,
'xavier_init'
,
'normal_init'
,
'uniform_init'
,
'kaiming_init'
]
\ No newline at end of file
mmcv/cnn/weight_init.py
0 → 100644
View file @
afa55d8b
import
torch.nn
as
nn
def
xavier_init
(
module
,
gain
=
1
,
bias
=
0
,
distribution
=
'normal'
):
assert
distribution
in
[
'uniform'
,
'normal'
]
if
distribution
==
'uniform'
:
nn
.
init
.
xavier_uniform_
(
module
.
weight
,
gain
=
gain
)
else
:
nn
.
init
.
xavier_normal_
(
module
.
weight
,
gain
=
gain
)
if
hasattr
(
module
,
'bias'
):
nn
.
init
.
constant_
(
module
.
bias
,
bias
)
def
normal_init
(
module
,
mean
=
0
,
std
=
1
,
bias
=
0
):
nn
.
init
.
normal_
(
module
.
weight
,
mean
,
std
)
if
hasattr
(
module
,
'bias'
):
nn
.
init
.
constant_
(
module
.
bias
,
bias
)
def
uniform_init
(
module
,
a
=
0
,
b
=
1
,
bias
=
0
):
nn
.
init
.
uniform_
(
module
.
weight
,
a
,
b
)
if
hasattr
(
module
,
'bias'
):
nn
.
init
.
constant_
(
module
.
bias
,
bias
)
def
kaiming_init
(
module
,
mode
=
'fan_out'
,
nonlinearity
=
'relu'
,
bias
=
0
,
distribution
=
'normal'
):
assert
distribution
in
[
'uniform'
,
'normal'
]
if
distribution
==
'uniform'
:
nn
.
init
.
kaiming_uniform_
(
module
.
weight
,
mode
=
mode
,
nonlinearity
=
nonlinearity
)
else
:
nn
.
init
.
kaiming_normal_
(
module
.
weight
,
mode
=
mode
,
nonlinearity
=
nonlinearity
)
if
hasattr
(
module
,
'bias'
):
nn
.
init
.
constant_
(
module
.
bias
,
bias
)
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