Introduction
Welcome to the first lesson of our second module, "The Mechanics of Modern AI." In the previous module, we explored the three major paradigms of machine learning: supervised, unsupervised, and reinforcement learning. We finished by looking at how a reinforcement learning (RL) agent learns through trial and error, guided by a reward signal.
Today, we address the learning outcome: Describe the architecture of a neural network, including neurons, layers, weights, and activation functions. This is the "how" behind many of the advanced AI systems we've discussed. The "brain" of the RL agent that learned to play Atari games, and the core of models that classify images or translate languages, is a neural network.
Given your interest in the technical underpinnings of AI, this lesson will go beyond surface-level analogies and dissect the components that allow these networks to function. Understanding this architecture is a prerequisite for grasping concepts like model training, bias, and explainability, which are central to AI law and governance.
1. The Core Idea: From Biological Inspiration to Computational Model
While the term "neural network" is inspired by the human brain, it's best to think of it as a powerful mathematical and computational framework. These networks are designed to recognize patterns by breaking down complex information into a hierarchy of simpler concepts.
To get an intuitive feel for this structure, we'll start with a classic video from 3Blue1Brown that uses the task of handwritten digit recognition to introduce the main components.
But what is a neural network? | Deep learning chapter 1
This video provides an excellent visual introduction to neural networks. It explains how neurons are organized into layers and how they collectively work to process information, like identifying a handwritten digit.
Watch the segment from 02:43 to 04:39. Focus on these three key architectural ideas: Neurons: What they represent (a number called an 'activation'). Layers: The distinct roles of the input, hidden, and output layers. Information Flow: The idea that activations in one layer determine the activations in the next.
As the video explained, a neural network is essentially a collection of interconnected "neurons" organized in layers.
- Input Layer: Receives the raw data. For an image, this could be one neuron for every pixel.
- Hidden Layers: The intermediate layers where the bulk of the computation happens. Their activations are not directly specified by the input or desired output, hence the term "hidden."
- Output Layer: Produces the final result. For a classification task, this could be one neuron for each possible class.

The power of this layered structure lies in its ability to build a hierarchy of features. For image recognition, the first hidden layer might learn to detect simple edges from pixels, the second might combine those edges to detect shapes like loops and lines, and the final layers might assemble those shapes to recognize an object like a face or a handwritten digit.
2. The Neuron: The Network's Fundamental Unit
Let's zoom in on a single neuron to understand how it processes information. A neuron is a computational unit that takes multiple inputs, processes them, and produces a single output.

