Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
seminar-breakout
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Shashank Suhas
seminar-breakout
Commits
8591e253
Commit
8591e253
authored
Aug 29, 2017
by
Yuxin Wu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[ResNet] add non-preact resnet
parent
6a143365
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
2 deletions
+23
-2
examples/ResNet/imagenet_resnet_utils.py
examples/ResNet/imagenet_resnet_utils.py
+23
-2
No files found.
examples/ResNet/imagenet_resnet_utils.py
View file @
8591e253
...
...
@@ -139,9 +139,9 @@ def apply_preactivation(l, preact):
def
get_bn
(
zero_init
=
False
):
if
zero_init
:
return
lambda
x
,
_
:
BatchNorm
(
'bn'
,
x
,
gamma_init
=
tf
.
zeros_initializer
())
return
lambda
x
,
name
:
BatchNorm
(
'bn'
,
x
,
gamma_init
=
tf
.
zeros_initializer
())
else
:
return
lambda
x
,
_
:
BatchNorm
(
'bn'
,
x
)
return
lambda
x
,
name
:
BatchNorm
(
'bn'
,
x
)
def
preresnet_basicblock
(
l
,
ch_out
,
stride
,
preact
):
...
...
@@ -172,6 +172,27 @@ def preresnet_group(l, name, block_func, features, count, stride):
return
l
def
resnet_bottleneck
(
l
,
ch_out
,
stride
,
preact
):
l
,
shortcut
=
apply_preactivation
(
l
,
preact
)
l
=
Conv2D
(
'conv1'
,
l
,
ch_out
,
1
,
nl
=
BNReLU
)
l
=
Conv2D
(
'conv2'
,
l
,
ch_out
,
3
,
stride
=
stride
,
nl
=
BNReLU
)
l
=
Conv2D
(
'conv3'
,
l
,
ch_out
*
4
,
1
,
nl
=
get_bn
(
zero_init
=
True
))
return
l
+
resnet_shortcut
(
shortcut
,
ch_out
*
4
,
stride
,
nl
=
get_bn
(
zero_init
=
False
))
def
resnet_group
(
l
,
name
,
block_func
,
features
,
count
,
stride
):
with
tf
.
variable_scope
(
name
):
for
i
in
range
(
0
,
count
):
with
tf
.
variable_scope
(
'block{}'
.
format
(
i
)):
# first block doesn't need activation
l
=
block_func
(
l
,
features
,
stride
if
i
==
0
else
1
,
'no_preact'
if
i
==
0
else
'relu'
)
# end of each group need an extra activation
l
=
tf
.
nn
.
relu
(
l
)
return
l
def
resnet_backbone
(
image
,
num_blocks
,
group_func
,
block_func
):
with
argscope
(
Conv2D
,
nl
=
tf
.
identity
,
use_bias
=
False
,
W_init
=
variance_scaling_initializer
(
mode
=
'FAN_OUT'
)):
...
...
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