EfficientNet — MBConv with Squeeze-Excite, end-to-end VJP #
The hardest of the three flagship CNN VJPs in this stack (alongside the
ResNet cnnHasVJPAt and the MobileNet depthwise chain), because the
squeeze-excite gate is a genuine fan-out sub-network multiplied back
into the main path. We reuse seBlockHasVJP (SE.lean), which already
carries the product-rule fan-in for x ⊙ gate(x); here we supply the
concrete gate (seGate) — a real Vec → Vec differentiable map with its
own composed VJP — plus its differentiability.
What this file provides #
- The gate's pieces —
sigmoid,broadcastFlat(the adjoint of GAP), the concrete gateseGate = broadcast ∘ sigmoid ∘ dense ∘ swish ∘ dense ∘ GAPandseBlockFull(the fullx ⊙ gate(x)) — are op-level and live inSE.lean. mbconvBody/mbconvBodyHasVJP— one MBConv block bodyproject(1×1 conv-bn) ∘ SE ∘ depthwise(bn-swish) ∘ expand(1×1 conv-bn-swish), smooth everywhere (globalHasVJP).efficientnetHasVJP/efficientnetHasVJP_correct— a two-block end-to-end EfficientNet (stem → MBConv-with-SE-and-residual → MBConv-with-SE → globalAvgPool → dense head), a globalHasVJPbuilt byvjpComp, exposing thepdiv-contracted Jacobian;efficientnetHasVJPAt/efficientnetHasVJPAt_correctrestrict it to a point by.toHasVJPAt. The full sixteen-block B0 isefficientnetForwardBFull(EfficientNetFullB0.lean). Spatial dims held constant (stride-1; the separable striding/pooling plumbing is already inCNN.lean). Only the0 < εbatch-norm hypotheses are required — swish and sigmoid are smooth, so there are no relu-style kink hypotheses anywhere in the block.
References #
- Tan & Le 2019, EfficientNet: Rethinking Model Scaling for CNNs. https://arxiv.org/abs/1905.11946
conv → bn → swish block — everywhere VJP. Like convBnReluHasVJPAt but
with swish (smooth) instead of relu, so no smoothness hypothesis is
needed; this is a global HasVJP. Vec (ic*h*w) → Vec (oc*h*w).
Equations
- One or more equations did not get rendered due to their size.
Instances For
depthwise → bn → swish block — everywhere VJP. Depthwise conv
keeps channel count c; bn over c*h*w; swish smooth. Global
HasVJP. Vec (c*h*w) → Vec (c*h*w).
Equations
- One or more equations did not get rendered due to their size.
Instances For
MBConv block body (EfficientNet MBConv with squeeze-excite), in
flattened Vec space:
project(1×1 conv-bn) ∘ seBlockFull ∘ depthwise(bn-swish) ∘ expand(1×1 conv-bn-swish)
Channels: cin → cmid (expand 1×1), depthwise keeps cmid, SE keeps
cmid, project cmid → cout (1×1). Spatial h, w constant
(stride 1). Every stage is smooth everywhere (swish/sigmoid smooth;
convs/bn/depthwise/SE differentiable), so the body has a global
HasVJP. Vec (cin*h*w) → Vec (cout*h*w).
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Architectural choices (documented).
We assemble a representative EfficientNet, all in flattened Vec space,
spatial dims held constant (stride-1 throughout — pooling/striding is a
separable concern already covered by maxPoolFlat/strided conv in
CNN.lean; the VJP plumbing is identical):
stem (3×3 conv-bn-swish, ic → c)
→ MBConv₁ with SE, residual (stride-1, c → c identity skip)
→ MBConv₂ with SE, no skip (channel change c → cout)
→ globalAvgPool (cout·h·w → cout)
→ dense head (cout → nClasses)
MBConv₁ is the headline block: a genuine squeeze-excite gate
(seBlockFull) inside an identity residual. MBConv₂ exercises the
channel-changing path (no skip). Both blocks are smooth everywhere
(swish + sigmoid + convs + bn + SE), so only the 0 < ε batch-norm
hypotheses are needed — no relu-style kink hypotheses.
Equations
- One or more equations did not get rendered due to their size.
Instances For
End-to-end EfficientNet VJP (global). Every block is smooth
everywhere (swish + sigmoid SE gate + convs + BN, no ReLU/maxpool), so
the only hypotheses are the 0 < ε batch-norm conditions and the VJP
holds at every input — putting EfficientNet alongside
vitFullHasVJP (the weight-tied ViT) and convnextHasVJP as an unconditional
whole-network VJP. Chained through the global vjpComp.
Equations
- One or more equations did not get rendered due to their size.
Instances For
End-to-end EfficientNet VJP at a point — the global witness
restricted to a point. Kept for downstream _at consumers and the
comparator.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Public correctness theorem for efficientnetHasVJP (global) — the
full EfficientNet's backward equals the pdiv-contracted Jacobian
(Jacobian-transpose on the cotangent), at every input x. The
unconditional EfficientNet analogue of vitFullHasVJP_correct.
Public correctness theorem for efficientnetHasVJPAt — exposes
the witness's .correct field: the full EfficientNet's backward equals
the pdiv-contracted Jacobian (Jacobian-transpose on the cotangent).
EfficientNet analogue of cnnHasVJPAt_correct.