class
ZFNetForImageClassification
extends
PretrainedModelClassificationHeadMixinZFNetForImageClassification(config: ZFNetConfig)ZFNet with two 4096-dim fully-connected layers and a linear classifier.
Combines a ZFNet convolutional backbone with the
AlexNet-style classifier head: FC6 (256·6·6 → 4096), FC7
(4096 → 4096), and a final linear projection to
config.num_classes (default 1000 for ImageNet-1k).
lucid.nn.Dropout with config.dropout (0.5 in the
paper) is applied after both ReLU activations. When labels are
supplied to forward, cross-entropy loss is returned
alongside the logits.
Parameters
configZFNetConfigArchitecture spec. Use
zfnet_cls for the paper-cited
ImageNet-1k configuration.Attributes
configZFNetConfigStored copy of the config that built this model.
features, avgpoolSame backbone components as on
ZFNet.fc6, fc7nn.LinearThe two 4096-dim hidden fully-connected layers.
drop6, drop7nn.DropoutDropout layers applied after each ReLU in the hidden stack,
controlled by
config.dropout.classifiernn.ModuleFinal linear projection 4096 →
num_classes.Notes
From Zeiler & Fergus, "Visualizing and Understanding Convolutional Networks", ECCV 2014, §3. Top-5 ImageNet-1k validation error in the paper is 11.7%. The classifier head is identical to AlexNet's by design — ZFNet's contribution lives entirely in the first two convolutional layers.
Examples
>>> import lucid
>>> from lucid.models.vision.zfnet import zfnet_cls
>>> model = zfnet_cls()
>>> x = lucid.randn(4, 3, 224, 224)
>>> out = model(x)
>>> out.logits.shape
(4, 1000)Used by 2
Constructors
1Instance methods
1forward(x: Tensor, labels: Tensor | None = None)