# VGG¶

## VGG16¶

class chainercv.links.model.vgg.VGG16(n_class=None, pretrained_model=None, mean=None, initialW=None, initial_bias=None)[source]

VGG-16 Network.

This is a pickable sequential link. The network can choose output layers from set of all intermediate layers. The attribute pick is the names of the layers that are going to be picked by forward(). The attribute layer_names is the names of all layers that can be picked.

Examples

>>> model = VGG16()
# By default, forward returns a probability score (after Softmax).
>>> prob = model(imgs)
>>> model.pick = 'conv5_3'
# This is layer conv5_3 (after ReLU).
>>> conv5_3 = model(imgs)
>>> model.pick = ['conv5_3', 'fc6']
>>> # These are layers conv5_3 (after ReLU) and fc6 (before ReLU).
>>> conv5_3, fc6 = model(imgs)


chainercv.links.model.PickableSequentialChain

When pretrained_model is the path of a pre-trained chainer model serialized as a npz file in the constructor, this chain model automatically initializes all the parameters with it. When a string in the prespecified set is provided, a pretrained model is loaded from weights distributed on the Internet. The list of pretrained models supported are as follows:

• imagenet: Loads weights trained with ImageNet and distributed at Model Zoo.

Parameters
• n_class (int) – The number of classes. If None, the default values are used. If a supported pretrained model is used, the number of classes used to train the pretrained model is used. Otherwise, the number of classes in ILSVRC 2012 dataset is used.

• pretrained_model (string) – The destination of the pre-trained chainer model serialized as a npz file. If this is one of the strings described above, it automatically loads weights stored under a directory $CHAINER_DATASET_ROOT/pfnet/chainercv/models/, where $CHAINER_DATASET_ROOT is set as \$HOME/.chainer/dataset unless you specify another value by modifying the environment variable.

• mean (numpy.ndarray) – A mean value. If None, the default values are used. If a supported pretrained model is used, the mean value used to train the pretrained model is used. Otherwise, the mean value calculated from ILSVRC 2012 dataset is used.

• initialW (callable) – Initializer for the weights.

• initial_bias (callable) – Initializer for the biases.