No history yet

Introduction to Neural Networks

The Building Blocks of Neural Networks

At its heart, a neural network is inspired by the human brain. It's made of simple processing units called neurons, which are organized into layers. Think of it like a team of specialists working on a problem. The first layer, the input layer, receives the raw data, like the pixels of an image or the words in a sentence.

This information is then passed through one or more hidden layers. These are the core of the network where the real work happens. Each neuron in a hidden layer takes inputs from the previous layer, performs a small calculation, and passes its result to the next layer. Finally, the output layer produces the final result, such as a prediction or a classification.

The connections between these neurons have associated weights. A weight determines the strength and importance of a connection. A higher weight means the signal from one neuron has a stronger influence on the next. Each neuron also has a bias, which is an extra number that can shift the neuron's output up or down. During training, the network learns the best values for these weights and biases.

Making Decisions with Activation Functions

If neurons just did simple addition and multiplication, they could only learn very basic, straight-line relationships. The world is much more complex than that. This is where activation functions come in. After a neuron sums up its weighted inputs, it passes the result through an activation function.

An activation function is a mathematical gatekeeper that decides whether a neuron should be "activated" or not. It introduces non-linearity, allowing the network to learn intricate patterns in the data.

One common activation function is the Sigmoid function. It takes any number and squashes it into a value between 0 and 1. This is useful for outputs that represent a probability, like the chance of an email being spam.

σ(x)=11+ex\sigma(x) = \frac{1}{1 + e^{-x}}

Another popular choice is the Rectified Linear Unit (ReLU). It's even simpler: if the input is negative, it outputs zero; otherwise, it outputs the input number itself. Despite its simplicity, ReLU is incredibly effective and widely used in modern neural networks.

How Networks Learn

A neural network learns by repeatedly guessing, checking its answer, and adjusting its strategy. This process involves two main steps: forward propagation and backward propagation.

Forward Propagation

noun

The process of passing input data through the network from the input layer to the output layer to get a prediction.

Think of forward propagation as the network making a prediction. The input data flows forward through the layers, with each neuron performing its calculation and passing the result on, until the output layer produces a final guess.

But how does the network know if its guess is any good? It measures its error using a loss function. A loss function compares the network's prediction to the actual, correct answer and calculates a single number, the "loss," which represents how wrong the network was. A high loss means a bad guess; a low loss means a good one.

The goal of training is to minimize this loss. This is where backward propagation comes in.

Backward Propagation

noun

The process of calculating the gradient of the loss function with respect to the network's weights. It propagates the error backward from the output layer to the input layer.

After calculating the loss, the network works backward from the output layer. It figures out how much each weight and bias in the network contributed to the total error. This process uses calculus, specifically the chain rule, to find the gradient of the loss. The gradient is just a vector that points in the direction of the steepest increase in the loss.

To reduce the loss, we need to move in the opposite direction of the gradient. This is handled by an optimization algorithm. The most common one is Gradient Descent. It takes the gradient calculated during backpropagation and nudges the weights and biases in the direction that will lower the error. The size of that nudge is controlled by a parameter called the learning rate.

This cycle of forward propagation (guess), calculating loss (check), backward propagation (find blame), and updating weights (adjust) is repeated thousands or even millions of times. With each cycle, the network's predictions get a little bit better.

Quiz Questions 1/6

In a neural network, what is the primary role of the hidden layers?

Quiz Questions 2/6

What is the purpose of a weight in a neural network?

These core concepts form the foundation of nearly all deep learning models. Understanding how neurons, layers, and the learning cycle work is the first step to mastering more complex architectures.