Black FridayUpgrade your career this Black Friday. Get up to ₹60,000 Scholarship on IIT programsUp to ₹60K Black Friday Scholarship52 seats leftOffer ends Fri, 27 Nov, 11:59 pm IST.

Black Friday Scholarship – IIT Jammu & IIT Roorkee

The best Black Friday deal isn't a gadget. It's your next career move.

Get up to ₹60,000 Black Friday Scholarship on our PG programs with IIT Jammu and iHUB DivyaSampark, IIT Roorkee. IIT certification, 12 live sessions with IIT faculty and 100% placement assistance.

Only 52 seats left. Offer ends Fri, 27 Nov, 11:59 pm IST

3,905 engineers placed since 2019 · 1,276 hiring companies

By submitting you agree to our Terms and Privacy Policy.

Your free demo class is requested

Browse courses

Backpropagation calculator, step by step

Backpropagation finds how much each weight of a neural network contributes to the error. Run the network forward, then apply the chain rule from the error back to every weight: ∂E/∂w = δ × the input that weight multiplies. A gradient-descent step then moves each weight by −η∂E/∂w. For Mazur's classic 2-2-2 example below, the error falls from 0.298371109 to 0.291027774 after one step.

Edit any input, weight, bias, target or activation and see every net, out, δ, gradient and new weight, each gradient checked against finite differences. Free, runs in your browser. For the update rule and learning rate on their own, see the gradient descent calculator.

Mazur (2015) worked example reproduced · Goodfellow, Bengio and Courville (Deep Learning ch. 6) · PyTorch and Keras activation docs · Nielsen ch. 5 · checked against an independent solution (40,017 checks at build) · Updated 24 Nov 2026

One forward pass, one backward pass and one update. Every number below follows from these inputs.

Hidden layer
One line per unit: 2 weights from the inputs, then the bias.
Output layer
One line per unit: 2 weights from the units of the hidden layer, then the bias.
  • Mazur's network: inputs 0.05 and 0.10, targets 0.01 and 0.99, w1 … w8 = 0.15 … 0.55, b1 = 0.35, b2 = 0.60, sigmoid, η = 0.5.
w1 0.15w1 = 0.15w2 0.20w2 = 0.2w3 0.25w3 = 0.25w4 0.30w4 = 0.3w5 0.40w5 = 0.4w6 0.45w6 = 0.45w7 0.50w7 = 0.5w8 0.55w8 = 0.55i10.0500i20.1000h10.5933h20.5969o10.7514t 0.01o20.7729t 0.99

Click a weight (on the diagram or in the table) to see its chain rule. Highlighted: the weight, its units and every path from it to the error.

∂E/∂w5 = ∂E/∂outo1 × ∂outo1/∂neto1 × ∂neto1/∂w5

= 0.741365 × 0.186816 × 0.593270 = 0.082167

∂E/∂out = out − target = 0.751365 − 0.010000; ∂out/∂net = f′(neto1); ∂net/∂w5 = outh1.

new w5 = 0.400000 − 0.5 × 0.082167 = 0.358916

Step through:
Forward pass
Unitnetout = f(net)fnet = Σ w·in + b
h10.3775000000.593269992sigmoid0.1500×0.0500 + 0.2000×0.1000 + 0.3500
h20.3925000000.596884378sigmoid0.2500×0.0500 + 0.3000×0.1000 + 0.3500
o11.1059059670.751365070sigmoid0.4000×0.5933 + 0.4500×0.5969 + 0.6000
o21.2249214040.772928465sigmoid0.5000×0.5933 + 0.5500×0.5969 + 0.6000

Etotal = Σ ½ (target − out)² = 0.298371109

