Skip to main content

Welcome to a Grasp lesson

Create a free account to keep studying and create your own study path.

Lesson 10

Backpropagation Explained: ANN Training Fundamentals

Recommended resources

Hello! In our previous lesson, we assembled the static components of an Artificial Neural Network: its neurons, layers, and activation functions. We now have the complete architecture, but a network is only useful if it can learn from data.

Today's lesson addresses the learning outcome: Explain the purpose and conceptual steps of the Backpropagation algorithm for training an ANN in an exam context. We will uncover the dynamic process that allows a network to adjust itself and improve its predictions. This is the core mechanism behind how most deep learning models "learn." By the end of this lesson, you'll be able to describe this crucial algorithm and its steps, preparing you for typical exam questions on the topic.

1. The Goal: Minimizing Prediction Error

Before we dive into the algorithm, let's clarify its purpose. When we first initialize a neural network, its weights and biases are set to random values. Its predictions are, therefore, completely arbitrary and incorrect. The goal of training is to systematically adjust these weights and biases so that the network's output gets progressively closer to the correct answer.

To do this, we first need a way to measure how "wrong" the network's predictions are. This is the job of a loss function (also called a cost or error function). It takes the network's prediction and the true target value and computes a single number representing the error. A common example, especially for regression-style problems, is the Mean Squared Error (MSE).

This diagram shows a simple network, its output \(a_3\), the target \(y\), and a corresponding loss function \(L\). The goal of training is to minimize this loss.

The formula shown in the image, , is a classic example. If the output is very far from the target , the loss will be high. If they are close, the loss will be low. The entire training process is an optimization problem: we want to find the set of weights and biases that results in the minimum possible loss.

Backpropagation is the algorithm that tells us how to adjust the weights and biases to achieve this minimum.


2. The Core Idea: Propagating "Blame" Backwards

Imagine a network with millions of weights. After seeing a large error, how do we know which weights to adjust? Should we increase some? Decrease others? Which adjustments will have the biggest impact? This is the "credit assignment" or "blame assignment" problem.

Backpropagation solves this intuitively. Instead of trying to figure out the effect of each weight individually, it starts from the error at the very end and works its way backward through the network, layer by layer.

The 3Blue1Brown video below provides an exceptionally clear and intuitive walkthrough of this process, framing it as a series of "desired nudges" that propagate backward.

Backpropagation, intuitively | Deep Learning Chapter 3

This video, "Backpropagation, intuitively", is one of the best explanations available for the core logic of the algorithm. It avoids complex math and focuses entirely on the conceptual flow.

First, watch the introduction from the beginning to the recap to set the stage. Then, focus on the main intuitive walkthrough, from the start of the example. Pay close attention to how the desire to change an output neuron's activation creates desired changes in the weights, biases, and activations of the previous layer.

As the video explains, the process for a single training example works like this:

  1. The output neurons know how they need to change. For example, in a digit classifier, if the input is a '2', the '2' neuron's activation should be nudged up, and all others should be nudged down.
  2. This "desire" is propagated back to the last hidden layer. Each neuron in this layer receives a "nudge" based on how strongly it contributed to the output error. Neurons connected with strong positive weights to an output that needs to increase will be told to "increase your activation."
  3. This aggregated list of desired changes for the hidden layer is then used to calculate the desired changes for the next layer back, and so on.
  4. This backward flow of information tells us precisely how sensitive the final error is to each and every weight and bias in the network.

3. The Four Steps of the Backpropagation Algorithm

Now that you have the intuition, let's formalize it into the conceptual steps you'll need for an exam. The training process for a neural network using backpropagation is an iterative cycle. The following flowchart provides a great high-level summary.

A flowchart illustrating the iterative cycle of training an ANN: Forward Pass, Error Calculation, Backward Pass, and Weight Update, which are driven by an optimization algorithm like Gradient Descent.

This cycle can be broken down into four key steps.

What is Backpropagation? | IBM

This article from IBM provides an excellent, clear prose description of the four main steps of the backpropagation cycle.

Read the section "How does backpropagation work?". Focus on understanding the role of each of the four steps described: the Forward pass, the Loss function, the Backwards pass, and Gradient descent.

