No history yet

Introduction to Neural Networks

What is a Neural Network?

Artificial neural networks are computing systems inspired by the brain. They're designed to recognize patterns in data, much like how we learn to recognize faces or sounds. Instead of biological neurons, they use artificial ones called nodes.

These nodes are organized into layers. At a minimum, a neural network has an input layer that receives data and an output layer that produces a result. In between, there can be one or more hidden layers where the real work happens. Each node in one layer is connected to nodes in the next, and each connection has a weight, which represents the strength of the connection.

Lesson image

When you give the network data, like the pixels of an image, it flows from the input layer through the hidden layers to the output layer. This one-way flow is characteristic of the most common type, called a feedforward neural network. The network processes the data at each layer, adjusting it based on the connection weights, until it finally produces a guess or a prediction at the output layer.

Making Decisions

How does a node decide what information to pass on? It doesn't just add up its inputs. After summing the weighted inputs it receives, each node applies an activation function to the total. This function determines whether the node should be activated, or "fire," and how strongly.

Activation functions introduce non-linearity to the network, allowing it to learn complex patterns. Without them, a neural network would just be a complicated linear equation, no matter how many layers it had.

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, like the chance that an image contains a cat. Another popular one is the Rectified Linear Unit (ReLU), which simply outputs the input if it's positive, and zero otherwise.

How Neural Networks Learn

A brand-new neural network is a blank slate. Its connection weights are initialized with random values, so its first guesses are wild and meaningless. The process of turning this uninformed network into a useful tool is called training.

Training involves showing the network many examples from a dataset, each with a known correct answer. For each example, the network makes a prediction. Then, we calculate its error—how far off the prediction was from the correct answer—using a loss function. The goal is to adjust the network's weights to minimize this error.

Gradient Descent

noun

An optimization algorithm used to find the values of parameters (in this case, weights) that minimize a loss function.

The main engine behind this adjustment is an algorithm called gradient descent. Imagine you're standing on a foggy mountain and want to get to the lowest valley. You can't see the whole landscape, but you can feel the slope of the ground beneath your feet. The smartest move is to take a step in the steepest downward direction. Gradient descent does exactly this. It calculates the slope (the gradient) of the loss function with respect to each weight and nudges the weight in the downward direction to reduce the error.

The size of each step is called the learning rate. A learning rate that's too small makes training incredibly slow, while one that's too large can cause you to overshoot the lowest point and bounce around the valley forever.

But how does the network know which weights to blame for the error? A mistake in the final output could be the fault of any of the thousands or millions of connections throughout the network.

This is where backpropagation comes in. After calculating the total error at the output layer, the algorithm works backward through the network, from the last layer to the first. At each layer, it calculates how much the local nodes contributed to the overall error. It then uses this information to adjust the weights of the connections leading into that layer. This process efficiently distributes the blame and ensures every weight is updated correctly.

Let's test your understanding of these core concepts.

Quiz Questions 1/5

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

Quiz Questions 2/5

The process of adjusting a neural network's weights to minimize error is called _________.

By repeating this process of guessing, checking the error, and adjusting weights for thousands of examples, the network gradually learns the underlying patterns in the data.