Main Content

本页翻译不是最新的。点击此处可查看最新英文版本。

vgg16

VGG-16 卷积神经网络

  • VGG-16 network architecture

说明

VGG-16 是深度为 16 层的卷积神经网络。您可以从 ImageNet 数据库 [1] 中加载该网络的预训练版本,该版本基于 ImageNet 数据库的超过一百万个图像进行训练。该预训练网络可以将图像分类至 1000 个目标类别(例如键盘、鼠标、铅笔和多种动物)。因此,该网络已基于大量图像学习了丰富的特征表示。该网络的图像输入大小为 224×224。有关 MATLAB® 中预训练网络的详细信息,请参阅预训练的深度神经网络

您可以通过 classify 使用 VGG-16 网络对新图像进行分类。按照使用 GoogLeNet 对图像进行分类的步骤执行操作,但是用 VGG-16 替换 GoogLeNet。

要针对新分类任务重新训练网络,请按照训练深度学习网络以对新图像进行分类的步骤操作,但是加载 VGG-16 而不是 GoogLeNet。

示例

net = vgg16 返回基于 ImageNet 数据集训练的 VGG-16 网络。

此函数需要 Deep Learning Toolbox™ Model for VGG-16 Network 支持包。如果未安装此支持包,则函数会提供下载链接。

net = vgg16('Weights','imagenet') 返回基于 ImageNet 数据集训练的 VGG-16 网络。此语法等效于 net = vgg16

layers = vgg16('Weights','none') 返回未经训练的 VGG-16 网络架构。未经训练的模型不需要支持包。

示例

全部折叠

下载并安装 Deep Learning Toolbox Model for VGG-16 Network 支持包。

在命令行中键入 vgg16

vgg16

如果未安装 Deep Learning Toolbox Model for VGG-16 Network 支持包,该函数将在附加功能资源管理器中提供所需支持包的链接。要安装支持包,请点击链接,然后点击安装。通过在命令行中键入 vgg16 来检查安装是否成功。

vgg16
ans = 

  SeriesNetwork with properties:

    Layers: [41×1 nnet.cnn.layer.Layer]

使用深度网络设计器可视化网络。

deepNetworkDesigner(vgg16)

通过点击新建,在深度网络设计器中浏览其他预训练神经网络。

Deep Network Designer start page showing available pretrained neural networks

如果需要下载一个神经网络,请在所需的神经网络上暂停,然后点击安装以打开附加功能资源管理器。

加载预训练的 VGG-16 卷积神经网络,并检查层和类。

使用 vgg16 加载预训练的 VGG-16 网络。输出 net 是一个 SeriesNetwork 对象。

net = vgg16
net = 
  SeriesNetwork with properties:

    Layers: [41×1 nnet.cnn.layer.Layer]

使用 Layers 属性查看网络架构。该网络有 41 个层。16 个层具有可学习权重:13 个卷积层和 3 个全连接层。

net.Layers
ans = 
  41x1 Layer array with layers:

     1   'input'     Image 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

要查看网络学习的类的名称,您可以查看分类输出层(最终层)的 Classes 属性。通过指定前 10 个元素来查看前 10 个类。

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

输出参数

全部折叠

预训练的 VGG-16 卷积神经网络,以 SeriesNetwork 对象形式返回。

未经训练的 VGG-16 卷积神经网络架构,以 Layer 数组形式返回。

参考

[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 Recognition http://www.robots.ox.ac.uk/~vgg/research/very_deep/

扩展功能

版本历史记录

在 R2017a 中推出