Part I — Foundations · Chapter 1

Introduction: machine learning and deep learning

~25 min read4 interactive widgets4 plates

In this chapter

  1. What machine learning means
  2. The four key components
  3. The three kinds of machine learning
  4. From machine learning to deep learning
  5. Application areas
  6. The road to artificial intelligence
  7. What changed? Why now?
  8. The course: contents, laboratory, exam
  9. Check your understanding

1. What machine learning means

The course opens with a definition borrowed from Wikipedia: “Machine Learning (ML) is the study of computer algorithms that improve automatically through experience and by the use of data.” Every word in that sentence carries weight, and the slides immediately unpack what it means in practice.

The wake word example

The canonical example in the slides is the wake word: how would you write a program that responds to “Alexa” or “Okay, Google”? Every second the microphone collects thousands of samples. What rule could map from a snippet of raw audio to a prediction on whether the snippet contains the wake word?

Nobody knows how to write that rule by hand, and yet every human recognises the word without effort. This asymmetry is the whole justification for machine learning. The slides describe the way out in four moves:

  1. We cannot program a computer to recognise a wake word, but we are able to recognise it ourselves.
  2. We can collect and label a huge dataset containing examples of audio with and without the wake word.
  3. Instead of designing a system explicitly, we define a flexible program whose behaviour is determined by a number of parameters.
  4. We use the dataset to determine the best possible set of parameters with respect to some measure of performance.
Key idea

The shift is from writing the solution to writing a parametric family of possible solutions and letting data pick the member of the family that works. Everything that follows in this course — layers, losses, gradients, optimizers — is machinery for making that selection efficient.

The slides draw this as a loop: design the program → collect new data → measure the performance → update the parameters, and round again. Walk it in the explorer below.

2. The four key components

Whatever the task, the slides insist that every machine learning technique is assembled from the same four pieces. Learning them as a checklist pays off: when a model fails, the fault is always in one of these four.

ComponentWhat it isWhat the slides stress
Data What we can learn from We cannot do data science without data. We typically need to produce a suitable numerical representation. The more data we have, the easier our job becomes. But it is not enough to have lots of data: we need the right data.
Model How to transform the data The computational machinery for ingesting data of one type and spitting out predictions of a possibly different type.
Objective (loss) function How good (or bad) the model is It is defined with respect to the model parameters and depends upon the dataset.
Optimization algorithm How the parameters are adjusted It adjusts the model parameters to minimize the loss function. The most popular optimization algorithms for neural networks follow an approach called gradient descent.

3. The three kinds of machine learning

The slides divide the field into three major categories. The whole course is a tour of the first and the third, with a serious detour through the second (autoencoders, generative models).

Supervised learning addresses the task of predicting targets (labels) given input data (features). We provide the model with a dataset (the ground truth) consisting of labeled examples (xi, yi), where each example xi is paired with the correct label yi.

It splits into two sub-tasks:

  • Regression — the output is numerical (continuous).
  • Classification — the output is categorical (discrete).

That is the only difference between the two, according to the slides: the type of the output.

The goal of unsupervised learning is to infer the natural structure present within a set of unlabeled data. The most common unsupervised learning method is cluster analysis, used to group or segment datasets in order to extrapolate algorithmic relationships.

The slides also list dimensionality reduction under this heading — the theme that returns in Chapter 9 with autoencoders.

Reinforcement learning (RL) is learning by interacting with an environment. An RL agent learns from the consequences of its actions, rather than from being explicitly taught: trial and error learning.

It selects its actions on the basis of:

  • past experiences (exploitation);
  • new choices (exploration).

The loop is: the agent performs action at, the environment returns a reward rt and a state st. Chapter 12 develops this into Q-learning and deep Q-networks.

4. From machine learning to deep learning

The slides quote DeepAI: “Deep Learning (DL) is a ML technique that constructs artificial neural networks to mimic the structure and function of the human brain.” But the operational difference the course actually cares about is about features.

Key idea

Deep learning removes the human from the feature engineering step. The hidden layers are the feature extractor, and they are trained with the same gradient signal as the classifier sitting on top of them. This is the single sentence to remember from this chapter.

5. Application areas

The slides observe that since 2012, DL techniques have overcome traditional ML techniques in many application areas. The two slides that follow are essentially word clouds of what deep learning has eaten. Reproduced as a list, they are:

PerceptionLanguageDecision and controlCreation
Visual recognition
Handwriting generation
Pixel restoration
Image colorization
Natural language processing
Machine translation
Virtual assistants
News analysis
Image captioning
Image–language translation
Self driving car
Fraud detection
Healthcare
Recommendation systems
Demographic predictions
Predicting natural disasters
Game playing
Image generation
Editor’s note

The grouping into four columns is an editorial convenience for reading. The slides present the items as two unordered clouds; no ranking or taxonomy is implied by the course.

6. The road to artificial intelligence

One slide compresses eighty years into a single timeline. It is worth memorising, because the same names return throughout the course — LeCun and Bengio in Chapter 7, Rumelhart, Hinton and Williams in Chapter 4, Krizhevsky, Sutskever and Hinton in Chapter 7.

7. What changed? Why now?

The course poses the question directly. Many of the core concepts of DL were well known from the end of the last century. Why did DL approaches not replace traditional ML techniques for more than ten years? What happened that changed things?

The slides answer that though there are many factors, the two most crucial components appear to be:

  1. the appearance of large, high-quality labeled datasets;
  2. massively parallel computing with GPUs.

Why does DL require a large amount of data?

Because DL models contain millions (or even billions) of trainable parameters and they need to see a proportional amount of examples to get good performance. This is not a slogan: it is the reason data augmentation exists (Chapter 3), the reason the ImageNet challenge mattered (Chapter 7), and the reason GPT-3 needed 500 billion tokens (Chapter 10).

