No history yet

Introduction to Neural Networks

The Brain's Blueprint

At the heart of any neural network is a simple component inspired by the human brain: the neuron. Think of an artificial neuron as a tiny decision-maker. It receives one or more signals, or inputs, and based on those signals, it decides whether to send a signal of its own.

Each input signal has a certain importance, or weight. A higher weight means the neuron pays more attention to that input. The neuron takes all its weighted inputs, adds them up, and also includes a special value called a bias. The bias acts like a baseline threshold; it helps determine how high the summed signal needs to be before the neuron gets activated.

After summing everything up, the neuron doesn't just pass the raw number along. It runs the total through an activation function. This function is a crucial step that introduces non-linearity, allowing the network to learn complex patterns. Without it, a neural network, no matter how many layers it has, would behave just like a simple linear model.

Activation Function

noun

A mathematical function that determines the output of a neuron. It takes the weighted sum of inputs and a bias, and transforms it into an output signal that is then passed to the next neuron.

A common example is the sigmoid function, which squishes any input value into a range between 0 and 1. This is useful for representing probabilities, like the chance that an image contains a cat.

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

Connecting the Dots

A single neuron isn't very powerful. The real magic happens when we connect them together into a network. The simplest structure is a feedforward neural network. Information in this network flows in only one direction: from the input layer, through one or more hidden layers, to the output layer.

  • Input Layer: Receives the initial data, like the pixels of an image or the words in a sentence.
  • Hidden Layers: These are the intermediate layers between input and output. This is where most of the computation happens. The more hidden layers, the "deeper" the network.
  • Output Layer: Produces the final result, such as a classification (e.g., 'cat' or 'dog') or a numerical prediction.
Lesson image

Each neuron in a layer is typically connected to every neuron in the next layer, but not to neurons in the same layer or previous layers. This structured, one-way flow of information is what defines a feedforward network.

How a Network Learns

So how does a network go from random guesses to accurate predictions? It learns through a process of trial and error, guided by an algorithm called backpropagation.

Imagine the network is a student taking a multiple-choice test. On the first try, it guesses answers randomly. After finishing, it gets a score that shows how many answers were wrong. This "wrongness" is measured by a loss function. The goal is to minimize this loss.

Backpropagation is the process of figuring out which connections in the network were most responsible for the error and then adjusting them accordingly.

The network works backward from the final error, calculating how much each weight and bias contributed to it. It uses a technique from calculus called gradient descent. Think of the loss as a giant, hilly landscape. The goal is to find the lowest valley, which represents the lowest possible error. The gradient tells you which direction is the steepest downhill slope from your current position.

wnew=woldηLw_{\text{new}} = w_{\text{old}} - \eta \cdot \nabla L

The network takes a small step in that downhill direction by slightly adjusting all its weights and biases. This process is repeated thousands or even millions of times, with the network gradually descending into a valley of low error. With each iteration, its predictions get a little bit better, until it becomes a proficient problem-solver.

Quiz Questions 1/6

What is the primary role of an activation function in a neural network?

Quiz Questions 2/6

In a feedforward neural network, information flows from the input layer to the output layer, sometimes passing through intermediate layers. What are these intermediate layers called?