DenseNet
17 memberslucid.models.vision.densenetDenseNet family — Huang et al., CVPR 2017.
Huang, Gao, et al. "Densely Connected Convolutional Networks." Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition (CVPR), 2017, pp. 4700–4708.
DenseNet takes the residual-shortcut idea to its logical extreme. Inside each dense block, every layer receives as input the concatenated feature maps of all previous layers in the block, not just the immediately preceding layer. For a block of layers the -th layer computes
where denotes channel-wise concatenation and is a BN → ReLU → Conv composite (optionally preceded by a bottleneck). Each contributes a small fixed number of new feature maps — the growth rate — so the input width of layer grows linearly as .
This dense connectivity has three notable consequences. First, every layer has direct supervision-style access to the loss gradient through the concatenation paths, easing optimisation in very deep networks. Second, parameter efficiency is excellent: because each layer only adds (typically 12, 24, or 32) new channels rather than transforming the full activation, a DenseNet with 0.8 M parameters matches the accuracy of a 1.7 M parameter ResNet on CIFAR. Third, feature reuse is explicit — later layers can directly combine raw early features with refined deep features without re-encoding them.
The four ImageNet variants — DenseNet-121, 169, 201, and 264 —
differ only in the per-block layer counts (block_config). All
use four dense blocks separated by transition layers
( Conv + average pool) that
compress the channel count and halve the spatial resolution.
DenseNet-121 reaches a top-1 ImageNet error of 25.0% with 8 M
parameters, substantially better parameter efficiency than the
contemporary ResNet-50.
Classes
Functions
densenet_121→ DenseNetDenseNet-121 feature-extracting backbone (no classification head).
densenet_121_cls→ DenseNetForImageClassificationDenseNet-121 image classifier (backbone + GAP + linear head).
densenet_161→ DenseNetDenseNet-161 feature-extracting backbone (no classification head).
densenet_161_cls→ DenseNetForImageClassificationDenseNet-161 image classifier (backbone + GAP + linear head).
densenet_169→ DenseNetDenseNet-169 feature-extracting backbone (no classification head).
densenet_169_cls→ DenseNetForImageClassificationDenseNet-169 image classifier (backbone + GAP + linear head).
densenet_201→ DenseNetDenseNet-201 feature-extracting backbone (no classification head).
densenet_201_cls→ DenseNetForImageClassificationDenseNet-201 image classifier (backbone + GAP + linear head).
densenet_264→ DenseNetDenseNet-264 feature-extracting backbone (no classification head).
densenet_264_cls→ DenseNetForImageClassificationDenseNet-264 image classifier (backbone + GAP + linear head).
Weights
DenseNet121WeightsPretrained weights for lucid.models.densenet_121_cls.
DenseNet161WeightsPretrained weights for lucid.models.densenet_161_cls.
DenseNet169WeightsPretrained weights for lucid.models.densenet_169_cls.
DenseNet201WeightsPretrained weights for lucid.models.densenet_201_cls.