Backward pass (from the output back)
Unit∂E/∂out∂out/∂netδ = ∂E/∂nethow
o10.7413650700.1868156020.138498562out − target
o2−0.2170715350.175510053−0.038098237out − target
h10.0363503060.2413007090.008771355Σ δ·w (old weights)
h20.0413703230.2406134170.009954255Σ δ·w (old weights)
Gradients and the update (η = 0.5)
Weightfrom → toold∂E/∂w = δ·outfinite difference (rel. error)new = old − η ∂E/∂w
h1 → o10.4000000.0821670410.082167041 (1.3e−11)0.358916480
h2 → o10.4500000.0826676280.082667628 (1.9e−11)0.408666186
bo1bias → o10.6000000.1384985620.138498562 (1.3e−11)0.600000000 (kept)
h1 → o20.500000−0.022602540−0.022602540 (9.3e−11)0.511301270
h2 → o20.550000−0.022740242−0.022740242 (4.7e−11)0.561370121
bo2bias → o20.600000−0.038098237−0.038098237 (2.6e−11)0.600000000 (kept)
i1 → h10.1500000.0004385680.000438568 (1.2e−8)0.149780716
i2 → h10.2000000.0008771350.000877135 (9.8e−10)0.199561432
bh1bias → h10.3500000.0087713550.008771355 (3.5e−11)0.350000000 (kept)
i1 → h20.2500000.0004977130.000497713 (4.9e−9)0.249751144
i2 → h20.3000000.0009954250.000995425 (7.0e−10)0.299502287
bh2bias → h20.3500000.0099542550.009954255 (1.4e−10)0.350000000 (kept)

Etotal after one step = 0.291027774 (was 0.298371109, change −0.007343)

Finite difference: (E(w + h) − E(w − h)) / 2h with h = 10⁻⁵, a check that does not use the chain rule at all. For this example the largest relative difference is 1.2e−8. A large difference in your own working means a slip in a δ. ReLU's derivative at exactly 0 is taken as 0 and leaky ReLU's as α, a one-sided derivative as most software uses.

How does backpropagation work?

Backpropagation is the chain rule of calculus applied from the error back through the network, one layer at a time. Goodfellow, Bengio and Courville: "Back-propagation is an algorithm that computes the chain rule, with a specific order of operations that is highly efficient." Each unit gets a δ, the derivative of the error with respect to its net input. Every weight's gradient is then one multiplication:

Three passes. Forward: compute net and out for every unit and the error. Backward: compute δ for the output units, then for each hidden layer from the δs above it, using the old weights. Update: subtract η × gradient from each weight. The gradient descent calculator covers how big η can be.

Backpropagation numerical example, step by step

Matt Mazur's "A Step by Step Backpropagation Example" (2015) is the example most courses copy: two inputs, two sigmoid hidden units, two sigmoid outputs, squared error with the ½ ("The 1/2 is included so that exponent is cancelled when we differentiate later on") and η = 0.5. The forward pass:

The output-layer weight w5 has a three-factor chain:

A hidden-layer weight such as w1 affects both outputs through h1, so ∂E/∂outh1 is a sum over o1 and o2. It uses the old w5 and w7, not the new ones:

Does our calculator match the post? Yes, for every number of the step: the forward pass, all four output and all four hidden gradients and new weights (w5+ = 0.358916480, w1+ = 0.149780716) agree with the post to its last printed digit. The one exception is ∂Eo2/∂outh1, printed as −0.019049119, which comes out −0.019049118 here because the post rounds as it goes. Two of the post's later numbers differ. It gives the error after the first round as 0.291027924; the step as written gives 0.291027774. After 10,000 rounds it gives outputs 0.015912196 and 0.984065734; here they are 0.015913620 and 0.984064274. Both of the post's numbers come out exactly, to all nine digits (0.291027924; 0.015912196 and 0.984065734), if the hidden δs are computed with the already-updated w5 … w8. The post's own text warns against that ("we use the original weights, not the updated weights"), and the Python script it links computes the hidden δs before any update. Its 10,000-round error, 0.0000351085, is what the correct order gives after 9,999 steps (3.51085e−5). Small, but it shows how easy that slip is; tab 5 catches it.

The post keeps the biases fixed. With "update biases" ticked, each bias gets ∂E/∂b = δ and the error after one step is 0.280471447 instead of 0.291027774.

