Hello! Welcome to your next lesson in the "Advanced Machine Learning Models" module.
In our last lesson, we explored the practical art of model selection. We learned how to choose the right algorithm based on the problem and the data, and you saw the powerful heuristic: for complex, unstructured data like images or text, we often turn to deep learning.
Today, we take our first step into that exciting world. We will demystify what a "deep learning model" is by starting with its fundamental building block. The learning outcome for this lesson is to describe the structure of a multi-layer feedforward neural network. This is the classic and most fundamental type of neural network, forming the basis for many more advanced architectures you'll encounter later.
By the end of this 60-minute lesson, you will be able to:
- Explain the role of neurons, weights, biases, and activation functions.
- Identify the input, hidden, and output layers of a network.
- Describe how information flows through a feedforward network.
- Understand why this layered structure is so powerful.
Let's begin by building an intuition for what a neural network looks like.
1. The Big Picture: A Network of Neurons
At its core, an Artificial Neural Network (ANN) is a computational model inspired by the structure and function of the human brain. It consists of interconnected nodes, or "neurons," organized in layers.
To build a strong mental model, let's start with a fantastic visual explanation from the 3Blue1Brown channel.
But what is a neural network? | Deep learning chapter 1
This video provides an excellent intuition for what a neural network is and how its structure relates to a task, using the classic example of recognizing handwritten digits.
Watch from the beginning of the chapter at 02:43 until 04:39. Pay attention to: The concept of a neuron as a simple 'thing that holds a number' called an activation. How the network is broken down into an input layer, hidden layers, and an output layer. What each layer represents in the context of analyzing an image.
As you saw, the network is composed of layers. The first layer holds the input data (pixel values), the last layer holds the final output (the network's confidence for each digit), and the "hidden" layers in between are where the magic happens. Now, let's zoom in and see what each individual neuron is actually doing.
2. The Building Block: The Artificial Neuron
A single artificial neuron is a simple computational unit. It takes in several inputs, processes them, and produces a single output. This process always involves three steps:
- Compute a Weighted Sum: Each input connection to the neuron has a weight. The neuron multiplies each input value by its corresponding weight and sums them all up. A higher weight means the neuron considers that input more important.
- Add a Bias: After the weighted sum is calculated, a bias value is added. You can think of the bias as a way to make the neuron more or less likely to activate, independent of its inputs. It's an adjustable "knob" that helps the neuron fit the data better.
- Apply an Activation Function: The result (weighted sum + bias) is passed through an activation function. This function "squashes" the value into a desired range (e.g., between 0 and 1) and introduces non-linearity, which is crucial for the network's power.
This next clip from the same 3Blue1Brown video animates this process beautifully.
But what is a neural network? | Deep learning chapter 1
Let's look at exactly how a neuron computes its output value, or 'activation'. This clip explains the role of weights and biases in detail.
Watch from 09:03 to 12:42. Focus on understanding the core idea: a neuron's activation is determined by a weighted sum of the previous layer's activations, plus a bias, all fed into an activation function like the sigmoid.
So, a neuron's job is to "light up" (have a high activation) when it recognizes a specific pattern in its inputs. The weights define what pattern it's looking for, and the bias determines how strong that pattern needs to be before the neuron starts activating meaningfully.
3. Assembling the Network: The Multi-Layer Structure
Now, we arrange these simple neurons into a Multi-Layer Feedforward Network, also known as a Multilayer Perceptron (MLP). The structure consists of three types of layers.

Let's formally define each part.
-
Input Layer: This is the entry point of the network. It doesn't contain processing neurons; it simply holds the initial data for your problem. The number of nodes in the input layer is equal to the number of features in your dataset (e.g., for a 28x28 pixel image, you'd have 784 input nodes).
-
Hidden Layers: These are the layers between the input and output. A network can have one or more hidden layers. This is where the bulk of the computation happens. Each neuron in a hidden layer receives inputs from the previous layer, performs its calculation (weighted sum + bias + activation), and passes its output to the next layer. These layers allow the network to learn complex patterns and relationships in the data that a simple model couldn't capture.
-
Output Layer: This is the final layer of the network. It produces the ultimate result of the computation. The structure of the output layer depends on the problem you're solving:
- For regression (predicting a value like a price), it might be a single neuron with a linear activation function.
- For binary classification (predicting one of two classes), it's often a single neuron with a sigmoid activation function (outputting a probability between 0 and 1).
- For multi-class classification (predicting one of many classes), it's typically one neuron per class, using a softmax activation function.
The term feedforward means that information flows in only one direction—from the input layer, through the hidden layers, to the output layer. There are no loops or backward connections in the network's structure.
To solidify these definitions, let's consult a clear, concise written resource.
Notes on Multilayer, Feedforward Neural Networks
This document provides formal, textbook-style definitions for the components of a multilayer feedforward network.
Please read Section II, 'NETWORK STRUCTURE' on page 2. This short section clearly defines the input layer, hidden layers, and output layer, and reinforces the concepts of 'feedforward' and 'fully connected' layers.
The Crucial Role of Non-Linearity
You might wonder why we bother with activation functions like sigmoid. Why not just pass the weighted sum directly to the next layer? This is a critical point. If we only used linear operations (like sums and multiplications), a deep stack of layers would be mathematically equivalent to a single, simple linear layer. The non-linear activation functions are what allow the network to learn far more complex, curved decision boundaries and approximate any continuous function.
This short video clip explains this concept perfectly.
Feed-Forward Neural Networks (DL 07)
Let's see why non-linear activation functions are the secret ingredient that gives neural networks their power.
Watch from 07:00 to 08:22. The key insight is that without non-linearity in the hidden layers, a deep network loses its advantage over a simple linear model.
4. A Compact View: The Power of Linear Algebra
As you can imagine, writing out the calculations for every single neuron connection would be incredibly tedious. This is where your knowledge from the linear algebra module comes in handy. The entire forward pass for a layer can be expressed with a single, elegant matrix equation.
Let:
- be the vector of activations from the previous layer ().
- be the matrix of weights for the current layer (), where each row corresponds to the weights for one neuron.
- be the vector of biases for the current layer ().
- be the activation function.
Then, the vector of activations for the current layer, , is:
This compact form is not just for notation; it's how libraries like PyTorch and TensorFlow perform these calculations at incredible speeds, leveraging highly optimized matrix operations on GPUs.
Let's watch one last clip that visualizes this matrix representation.
But what is a neural network? | Deep learning chapter 1
This final clip shows how the entire layer's computation can be neatly represented using matrix-vector operations, a concept central to all modern deep learning frameworks.
Watch from 13:26 to 15:17. See how the many individual weighted sums for a layer are consolidated into a single matrix-vector multiplication. This is a crucial link between the network's structure and its practical implementation.
Test your understanding!
Consider the following simple, fully connected feedforward neural network:
- An input layer with 4 neurons.
- A single hidden layer with 8 neurons.
- An output layer with 1 neuron.
- How many layers does this network have in total (counting input, hidden, and output)?
- How many weights are there for the connections between the input layer and the hidden layer? (Do not include bias weights).
- How many bias values are there in the entire network?
Show answer
- The network has 3 layers: one input, one hidden, and one output.
- Since the layers are fully connected, every neuron in the input layer (4 neurons) connects to every neuron in the hidden layer (8 neurons). The total number of weights is .
- Each neuron in the hidden layer (8 neurons) and the output layer (1 neuron) has its own bias. The input layer neurons do not have biases. Therefore, there are bias values in total.
Conclusion
Great work today! You've taken a significant first step into understanding the architecture of neural networks. These concepts are the foundation upon which all of deep learning is built.
Key Takeaways:
- A multi-layer feedforward neural network is composed of an input layer, one or more hidden layers, and an output layer.
- The fundamental unit is the neuron, which computes a weighted sum of its inputs, adds a bias, and applies a non-linear activation function.
- Information flows in one direction (feedforward) from input to output.
- The entire structure—the number of layers and the number of neurons per layer—is called the network's architecture.
- Non-linear activation functions are essential for the network to learn complex patterns.
- Linear algebra provides a compact and efficient way to represent and compute the network's operations.
Preview of the Next Lesson:
Today, we learned that neurons use activation functions, but we only briefly mentioned a few like sigmoid. In the next lesson, we will dive deeper and explain the role of different activation functions like Sigmoid, ReLU, and Softmax. You will learn what each one does, where it's typically used, and why modern networks often prefer one over the other.