Deep Learning Fundamentals


Deep Learning Fundamentals

Simon
Welcome! Today we're unpacking deep learning: what it is, how neural networks process information, and how they learn from examples. Let's begin with the basic definition. Deep learning is a type of machine learning that extracts features from input data through multiple layers of formulas.

Maria
And some well-known examples include deep neural networks, deep belief networks, deep reinforcement learning, recurrent neural networks, and convolutional neural networks. Most modern deep learning algorithms are built using neural networks, which is why people sometimes use “deep learning” and “neural network” as if they mean the same thing.

Simon
But they aren't exactly interchangeable. A neural network is an algorithm used to implement AI, while deep learning describes a kind of machine learning approach. Reinforcement learning can be implemented without neural networks, even though many modern deep learning systems do use them.

Maria
So what is an artificial neural network, then? It's a collection of connected artificial neurons. The name might make us imagine tiny electronic copies of brain cells, but the lecture emphasizes that artificial neurons work differently from neurons in living organisms.

Simon
Right. An artificial neuron is a mathematical function, or a combination of functions. It receives data, applies an activation function to that input, and returns a result. Connecting many of these mathematical units lets a network process input and derive information from it.

Maria
Activation functions can vary depending on the input data or the role of a neuron. And although a real-world object may not look like a number, the lecture's starting point is that many facts about the world can be expressed numerically. Data is information that can be expressed, so neural networks can process data by processing numbers.

Simon
As data moves through a neural network, it is transformed into features. Those features are information derived from the real world, though they may or may not be useful. There are many ways to connect neurons; for our introduction, we're focusing on a fully connected network.

Maria
In a fully connected network, each neuron sends its output to every neuron in the next layer. The input layer receives the data, and the output layer returns the network's result. Any layers between those are called hidden layers. The example in the lecture has one hidden layer.

Simon
Each neuron can have one or more input ports, connected either to the network's original data or to outputs from the previous layer. It assigns a weight to each input port, which lets the network represent how important each input is. The neuron adds up the weighted inputs, then applies an activation function.

Maria
The process of passing values forward through the layers is called forward propagation. Let's make that concrete with the lecture's simple spam detector. It uses three yes-or-no inputs: is the sender on a blacklist, does the email contain the word “password,” and is an “exe” file attached?

Simon
For this example, true is represented by 1 and false by 0. The sender being blacklisted gets a weight of 0.5, the word “password” gets 0.2, and an exe attachment gets 0.3. The activation function will label the message spam if the weighted sum is greater than 0.5.

Maria
Now suppose the sender is blacklisted, “password” is absent, and an exe file is attached. The inputs are 1, 0, and 1, so their weighted sum is 1 times 0.5, plus 0 times 0.2, plus 1 times 0.3. That totals 0.8, which is above the threshold, so the network returns a spam result.

Simon
In practice, the activation function returns a numerical value; for this simple illustration, it returns 1 for spam and 0 otherwise. Real networks can have far more inputs and layers, but the basic idea—combine weighted inputs and apply functions—remains similar.

Maria
The next question is how a network learns. We'll focus on supervised learning, a very common approach for modern AI models. It learns from pairs: an input and its correct answer. The lecture compares this to studying for a quiz by memorizing questions alongside their answers.

Simon
The network first receives an input and calculates an output through its activation functions. That output may be right or wrong. In supervised learning, the model compares its output with the correct answer, then changes its internal weights so that it can produce a more suitable result the next time it sees that input.

Maria
That adjustment process is called training. A useful measure is the error: the difference between the correct answer and the model's output. The lecture describes loss as the square of that error. You don't need to focus on the exact calculation here; the key idea is that larger errors mean larger loss, and training aims to reduce the loss.

Simon
Forward propagation carries values from input to output. Back propagation uses the loss to work backward and adjust weights in earlier layers. Because each layer's outputs become the next layer's inputs, changing a weight in one place can affect the final answer—and therefore the loss.

Maria
For anyone curious about the calculus behind that, the network needs to know how the loss changes when a weight changes. A derivative measures that relationship. If we can't find the derivative directly, the chain rule lets us express it as a product of derivatives through the steps connecting the weight to the loss.

Simon
In the lecture's simple neuron example, the input is multiplied by a weight to form a weighted sum, and that sum goes into an activation function. The output is then compared with the correct answer to calculate loss. So the chain of relationships runs from weight, to weighted sum, to output, to loss.

Maria
The lecture illustrates this using the sigmoid activation function. For sigmoid, the derivative of the output with respect to its weighted-sum input can be written as output multiplied by one minus output. And because the weighted sum contains input multiplied by weight, its derivative with respect to the weight is the input.

Simon
Putting those pieces together, the loss's derivative with respect to a weight can be found by multiplying the relevant derivatives: how loss changes with output, how output changes with the weighted sum, and how the weighted sum changes with weight. The important takeaway isn't memorizing a formula; it's that the chain rule makes this calculation possible.

Maria
That derivative is called the gradient. Picture a graph with weight on one axis and loss on the other. At the current weight, the gradient is the slope of the tangent to the loss curve. Its sign tells us which direction to move the weight to reduce loss.

Simon
If the gradient is positive, increasing the weight increases the loss, so we should move the weight lower. If the gradient is negative, increasing the weight decreases the loss, so we should move it higher. A common update rule expresses this as: new weight equals old weight minus learning rate times gradient.

Maria
The learning rate is a positive value that controls how large each weight adjustment is; the lecture gives 0.0005 as an example of a constant that might be used. A larger learning rate means a larger change. Either way, the goal is to use the gradient to adjust weights in the direction that lowers loss.

Simon
The same kind of update is made for the other neurons and layers, using gradients calculated through the chain rule. Larger neural networks require more of these calculations, which is one reason GPUs are used to perform them quickly.

Maria
So far, we've described an update using one input-and-answer pair. With many examples, the process is repeated across all the training pairs. Completing back propagation across all the training data once is called one epoch, and neural networks are usually trained for multiple epochs.

Simon
Training is complete after the weights have been updated across the data several times. The lecture notes that a large amount of data can sometimes mean training can be completed with fewer epochs. The central idea remains that training modifies weights based on errors so the model's loss—and therefore its errors—goes down.

Maria
And let's distinguish training from inference. Training changes the network's weights using examples and their correct answers. Inference means producing an output for an input; prediction is one kind of inference. For neural networks, inference is also called forward propagation.

Simon
Let's recap the whole picture. An artificial neural network is a connected set of mathematical functions, with activation functions operating on inputs. The network assigns importance through weights, transforms data through layers, and produces a numerical output. Since numerical values can represent real-world information, the network can derive new information from input data.

Maria
Most deep learning models use neural network techniques, and even unsupervised-learning neural networks are trained in a direction that reduces loss. There are also deep learning approaches based on statistics or probability, but understanding those requires substantial knowledge of those subjects.

Simon
So the big ideas to carry forward are: deep learning uses multiple layers to extract features; neural networks are a common way to implement it; and supervised networks learn by comparing outputs with correct answers and adjusting weights through back propagation. Next time, we'll move on to Keras.

Ask anything
We've read this whole study set, so questions about it get the best answers.