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
96845c19
"git@developer.sourcefind.cn:OpenDAS/mmdetection3d.git" did not exist on "2799b660556801568367d5fa24595ef79274d3a3"
Commit
96845c19
authored
Jul 10, 2017
by
Jeremy Lewi
Committed by
Sergio Guadarrama
Jul 10, 2017
Browse files
Add an option to make auxilary logits optional in inception v3. (#1862)
parent
3d97b007
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
24 deletions
+27
-24
slim/nets/inception_v3.py
slim/nets/inception_v3.py
+27
-24
No files found.
slim/nets/inception_v3.py
View file @
96845c19
...
@@ -425,6 +425,7 @@ def inception_v3(inputs,
...
@@ -425,6 +425,7 @@ def inception_v3(inputs,
prediction_fn
=
slim
.
softmax
,
prediction_fn
=
slim
.
softmax
,
spatial_squeeze
=
True
,
spatial_squeeze
=
True
,
reuse
=
None
,
reuse
=
None
,
create_aux_logits
=
True
,
scope
=
'InceptionV3'
):
scope
=
'InceptionV3'
):
"""Inception model from http://arxiv.org/abs/1512.00567.
"""Inception model from http://arxiv.org/abs/1512.00567.
...
@@ -457,6 +458,7 @@ def inception_v3(inputs,
...
@@ -457,6 +458,7 @@ def inception_v3(inputs,
of shape [B, 1, 1, C], where B is batch_size and C is number of classes.
of shape [B, 1, 1, C], where B is batch_size and C is number of classes.
reuse: whether or not the network and its variables should be reused. To be
reuse: whether or not the network and its variables should be reused. To be
able to reuse 'scope' must be given.
able to reuse 'scope' must be given.
create_aux_logits: Whether to create the auxiliary logits.
scope: Optional variable_scope.
scope: Optional variable_scope.
Returns:
Returns:
...
@@ -481,30 +483,31 @@ def inception_v3(inputs,
...
@@ -481,30 +483,31 @@ def inception_v3(inputs,
depth_multiplier
=
depth_multiplier
)
depth_multiplier
=
depth_multiplier
)
# Auxiliary Head logits
# Auxiliary Head logits
with
slim
.
arg_scope
([
slim
.
conv2d
,
slim
.
max_pool2d
,
slim
.
avg_pool2d
],
if
create_aux_logits
:
stride
=
1
,
padding
=
'SAME'
):
with
slim
.
arg_scope
([
slim
.
conv2d
,
slim
.
max_pool2d
,
slim
.
avg_pool2d
],
aux_logits
=
end_points
[
'Mixed_6e'
]
stride
=
1
,
padding
=
'SAME'
):
with
tf
.
variable_scope
(
'AuxLogits'
):
aux_logits
=
end_points
[
'Mixed_6e'
]
aux_logits
=
slim
.
avg_pool2d
(
with
tf
.
variable_scope
(
'AuxLogits'
):
aux_logits
,
[
5
,
5
],
stride
=
3
,
padding
=
'VALID'
,
aux_logits
=
slim
.
avg_pool2d
(
scope
=
'AvgPool_1a_5x5'
)
aux_logits
,
[
5
,
5
],
stride
=
3
,
padding
=
'VALID'
,
aux_logits
=
slim
.
conv2d
(
aux_logits
,
depth
(
128
),
[
1
,
1
],
scope
=
'AvgPool_1a_5x5'
)
scope
=
'Conv2d_1b_1x1'
)
aux_logits
=
slim
.
conv2d
(
aux_logits
,
depth
(
128
),
[
1
,
1
],
scope
=
'Conv2d_1b_1x1'
)
# Shape of feature map before the final layer.
kernel_size
=
_reduced_kernel_size_for_small_input
(
# Shape of feature map before the final layer.
aux_logits
,
[
5
,
5
])
kernel_size
=
_reduced_kernel_size_for_small_input
(
aux_logits
=
slim
.
conv2d
(
aux_logits
,
[
5
,
5
])
aux_logits
,
depth
(
768
),
kernel_size
,
aux_logits
=
slim
.
conv2d
(
weights_initializer
=
trunc_normal
(
0.01
),
aux_logits
,
depth
(
768
),
kernel_size
,
padding
=
'VALID'
,
scope
=
'Conv2d_2a_{}x{}'
.
format
(
*
kernel_size
))
weights_initializer
=
trunc_normal
(
0.01
),
aux_logits
=
slim
.
conv2d
(
padding
=
'VALID'
,
scope
=
'Conv2d_2a_{}x{}'
.
format
(
*
kernel_size
))
aux_logits
,
num_classes
,
[
1
,
1
],
activation_fn
=
None
,
aux_logits
=
slim
.
conv2d
(
normalizer_fn
=
None
,
weights_initializer
=
trunc_normal
(
0.001
),
aux_logits
,
num_classes
,
[
1
,
1
],
activation_fn
=
None
,
scope
=
'Conv2d_2b_1x1'
)
normalizer_fn
=
None
,
weights_initializer
=
trunc_normal
(
0.001
),
if
spatial_squeeze
:
scope
=
'Conv2d_2b_1x1'
)
aux_logits
=
tf
.
squeeze
(
aux_logits
,
[
1
,
2
],
name
=
'SpatialSqueeze'
)
if
spatial_squeeze
:
end_points
[
'AuxLogits'
]
=
aux_logits
aux_logits
=
tf
.
squeeze
(
aux_logits
,
[
1
,
2
],
name
=
'SpatialSqueeze'
)
end_points
[
'AuxLogits'
]
=
aux_logits
# Final pooling and prediction
# Final pooling and prediction
with
tf
.
variable_scope
(
'Logits'
):
with
tf
.
variable_scope
(
'Logits'
):
...
...
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