class
CSPNetForImageClassification
extends
PretrainedModelClassificationHeadMixinCSPNetForImageClassification(config: CSPNetConfig)CSPNet image classifier — backbone + GAP + dropout + linear head.
Wraps a CSPNet trunk and appends the timm-style
ClassifierHead (global-average-pool, dropout, Linear) so the
whole pipeline returns (B, num_classes) logits. Use this entry
point when training or fine-tuning on classification datasets.
Parameters
configCSPNetConfigHyperparameters including
num_classes and head dropout.Attributes
stemnn.ModuleConv-BN-act stem assembled from the config
stem block.stagesnn.ModuleListThe four CSP / Darknet stages emitting the
C2..C5 feature
pyramid.avgpoolnn.AdaptiveAvgPool2dGlobal average pool over the final feature map.
classifiernn.LinearFinal linear projection to
num_classes (named head.fc to
match the upstream timm layout for direct checkpoint loading).Notes
Reference: Wang et al., "CSPNet: A New Backbone that can Enhance Learning Capability of CNN", CVPRW 2020 (arXiv:1911.11929).
Examples
>>> from lucid.models import cspresnet_50_cls
>>> model = cspresnet_50_cls()
>>> import lucid
>>> x = lucid.randn(1, 3, 224, 224)
>>> out = model(x)
>>> out.logits.shape
(1, 1000)Used by 2
Constructors
1Instance methods
1forward(x: Tensor, labels: Tensor | None = None)