So far, we've considered two examples of artificial intelligence: game-playing and computer vision.
We've also seen the human brain automatically performs tasks that don't break easily into algorithmic rules for a computer. This approach often devolves into a maze of caveats, minutiae, and special cases.
Intelligence, natural or artificial, is flexible. The human brain, unlike a computer, doesn’t follow a prescriptive program to make decisions. If we were able to create a program that works more like the human brain, what would it look like? What could it do? What would its limits be?
These are questions we'll start to answer in this quiz and return to throughout the course.
The brain contains more than billion cells, called neurons, which influence one another via small pulses of electricity. A particular neuron doesn't talk directly with every other neuron; they are connected into structures that perform specialized functions. These structures are biological neural networks.
The human brain is too complex to discuss in much detail here. Even today, neuroscientists do not fully understand how it works. We don't need to know all the details to land on its most important characteristic: brains learn from experience.
Each time you learn a new game, a dance, or a mathematical skill, neurons strengthen their lines of communication with some neurons and prune their connections with others. The structure of neural networks evolves as you gain new abilities.
Artificial neurons, the basic units of an ANN, behave more or less like biological neurons. An artificial neuron responds to information in signals it receives, and sends out its own signal to other neurons.
The single artificial neuron below has inputs that can each be in two states:
off. You can click on an input to change its state.
The response of the neuron is indicated by its color. When the neuron turns completely black, it means it's fully activated by the inputs. When the inputs completely inhibit its activity, it is white. It is partially filled when its output is between the maximum and minimum.
Some of the inputs drive the neuron toward its active state, and others inhibit its activity. Which color inputs drive the neuron toward its active state?
The artificial neuron on the previous page responds to different inputs in a predictable fashion, but it has no purpose as far as we can tell.
Now here's a neuron with a real purpose:
You're a volunteer chaperone on a bus full of hungry kids. It's a long drive, so, to preserve your sanity, you program an artificial neuron to control a snack dispenser.
It asks, "What snack would you like?" The two options are a cookie and some celery. Each kid makes a selection and if the neuron is activated, a snack is dispensed.
A selection is made by switching the corresponding input from
on. What happens if they select both?
It might not seem like much, but the neuron in the previous question is replicating an important logical function: It also kept the bus from descending into madness — any hungry kid received the snack they requested.
We'll explore how neurons are configured to reproduce logical functions in greater depth in the next chapter. But for now there are more pressing matters: the cookies and celery are running low, putting the snack-dispensing artificial neuron on an unsustainable path.
To avoid disaster, you make a slight change to the internal configuration of the neuron, hopeful that its new logic will better ration the remaining supplies.
The snack dispenser now asks the children, "Which of these snacks have you had today?"
Under what conditions will you be given a snack with the new logic? (Note that the connection between the inputs and the neuron are pink now.)
A few principles have emerged from our first encounter with an artificial neuron:
- an artificial neuron follows rules mechanically as it goes from inputs to output, and
- an artificial neuron can have a different response to the same inputs if we make slight changes in its internal configuration.
We'll spend almost the entire next chapter exploring how single neurons work, but the real power of neurons comes from wiring them together into a network or, as they say, a neural network.
What this means in practice is feeding the output of one artificial neuron into the input of another.
By stacking neurons in layers, we create the potential to make increasingly complex predictions... as long as we can find the right connections between the layers.
For example, here's an artificial neural network that can recognize the digits through Its inputs are a field of pixels which are fed through two layers of neurons, after which the network makes a guess in the form of activated neurons in the top layer.
By carefully setting the connections among neurons, we can give it the ability to classify a decent fraction of hand-drawn digits. This is a much more interesting result than the snack dispenser
Try it out for yourself. How does it do? Where does it go wrong?
Note: The images in the database used to train this network are centered with the total height of the digit nearly equal to the full pixels. This network doesn't automatically rescale and center the digits you draw, so if you want to give this artificial neural network a chance to classify your inputs correctly, you need to center them.
As capable as it is, this neural network isn't "thinking" — it's a mathematical waterfall. Inputs cascade through layers of calculation to end up at an output.
Here's the same network, but with the connections between the layers randomized:
If you ask it to predict what digit you've drawn, its predictions are wildly off.
Nobody can tell what these connections need to be ahead of time, and stripped of the correct ones, the ANN's predictions are no better than random guesses.
Finding these connections is the crux of neural networks. As we'll see later, the magic of ANNs is that they can learn them through experience.
But how does it learn?
During training, the artificial neural network (ANN, from this point on) is fed examples of digits. For each input, the ANN makes its best guess about what digit is represented, and its guess is compared to the correct answer (the identity of the digit it was shown).
If its guess is correct, then nothing happens.
But if its guess is incorrect, then the computational machinery within the ANN is updated so that it’s more likely to be correct the next time.
To get a sense for how ANNs use guesses to learn, let's play a game many of us are familiar with, called "Where The Hell Are My Keys?"
You thought they were in your pocket, but as you go to lock your door, you realize you have no idea — they could be anywhere in your apartment — so you start checking every shelf, jacket, drawer, and cereal box to find them. Because this is such a joyous experience, we've created a simulation of it for you below.
Each gray tile represents a place in your apartment where your keys could be hiding. To make a guess, click a tile. If the key is there, it will show itself, and if it's not, the tile will turn gray.
If there are places in your apartment, about how long will it take to find your keys?
On the last page, you searched for a key using trial and error. This can take a long time, especially if the space of possibilities is large. Guessing wrong on one tile gives you no information on how to adjust your future guesses.
However, a simple change makes the search a lot faster: feedback.
So, one day you rig your key with a transmitter that tells your phone when you're getting closer. When you lose your key, you use the feedback on your phone to figure out where you left your keys that day.
Below, you can look for your keys again. But this time, we've colored the spaces under the tiles. If the tile turns a shade of blue, you are far from the key. And as you get closer, the tiles get redder.
With meaningful feedback to tell you how wrong you are, you can improve your guesses with time.
Although "Where The Hell Are My Keys?" is an extremely simple game, it contains two features of learning that take place in biological brains and ANNs:
It's amazing how much improvement can be made with feedback.
A decent strategy can find the keys in about 10 guesses. But, with some ingenuity, you should be able to get down to 6 or even less.
What's the lowest average you can achieve?
If you play Key Search long enough, you may notice that it feels less like you're thinking and more like you're matching patterns.
Despite having no concept of deductive reasoning, ANNs can do things like finding cats in pictures purely through pattern matching. This has brought enormous power to tasks like diagnosing tumors, playing defined games like chess, and driving cars.
There's a lot more to say about how ANNs work, and in the rest of the course we'll dive into the details. Each chapter will answer a different question related to ANNs:
Along the way, you'll be able to interact with artificial neurons and ANNs as you start with the basics up and climb toward modern concepts, such as convolutional nets and backpropagation. All of the computation is wrapped up in our interactive ANNs, so you don't get tangled in technicalities.
Put the neural networks inside your skull to good use, and let's get started!