Lesson 1 of 8 · The Idea
What Is Deep Learning?
What deep learning is, how it fits inside AI and machine learning, why stacked layers learn their own features, and when it is the right tool to use.
- 6 min read
- Beginner
- Reviewed
- What deep learning is, in one sentence
- How AI, machine learning and deep learning fit inside each other
- Why the word deep refers to layers
- When deep learning is the right tool, and when it is not
Three circles, one family
Self-driving cars, chatbots, voice assistants and photo search all use deep learning. To see where it fits, picture three circles, each inside the one before:
- Artificial intelligence (AI) is the broadest circle: any technique that makes computers do tasks that seem to need intelligence, from hand-written rules to modern chatbots.
- Machine learning (ML) is inside AI: systems that learn patterns from examples instead of following rules a person wrote.
- Deep learning (DL) is inside machine learning: models built from many layers of simple units called neurons.
Why it is called deep
A neural network passes data through a series of layers. Each layer takes the numbers from the layer before, combines them and passes new numbers on. "Deep" simply means there are many layers between the input and the output.
When researchers looked inside networks trained on photos, they found that the layers had organised themselves from simple to complex:
- Early layers respond to edges, small angles and changes in brightness.
- Middle layers combine those into textures, curves and simple shapes.
- Later layers respond to parts of objects, such as eyes, wheels or door handles.
- The last layer turns all of that into the answer, such as "dog" or "car".
Nobody told the network to look for edges or wheels. It found those patterns because they helped it give correct answers.
See layers at work
Here is a tiny network whose weights have already been chosen. Each layer turns the numbers it receives into new numbers. Press Run and watch the four input numbers become two, then one final score.
import math
inputs = [0.8, -0.4, 1.2, 0.5]
def layer_1(values):
# four simple detectors, one per input
return [max(0.0, 1.5 * v + 0.1) for v in values]
def layer_2(values):
# combine the detectors in pairs
first = 0.7 * values[0] + 0.3 * values[1]
second = 0.5 * values[2] + 0.9 * values[3]
return [max(0.0, first), max(0.0, second)]
def layer_3(values):
# one final score, squashed into a probability between 0 and 1
score = 1.2 * values[0] + 1.8 * values[1] - 0.5
return 1 / (1 + math.exp(-score))
h1 = layer_1(inputs)
h2 = layer_2(h1)
p = layer_3(h2)
print("input: ", inputs)
print("layer 1:", [round(v, 3) for v in h1])
print("layer 2:", [round(v, 3) for v in h2])
print(f"layer 3: probability {p:.1%}")Try changing a number in inputs and run it again. Every layer's output changes, because each layer depends on the one before. Training, which you will see later in this course, is the process of finding good numbers for those weights automatically.
Where deep learning shines
Deep learning is at its best with large amounts of unstructured data, data that is not already a neat table of columns:
- Images and video: recognising objects, reading medical scans, generating pictures.
- Language: translation, summaries, chatbots and code assistants.
- Sound: speech-to-text, voice assistants and generated speech.
- Science: predicting protein shapes and forecasting weather.
It is often not the best choice when:
- You have little data. With a few hundred examples, a large network tends to memorise them instead of learning the pattern.
- Your data is a table. For rows and columns, such as customers or sales, tree-based models like gradient boosting are usually as good or better, and much faster to train.
- You must explain every decision. A simple model, such as a decision tree, is easier to explain to a bank customer or a regulator.
Common mistakes
A network is often described by the size of each layer, from input to output. Count the hidden layers and print whether the network is deep.
def describe(layer_sizes):
# layer_sizes lists every layer, from the input layer to the output layer.
# Hidden layers are the ones between the first and the last.
# Print the number of hidden layers, then whether the network is deep
# (more than one hidden layer).
pass
describe([784, 128, 64, 10])
describe([4, 8, 1])
# Output must be exactly:
# hidden layers: 2, deep: True
# hidden layers: 1, deep: False
What does the word deep in deep learning refer to?
Summary
- Deep learning is a kind of machine learning, which is a kind of AI.
- A neural network passes data through layers; "deep" means many of them.
- The layers learn their own features, from simple edges to whole objects.
- It shines with large amounts of images, text and sound. For small tables of data, simpler models often win.
Next: what changes when you move from classical machine learning to deep learning.
Finished reading? Tick it off to track your progress.