What is a neural network?

A neural network is a function built from layers of simple units. Each unit adds up its inputs times weights, adds a bias, and passes the sum through an activation function: out = f(Σ w·in + b). Mazur's network has 8 weights and 4 biases; training means finding the values that make the outputs match the targets. Backpropagation supplies the gradient for that search.

What is deep learning?

Deep learning is machine learning with neural networks that have many layers, so each layer can build features out of the layer before. The same backpropagation trains them; the gradient just passes through more layers. That depth is also the difficulty: the gradient is a product of one factor per layer, and it can shrink to nothing (see the vanishing gradient below).

What is the role of the activation function?

It makes the network non-linear. Without it, layers collapse: Goodfellow 6.1, "if f(1) were linear, then the feedforward network as a whole would remain a linear function of its input." For a 2-2-1 network with a linear hidden layer:

A single linear layer cannot separate XOR ("a linear model is not able to represent the XOR function", Goodfellow 6.1), so the best it can do is output 0.5 for all four patterns, error 0.5. In our 100 seeded runs the linear hidden layer never got below 0.50. With sigmoid hidden units 87 runs reached error below 0.01, with tanh 74, with ReLU 25 and with leaky ReLU 39. The activation's derivative also sets how much gradient passes through each unit, which is why the choice matters for training.

What are the different types of activation functions?

The table gives each common activation with its derivative. f′(0) and the largest slope are computed by the calculator. Swish and GELU peak above 1 (at x = 2.40 and x = √2).

Functionf(x)Rangef′(x)f′(0)max |f′|Zero-centredTypical use
Binary step if , else {0, 1} (undefined at 0)–0noThe perceptron; no gradient, so backprop cannot train through it
Linear (identity)(−∞, ∞)11yesRegression outputs; in a hidden layer the layers collapse into one
Sigmoid (logistic)(0, 1)0.250.25noBinary-class output (a probability); hidden use now discouraged (saturates)
tanh(−1, 1)11yesHidden layers when a sigmoid-shaped unit is wanted (Goodfellow 6.3.2: usually better than sigmoid)
ReLU[0, ∞) if , else 01noThe default recommendation for hidden layers (Goodfellow 6.1)
Leaky ReLU (α = 0.01) if , else (−∞, ∞) or 0.011nearlyReLU that keeps a small gradient for x < 0 (dying ReLU)
PReLU (learnt α) if , else , learnt(−∞, ∞) or 0.251nearlyLeaky ReLU with α learnt (PyTorch starts a at 0.25)
ELU (α = 1) if , else (−α, ∞) or 11nearlySmooth for x < 0, outputs down to −α
Swish / SiLU[−0.278, ∞)0.51.0998noSmooth, dips below 0; PyTorch calls it SiLU
GELU (exact)[−0.170, ∞)0.51.1289noSmooth ReLU-like unit; PyTorch and Keras default to this exact form
GELU (tanh approximation)[−0.170, ∞)by the chain rule0.51.129noapproximate='tanh' in PyTorch; faster, close to the exact form
Softmax (2 classes, p₁)(0, 1), sums to 10.250.25noMulti-class output, with cross-entropy loss

Two library defaults differ: PyTorch's LeakyReLU has negative_slope 0.01, Keras's leaky_relu 0.2. Goodfellow 6.3.2 on sigmoid and tanh: "When a sigmoidal activation function must be used, the hyperbolic tangent activation function typically performs better than the logistic sigmoid." For a multi-class output, softmax with cross-entropy gives the simplest δ of all:

What is the vanishing gradient problem?

