Skip to content
AI & Machine Learning Medium #vanishing#exploding#gradients

Vanishing & Exploding Gradients

Repeated multiplication by small numbers vanishes. By large numbers, explodes. The depth tax.

A free, animated vanishing & exploding gradients you can read here or embed on any website, from Scrollchart.

Vanishing & Exploding Gradients

Vanishing & Exploding GradientsSpectral norm < 1 vanishes; > 1 explodes. Log gradient magnitude vs depth.11020304050-8-40+4+8Layer depthlog₁₀ gradient magnitude

A chain of layer Jacobians. If each has spectral norm less than 1 the product collapses; if greater than 1 it explodes. Plotted against depth on a log scale. Mitigations (proper init, normalization, residuals, gradient clipping) annotated.

Good for

  • Deep learning course material explaining why plain MLPs fail at depth 20+
  • ResNet and normalization architecture explainers connecting the problem to the fix
  • Debugging articles for training instability and loss spikes in large models

Source & accuracy

This vanishing & exploding gradients is an editorial illustration built to represent the concept accurately. Where it shows figures, they are typical or representative values chosen to make the relationship clear, not a single underlying dataset. The diagram and its explainer are reviewed and maintained centrally, and updated over time as understanding improves.

Gradient magnitudes in the chain rule

Backpropagation chains gradients through layers via repeated multiplication. If the gradient at each layer is 0.9, then after 50 layers it is 0.9^50, essentially zero. Early layers receive negligible updates and stop learning. Conversely, if each layer multiplies by 2, the gradient becomes 2^50, a trillion-fold explosion that causes massive weight updates and training divergence. The problem stems from the chain rule: a network with many layers naturally multiplies gradients many times. The magnitude depends on activation functions (sigmoids have gradients bounded by 0.25, dangerous for deep networks) and weight matrices (multiplying by the same weight repeatedly amplifies or attenuates gradients). Vanilla RNNs suffer acutely because they reuse the same weight matrix across timesteps, amplifying this effect over sequence length.

Solutions and modern stabilization

Gradient clipping caps gradient norm to prevent explosions, a simple fix that works. Careful initialization (like He initialization) sets up weights so gradients neither shrink nor explode early in training. Normalization layers (batch norm, layer norm) keep activations in reasonable ranges, preventing extreme gradient values. Residual connections provide skip paths where gradients flow with magnitude 1, solving the depth problem. Modern architectures combine all of these, enabling training of networks 100+ layers deep. The field learned that deep networks are not inherently impossible to train; they just require careful engineering. Understanding vanishing/exploding gradients is key to diagnosing training failures in modern networks.

Embed this diagram

Add this animated vanishing & exploding gradients to your own site. Copy one line of HTML, or use the embed builder for theme and sizing options.

Reference

What this is
A free, embeddable, animated vanishing & exploding gradients for any website.
Who uses it
AI/ML blogs, CS educators.
How to embed
Copy one line of HTML. No signup. No watermark. Works in WordPress, Webflow, Ghost, Substack, plain HTML.
File size
iframe embed, ~80 KB gzipped (loads on demand, does not block your page paint).
License
Free forever. Editorial explainer text included; updated centrally over time.

Embed format options

Copy the universal HTML snippet, the WordPress shortcode, or an iframe fallback - see the WordPress plugin page for details. Any format keeps the same Core Web Vitals profile and the same explainer text.

Embed snippet
<div data-scrollchart="vanishing-exploding-gradients" data-scrollchart-v="1"></div>
<script src="https://scrollchart.com/embed.js" async></script>

Frequently asked questions

Where can I get a free animated "Vanishing & Exploding Gradients" for my website?
Scrollchart provides "Vanishing & Exploding Gradients" as a free, embeddable animated diagram you can add to any website with one line of HTML. No signup is required and there is no watermark. The diagram and its explainer text are served from scrollchart.com, so the embed stays current without any maintenance on your end.
How do I embed a vanishing & exploding gradients in a developer or tech blog?
Copy the one-line snippet from the Scrollchart diagram page and paste it into your post HTML. It works in any static site generator, CMS, or hand-coded HTML page. The embed is a thin loader, not an iframe, so the content is fully in your DOM.