Main Content

vgg16

VGG-16 convolutional neural network

  • VGG-16 network architecture

Description

VGG-16 is a convolutional neural network that is 16 layers deep. You can load a pretrained version of the network trained on more than a million images from the ImageNet database[1]. The pretrained network can classify images into 1000 object categories, such as keyboard, mouse, pencil, and many animals. As a result, the network has learned rich feature representations for a wide range of images. The network has an image input size of 224-by-224. For more pretrained networks in MATLAB®, seePretrained Deep Neural Networks.

You can useclassifyto classify new images using the VGG-16 network. Follow the steps ofClassify Image Using GoogLeNetand replace GoogLeNet with VGG-16.

To retrain the network on a new classification task, follow the steps ofTrain Deep Learning Network to Classify New Imagesand load VGG-16 instead of GoogLeNet.

example

net= vgg16returns a VGG-16 network trained on the ImageNet data set.

This function requires Deep Learning Toolbox™ Modelfor VGG-16 Networksupport package. If this support package is not installed, then the function provides a download link.

net= vgg16('Weights','imagenet')returns a VGG-16 network trained on the ImageNet data set. This syntax is equivalent tonet = vgg16.

layers= vgg16('Weights','none')returns the untrained VGG-16 network architecture. The untrained model does not require the support package.

Examples

collapse all

Download and install Deep Learning Toolbox Modelfor VGG-16 Networksupport package.

Typevgg16at the command line.

vgg16

If Deep Learning Toolbox Modelfor VGG-16 Network万博1manbetx支持包没有安装,然后手段n provides a link to the required support package in the Add-On Explorer. To install the support package, click the link, and then clickInstall. Check that the installation is successful by typingvgg16at the command line.

vgg16
ans = SeriesNetwork with properties: Layers: [41×1 nnet.cnn.layer.Layer]

Visualize the network using Deep Network Designer.

deepNetworkDesigner(vgg16)

Explore other pretrained networks in Deep Network Designer by clickingNew.

Deep Network Designer start page showing available pretrained networks

If you need to download a network, pause on the desired network and clickInstallto open the Add-On Explorer.

Load a pretrained VGG-16 convolutional neural network and examine the layers and classes.

Usevgg16to load the pretrained VGG-16 network. The outputnetis aSeriesNetworkobject.

net = vgg16
net = SeriesNetwork with properties: Layers: [41×1 nnet.cnn.layer.Layer]

View the network architecture using theLayersproperty. The network has 41 layers. There are 16 layers with learnable weights: 13 convolutional layers, and 3 fully connected layers.

net.Layers
ans = 41 x1层与层:数组1输入图像放大e Input 224x224x3 images with 'zerocenter' normalization 2 'conv1_1' Convolution 64 3x3x3 convolutions with stride [1 1] and padding [1 1 1 1] 3 'relu1_1' ReLU ReLU 4 'conv1_2' Convolution 64 3x3x64 convolutions with stride [1 1] and padding [1 1 1 1] 5 'relu1_2' ReLU ReLU 6 'pool1' Max Pooling 2x2 max pooling with stride [2 2] and padding [0 0 0 0] 7 'conv2_1' Convolution 128 3x3x64 convolutions with stride [1 1] and padding [1 1 1 1] 8 'relu2_1' ReLU ReLU 9 'conv2_2' Convolution 128 3x3x128 convolutions with stride [1 1] and padding [1 1 1 1] 10 'relu2_2' ReLU ReLU 11 'pool2' Max Pooling 2x2 max pooling with stride [2 2] and padding [0 0 0 0] 12 'conv3_1' Convolution 256 3x3x128 convolutions with stride [1 1] and padding [1 1 1 1] 13 'relu3_1' ReLU ReLU 14 'conv3_2' Convolution 256 3x3x256 convolutions with stride [1 1] and padding [1 1 1 1] 15 'relu3_2' ReLU ReLU 16 'conv3_3' Convolution 256 3x3x256 convolutions with stride [1 1] and padding [1 1 1 1] 17 'relu3_3' ReLU ReLU 18 'pool3' Max Pooling 2x2 max pooling with stride [2 2] and padding [0 0 0 0] 19 'conv4_1' Convolution 512 3x3x256 convolutions with stride [1 1] and padding [1 1 1 1] 20 'relu4_1' ReLU ReLU 21 'conv4_2' Convolution 512 3x3x512 convolutions with stride [1 1] and padding [1 1 1 1] 22 'relu4_2' ReLU ReLU 23 'conv4_3' Convolution 512 3x3x512 convolutions with stride [1 1] and padding [1 1 1 1] 24 'relu4_3' ReLU ReLU 25 'pool4' Max Pooling 2x2 max pooling with stride [2 2] and padding [0 0 0 0] 26 'conv5_1' Convolution 512 3x3x512 convolutions with stride [1 1] and padding [1 1 1 1] 27 'relu5_1' ReLU ReLU 28 'conv5_2' Convolution 512 3x3x512 convolutions with stride [1 1] and padding [1 1 1 1] 29 'relu5_2' ReLU ReLU 30 'conv5_3' Convolution 512 3x3x512 convolutions with stride [1 1] and padding [1 1 1 1] 31 'relu5_3' ReLU ReLU 32 'pool5' Max Pooling 2x2 max pooling with stride [2 2] and padding [0 0 0 0] 33 'fc6' Fully Connected 4096 fully connected layer 34 'relu6' ReLU ReLU 35 'drop6' Dropout 50% dropout 36 'fc7' Fully Connected 4096 fully connected layer 37 'relu7' ReLU ReLU 38 'drop7' Dropout 50% dropout 39 'fc8' Fully Connected 1000 fully connected layer 40 'prob' Softmax softmax 41 'output' Classification Output crossentropyex with 'tench' and 999 other classes

To view the names of the classes learned by the network, you can view theClassesproperty of the classification output layer (the final layer). View the first 10 classes by specifying the first 10 elements.

net.Layers(end).Classes(1:10)
ans =10×1 categorical arraytench goldfish great white shark tiger shark hammerhead electric ray stingray cock hen ostrich

Output Arguments

collapse all

Pretrained VGG-16 convolutional neural network returned as aSeriesNetworkobject.

Untrained VGG-16 convolutional neural network architecture, returned as aLayerarray.

References

[1]ImageNet. http://www.image-net.org

[2] Russakovsky, O., Deng, J., Su, H., et al. “ImageNet Large Scale Visual Recognition Challenge.”International Journal of Computer Vision (IJCV). Vol 115, Issue 3, 2015, pp. 211–252

[3] Simonyan, Karen, and Andrew Zisserman. "Very deep convolutional networks for large-scale image recognition." arXiv preprint arXiv:1409.1556 (2014).

[4]Very Deep Convolutional Networks for Large-Scale Visual Recognitionhttp://www.robots.ox.ac.uk/~vgg/research/very_deep/

Extended Capabilities

版本历史

Introduced in R2017a