VGG

class paddle.vision.models. VGG ( features, num_classes=1000, with_pool=True ) [source]

VGG model from “Very Deep Convolutional Networks For Large-Scale Image Recognition”.

Parameters
  • features (nn.Layer) – Vgg features create by function make_layers.

  • num_classes (int, optional) – Output dim of last fc layer. If num_classes <= 0, last fc layer will not be defined. Default: 1000.

  • with_pool (bool, optional) – Use pool before the last three fc layer or not. Default: True.

Returns

Layer. An instance of VGG model.

Examples

>>> import paddle
>>> from paddle.vision.models import VGG
>>> from paddle.vision.models.vgg import make_layers

>>> vgg11_cfg = [64, 'M', 128, 'M', 256, 256, 'M', 512, 512, 'M', 512, 512, 'M']

>>> features = make_layers(vgg11_cfg)

>>> vgg11 = VGG(features)

>>> x = paddle.rand([1, 3, 224, 224])
>>> out = vgg11(x)

>>> print(out.shape)
[1, 1000]
forward ( x )

forward

Defines the computation performed at every call. Should be overridden by all subclasses.

Parameters
  • *inputs (tuple) – unpacked tuple arguments

  • **kwargs (dict) – unpacked dict arguments