Welcome to the next stage of our course. Having covered fundamental machine learning concepts like optimization and regularization, we now shift our focus to the architecture that forms the backbone of modern AI: the neural network. In the previous lesson, we learned how to prevent models from overfitting. Now, we'll start building the model itself.
Today's lesson addresses the fundamental structure of a feedforward neural network (FFNN). You will learn to describe its core components: layers, neurons, weights, biases, and activation functions. Understanding this architecture is essential, as it is the foundational blueprint for more complex models you'll encounter later, including the transformers used in large language models.
From Pixels to Predictions: The Intuition of Neural Networks
At its core, a neural network is a computational model inspired by the brain's structure. It's designed to recognize patterns by processing information through a series of interconnected nodes, or "neurons." The simplest and most common type of architecture is the feedforward network, where information flows in only one direction—from input to output—without any loops. You can think of it as a directed acyclic graph where each node performs a simple computation.
The celebrated 3Blue1Brown video, "But what is a neural network?", provides an unparalleled visual intuition for this process. We will use it to build a mental model of how a network recognizes something complex, like a handwritten digit, by breaking the problem down into hierarchical layers of abstraction.
But what is a neural network? Chapter 1, Deep learning
Please watch the first part of this video from 3Blue1Brown. It masterfully explains the high-level structure and the "why" behind using layers.
Watch from the beginning until the end of the conceptual overview. As you watch, focus on: The role of the input, hidden, and output layers. The idea that hidden layers could learn to detect sub-components of an image (e.g., edges and loops) and combine them to form a final prediction.
This idea of learning hierarchical features—from simple edges in the first hidden layer to more complex shapes in deeper layers—is a central concept in deep learning.
The Anatomy of a Neuron
Now, let's zoom in from the network level to its fundamental building block: a single neuron (or node). Each neuron in a hidden or output layer performs a two-step computation.
- Linear Combination: It calculates a weighted sum of all its inputs and adds a bias.
- Activation: It passes this result through a non-linear activation function.

Let's break down these components:
- Weights (): These are learnable parameters that determine the strength of the connection between neurons. A higher weight means the input from that connection has more influence on the neuron's output.
- Bias (): This is another learnable parameter that acts like an intercept in a linear equation. It allows the neuron to shift its activation function, giving it more flexibility. A bias can be thought of as a threshold the neuron needs to overcome before it "fires" meaningfully.
- Activation Function (): This is a non-linear function that determines the neuron's output. The non-linearity is crucial; without it, a multi-layer network would be mathematically equivalent to a single-layer network, unable to learn complex patterns.
This structure might seem familiar. In fact, a single neuron using a sigmoid activation function is mathematically equivalent to logistic regression, a model you may have encountered before. The Stanford lecture by Andrew Ng provides a clear bridge from logistic regression to the concept of a neuron.
Lecture 11 - Introduction to Neural Networks | Stanford CS229: Machine Learning (Autumn 2018)
This segment from the Stanford CS229 lecture formally defines a neuron's computation and explicitly connects it to logistic regression.
Watch the section from the start of the logistic regression explanation. Focus on the equation "neuron = linear + activation" and how weights and biases are defined as the model's parameters.
Assembling the Network: Layers
Neurons are organized into layers. A typical feedforward network, also known as a Multi-Layer Perceptron (MLP), has at least three types of layers:

-
Input Layer: This is the network's entry point. Each neuron in this layer represents a single feature of the input data (e.g., a pixel value in an image, a word embedding). This layer doesn't perform any computation; it simply passes the data to the first hidden layer.
-
Hidden Layers: These are the layers between the input and output. This is where the bulk of the computation occurs. Each neuron in a hidden layer receives inputs from all neurons in the previous layer, performs its weighted sum and activation, and passes its output to all neurons in the next layer. The "depth" of a deep learning model refers to the number of hidden layers.
-
Output Layer: This is the final layer that produces the network's prediction. Its design is specific to the task:
- Regression: Typically a single neuron with a linear (or no) activation function to output a continuous value.
- Binary Classification: A single neuron with a sigmoid activation function to output a probability between 0 and 1.
- Multi-class Classification: One neuron per class, usually with a softmax activation function, which converts the raw outputs (logits) into a probability distribution where all outputs sum to 1.
The following reading from DataCamp provides a clear, structured overview of these layers and their components.
Feed-Forward Neural Networks Explained: A Complete ...
This article breaks down the architecture of an MLP, detailing the specific roles of the input, hidden, and output layers.
Please read the section titled "Architecture of a Feed-Forward Neural Network". Focus on the descriptions of the Input layer, the Hidden layers, and the Output layer, noting how the output layer's design changes based on the problem type.
The Forward Pass: From Input to Output
The process of passing an input through the network to generate an output is called forward propagation or the forward pass. At each layer, the computations can be expressed efficiently using matrix algebra.
For a given layer , the output activations are calculated from the previous layer's activations as follows:
-
Calculate the weighted sum plus bias, often called the pre-activation or logits, :
-
Apply the activation function element-wise to get the new activations :
Here:
- is the weight matrix for layer , where each column corresponds to the weights of a neuron in layer .
- is the bias vector for layer .
- is the vector of activations from the previous layer (with being the input data).
This process is repeated layer by layer, from the input to the output, composing functions to transform the raw data into a final prediction. The Stanford lecture explains this matrix formulation clearly.
Lecture 11 - Introduction to Neural Networks | Stanford CS229: Machine Learning (Autumn 2018)
This final video segment formalizes the forward propagation process using matrix equations. Given your background, this precise mathematical representation should be very clear.
Watch the clip from the introduction to the multi-layer network. Pay close attention to how the sequence of matrix multiplications and activation functions describes the entire forward pass and how the dimensions of the weight matrices and bias vectors are determined.
Conclusion
In this lesson, we have dissected the architecture of a feedforward neural network. We've seen how it's built from simple, interconnected computational units called neurons, which are organized into layers.
Key Takeaways:
- Feedforward Neural Networks (FFNNs) process information in a single direction, from the input layer, through one or more hidden layers, to the output layer.
- A neuron computes a weighted sum of its inputs, adds a bias, and then applies a non-linear activation function.
- Weights and biases are the learnable parameters of the network, adjusted during training.
- Activation functions (like ReLU, Sigmoid, Softmax) introduce non-linearity, enabling the network to learn complex patterns that go beyond simple linear relationships.
- The network is structured into an input layer (receives data), hidden layers (perform computation and feature extraction), and an output layer (produces the final prediction).
- Forward propagation is the process of passing input data through the network's layers to generate a prediction, a process efficiently described by matrix operations.
Now that you understand the structure of a neural network and how it makes a prediction, the next logical question is: How does it learn? Our next lesson will introduce backpropagation, the fundamental algorithm that allows a network to calculate the error in its predictions and adjust its weights and biases accordingly.