|
import tensorflow as tf
|
|
|
|
slim = tf.contrib.slim
|
|
|
|
|
|
def vgg_arg_scope(weight_decay=0.0005):
|
|
with slim.arg_scope([slim.conv2d, slim.fully_connected],
|
|
activation_fn=tf.nn.relu,
|
|
weights_regularizer=slim.l2_regularizer(weight_decay),
|
|
biases_initializer=tf.zeros_initializer()):
|
|
with slim.arg_scope([slim.conv2d], padding='SAME') as arg_sc:
|
|
return arg_sc
|
|
|
|
|
|
def vgg_16(inputs, scope='vgg_16'):
|
|
with tf.variable_scope(scope, 'vgg_16', [inputs]) as sc:
|
|
with slim.arg_scope([slim.conv2d, slim.fully_connected, slim.max_pool2d]):
|
|
net = slim.repeat(inputs, 2, slim.conv2d, 64, [3, 3], scope='conv1')
|
|
net = slim.max_pool2d(net, [2, 2], scope='pool1')
|
|
net = slim.repeat(net, 2, slim.conv2d, 128, [3, 3], scope='conv2')
|
|
net = slim.max_pool2d(net, [2, 2], scope='pool2')
|
|
net = slim.repeat(net, 3, slim.conv2d, 256, [3, 3], scope='conv3')
|
|
net = slim.max_pool2d(net, [2, 2], scope='pool3')
|
|
net = slim.repeat(net, 3, slim.conv2d, 512, [3, 3], scope='conv4')
|
|
net = slim.max_pool2d(net, [2, 2], scope='pool4')
|
|
net = slim.repeat(net, 3, slim.conv2d, 512, [3, 3], scope='conv5')
|
|
|
|
return net
|