NoteOnMe博客平台搭建
Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

28 linhas
1.3 KiB

  1. import tensorflow as tf
  2. slim = tf.contrib.slim
  3. def vgg_arg_scope(weight_decay=0.0005):
  4. with slim.arg_scope([slim.conv2d, slim.fully_connected],
  5. activation_fn=tf.nn.relu,
  6. weights_regularizer=slim.l2_regularizer(weight_decay),
  7. biases_initializer=tf.zeros_initializer()):
  8. with slim.arg_scope([slim.conv2d], padding='SAME') as arg_sc:
  9. return arg_sc
  10. def vgg_16(inputs, scope='vgg_16'):
  11. with tf.variable_scope(scope, 'vgg_16', [inputs]) as sc:
  12. with slim.arg_scope([slim.conv2d, slim.fully_connected, slim.max_pool2d]):
  13. net = slim.repeat(inputs, 2, slim.conv2d, 64, [3, 3], scope='conv1')
  14. net = slim.max_pool2d(net, [2, 2], scope='pool1')
  15. net = slim.repeat(net, 2, slim.conv2d, 128, [3, 3], scope='conv2')
  16. net = slim.max_pool2d(net, [2, 2], scope='pool2')
  17. net = slim.repeat(net, 3, slim.conv2d, 256, [3, 3], scope='conv3')
  18. net = slim.max_pool2d(net, [2, 2], scope='pool3')
  19. net = slim.repeat(net, 3, slim.conv2d, 512, [3, 3], scope='conv4')
  20. net = slim.max_pool2d(net, [2, 2], scope='pool4')
  21. net = slim.repeat(net, 3, slim.conv2d, 512, [3, 3], scope='conv5')
  22. return net