VGG-16又称为OxfordNet,是由牛津视觉几何组(Visual Geometry Group)开发的卷积神经网络结构。
VGG在2014年的 ILSVRC localization and classification 两个问题上分别取得了第一名和第二名
论文原标题《VERY DEEP CONVOLUTIONAL NETWORK SFOR LARGE-SCALE IMAGE RECOGNITION》
论文被发表在ICLR 2015上,比较起ALEXNET, VGG对图片有更精确的估值以及更省空间。
网络结构:http://ethereon.github.io/netscope/#/preset/vgg-16
如下图:
由上图可以清晰的看出13个卷积层+3个全连接层=16层。
testvgg.py如下:
import numpy as np
import tensorflow as tf
import vgg16
import utils
#https://github.com/leihe001/tensorflow-vgg
img1 = utils.load_image("./test_data/laska.jpg")
img2 = utils.load_image("./test_data/puzzle.jpeg")
batch1 = img1.reshape((1, 224, 224, 3))
batch2 = img2.reshape((1, 224, 224, 3))
batch = np.concatenate((batch1, batch2), 0)
with tf.Session(
config=tf.ConfigProto(gpu_options=(tf.GPUOptions(per_process_gpu_memory_fraction=0.7)))) as sess:
images = tf.placeholder("float", [2, 224, 224, 3])
feed_dict = {images: batch}
vgg = vgg16.Vgg16()
with tf.name_scope("content_vgg"):
vgg.build(images)
prob = sess.run(vgg.prob, feed_dict=feed_dict)
print(prob)
utils.print_prob(prob[0], './synset.txt')
utils.print_prob(prob[1], './synset.txt')
结果如下:
需要下载vgg16.npy
网址为 ftp://mi.eng.cam.ac.uk/pub/mttt2/models/vgg16.npy
参考文献:
1.常见网络结构
http://www.cnblogs.com/houkai/p/6553221.html#_caption_4
2.vgg in tensorflow
https://www.cs.toronto.edu/~frossard/post/vgg16/