No history yet

Introduction to Neural Networks

The Brain of the Machine

At the heart of artificial intelligence are neural networks, systems inspired by the web of neurons in the human brain. Just as our brains use neurons to process information, neural networks use artificial neurons, or nodes, to find patterns in data. It’s a powerful way to teach a machine how to learn.

A single neuron is a simple computing unit. It receives one or more inputs, each with an associated weight. Think of weights as a measure of importance; a higher weight means that input has more influence on the neuron's output. The neuron sums up these weighted inputs, adds a value called a bias, and then passes the result through an activation function to produce its final output.

But a single neuron can't do much on its own. The real power comes from connecting many of them together in layers. A typical neural network has at least three types of layers:

Input Layer: This is the network's front door. It receives the initial data. For example, if you're trying to predict a house's price, the inputs might be its square footage, number of bedrooms, and location.

Hidden Layers: These are the layers between the input and output. This is where most of the computation happens. Each neuron in a hidden layer receives inputs from the previous layer and passes its output to the next. A network can have many hidden layers; networks with more than one are called deep neural networks.

Output Layer: This is the final layer that produces the result. For our house price example, it might be a single neuron that outputs the predicted price.

Lesson image

Making Decisions

After a neuron sums its weighted inputs, it doesn't just pass that sum along. It uses an activation function to transform the number in a specific way. Why? Because most real-world data isn't simple and linear. Activation functions introduce non-linearity, allowing the network to learn complex relationships and patterns in the data.

Without them, a neural network, no matter how many layers it has, would behave just like a simple linear model. The activation function is what gives the network its power to model intricate data, like identifying a cat in a photo or understanding the nuance of human language.

One common example is the sigmoid function, which squishes any input value into a range between 0 and 1. This is useful for predicting probabilities, such as the probability that an email is spam.

σ(z)=11+ez\sigma(z) = \frac{1}{1 + e^{-z}}

Other popular activation functions include the Rectified Linear Unit (ReLU), which is computationally efficient, and Tanh, which squishes values between -1 and 1. The choice of activation function depends on the problem the network is trying to solve.

How a Network Learns

A neural network learns by example. We show it a large dataset and ask it to make predictions. Initially, its predictions will be completely wrong because its weights and biases are set to random values. The magic is in how it adjusts these values to get better over time. This process is called training.

Training involves a cycle of two main steps: a forward pass and a backward pass.

Loss Function

noun

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

First, in the forward pass, we feed an input (like a house's features) into the network. The data flows through the layers, from input to output, and the network makes a prediction. We then compare this prediction to the actual correct answer (the real house price) using a loss function. The loss function gives us a single number that tells us how wrong the network was. A high loss means a bad prediction; a low loss means a good one.

Next comes the backward pass, or backpropagation. This is the core of the learning process. The network uses calculus to figure out how much each weight and bias in the entire network contributed to the final error. It's like assigning blame. It then adjusts each weight and bias slightly in the direction that will reduce the error. For weights that contributed a lot to the error, the adjustment is bigger.

The network repeats this cycle of forward and backward passes thousands or even millions of times, using many different examples from the dataset. With each cycle, the weights and biases are nudged closer to the values that produce the most accurate predictions. This gradual, iterative process is how the network learns to map inputs to correct outputs.

Quiz Questions 1/5

In a neural network, what is the primary role of a 'weight' associated with an input?

Quiz Questions 2/5

What is the main purpose of an activation function in a neural network?

This foundational structure of neurons, layers, and learning through backpropagation is the basis for almost all modern AI, including the powerful models we'll explore next.