---
title: Backpropagation Algorithm Explained
---

Backpropagation is a fundamental algorithm used for training artificial neural networks. It involves propagating the error backwards through the network layers to adjust weights and minimize prediction errors. The core idea behind backpropagation can be broken down into two main components: forward propagation and backward propagation, which together form the complete learning process of a neural network.

#### Forward Propagation

During forward propagation, input data is passed through each layer of neurons in sequential order until it reaches the output layer. Each neuron applies an activation function to its inputs and produces an output that serves as input for the subsequent layer. The process continues until we obtain predictions from the neural network's final layer.

$\text{Output}_l = f(\sum_{i=1}^{n} w_{il} * \text{Input}_{l-1}(i) + b_l)$

Here, $f$ represents the activation function (such as sigmoid or ReLU), $w_{il}$ denotes the weight connecting neuron $i$ in layer $l-1$ to neuron $l$, $\text{Input}_{l-1}(i)$ is the input from the previous layer's neuron $i$, and $b_l$ is the bias term for neuron $l$.

#### Backward Propagation

Backpropagation begins after obtaining predictions during forward propagation. It calculates the error between predicted outputs and actual targets, then backtracks through the network layers to update weights accordingly. The goal of this process is to minimize prediction errors by adjusting neuron weights in a way that reduces the loss function's value.

The key steps involved in backpropagation are:
1. **Compute Gradients**: Calculate gradients for each weight and bias term using the chain rule, which quantifies how changes to these parameters affect the overall error of the network.
2. **Update Weights**: Adjust weights by subtracting a fraction (learning rate) multiplied by their corresponding gradient values. This step is crucial in driving the learning process forward.
3. **Iterate**: Repeat steps 1 and 2 for multiple iterations or epochs, allowing the network to learn from previous mistakes and improve its predictions over time.

$\Delta w_{il} = -\eta * \frac{\partial E}{\partial w_{il}}$

Here, $\Delta w_{il}$ represents the change to be made in weight $w_{il}$, $\eta$ is the learning rate, and $\frac{\partial E}{\partial w_{il}}$ denotes the partial derivative of the error function with respect to weight $w_{il}$.

To illustrate backpropagation's impact on neural network training, let's consider a simple example using the mean squared error (MSE) loss function:

$E = \frac{1}{2N} \sum_{i=1}^{N} (\hat{y}_i - y_i)^2$

In this equation, $E$ represents the error of the network's predictions, $\hat{y}_i$ denotes predicted output for input $i$, and $y_i$ is the corresponding true target value. By applying backpropagation to minimize MSE, we can observe how weights are adjusted across multiple iterations to improve the network's performance.

In summary, backpropagation plays a pivotal role in training neural networks by enabling them to learn from their errors and optimize predictions over time. By understanding this algorithm's inner workings and its impact on model training, we can better appreciate how artificial neural networks achieve remarkable predictive capabilities across diverse domains.