VGG feature-extracting backbone (no fully-connected head).
Implements the unified VGG topology from Simonyan & Zisserman,
"Very Deep Convolutional Networks for Large-Scale Image
Recognition", ICLR 2015. All variants (VGG-11/13/16/19, with or
without lucid.nn.BatchNorm2d) share the same macro
structure: five blocks of stacked convolutions
interleaved with max-pools, with channel widths
fixed at (64, 128, 256, 512, 512). Only the number of
convolutions per block changes between variants. A final
lucid.nn.AdaptiveAvgPool2d collapses the feature map to
so the backbone output is fixed-size regardless of
input resolution.
Parameters
configVGGConfigvgg_11, vgg_13, vgg_16, vgg_19
and their *_bn variants) for paper-cited configurations.Attributes
configVGGConfigfeaturesnn.Sequentialconfig.arch and
config.batch_norm — see _build_features.avgpoolnn.AdaptiveAvgPool2dfeature_infolist[FeatureInfo]BackboneMixin for downstream decoder modules.Notes
From Simonyan & Zisserman, ICLR 2015, Table 1. The motivating insight is that two stacked convolutions cover the same receptive field as a single convolution but use only parameters versus , while inserting an extra nonlinearity between them. Three stacked layers match a receptive field at versus parameters and two extra nonlinearities. Depth at a fixed receptive field therefore buys representational power essentially for free. VGG backbones became the standard feature extractor for downstream tasks (Faster R-CNN, neural style transfer) for several years after publication.
Examples
Build a VGG-16 backbone and run a single forward pass:
>>> import lucid
>>> from lucid.models.vision.vgg import vgg_16
>>> backbone = vgg_16()
>>> x = lucid.randn(2, 3, 224, 224)
>>> out = backbone(x)
>>> out.last_hidden_state.shape # (B, 512, 7, 7)
(2, 512, 7, 7)Used by 2
Constructors
1Properties
1feature_info: list[FeatureInfo]Instance methods
2forward(x: Tensor)Run Fast R-CNN on a batch of images.
Parameters
xproposalstargetsReturns
BaseModelOutputObjectDetectionOutput:
logits : (Σ N_i, num_classes + 1) raw class logits.
pred_boxes : (Σ N_i, 4) decoded xyxy top-class boxes.
loss : scalar multi-task loss (only with targets).