EfficientNet
PretrainedModelBackboneMixinEfficientNet(config: EfficientNetConfig)EfficientNet feature-extracting backbone (no classification head).
Implements the compound-scaled topology from Tan & Le, "EfficientNet: Rethinking Model Scaling for Convolutional Neural Networks", ICML 2019 (arXiv:1905.11946). The baseline (B0) is a NAS-designed network of MBConv blocks — inverted-residual bottlenecks (MobileNet-v2 style) augmented with a squeeze-and-excitation module and the swish (SiLU) activation. Successive B-variants (B0 through B7) apply the paper's compound-scaling rule
to scale depth, width, and resolution jointly along a single coefficient .
The body is a 3×3 stem (stride 2) followed by seven MBConv
stages and a final 1×1 head expansion to round(1280 · width_mult) channels. Stochastic depth (drop_connect_rate)
is applied linearly across blocks as a strong regulariser at
large depth.
Parameters
configEfficientNetConfigefficientnet_b0 through efficientnet_b7)
for paper-cited variants.Attributes
configEfficientNetConfigfeaturesnn.Sequentialconfig.width_mult and
config.depth_mult.avgpoolnn.AdaptiveAvgPool2d(B, C, 1, 1).feature_ infolist[FeatureInfo]BackboneMixin for downstream FPN / decoder
modules.Notes
Each MBConv block applies
with a residual when stride is 1 and channel counts match.
During training the residual branch is randomly dropped with
probability drop_connect_rate * block_idx / (total - 1) —
deeper blocks get a higher drop probability, matching the
"deep network regularisation" recipe of stochastic depth.
Examples
Build an EfficientNet-B0 backbone and run a forward pass:
>>> import lucid
>>> from lucid.models.vision.efficientnet import efficientnet_b0
>>> backbone = efficientnet_b0()
>>> x = lucid.randn(2, 3, 224, 224)
>>> out = backbone(x)
>>> out.last_hidden_state.shape
(2, 1280, 1, 1)Used by 2
Constructors
1Instance methods
2forward(x: Tensor)Override in subclasses to define the computation.
Run the backbone's feature-extraction pass.
Parameters
(B, C, H, W).Returns
TensorFeature map at the deepest stage. Concrete subclasses may additionally stash earlier stages on the instance so multi-stage consumers can fetch them.
Examples
The map returned is the one feature_info lists last, so a
neck can size itself from that entry without running the model.
>>> import lucid
>>> from lucid.models import create_model
>>> backbone = create_model("resnet_18").eval()
>>> last = backbone.feature_info[-1]
>>> last.num_channels, last.reduction
(512, 32)
>>> backbone.forward_features(lucid.randn((1, 3, 64, 96))).shape
(1, 512, 2, 3)
Each side is divided by the advertised reduction on its own, so
a non-square input keeps its aspect ratio.