The gradient reaching an early layer is a product of one factor w·f′(net) per layer above it. Nielsen (ch. 5) notes the sigmoid derivative "reaches a maximum at σ′(0) = 1/4", so with ordinary weights each factor is below 1/4 and the product shrinks geometrically: 0.2520 = 9.1e−13. Measured in tab 4, for 20 hidden layers with Xavier initialisation, sigmoid's first-layer gradient is 10−12.9 against 10−0.3 at the last hidden layer, 13 orders of magnitude apart. tanh with Xavier (10−1.0 vs 10−1.1) and ReLU with He initialisation (10−1.2 vs 10−1.0) stay within about one. In plain words: with deep sigmoid stacks the first layers get almost no update, so they keep their random start. That is why hidden layers use ReLU-type units with matched initialisation. Goodfellow 6.3.2 on sigmoidal units: "their use as hidden units in feedforward networks is now discouraged".

Does backpropagation update the weights?

Strictly, no: it computes the gradients, and an optimiser updates the weights. Goodfellow 6.5: "back-propagation refers only to the method for computing the gradient, while another algorithm, such as stochastic gradient descent, is used to perform learning using this gradient." In everyday use "backpropagation" often means the whole loop of forward pass, backward pass and update, as in this calculator's step.

What 93 public neural network challenge reports say (as of 24 Nov 2026)

We read the 93 public Skill-Lync reports titled "Supervised Learning - Classification Week 9 Challenge", as of 24 Nov 2026, n = 93, 0 image-only. Each answers five questions: what a neural network is, what deep learning is, the role of the activation function, its types, and backpropagation. A row counts the reports whose text shows the thing; the links are examples.

What stands out: all 93 explain backpropagation in words only, with no equation, worked number or code. 90 name the sigmoid and 91 ReLU, but only 10 give any derivative, though backprop multiplies by one at every unit. 29 mention the vanishing gradient. The calculator adds the numbers the prose leaves out. These are first-party counts, a starting point rather than a measure of ability.

Common backpropagation slips and how to fix them

  • Missing the activation derivative. δ = ∂E/∂out × f′(net), at the output and in every hidden layer. For Mazur's o1, leaving it out gives δ = 0.741365 instead of 0.138499.
  • Using the new output weights for the hidden δs. Compute every δ first, then update. With the new w5 … w8, w1+ becomes 0.149817639 instead of 0.149780716.
  • Sign of the error derivative. For E = ½(target − out)², ∂E/∂out = out − target. Writing target − out flips every gradient, and the update then climbs the error.
  • The ½ in the loss. Dropping it doubles E and every gradient (0.596742218 instead of 0.298371109), which acts like doubling η. Either is fine if used consistently; compare like with like.
  • σ′ at the wrong place. σ′(net) = out(1 − out). Writing σ(out)(1 − σ(out)) applies the sigmoid twice.

Tab 5 tests these and five more against any cell you type.

How we checked the calculator

An independent Python script, scripts/verify/backprop.py, recomputes everything with its own code. Where the browser code multiplies element-wise derivatives, it builds each layer's full Jacobian. This page refuses to build if the two differ in any of 40,017 numbers or verdicts (11,968 more assertions run inside the script, 361 cases). The cases include 210 random networks of 1 to 4 layers and up to 8 units with every activation and both losses, compared cell by cell. Every gradient is also checked against central finite differences. Edge cases: ReLU exactly at 0, saturation at net = ±30, softmax with logits near 1,000, η = 0 and a one-unit network. Mazur's published numbers are asserted one by one. The script also checks the slips of tab 5, the activation table, the XOR seed counts and the vanishing-gradient norms, and runs the tab 6 script. Two deliberate bugs (dropping f′ in the hidden δ, and backpropagating with the updated weights) each make the build fail.

What this calculator does not cover

  • Mini-batches, momentum, Adam. One pattern per step in tab 1, the full XOR batch in tab 2, plain gradient descent with a fixed η.
  • Convolutional and recurrent layers. Fully connected layers only; the chain rule is the same, the bookkeeping is not.
  • Large networks. Up to 8 units per layer and 3 weight layers in the editor, so every number fits on the screen.
  • Regularisation and dropout. The loss is MSE or cross-entropy alone.
Learn deep learning with Python

Neural networks, activation functions and backpropagation are part of Skill-Lync's PG program in data analytics and data science; the Advanced Deep Learning course goes on to CNNs and sequence models.

Frequently asked questions

