Backpropagation Gradient Calculator

Compute forward passes, layer gradients, numerical checks, optimiser updates, and diagnostic reports for configurable neural networks using clear step-by-step calculations and practical visual explanations.

Calculation Results

Review predictions, losses, gradients, checks, updates, and warnings.

Original loss
Updated loss
Loss improvement
Global gradient norm

Predictions

Layer Summary

Gradient Details

Parameter Updates

Numerical Gradient Check

Network Diagram

Gradient Magnitudes

Step-by-Step Report


    

Network Structure

Define a fully connected network from inputs through outputs.

Example: 2,3,1 creates input, hidden, and output layers.
Provide one activation for every non-input layer.
Optional comma-separated names.

Training Data

Enter samples and targets as JSON arrays or CSV rows.

Rows are samples. Columns are input features.
Target width must match the output layer.

Weights and Biases

Generate parameters automatically or provide complete JSON matrices.

Gradient and Optimiser Settings

Configure learning, regularisation, clipping, and update behaviour.

Numerical Gradient Checking

Compare analytical gradients against central finite differences.

Formula Used

z(l) = a(l-1)W(l) + b(l)
a(l) = f(l)(z(l))
δ(L) = ∂L/∂z(L)
δ(l) = (δ(l+1)W(l+1)T) ⊙ f′(z(l))
∂L/∂W(l) = a(l-1)Tδ(l) / m
Wnew = Wold − η∂L/∂W
∂L/∂θ ≈ [L(θ + ε) − L(θ − ε)] / 2ε

How to Use

  1. Enter layer sizes and matching activation functions.
  2. Provide input samples and target values.
  3. Select initialisation, loss, optimiser, and gradient settings.
  4. Enable numerical checking when gradient verification is needed.
  5. Calculate and review every displayed result table.

Example Data

SettingExamplePurpose
Architecture2,3,1Two inputs, three hidden neurons, one output.
Activationstanh,sigmoidHidden nonlinear transformation and binary output.
Inputs[[0.2,0.7],[0.8,0.1]]Two training samples with two features.
Targets[[1],[0]]Binary labels matching one output neuron.
LossBinary Cross-EntropyMeasures binary probability prediction error.

Backpropagation Notes

Backpropagation sends output error toward earlier network layers. Each layer applies the chain rule to its inputs. This reveals how every parameter changes the final loss.

Large gradients may create unstable and destructive parameter updates. Tiny gradients can prevent useful learning in deep networks. Clipping and suitable activations often improve training stability greatly.

Numerical checking estimates derivatives by perturbing individual parameters. It is slower than analytical backpropagation during normal training. Use it mainly for debugging formulas and implementations carefully.

Frequently Asked Questions

What does this calculator compute?

It computes forward values, losses, gradients, and updates. It also checks selected gradients numerically. Results explain each network layer with clear tables.

Which network types are supported?

The calculator supports dense feed-forward neural networks. Hidden layers may use different activation functions. Recurrent and convolutional operations require separate specialised calculations.

Why must matrix dimensions match?

Every layer expects a fixed number of inputs. Incorrect dimensions prevent valid multiplication and gradient propagation. Validation identifies mismatches before performing any calculation steps.

What is numerical gradient checking?

It approximates derivatives using small parameter changes. The estimate is compared with analytical backpropagation. Small relative differences usually indicate correct gradient calculations.

What causes vanishing gradients?

Repeated small derivatives reduce gradients across deep layers. Saturating sigmoid functions can worsen this behaviour. ReLU variants and careful initialisation often reduce problems.

What causes exploding gradients?

Repeated large derivatives can magnify gradients dramatically. Updates may then become unstable or non-finite. Gradient clipping limits harmful update magnitudes during training.

Which optimiser should I choose?

SGD offers simple and transparent parameter updates. Adam often works well for quick experimentation. Final choices should depend on validation performance and stability.

Can I enter custom parameters?

Choose custom JSON in the initialisation selector. Then provide every weight matrix and bias vector. Their dimensions must match the declared network structure.

Are exported results suitable for reports?

CSV exports structured tables for further analysis. PDF and printing provide readable calculation summaries. Always verify important results before making final decisions.

Related Calculators

Neural Network Parameter CalculatorActivation Function CalculatorReLU Function CalculatorTanh Function CalculatorNeural Network Weighted Sum CalculatorForward Propagation CalculatorLearning Rate CalculatorEpoch and Iteration CalculatorDropout CalculatorWeight Initialization Calculator

Important Note: All the Calculators listed in this site are for educational purpose only and we do not guarentee the accuracy of results. Please do consult with other sources as well.