The impact of GPUs

The comparison the slides make is architectural, not marketing:

CPU coreGPU core
Design goalSupports an extremely broad variety of tasks, in addition to performing computationsOptimized exclusively for data computations
Cores per chipBaselineAlmost 200 times more processors per chip
What acceleratesfloat32 computations; matrix multiplication, convolution and large element-wise operations accelerate a lot (5–50×)

The end-to-end consequence: DL applications, which perform large numbers of computations on a vast amount of data, can see performance improvements of about 10 to 20 times when running on a GPU versus a CPU.

For the exam

“Why now?” is a classic opening question. The answer has exactly two headline components in this course: large, high-quality labeled datasets and massively parallel computing with GPUs. Add the reason DL is data hungry (millions to billions of trainable parameters need a proportional number of examples) and you have the full expected answer.

8. The course: contents, laboratory, exam

The logistics deck states the goal plainly: the course aims at providing advanced skills, both theoretical and practical, on machine learning and in particular on deep learning. At the end of the course the student will be able to:

Contents

The syllabus, in the order the slides list it: introduction to deep learning; linear algebra, calculus and automatic differentiation; artificial neural networks; backpropagation; optimization algorithms; convolutional neural networks; recurrent neural networks; autoencoders; transformers; generative models; reinforcement learning; natural language processing (a practical example).

Laboratory

Deep learning tutorials based on:

Exam and team project

The examination consists of the realization and discussion of a deep learning team project (2–3 students) on a topic agreed with the teacher, plus an oral test.

The project must be original deep learning work: either existing tools applied to a novel problem, or novel solutions. Its phases are:

  1. proposal registration;
  2. wait for the proposal acceptance;
  3. work as a team on the project;
  4. deliver the project at least one week before the project discussion;
  5. final presentation.
PhaseWhat to send
Proposal registration By e-mail: student names; project title; project proposal containing problem description, datasets used, possible solutions, and metrics used to evaluate the performance.
Delivery By e-mail, a Jupyter notebook (similar to a tutorial notebook used during the course): fully executable on Colab; not only code but also descriptions, comments, graphs, images; the team contribution or improvement with respect to existing solutions must be highlighted; rigorous performance analysis (separated train, validation and test sets); error analysis.
Final presentation Project presentation and discussion. All team members must be present. Prepare some slides.
Careful

Two delivery requirements are easy to lose points on and are explicitly written in the project deck: the notebook must be fully executable on Colab, and the performance analysis must use separated train, validation and test sets plus an error analysis. A notebook that only reports a final accuracy number does not satisfy the brief.

Readings and contacts

The primary reading is the slides of the course. Suggested readings:

Contacts: e-mail and Teams at [email protected]. Office hours are published on the website of Matteo Ferrara.

9. Chapter summary

Check your understanding

Why can the wake word problem not be solved by writing an explicit algorithm?

Because every second the microphone collects thousands of raw samples and nobody knows the rule that maps a snippet of raw audio to the presence of the wake word. Humans recognise the word effortlessly but cannot express the rule. The machine learning answer is to collect and label a huge dataset, define a flexible program whose behaviour is determined by a number of parameters, and use the dataset to find the parameters that maximise a measure of performance.

List the four key components of a machine learning technique and say what each one is responsible for.

Data (what we learn from, in a suitable numerical representation), model (the computational machinery that ingests data of one type and produces predictions of a possibly different type), objective or loss function (quantifies how good or bad the model is, defined with respect to the parameters and dependent on the dataset), and optimization algorithm (adjusts the parameters to minimize the loss; for neural networks it is almost always a variant of gradient descent).

What exactly distinguishes regression from classification?

Only the type of the output. In regression the output is numerical (continuous); in classification it is categorical (discrete). Both are forms of supervised learning, in which the model is given a ground truth of labeled examples (xi, yi).

What is the operational difference between traditional machine learning and deep learning?

Where the features come from. In traditional ML the raw data are analyzed by a domain expert who identifies robust features to reduce complexity and make patterns more visible to the learning algorithm. In DL, a large number of hidden layers extracts features from the raw data and transforms them into different levels of abstraction, learning the representation instead of receiving it.

Why does deep learning need so much data?

Because DL models contain millions or even billions of trainable parameters, and they need to see a proportional amount of examples to reach good performance. More data alone is not sufficient either: the slides stress that we also need the right data.

Why did GPUs make such a difference, and how big is the difference?

A CPU core is designed to support an extremely broad variety of tasks in addition to performing computations, whereas a GPU core is optimized exclusively for data computations, and a GPU packs almost 200 times more processors per chip. Matrix multiplication, convolution and large element-wise operations accelerate by 5 to 50 times; real DL applications see improvements of about 10 to 20 times versus a CPU.

What happened in 2012 and why is it the hinge of the timeline?

AlexNet won ILSVRC-2012 (Krizhevsky, Sutskever, Hinton). It is the point where deep learning overtakes traditional ML in application after application, which is why the slides date the modern DL era from 2012 even though the core concepts were known from the end of the previous century.

What does the exam consist of?

Two parts: the realization and discussion of a deep learning team project (2–3 students, topic agreed with the teacher), and an oral test. The project must be original work: existing tools applied to a novel problem, or novel solutions. It is delivered as a Jupyter notebook fully executable on Colab, containing descriptions, comments, graphs and images, a rigorous performance analysis with separated train, validation and test sets, and an error analysis.

Reinforcement learning selects actions on the basis of two things. Which?

Past experiences (exploitation) and new choices (exploration). The agent learns from the consequences of its actions rather than from being explicitly taught, receiving positive feedback for good actions and a penalty for bad ones. Chapter 12 formalises the trade-off as the exploration versus exploitation dilemma.