Neural Networks and Deep Learning
See how an artificial neuron weighs its inputs, how layers of neurons form a network, and how training adjusts weights to reduce errors.
Welcome back!
Step 1 of 11Learn
A neuron is a weighted vote
Despite the brain-inspired name, an artificial neuron is simple arithmetic. Picture a neuron deciding whether you should go for a run this evening. It takes a few inputs:
- Is the weather nice? (1 = yes, 0 = no)
- Hours of sleep last night (for example 7)
- Did you already exercise today? (1 = yes, 0 = no)
Each input has a weight showing how much it matters and in which direction. Nice weather might have a weight of +2, sleep +0.5 per hour, and already exercising −3. The neuron multiplies each input by its weight and adds them up, then adds a bias, a constant that shifts the threshold, say −4:
(1 × 2) + (7 × 0.5) + (0 × −3) − 4 = 2 + 3.5 + 0 − 4 = 1.5
Finally, the sum goes through an activation function, which turns it into the neuron's output. A popular simple one, ReLU, outputs the sum if it is positive and 0 otherwise. Another, the sigmoid, squeezes any number into the range 0 to 1, which can be read like a probability. A sum of 1.5 gives a sigmoid output of about 0.82: a strong lean toward going for a run.
That is the whole neuron: multiply, add, squash. A single neuron can only draw simple boundaries. The magic comes from connecting thousands or billions of them and letting training choose all the weights.
Step 2 of 11Try the calculator
One artificial neuron
Change the inputs and weights to see the weighted sum and the sigmoid output. Inputs: weather (1 or 0), hours of sleep, already exercised (1 or 0).
- Weighted sum z
- 1.5
- ReLU output max(0, z)
- 1.5
- Sigmoid output (0 to 1)
- 0.818
Step 3 of 11Practice · Work it out
A neuron has inputs 3 and 2 with weights 0.5 and −1, and a bias of 4. What is its weighted sum before the activation function?
Step 4 of 11Note
Step 5 of 11Learn
From neurons to networks
A neural network arranges neurons in layers.
- The input layer receives the raw features: the pixel brightness values of an image, or numbers representing words.
- One or more hidden layers each take the previous layer's outputs as their inputs. Every neuron computes its own weighted sum and activation.
- The output layer produces the answer: for example, ten numbers giving the probability that a handwritten digit is 0 through 9.
Networks with many hidden layers are called deep, hence deep learning. Depth matters because each layer can build on the patterns found by the layer before. In an image network, early layers tend to respond to simple edges and color patches. Middle layers combine edges into textures and shapes like circles and corners. Later layers respond to parts of objects, such as eyes, wheels or leaves, and the final layer combines those into "cat" or "bicycle." Nobody programs these features; they emerge during training because they help reduce errors.
Modern networks are enormous. An image classifier might have tens of millions of weights; the largest language models have hundreds of billions. Each weight is a number tuned during training. This scale is why training a leading model takes huge data centers, while running it on a single question takes far less.
It is also why neural networks are hard to explain. A decision emerges from millions of small weighted contributions, not from a readable rule. Researchers in the field of interpretability work on tools to understand what is happening inside.
Step 6 of 11Practice · Put in order
Put the steps of a forward pass through a neural network in order.
Drag the items, or use the arrow buttons, to put them in order.
- Raw features enter the input layer
- The output layer combines the last hidden layer's outputs into a prediction
- Each hidden neuron computes a weighted sum of the previous layer's outputs plus its bias
- An activation function transforms each hidden neuron's sum
Step 7 of 11Learn
How a network learns
A freshly created network has random weights, so its predictions are garbage. Training fixes that through a loop repeated millions of times:
- Predict. Feed a batch of training examples forward through the network.
- Measure the error. A loss function scores how wrong the predictions are compared with the labels. Predicting 0.9 for "cat" when the image is a cat gives a small loss; predicting 0.1 gives a large one.
- Assign blame. An algorithm called backpropagation works backward through the layers and calculates, for every single weight, which direction to nudge it to reduce the loss.
- Adjust. Each weight moves a small step in that direction. This is gradient descent: like walking downhill in fog by always stepping in the direction that slopes down most steeply. The size of each step is the learning rate.
Repeat over the whole dataset many times, and the loss falls. Each full pass through the training data is called an epoch.
The learning rate is a balancing act. Steps that are too large overshoot the valley and make the loss bounce around or explode. Steps that are too small make training painfully slow.
Notice what training does not involve: no one tells the network which features to look for. It discovers useful internal patterns because they reduce the loss. This is why deep learning works so well on images, audio and language, where useful features are too complex for people to design by hand, and why it needs so many examples to get there.
Step 8 of 11Explore
The sigmoid activation
The sigmoid turns a neuron's weighted sum into an output between 0 and 1. Change the weight w and bias b of a one-input neuron and watch how the curve shifts and steepens. A larger weight makes the neuron switch more sharply; the bias moves the switching point.
- Input where output = 0.5 (−b/w)
- 0
Step 9 of 11Flashcards
Neural network vocabulary
Tap a card to flip it.
Step 10 of 11Practice · True or false
During training, programmers manually set which features each hidden neuron should detect.
Step 11 of 11Practice · Choose one
During training, the loss jumps around wildly and sometimes grows instead of shrinking. Which change is most likely to help?
Lesson complete!