Crate #4: Neural Networks β The Brain Factory
Inspired by brains, powered by math
π Prerequisites
What's a Neural Network?
Your brain has about 86 billion neurons β tiny cells that send electrical signals to each other. Each neuron receives signals, decides whether to "fire," and passes signals to the next neurons. That network of connections is what lets you think, see, remember, and daydream about lunch.
An artificial neural network (ANN) is a loose imitation of this. It's made of simple mathematical "neurons" arranged in layers, where each neuron takes some numbers in, does simple math, and passes a number out.
Here's the key insight: ONE artificial neuron is dumb. It's basically a calculator that can only add and multiply. But MILLIONS of them connected together can recognize faces, translate languages, and generate art.
This is called "emergence" β simple pieces combining to create complex behavior. Ants are dumb individually but build incredible colonies. Neural network neurons are dumb individually but solve incredible problems.
Layers: The Sandwich of Intelligence
Neural networks are organized in layers, like a sandwich:
INPUT LAYER β Where the data comes in. For an image, each pixel's color becomes one input. A 100x100 pixel image has 10,000 inputs.
HIDDEN LAYERS β The middle layers where the magic happens. Each layer transforms the data, finding increasingly complex patterns. Early layers might detect edges and colors. Middle layers spot shapes (circles, lines). Later layers recognize objects (eyes, noses, wheels).
OUTPUT LAYER β The answer. For a cat-vs-dog classifier, it might have 2 outputs: the probability it's a cat and the probability it's a dog.
"Deep Learning" just means "neural networks with lots of hidden layers." That's it. The word "deep" refers to the number of layers, not some profound philosophical depth. Modern networks can have hundreds of layers.
Each connection between neurons has a weight β a number that controls how much influence one neuron has on the next. Training is the process of adjusting all these weights until the network gives correct answers. A model like GPT-4 has hundreds of billions of these weights.
How Do They Actually Learn?
The learning algorithm is called backpropagation, and it works like this:
1. FORWARD PASS β Feed an input through the network and get an output. "This image is... 80% dog, 20% cat."
2. CALCULATE ERROR β Compare to the real answer. "Actually, it's a cat. You were way off."
3. BACKWARD PASS β Working backwards through the layers, figure out which weights contributed most to the error.
4. ADJUST β Nudge those weights a tiny bit in the direction that would reduce the error.
5. REPEAT β Do this with the next example. And the next. And the next. Millions of times.
Imagine you're throwing darts blindfolded. After each throw, someone tells you "too far left" or "a bit high." You can't see the target, but after thousands of throws and adjustments, you'd start hitting close to the bullseye. That's backpropagation.
The amount you adjust each time is called the learning rate. Too big? You'll overshoot and never settle on a good answer. Too small? It'll take forever to learn. Finding the right learning rate is more art than science.
π€ Think About It
- Why do you think they call them 'neural' networks even though they're very different from actual brains?
- If a neural network has too few layers, it can't learn complex patterns. If it has too many, it memorizes the training data instead of learning general rules. Why might this happen?
- A neural network that memorizes training data but fails on new data is called 'overfitting.' Can you think of a human example of this?
π¬ Try This
- Draw a simple neural network on paper: 3 input neurons, 4 hidden neurons, 2 outputs. Draw all the connections. How many weights do you need? (Answer: 3Γ4 + 4Γ2 = 20)
- Visit playground.tensorflow.org and build neural networks in your browser. Change the layers, neurons, and data to see what happens.
- Try to teach yourself a new card game using ONLY trial and error (no reading rules). That's reinforcement learning β similar to how neural networks learn.
π Go Deeper
π― Fun Fact
The original idea for artificial neural networks came from a 1943 paper by Warren McCulloch and Walter Pitts. They designed a mathematical model of a neuron using simple logic gates. The catch? Nobody had computers powerful enough to run their ideas for decades. McCulloch never saw his work become the foundation of modern AI.
π Quick Quiz
1. What makes deep learning 'deep'?
2. What is backpropagation?
3. What happens if the learning rate is too high?
