No history yet

Deep Learning Foundations

What Are Neural Networks?

At its heart, a neural network is a computational model inspired by the human brain. It's designed to recognize patterns by processing information through a series of interconnected nodes, much like neurons. These nodes are organized into layers.

Think of it as a team of specialists. The first layer receives the raw data, like the pixels of an image or the words in a sentence. It does some initial processing and then passes its findings to the next layer, which looks for more complex patterns. This continues until the final layer makes a decision or prediction.

There are three main types of layers:

  • Input Layer: This is the network's front door. It takes in the initial data for the task.
  • Hidden Layers: These are the layers between the input and output. A network can have zero or many hidden layers. This is where most of the computation happens, as the network tries to find relationships within the data.
  • Output Layer: This is the final layer that produces the result, such as a classification (e.g., 'cat' or 'dog') or a numerical value.

Making Decisions with Activation Functions

Each node in a neural network needs to decide whether the information it has received is important enough to pass on. It makes this decision using an activation function.

Think of it as a gatekeeper. The function takes the combined input signals to a node and transforms them into an output signal. Crucially, most activation functions are non-linear. This allows the network to learn complex patterns in the data. Without them, the network could only learn simple, linear relationships, no matter how many layers it had.

Activation Function

noun

A mathematical function that determines the output of a node in a neural network, based on its input. It introduces non-linear properties to the network.

A very popular and simple activation function is the Rectified Linear Unit, or ReLU. Its rule is straightforward: if the input is positive, pass it through. If the input is zero or negative, the output is zero.

f(x)=max(0,x)f(x) = \max(0, x)

Learning From Mistakes

A neural network learns by comparing its predictions to the correct answers and adjusting itself to be less wrong next time. But how does it measure how wrong it is? That’s the job of a loss function (also called a cost function).

Imagine you're practicing archery. The loss function is like a rule for scoring. It measures the distance between where your arrow hit and the bullseye. A perfect shot has a loss of zero. The further you are from the center, the higher your loss. The goal of training is to minimize this loss.

Loss Function

noun

A function that calculates the difference, or error, between a neural network's predicted output and the actual, correct output.

One common loss function is Mean Squared Error (MSE). It's often used for tasks where the network predicts a continuous number, like a price or a temperature. It calculates the average of the squared differences between the predicted and actual values.

MSE=1ni=1n(yiy^i)2\text{MSE} = \frac{1}{n} \sum_{i=1}^{n} (y_i - \hat{y}_i)^2

Getting Better Over Time

Once the network calculates its loss, it needs a strategy to reduce it. This process is called optimization, and the most common method is gradient descent.

Think of the loss function as a hilly landscape, and the network's current state is a point on that landscape. The goal is to get to the lowest valley, which represents the lowest possible error. Gradient descent is like taking a small step in the steepest downhill direction. The "gradient" is just a mathematical term for the slope or steepness. The network calculates this gradient and adjusts its internal parameters (the weights on its connections) slightly in the opposite direction to go 'downhill'.

But how does the network know exactly which of its thousands or millions of connections to adjust, and by how much? This is where backpropagation comes in.

Backpropagation is the algorithm that efficiently calculates the gradient. It works backward from the output layer. First, it figures out how much the final layer's connections contributed to the error. Then, it moves to the previous layer and does the same, and so on, all the way back to the first layer. It's like assigning blame for the error, layer by layer.

By combining gradient descent with backpropagation, the network can systematically adjust all of its connections after each prediction, gradually getting better and better at its task.

Quiz Questions 1/5

What is the primary role of the hidden layers in a neural network?

Quiz Questions 2/5

A neural network is trained to predict house prices. After making a prediction, it calculates the average of the squared differences between its predicted prices and the actual prices. Which component is it using?

These core concepts form the bedrock of deep learning. Understanding how networks are built, how they decide, and how they learn is the first step toward mastering more complex and powerful models.