"git@developer.sourcefind.cn:OpenDAS/ollama.git" did not exist on "564b558c92973ae9eda4ad585359e7f39b2dbff2"
Commit 96845c19 authored by Jeremy Lewi's avatar Jeremy Lewi Committed by Sergio Guadarrama
Browse files

Add an option to make auxilary logits optional in inception v3. (#1862)

parent 3d97b007
...@@ -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'):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment