Skip to main content

Welcome to a Grasp lesson

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

Lesson 80

Understanding Multi-Layer Feedforward Neural Network Architecture

Recommended resources

Introduction

Welcome to the next lesson in our journey into Neural Network Fundamentals. In the previous lesson, we zoomed in on the single artificial neuron and the crucial role of activation functions. You learned that these functions, like ReLU and Sigmoid, introduce the non-linearity that allows networks to capture complex patterns, and that different functions are suited for different tasks, especially in the output layer.

Now, it's time to zoom out. A single neuron is limited, but by connecting them, we can build powerful computational structures. This lesson's objective is to describe the architecture of a multi-layer feedforward neural network. We will explore how individual neurons are organized into layers and how these layers are stacked to form the backbone of most modern AI models.

Understanding this architecture is fundamental. It's the blueprint for the "brain" you're learning to build. For someone aiming to engineer transformative technology, knowing this blueprint is like an architect understanding the principles of a skyscraper before designing one.


From Neurons to Networks: The Layered Structure

A neural network organizes its neurons into a series of layers. Information flows in one direction—from the first layer to the last—which is why it's called a feed-forward network.

To build a strong intuition for this structure, let's start with a classic video from 3Blue1Brown. It uses the problem of recognizing handwritten digits to motivate why we need layers and what role each one plays.

But what is a neural network? | Deep learning chapter 1

This video, 'But what is a neural network?', masterfully visualizes the core concepts of a neural network's structure. We'll focus on the first part, which introduces the idea of layers.

Watch from 02:43 to 04:39. Pay close attention to how the network is broken down into an input layer, hidden layers, and an output layer. Notice how the activations in one layer determine the activations in the next.

As the video illustrated, a typical feed-forward network has three types of layers:

  1. Input Layer: The entry point of the network.
  2. Hidden Layers: The intermediate layers where most of the computation occurs.
  3. Output Layer: The final layer that produces the result or prediction.

The Anatomy of a Feed-Forward Network

Let's formally define the architecture and its components. The most common type of feed-forward network used in practice is the Multi-Layer Perceptron (MLP).

A common point of confusion is the relationship between FFNNs and MLPs. Let's clarify that.

Feed-Forward Neural Networks Explained: A Complete Tutorial

This article from DataCamp, 'Feed-Forward Neural Networks Explained', provides a clear distinction between the general category of FFNNs and the specific type known as MLPs.

Read the section 'Early history of deep learning'. This will explain that while all MLPs are FFNNs, an MLP specifically refers to a feed-forward network with at least one hidden layer. This is the architecture we will be focusing on.

So, for our purposes, when we talk about a multi-layer feedforward network, we are describing an MLP. Let's look at its structure.

Multilayer Perceptron (MLP) Topology
This diagram shows the typical architecture of a Multi-Layer Perceptron (MLP), with an input layer, two hidden layers, and an output layer. The lines represent the connections between neurons in adjacent layers.

This structure is defined by a few key terms that come from the more formal academic literature.

[PDF] Lecture 5: Multilayer Perceptrons

This document from the University of Toronto, 'Lecture 5: Multilayer Perceptrons', gives us the formal definitions for the network's architecture.

Read the section 'Multilayer Perceptrons' (page 2), stopping before the XOR example. Focus on the definitions of 'input layer', 'output layer', 'hidden layers', 'fully connected', 'depth', and 'width'.

To summarize and solidify these concepts:

  • Layers: The network is organized into an input layer, one or more hidden layers, and an output layer.
  • Fully Connected (or Dense): In an MLP, each neuron in a given layer is connected to every neuron in the next layer. This is what the web of lines in the diagram represents.
  • Depth: The number of layers in the network. "Deep learning" refers to training networks with many layers (i.e., great depth).
  • Width: The number of neurons in a particular layer.

The Role of Each Layer

Now that we have the terminology, let's clarify the specific job of each layer type.

Feed-Forward Neural Networks Explained: A Complete Tutorial

The DataCamp article we looked at earlier also has a great section that breaks down the function of each layer type.

Read the section 'Architecture of a Feed-Forward Neural Network'. This will walk you through the roles of the input, hidden, and output layers.

Here's a breakdown based on that reading:

  • Input Layer: This layer doesn't perform any computation. Its neurons simply act as entry points, holding the values of the input features. For an image, this would be the pixel values; for predicting house prices, it might be features like square footage and number of bedrooms. The width of this layer is determined by the number of features in your dataset.

  • Hidden Layers: This is where the learning happens. Each neuron in a hidden layer receives outputs from all neurons in the previous layer. It then performs the calculation you're familiar with:

    1. Computes a weighted sum of its inputs.
    2. Adds a bias.
    3. Applies a non-linear activation function (like ReLU, which we discussed previously).
      The outputs of these neurons are then passed as inputs to the next layer. Through training, the weights and biases of these hidden layers are adjusted so the neurons learn to detect increasingly complex patterns.
  • Output Layer: This final layer produces the network's prediction. As we covered in the last lesson, its design is tailored to the specific problem:

    • Regression: Typically one neuron with a linear (or no) activation to predict a continuous value.
    • Binary Classification: One neuron with a sigmoid activation to output a probability between 0 and 1.
    • Multi-class Classification: One neuron per class with a softmax activation to output a probability distribution across all classes.

The Mathematics of Information Flow

We've described the static architecture. Now, let's formalize how data flows through it. The process is a sequence of matrix operations, which is why having some familiarity with linear algebra is so helpful.

The 3Blue1Brown video provides a fantastic conceptual bridge from the visual idea of connections to the underlying mathematics.

But what is a neural network? | Deep learning chapter 1

Let's return to the 3Blue1Brown video to see how the connections between layers are represented mathematically.

Watch the segments from 08:21 to 10:14 and 13:26 to 15:17. The first part explains the role of weights and biases in calculating a neuron's activation. The second part shows how all these calculations can be expressed compactly using vectors and matrices.

The video demonstrates that the activation of a single neuron is a weighted sum of the previous layer's activations, plus a bias, all passed through an activation function. When you consider all the neurons in a layer, this entire set of calculations can be written as a single, clean equation using matrix multiplication.

Let's look at the formal mathematical notation. Given your background, seeing the equations laid out will help solidify the theory.

[PDF] Lecture 5: Multilayer Perceptrons

The UofT lecture notes provide the precise mathematical formulation for the computations in an MLP.

Re-read the end of page 2 and page 3, this time focusing on the equations. Pay close attention to Equation (1), which shows the calculation in scalar form (for a single neuron), and Equation (2), which shows the much cleaner vectorized form.

To recap the vectorized notation, the activation vector of a layer, , is computed from the activation vector of the previous layer, , as follows:

Where:

  • is the vector of activations for layer .
  • is the activation function (e.g., ReLU), applied element-wise.
  • is the weight matrix for layer , where each entry is the weight from neuron in the previous layer to neuron in the current layer.
  • is the bias vector for layer .

This elegant equation describes the entire transformation from one layer to the next. The whole network is just a chain of these transformations.


Conclusion

In this lesson, we moved from the single neuron to the complete architecture of a multi-layer feedforward neural network (MLP). You now have the blueprint for the fundamental structure used in a vast range of AI applications.

Key Takeaways:

  • A feed-forward neural network processes data in one direction through a series of layers: an input layer, one or more hidden layers, and an output layer.
  • An MLP is a "fully connected" network, meaning every neuron in one layer connects to every neuron in the next.
  • The input layer holds the initial data, the hidden layers perform non-linear transformations to learn complex features, and the output layer produces the final prediction.
  • The entire process of information flowing from one layer to the next can be expressed efficiently using matrix and vector operations, forming the core computation of the network.

Preview of the Next Lesson:
We have now described the static architecture and the mathematical formula for one layer's computation. In the next lesson, we will put this into motion. We will explain the process of forward propagation, which is the step-by-step procedure of taking a single input, passing it through the entire network, layer by layer, to generate a final prediction.