No history yet

Introduction to Neural Networks

The Simplest Neuron

Neural networks are inspired by the human brain. The brain is made of billions of tiny cells called neurons that communicate with each other. An artificial neural network does something similar, but with math instead of biology.

Lesson image

The simplest form of an artificial neuron is called a perceptron. It takes in several inputs, each with its own importance or weight. Think of it like making a decision. When you decide whether to bring an umbrella, you might consider several inputs: Is it cloudy? What does the weather app say? Is the ground already wet? You probably give more weight to the weather app than to whether the ground is wet.

A perceptron does the same. It multiplies each input by its weight, adds them all up, and includes a special value called a bias. The bias is like a baseline tendency. For example, you might be naturally cautious and tend to bring an umbrella even if there's only a small chance of rain. That's a high bias towards taking the umbrella.

The perceptron's core job is to weigh evidence and make a simple decision.

The formula for this process looks like this: the sum of (weight × input), plus the bias. Let's say we have inputs x1,x2,,xnx_1, x_2, \dots, x_n and corresponding weights w1,w2,,wnw_1, w_2, \dots, w_n. The calculation is:

Sum=(w1x1+w2x2++wnxn)+bias\text{Sum} = (w_1x_1 + w_2x_2 + \dots + w_nx_n) + \text{bias}

After summing everything up, the perceptron needs to make a final yes-or-no decision. This is where an activation function comes in.

Making the Call

An activation function takes the summed output from the perceptron and decides what the neuron's final output should be. It acts as a gatekeeper, determining if the signal is strong enough to pass on.

The simplest activation function is a step function. If the summed input is greater than a certain threshold (say, zero), it outputs a 1 (or "yes"). If not, it outputs a 0 (or "no"). It's a binary, all-or-nothing decision.

However, this on/off switch is too rigid for learning complex patterns. Modern neural networks use smoother activation functions. A popular one is the Sigmoid function, which squishes any input value into a smooth curve between 0 and 1. Instead of a hard "yes" or "no," it gives a probability. A value of 0.8 might mean "very likely yes," while 0.1 means "very likely no."

Sigmoid(z)=11+ez\text{Sigmoid}(z) = \frac{1}{1 + e^{-z}}

Another common function is the Rectified Linear Unit, or ReLU. It's even simpler: if the input is positive, it passes that value along. If the input is negative, it outputs zero. This simplicity makes it very efficient for training large networks.

ReLU(z)=max(0,z)\text{ReLU}(z) = \max(0, z)

Building a Network

A single neuron can only make simple decisions. The real power comes from connecting many of them together into a network. The most basic architecture is the feedforward neural network.

In this setup, neurons are organized into layers. The first layer is the input layer, where the network receives its initial data. The last layer is the output layer, which produces the final result. In between are one or more hidden layers. These hidden layers are where the network does most of the heavy lifting, finding patterns and features in the data that aren't immediately obvious.

Lesson image

Information flows in one direction, from the input layer, through the hidden layers, to the output layer. There are no loops or backward connections. Each neuron in one layer is typically connected to every neuron in the next layer, passing its output forward as an input for the next set of calculations.

Imagine trying to identify a picture of a cat. The input layer might receive the raw pixel values. The first hidden layer could learn to recognize simple edges and curves. The next hidden layer might combine those edges to identify shapes like ears and whiskers. Finally, the output layer would take those recognized features and conclude, "It's a cat."

Let's test your understanding of these fundamental building blocks.

Quiz Questions 1/5

What is the primary role of 'weights' in a perceptron?

Quiz Questions 2/5

Which activation function is known for its simplicity and efficiency, outputting the input value if it's positive and zero otherwise?

By stacking these simple mathematical units into layers, neural networks can learn to solve incredibly complex problems, from understanding language to driving a car.