Let's summarize those steps:

  1. Forward Pass: You've seen this in the last lesson. A single training example (e.g., the pixels of an image) is fed into the input layer. The network processes the input layer by layer, applying weights, biases, and activation functions, until it produces a prediction at the output layer.

  2. Error Calculation: The loss function compares the network's prediction to the actual target label from the training data. This computes the error value, quantifying how wrong the prediction was.

  3. Backward Pass (Backpropagation): This is the core of the algorithm. The error is propagated backward from the output layer. Using the chain rule from calculus, the algorithm calculates the gradient of the loss function with respect to each weight and bias. You don't need to perform the calculus for your exam, but you should know what the gradient represents: it is a vector that points in the direction of the steepest increase in the loss. In simpler terms, it tells us how much a small change in each weight/bias will affect the total error.

  4. Weight Update: The gradients calculated in the backward pass are used to update all the weights and biases in the network. This is done using an optimization algorithm, most commonly Gradient Descent. The basic update rule is:

    We subtract the gradient because we want to move in the opposite direction of the steepest ascent—we want to go "downhill" on the loss curve. The learning rate is a small number that controls how big of a step we take.

This entire four-step cycle is repeated thousands of times, each time with a new batch of training data, causing the network's loss to gradually decrease and its predictions to become more accurate.


4. A Walkthrough Exam-Style Example

To solidify your understanding, it's helpful to see how these steps apply to a simple network with actual numbers. You will not be expected to perform these calculations from scratch in an exam, but you should be able to follow the logic.

The following resource provides a step-by-step numerical example.

Backpropagation in Neural Network

This GeeksforGeeks article provides a clear, conceptual overview followed by a concrete numerical example.

First, read the section "Working of Back Propagation Algorithm" for a concise recap of the forward and backward passes. Then, carefully follow the numerical "Example of Back Propagation in Machine Learning." Trace how the initial inputs and weights are used to compute the outputs in the Forward Propagation section. Then, see how the error is calculated and used to update the weights in the Back Propagation section.

By following the example, you can see the abstract steps in action:

  • The Forward Pass computes the final output (0.67).
  • The Error Calculation finds the difference between the target (0.5) and the output, resulting in an error of -0.17.
  • The Backward Pass uses this error to calculate error terms (deltas) for each neuron and then calculates the required change for each weight (Δw).
  • The Weight Update step applies these changes to get the new weights, completing one iteration. The process would then repeat with these new weights.

5. Practicalities and Key Terminology

For your exam, it's good to be aware of a few related concepts.

  • Efficiency: Why use such a complex algorithm? Because it is incredibly efficient. The alternative would be to tweak each weight one by one and see how it affects the error, which would require millions of forward passes. Backpropagation calculates the entire gradient for all weights in just one forward pass and one backward pass.

  • Stochastic Gradient Descent (SGD): Calculating the average gradient over the entire training dataset for every single update step is computationally very expensive. In practice, we use a technique called Stochastic Gradient Descent. The training data is shuffled and broken into small mini-batches (e.g., 32 or 64 examples). The algorithm then performs the four-step cycle on just one mini-batch to update the weights. This is much faster and, while the path to the minimum loss is more "drunken" and less direct, it works extremely well in practice.


Conclusion

In this lesson, we demystified the process of how a neural network learns. You now have a conceptual and practical understanding of backpropagation, the engine of modern deep learning.

Here are the key takeaways for your exam:

  • Purpose: Backpropagation is an algorithm to train ANNs by efficiently computing the gradient of the loss function.
  • Core Idea: It works by propagating an error signal backward through the network to assign "blame" to each weight and bias for the overall error.
  • The Four Steps: The training loop consists of a Forward Pass (make a prediction), Error Calculation (compute loss), Backward Pass (calculate gradients), and Weight Update (apply changes via gradient descent).
  • Key Components: The process relies on a loss function to measure error, the chain rule to calculate gradients, and an optimizer like Gradient Descent to update weights using a learning rate.

This lesson concludes our module on advanced supervised models. We've covered SVMs and the architecture and training of ANNs. In our next module, we will switch from supervised to unsupervised learning and explore methods for discovering patterns in data without predefined labels, starting with Association Rule Mining and the Apriori algorithm.