def fc_layers(net,
scope,
end_points_collection,
num_classes=1000,
is_training=True,
dropout_keep_prob=0.5,
spatial_squeeze=True,
name_prefix=None):
full_scope_name = lambda scope_name: scope_name if name_prefix is None else '%s_%s' % (name_prefix, scope_name)
# Use conv2d instead of fully_connected layers.
with slim.arg_scope([slim.conv2d],
weights_initializer=trunc_normal(0.005),
biases_initializer=tf.constant_initializer(0.1),
outputs_collections=[end_points_collection]):
net = slim.conv2d(net, num_classes, [1, 1],
activation_fn=None,
normalizer_fn=None,
biases_initializer=tf.zeros_initializer(),
scope=full_scope_name('fc8'))
if spatial_squeeze:
net = tf.squeeze(net, [1, 2], name=full_scope_name('fc8/squeezed'))
ops.add_to_collection(end_points_collection, net)
return net, end_points_collection
评论列表
文章目录