MobileNetV2 Item D — pinning the inverted-residual cotangent chain #
MobileNetV2Close.lean (Item C) certifies each MobileNetV2 conv/depthwise param output for any
cotangent c at that layer's output. This file pins c to the cotangent the actual backward chain
delivers — the MobileNetV2 analogue of CnnChainClose (and of ResNet-34's, deleted 2026-09-08), "the genuinely-new,
fiddliest piece" (planning/archive/mobilenetv2_close.md Item D).
The chain through an inverted-residual block composes the rendered backward denotations — the relu6
two-sided-kink mask (selectMid, if 0<x<6), the per-channel BN input-VJP (bnPerChannelTensor3_grad_input,
= bnPerChannelBack's denotation), the 1×1 conv input-VJP (conv2d_has_vjp3 via the flatten bridge,
= convBack's denotation), and the depthwise input-VJP (depthwiseFlat_has_vjp / depthwiseStride2FlatXla_has_vjp,
= depthwiseBack / depthwiseStridedBack's denotation) — back through project → depthwise → expand:
block: o = [ addV( bn(conv₁ₓ₁ₚ( relu6(bn(dwconv( relu6(bn(conv₁ₓ₁ₑ x)) ))) )), x ) if skip ] [ bn(conv₁ₓ₁ₚ( relu6(bn(dwconv( relu6(bn(conv₁ₓ₁ₑ x)) ))) )) else ]
The project bottleneck is linear (no relu6 after the addV), so — unlike r34's relu(add(…)) —
the cotangent at the project-BN output is dyOut directly (skip and no-skip alike); that is what
makes invresCotPc a plain BN-back. The depthwise is stride-1 (skip blocks) or stride-2 (downsampling
blocks), so the expand-side cotangent lives at the input spatial (2h×2w) for downsampling blocks — the
_s1 / _s2 split below. Each conv/depthwise θ output then denotes θ − lr·(certified ∂/∂θ · the actual-chain-cotangent). Pins the cotangent; the = ∂loss/∂θ fold stays separate, as for the CNN.
3-axiom clean.
Cotangent at the project conv output (oc ch @h): bn-back(dyOut). The project bottleneck
is linear (no relu6 after the residual addV), so the project-BN output cotangent is the block
output cotangent dyOut directly — skip and no-skip alike.
Equations
- Proofs.invresCotPc ε γp pc dyOut = Proofs.bnPerChannelTensor3_grad_input oc h w ε γp pc dyOut
Instances For
Cotangent at the depthwise conv output (mid ch @h): continue through the project 1×1
conv-back, the depthwise relu6 mask (selectMid on dn), and bn-back(γd).
Equations
- One or more equations did not get rendered due to their size.
Instances For
Cotangent at the expand conv output, stride-1 block (mid ch @h): continue through the
stride-1 depthwise conv-back, the expand relu6 mask (selectMid on en), bn-back(γe).
Equations
- One or more equations did not get rendered due to their size.
Instances For
Cotangent at the expand conv output, stride-2 (downsampling) block (mid ch @2h, since the
expand acts at the block-input spatial): the depthwise is strided, so its input-VJP
zero-upsamples; er/en/ec live at 2h×2w.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Cotangent at the stem conv output (16 ch @112): bn-back( relu6'(stn) ⊙ dyStem ), where
dyStem is the cotangent block-1 delivers at the stem's relu6 output. (MobileNetV2's stem has no
maxpool — just conv→bn→relu6 — so this is simpler than r34's stem.)
Equations
Instances For
Project 1×1 conv weight, chain-certified. Wpⁿ denotes Wp − lr·(certified ∂conv/∂Wp · bn-back(dyOut)).
Project 1×1 conv bias, chain-certified.
Depthwise weight, chain-certified (stride-1 block). Wdⁿ denotes Wd − lr·(certified ∂(depthwiseConv2d)/∂Wd · the chain cotangent at the depthwise output).
Depthwise bias, chain-certified (stride-1 block).
Depthwise weight, chain-certified (stride-2 downsampling block). The strided depthwise weight bridge at the chain cotangent.
Depthwise bias, chain-certified (stride-2 downsampling block).
Expand 1×1 conv weight, chain-certified (stride-1 block). Weⁿ denotes We − lr·(certified ∂conv/∂We · the deepest in-block cotangent) — the generic 1×1 bridge at invresCotEcS1.
Expand 1×1 conv weight, chain-certified (stride-2 downsampling block). The block input is at
2h×2w; the chain cotangent is invresCotEcS2 (the strided depthwise input-VJP).
Stem 3×3 strided conv weight, chain-certified. sWⁿ denotes sW − lr·(certified ∂(flatConvStride2Xla)/∂sW · bn-back(relu6'(stn) ⊙ the block-1 input cotangent)).