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
ModelZoo
ResNet50_tensorflow
Commits
32229eae
Commit
32229eae
authored
Oct 15, 2019
by
Yeqing Li
Committed by
A. Unique TensorFlower
Oct 15, 2019
Browse files
Internal change
PiperOrigin-RevId: 274918820
parent
63e20270
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
8 deletions
+9
-8
official/vision/detection/modeling/architecture/heads.py
official/vision/detection/modeling/architecture/heads.py
+6
-6
official/vision/detection/modeling/architecture/nn_ops.py
official/vision/detection/modeling/architecture/nn_ops.py
+3
-2
No files found.
official/vision/detection/modeling/architecture/heads.py
View file @
32229eae
...
...
@@ -124,7 +124,7 @@ class FastrcnnHead(object):
"""
self
.
_num_classes
=
num_classes
self
.
_mlp_head_dim
=
mlp_head_dim
self
.
_batch_norm_relu
=
batch_norm_relu
()
self
.
_batch_norm_relu
=
batch_norm_relu
def
__call__
(
self
,
roi_features
,
is_training
=
None
):
"""Box and class branches for the Mask-RCNN model.
...
...
@@ -151,11 +151,11 @@ class FastrcnnHead(object):
units
=
self
.
_mlp_head_dim
,
activation
=
None
,
name
=
'fc6'
)(
roi_features
)
net
=
self
.
_batch_norm_relu
(
net
,
is_training
=
is_training
)
net
=
self
.
_batch_norm_relu
(
fused
=
False
)(
net
,
is_training
=
is_training
)
net
=
tf
.
keras
.
layers
.
Dense
(
units
=
self
.
_mlp_head_dim
,
activation
=
None
,
name
=
'fc7'
)(
net
)
net
=
self
.
_batch_norm_relu
(
net
,
is_training
=
is_training
)
net
=
self
.
_batch_norm_relu
(
fused
=
False
)(
net
,
is_training
=
is_training
)
class_outputs
=
tf
.
keras
.
layers
.
Dense
(
self
.
_num_classes
,
...
...
@@ -189,7 +189,7 @@ class MaskrcnnHead(object):
"""
self
.
_num_classes
=
num_classes
self
.
_mrcnn_resolution
=
mrcnn_resolution
self
.
_batch_norm_relu
=
batch_norm_relu
()
self
.
_batch_norm_relu
=
batch_norm_relu
def
__call__
(
self
,
roi_features
,
class_indices
,
is_training
=
None
):
"""Mask branch for the Mask-RCNN model.
...
...
@@ -240,7 +240,7 @@ class MaskrcnnHead(object):
bias_initializer
=
tf
.
zeros_initializer
(),
name
=
'mask-conv-l%d'
%
i
)(
net
)
net
=
self
.
_batch_norm_relu
(
net
,
is_training
=
is_training
)
net
=
self
.
_batch_norm_relu
(
)(
net
,
is_training
=
is_training
)
kernel_size
=
(
2
,
2
)
fan_out
=
256
...
...
@@ -256,7 +256,7 @@ class MaskrcnnHead(object):
bias_initializer
=
tf
.
zeros_initializer
(),
name
=
'conv5-mask'
)(
net
)
net
=
self
.
_batch_norm_relu
(
net
,
is_training
=
is_training
)
net
=
self
.
_batch_norm_relu
(
)(
net
,
is_training
=
is_training
)
kernel_size
=
(
1
,
1
)
fan_out
=
self
.
_num_classes
...
...
official/vision/detection/modeling/architecture/nn_ops.py
View file @
32229eae
...
...
@@ -31,6 +31,7 @@ class BatchNormRelu(tf.keras.layers.Layer):
trainable
=
True
,
relu
=
True
,
init_zero
=
False
,
fused
=
True
,
name
=
None
):
"""A class to construct layers for a batch normalization followed by a ReLU.
...
...
@@ -43,6 +44,7 @@ class BatchNormRelu(tf.keras.layers.Layer):
relu: `bool` if False, omits the ReLU operation.
init_zero: `bool` if True, initializes scale parameter of batch
normalization with 0. If False, initialize it with 1.
fused: `bool` fused option in batch normalziation.
name: `str` name for the operation.
"""
self
.
_use_relu
=
relu
...
...
@@ -51,14 +53,13 @@ class BatchNormRelu(tf.keras.layers.Layer):
gamma_initializer
=
tf
.
keras
.
initializers
.
Zeros
()
else
:
gamma_initializer
=
tf
.
keras
.
initializers
.
Ones
()
# TODO(yeqing): Check if we can change the fused=True again.
self
.
_batch_norm_op
=
tf
.
keras
.
layers
.
BatchNormalization
(
momentum
=
momentum
,
epsilon
=
epsilon
,
center
=
True
,
scale
=
True
,
trainable
=
trainable
,
fused
=
Fal
se
,
fused
=
fu
se
d
,
gamma_initializer
=
gamma_initializer
,
name
=
name
)
...
...
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