Here's how the calculation works, following the diagram above:
- Weighted Sum: The neuron receives inputs from the neurons in the previous layer. Each of these connections has an associated weight (). The weight signifies the importance of that input. A large positive weight means the input strongly excites the neuron, while a large negative weight means it strongly inhibits it. The neuron calculates a weighted sum of all its inputs.
- Bias: After the weighted sum is calculated, a bias () is added. You can think of the bias as a thumb on the scale. A high bias makes it easier for the neuron to activate, while a low (negative) bias makes it harder. It essentially shifts the activation threshold.
- Activation Function: The final result (weighted sum + bias) is passed through an activation function (). This function "squishes" the output into a desired range (e.g., between 0 and 1) and, crucially, introduces non-linearity, which we'll discuss next.
Let's see this in action. The next video segment explains precisely how weights and biases are used to make a neuron in the second layer respond to a specific pattern (like a vertical edge) in the input pixels.
But what is a neural network? | Deep learning chapter 1
This segment clearly explains the roles of weights and biases in determining a neuron's behavior. It builds on the digit recognition example to show how a neuron can be 'tuned' to detect specific features.
Watch from 08:21 to 12:31. Focus on understanding: How positive and negative weights can be configured to detect a pattern (like an edge). The role of the bias in determining how active the inputs need to be before the neuron 'fires'. The enormous number of weights and biases ('parameters') in even a simple network.
So, the weights and biases are the "knobs and dials" of the network. The process of "learning" or "training" a neural network is simply the process of finding the optimal values for all these weights and biases to make the network perform its task correctly.
Test your understanding!
Imagine a single neuron in the first hidden layer of a network designed to process 10x10 pixel black-and-white images. Its job is to detect a horizontal line in the middle of the image. How would you intuitively set its weights and bias?
(Assume input activations are 1 for white pixels and 0 for black pixels.)
Show answer
- Weights: You would set high positive weights for the connections coming from the input neurons corresponding to the pixels in the middle rows of the image. You would set weights of zero or slightly negative values for all other pixels (top, bottom, and surrounding pixels). This way, the weighted sum will be highest when the middle pixels are white and others are black.
- Bias: You would set a relatively high negative bias. This ensures the neuron only activates when a strong horizontal line pattern is present (i.e., when the weighted sum is large enough to overcome the negative bias), and not just from random noise or a few scattered white pixels.
3. Activation Functions: Introducing Non-Linearity
One of the most critical components of a neuron is its activation function. As we've seen, this function takes the weighted sum + bias and produces the neuron's final output. But why is it so important?
A neural network's power comes from its ability to learn complex, non-linear relationships in data. If we didn't have activation functions (or only had linear ones), a deep neural network, no matter how many layers, would behave just like a single-layer network. It would only be capable of learning linear patterns, which is too restrictive for most real-world problems.
Let's explore the most common activation functions and their properties.
Activation Functions - EXPLAINED!
This video from CodeEmporium focuses specifically on activation functions. It explains why they are essential for learning complex patterns and compares the most common types.
Watch the first four minutes (00:00 to 04:05). Pay attention to the answers to these questions: What is the primary purpose of a non-linear activation function? What is the Sigmoid function and what is its major drawback (the 'vanishing gradient' problem)? What is the ReLU (Rectified Linear Unit) function, and why is it often preferred over Sigmoid? What is the 'dying ReLU' problem and how do functions like Leaky ReLU address it?
To summarize the key functions:
- Sigmoid: S-shaped curve that squishes values between 0 and 1. It was historically popular due to its biological analogy (neurons are either 'off' or 'on'). However, it suffers from the vanishing gradient problem, where the function's slope becomes very close to zero for large positive or negative inputs, effectively stopping the learning process in deep networks.
- ReLU (Rectified Linear Unit): A simple but powerful function that outputs the input if it's positive, and zero otherwise (). It is computationally efficient and largely avoids the vanishing gradient problem, making it the most common activation function for hidden layers today. Its main drawback is the "dying ReLU" problem, where neurons can get stuck in a state where they always output zero and stop learning.
- Leaky ReLU & others: Variants of ReLU that allow a small, non-zero gradient when the input is negative, mitigating the "dying ReLU" problem.
The choice of activation function is a key architectural decision in designing a neural network.
4. The Complete Architecture in Practice
Now we can put all the pieces together:
- We start with input data, which sets the activations of the input layer.
- This information propagates to the first hidden layer. For each neuron in this layer, we compute a weighted sum of the inputs, add a bias, and apply an activation function (like ReLU).
- This process repeats for each subsequent hidden layer.
- Finally, the activations of the last hidden layer are used to compute the activations of the output layer. The activation function for the output layer is often different and depends on the task (e.g., Sigmoid for binary classification, or another function called Softmax for multi-class classification).
This entire process of passing data forward through the network can be expressed very compactly using linear algebra. As the 3Blue1Brown video briefly showed, the activations of a layer can be calculated with a single equation:
\text{activation}_{(\text{layer L})} = \text{activation_function} ( (\text{Weight_Matrix} \times \text{activation}_{(\text{layer L-1})}) + \text{Bias_Vector} )Given your Python background, it's useful to see how these abstract concepts are defined in a practical context. The following resource provides a brief, high-level description of these building blocks before implementing them.
Deep learning on MNIST - Numpy Tutorials
This NumPy tutorial clearly defines the building blocks of a neural network in a practical, code-oriented context. It will help connect the concepts we've discussed to their implementation.
Read the sections 'Neural network building blocks with NumPy' and 'Model architecture and training summary'. You don't need to understand the code, but focus on how the text describes the role of Layers, Weights, and the ReLU Activation function.
This reading reinforces how these individual components—layers, weights, and activation functions—come together to form a complete, functioning architecture that passes information from input to output.
Conclusion
In this lesson, we have deconstructed the fundamental architecture of a neural network. This foundational knowledge is essential for understanding how modern AI models work, what their limitations are, and where legal and ethical risks might arise.
Key Takeaways:
- A neural network is an information processing system composed of interconnected neurons organized in layers (input, hidden, output).
- Each connection has a weight, and each neuron has a bias. These are the tunable parameters that are learned during training.
- A neuron calculates a weighted sum of its inputs, adds its bias, and passes the result through a non-linear activation function.
- Activation functions like ReLU are critical for enabling networks to learn complex, non-linear patterns, which is the source of their power.
- The entire architecture is a complex, multi-layered function that maps an input (like an image) to an output (like a label).
Preview of the Next Lesson:
We now know what a neural network is made of. The next logical question is: how does it learn the correct values for its millions of weights and biases? In our next lesson, we will explore the training loop, covering forward propagation (making a prediction), loss functions (quantifying error), and the crucial algorithm of backpropagation (updating the weights to reduce the error).