How do you calculate backpropagation by hand?

Do a forward pass and write down net and out for every unit, then the error. Go backwards: for each output unit δ = (out − target) × f′(net), for each hidden unit δ = (Σ δ × old weight) × f′(net). Each weight's gradient is δ times the input it multiplies. Then subtract η times the gradient.

What is the derivative of the sigmoid function?

σ′(x) = σ(x)(1 − σ(x)), so with out = σ(net) it is simply out(1 − out). It peaks at x = 0, where it is 0.25, and falls towards 0 on both sides: at x = 5 it is 0.00665. That small maximum is why stacked sigmoid layers shrink the gradient.

Why do we need activation functions in a neural network?

Without a non-linear activation, two layers W₂(W₁x + b₁) + b₂ are one layer with weights W₂W₁, however deep the network. Such a network cannot learn XOR: in 100 seeded trials a linear hidden layer reached error 0.50 at best, while sigmoid hidden units solved 87 of them.

What is the vanishing gradient problem?

In a deep network the gradient for an early layer is a product of many factors f′(net) × w. With sigmoid each f′ is at most 0.25, so the product shrinks fast. In our 20-layer test the first layer's gradient was about 10^13 times smaller than the last layer's, so early layers barely learn.

Why is ReLU used instead of sigmoid?

ReLU's derivative is exactly 1 for every positive input, so it does not shrink the gradient the way sigmoid's (at most 0.25) does, and it is cheap to compute. Its weakness is units stuck at negative net, which get zero gradient ("dying ReLU"); leaky ReLU keeps a small slope there.

Does backpropagation update biases?

Standard backpropagation gives the bias of each unit the gradient ∂E/∂b = δ, the same δ as its weights with input 1, and gradient descent updates it like a weight. Mazur's well-known worked example keeps the biases fixed for simplicity; tick "update biases" in the calculator to train them.

Is backpropagation the same as gradient descent?

No. Backpropagation computes the gradient of the error with respect to every weight using the chain rule. Gradient descent, or another optimiser such as Adam, then uses that gradient to change the weights. Goodfellow and colleagues stress this: backpropagation "refers only to the method for computing the gradient".

Related on Skill-Lync

Sources

  • Matt Mazur, "A Step by Step Backpropagation Example", 17 March 2015 (mattmazur.com): network, inputs, weights, every intermediate number, the ½, "use the original weights"; and its linked Python script (github.com/mattm/simple-neural-network), read for the update order.
  • Goodfellow, Bengio and Courville, Deep Learning (MIT Press, 2016), chapter 6: 6.1 (XOR, linear layers collapse, ReLU the default recommendation), eq. 6.33 (stable softmax), 6.3 (one-sided derivatives at 0), 6.3.1 (leaky ReLU and PReLU), 6.3.2 (sigmoid saturation, tanh), 6.5 (back-propagation computes only the gradient; the chain rule).
  • Michael Nielsen, Neural Networks and Deep Learning, chapter 5 "Why are deep neural networks hard to train?": σ′(0) = 1/4 and the vanishing gradient.
  • PyTorch 2.15 documentation: GELU (approximate='none' default, tanh form), LeakyReLU (negative_slope 0.01), PReLU (init 0.25), ELU (α 1.0), SiLU (swish), nn.init (xavier_normal_, kaiming_normal_, Glorot and Bengio 2010, He et al. 2015).
  • Keras 3 API, layer activations: relu, sigmoid, tanh, softmax, elu, gelu (approximate=False), silu/swish, leaky_relu (negative_slope 0.2), linear.
  • Skill-Lync, the 93 public neural network challenge reports, read 24 Nov 2026.
Free counselling

From a hand-worked δ to models you can train and explain.

Data and machine learning roles want people who can say why a network learns, or why it does not. A Skill-Lync counsellor can map the data science or deep learning course that fits your background.

Talk to a course counsellor

Free. We call you back, usually the same day.

By submitting you agree to our Terms and Privacy Policy.

Talk to a career counsellor

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.