Skip to content
AI360XpertBeta
Playgrounds

Neural Networks

Skip / Residual Connections

An activation receives the signed sum of every outgoing reverse path; an identity contribution does not bound the total gradient away from zero.

Guided steps 1 / 4

Stage 1 of 4: Forward graph

2 scalar steps, skip connections off, two-step, linear branch. x=1, shared w=0.9, supplied u=1. Post-add identity. Output=0.810000; input adjoint=0.810000. Inspect a0.

2 scalar steps, skip connections off, two-step, linear branch. x=1, shared w=0.9, supplied u=1. Post-add identity. Output=0.810000; input adjoint=0.810000. Inspect a0.

All current settings remain active at every stage: two-step; shortcuts Off; branch linear; w=0.9; supplied u=1.

Input a0=x=1; no incoming block.

  • Activation node
  • Branch (straight; dashed if local derivative negative)
  • Shortcut (arched)
Adjust parameters
Output activation0.810000Output activation: 0.810000
Supplied upstream1.000Supplied upstream: 1.000
Input adjoint g₀0.810000Input adjoint g₀: 0.810000
Shared w adjoint1.800000Shared w adjoint: 1.800000

What exact computation produced this activation?

Each step multiplies the preceding activation by shared w, applies the branch activation, then adds the stated shortcut. The post-addition map is identity.

Branch

The computed f(w·a) contribution, distinct from the shortcut and addition.

Check this stage

Check your understanding

Inspect how scalar branches and shortcuts add signed gradient contributions, including exact cancellation and amplification.

What a shortcut contributes

A skip connection adds another route through the computation. Reverse differentiation sums the signed contributions from all real routes. An identity route contributes its downstream signal unchanged, but that does not guarantee that the total gradient stays large or nonzero.

Start with Forward graph. Select an activation in the graph or use Inspect activation. Read its branch input, product, branch output, shortcut and addition separately. Every step uses the same scalar parameter ww. There is no bias. The branch activation is linear by default; the final stage also offers tanh. After addition the map is identity, with derivative one.

This is a deterministic derivative experiment. It has no target, loss, optimiser, parameter update or training history. The output adjoint uu is supplied, initially one. Calling an input-activation adjoint an early-layer parameter update would confuse two different derivatives.

The two graphs are different

The retained Two-step graph has input a0=xa_0=x and branch bi=f(wai−1)b_i=f(w a_{i-1}). With skips on:

a1=b1,ai=bi+ai−2(i≥2).a_1=b_1,\qquad a_i=b_i+a_{i-2}\quad(i\geq2).

The shortcut into step ii starts at ai−2a_{i-2}, not at the branch input ai−1a_{i-1}. Consecutive shortcuts overlap. These are not separate canonical two-layer ResNet blocks.

In Identity blocks, every block has one boundary from ai−1a_{i-1} to aia_i. Its branch and shortcut share the same input:

ai=f(wai−1)+ai−1.a_i=f(w a_{i-1})+a_{i-1}.

Skips Off removes the shortcut additions in either topology. The paired plain readout holds input, depth, shared parameter, branch activation and supplied upstream signal fixed. Removing shortcuts changes the represented function and downstream activations. It is not a matched training-success experiment, nor does it hold every nonlinear branch operating point fixed.

Follow the actual reverse accumulation

Open Reverse accumulation. We initialise gD=ug_D=u and all other adjoints to zero. Visit destinations in reverse order. Each branch returns

gi−1+=gi wf′(wai−1).g_{i-1}\mathrel{+}=g_i\,w f'(w a_{i-1}).

Each real shortcut also returns gig_i to its stated source: i−2i-2 in the two-step graph or i−1i-1 in identity blocks. Both paths must be counted exactly once. Inspect a selected activation to see its outgoing paths, local Jacobians, downstream signals, signed contributions and accumulated sum. At the output, the signal is supplied rather than accumulated from outgoing paths.

For a hand check, use depth two, x=2x=2, w=0.5w=0.5, linear branch and u=3u=3. Plain activations are [2,1,0.5][2,1,0.5] and adjoints are [0.75,1.5,3][0.75,1.5,3]. The two-step shortcut changes the output to 2.52.5 and the input adjoint to 3.753.75: branch contribution 0.750.75 plus shortcut contribution 33.

The local parameter derivative at occurrence ii is f′(wai−1)ai−1f'(w a_{i-1})a_{i-1}. Because ww is shared across steps, its total adjoint is

wˉ=∑i=1Dgif′(wai−1)ai−1.\bar w=\sum_{i=1}^{D}g_i f'(w a_{i-1})a_{i-1}.

That is distinct from g0g_0, the input adjoint. The drawer also retains unscaled input tangents ∂ai/∂x\partial a_i/\partial x, which remain meaningful when supplied u=0u=0. No update is applied to ww.

Identity is a contribution, not a guarantee

