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
f870a49c
Commit
f870a49c
authored
Feb 28, 2018
by
Yuxin Wu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[FasterRCNN] allow FREEZE_AFFINE
parent
43d2bffb
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
2 deletions
+16
-2
examples/FasterRCNN/basemodel.py
examples/FasterRCNN/basemodel.py
+14
-1
examples/FasterRCNN/config.py
examples/FasterRCNN/config.py
+1
-0
tensorpack/models/batch_norm.py
tensorpack/models/batch_norm.py
+1
-1
No files found.
examples/FasterRCNN/basemodel.py
View file @
f870a49c
...
...
@@ -9,12 +9,25 @@ from tensorpack.tfutils.scope_utils import auto_reuse_variable_scope
from
tensorpack.models
import
(
Conv2D
,
MaxPooling
,
BatchNorm
,
BNReLU
)
import
config
def
maybe_freeze_affine
(
getter
,
*
args
,
**
kwargs
):
# custom getter to freeze affine params inside bn
name
=
args
[
0
]
if
len
(
args
)
else
kwargs
.
get
(
'name'
)
if
name
.
endswith
(
'/gamma'
)
or
name
.
endswith
(
'/beta'
):
if
config
.
FREEZE_AFFINE
:
kwargs
[
'trainable'
]
=
False
return
getter
(
*
args
,
**
kwargs
)
@
contextmanager
def
resnet_argscope
():
with
argscope
([
Conv2D
,
MaxPooling
,
BatchNorm
],
data_format
=
'NCHW'
),
\
argscope
(
Conv2D
,
use_bias
=
False
),
\
argscope
(
BatchNorm
,
use_local_stat
=
False
):
argscope
(
BatchNorm
,
use_local_stat
=
False
),
\
tf
.
variable_scope
(
tf
.
get_variable_scope
(),
custom_getter
=
maybe_freeze_affine
):
yield
...
...
examples/FasterRCNN/config.py
View file @
f870a49c
...
...
@@ -17,6 +17,7 @@ CLASS_NAMES = [] # NUM_CLASS strings. Will be populated later by coco loader
# basemodel ----------------------
RESNET_NUM_BLOCK
=
[
3
,
4
,
6
,
3
]
# for resnet50
# RESNET_NUM_BLOCK = [3, 4, 23, 3] # for resnet101
FREEZE_AFFINE
=
False
# do not train affine parameters inside BN
# schedule -----------------------
BASE_LR
=
1e-2
...
...
tensorpack/models/batch_norm.py
View file @
f870a49c
...
...
@@ -201,7 +201,7 @@ def BatchNorm(x, use_local_stat=None, momentum=0.9, epsilon=1e-5,
'decay'
:
'momentum'
})
def
BatchRenorm
(
x
,
rmax
,
dmax
,
momentum
=
0.9
,
epsilon
=
1e-5
,
scale
=
True
,
bias
=
True
,
gamma_initializer
=
None
,
scale
=
True
,
center
=
True
,
gamma_initializer
=
None
,
data_format
=
'channels_last'
):
"""
Batch Renormalization layer, as described in the paper:
...
...
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