For a genuine identity residual block y=x+F(x)y=x+F(x), the total Jacobian is I+JFI+J_F. For column adjoints, reverse propagation is

xˉ=(I+JF)Tyˉ.\bar x=(I+J_F)^\mathsf{T}\bar y.

In this scalar identity-block experiment the local total is 1+wf′(wx)1+w f'(w x). The identity contribution is one; the total need not be one.

In Cancellation and scale, choose Cancel the identity. Linear w=−1w=-1 gives F(x)=−xF(x)=-x, so branch derivative −1-1 cancels identity derivative +1+1. Select the activation before the final block to inspect two nonzero returning contributions that sum to zero. A nonzero identity path supplies no unconditional lower bound on the norm of the total gradient.

Next use linear w=1w=1, skips On, identity blocks and depth ten. The total input derivative is 210=10242^{10}=1024 with u=1u=1. Large gradients can amplify; they are not automatically healthy. Set w=0w=0: identity blocks pass the input through, whereas the two-step graph alternates xx and zero. Zero branch output at one input is not, in general, proof of zero branch derivative everywhere.

With tanh, inspect f′(z)=1−tanh⁡2(z)f'(z)=1-\tanh^2(z). Saturation can make the branch slope small. Double-precision endpoint rounding may make it exactly zero. Readout rounding is a display choice, not evidence of underflow or permanent inability to learn. Bounded finite controls do not manufacture a numerical-failure threshold. Nonfinite arithmetic is a separate computational condition.

What this says about ResNet

The original residual-learning paper studies residual parameterisation in actual trained architectures. Its original block has a ReLU after addition. In that case the complete Jacobian is DReLU(I+JF)D_{\mathrm{ReLU}}(I+J_F), and a negative pre-activation can block the apparent identity route. The identity-mapping paper analyses shortcut and after-addition maps separately and motivates pre-activation units. Moving activations inside the branch does not make the branch linear.

This lab has no post-addition nonlinearity, projection, shortcut scaling or dimension change. A projected shortcut PxPx would contribute PP, so the total before any post-add map would be P+JFP+J_F and reverse mode would transpose that total. Matching dimensions is necessary for addition; projection is one architectural option rather than an identity guarantee.

Residual parameterisation can ease optimisation in studied settings. It does not completely solve vanishing gradients. Depth, representational capacity, optimisation success and generalisation are different questions. In particular, stacking scalar linear branches still produces a scalar linear map; more depth here does not demonstrate richer nonlinear capacity.

Read the display and restore the experiment

Straight lines are branches; arches are shortcuts. Negative branch Jacobians use dashes as well as signed numbers. Nodes and labels paint above connections. Positions illustrate connectivity, not activation magnitude. Widths have a structural minimum and a display cap; compressed layouts omit node labels rather than shrinking their text. Metrics round; Under the hood preserves raw double values, all steps, all edges and all accumulated adjoints. There is no sampled field, geometric projection or clipping of the computation.

Earlier stages retain all active settings even when some controls are introduced later. Inspection changes only the selected activation. Mathematical, stage and mode edits clear predictions; inspection preserves them. Restore experiment restores settings, selection, stage, sandbox and prediction after later edits. Reset retains the guided stage, restores defaults, returns guided and clears guesses and recovery. Shared links recompute all settings, selection and display stage in guided mode; they exclude guesses, recovery and local progress.

Try the retained depth-ten challenge. With w=0.9w=0.9, linear branch and skips Off, g0=0.910≈0.348678g_0=0.9^{10}\approx0.348678 for u=1u=1. Turning on two-step shortcuts adds real paths and changes both the function and derivative. Neither number establishes training success.

Stage recap

  1. Forward graph

    Each step multiplies the preceding activation by shared w, applies the branch activation, then adds the stated shortcut. The post-addition map is identity.

  2. Reverse accumulation

    Start with supplied output adjoint u. Multiply by each real local Jacobian and add contributions at reused activations. No loss or update is computed.

  3. Shortcut endpoints

    Two-step shortcuts add aᵢ₋₂ to f(w·aᵢ₋₁), overlapping neighbouring steps. Identity blocks instead add aᵢ₋₁ at every step: their local total is 1 + w f′.

  4. Cancellation and scale

    Yes. For identity blocks F(x)=−x, the branch derivative −1 cancels +1. Positive factors above one can amplify gradients. Neither magnitude certifies training health.

Reference

Reverse accumulation
gᵢ is the sum of outgoing local-Jacobian × downstream-adjoint contributions; gᴰ=u is supplied.
Identity block
y=x+F(x); total J=I+J_F. Reverse mode applies Jᵀ to the output adjoint.
Shared parameter
Sum every occurrence derivative for w. An input-activation adjoint is not a parameter update.
ResNet scope
This scalar model has no convolution, projection, normalisation, loss or optimiser.

Break it on purpose

With identity blocks and a linear branch w = −1, branch and shortcut derivatives cancel. The input adjoint is zero despite the identity contribution.