2023 AN2DL DeepLearning Intro
2023 AN2DL DeepLearning Intro
2023 AN2DL DeepLearning Intro
2
Teaching
3
Course Objectives
4
A Course with Code Sharing
The same teachers will teach the same topics to both classes, but you
need to be enrolled in the right course and attend the right lectures …
5
The Teachers
Official teacher, please refer
to me for bureaucratic stuff!
Prof. Matteo Matteucci
• Neural Networks
• Deep Learning
• Sequence Learning
A detailed schedule on
Google Calendar
7
The Students
???
Students are expected to:
• To attend the proper classes according to their program
• Feel confortable with basic statistics and calculus
• Feel confortable with basic programming (Python)
• Be ready to act as «guinea pigs» for this course edition
• Be curious and willing to learn ...
Students are not expected to:
• Know more than what is usually tought in basic engineerig courses
• Know already about machine learning (althought it doesn’t hurt)
• Be hyper-skilled python hackers (you’ll not need it)
• ...
8
Course syllabus
9
Course Website and Detailed Schedule
https://chrome.deib.polimi.it/index.php?title=Artificial_Neural_Networks_and_Deep_Learning
11
Lectures Schedule and Timings CSE
Please drop us an email if you plan to attend the other course, as this
needs to be authorized
Check the detailed schedule (including Lecture Topics) as due to calendar
issues, the two courses are not perfectly aligned!
CSE: https://boracchi.faculty.polimi.it/teaching/AN2DLCalendar_CS.htm
BIO+MTM: https://boracchi.faculty.polimi.it/teaching/AN2DLCalendar.htm
12
Course Evaluation AN2DL
13
Written Examination
Please, make sure you can run the test quiz well ahead the exam.
14
Go to https://remoteexam.polimi.it/
15
Search for our course (that will be updated…)
16
Run the test (it’s already there)
17
Run the test (but read instructions)!
The test is configured exactly as the exam form. Please, make sure you can successfully
accomplish the following tasks with your laptop at your earliest convenience:
• Go to the https://remoteexam.polimi.it/ website and select the "[2023-2024] Artificial
Neural Networks and Deep Learning [Giacomo Boracchi Matteo Matteucci]" course
• Log in with your student credentials and select the "test exam for AY 23-24 sessions".
• In case you do not have SEB installed, you will have the option to install SEB. Make sure
SEB is installed before the exam.
• Make sure everything goes smoothly and you can fill in the quiz.
• After submitting the answers, you can quit the SEB session. You will be prompted a quit
password, use "IAmDone".
If you cannot access the form through the SEB, you won't have the chance to give the exam.
18
Course Evaluation!
21
IC Course Evaluation
22
Synergies with Other Courses
23
Ironing out the kinks ...
Some details have not been sorted out yet today, working on those ..
• WeBeep Use
• No we use the calendar and enrolled students emails
• Projects/Competitions:
• How many people per group (2-3 people)
• Competitions out 2nd November & 6th December
• Practical evaluation of challenges:
• Not doing it scores up to 0 points
• Doing it with basic tools present in class
up to 1-4 points (?)
• Doing it with passion and in a propositive
manner up to 5 points (?)
• Automated scoring / code plagiarism check (?)
24
Frequently Asked Question (up to now)
25
Frequently Asked Question (up to now)
Other questions?
26
https://boracchi.faculty.polimi.it/teaching/AN2DLCalendar_CS.htm
27
Artificial Neural Networks and Deep Learning
- Machine Learning vs Deep Learning-
29
Standard Programming
/* What is this program about?*/
# include<stdio.h>
int main()
{ Can you write a program that
int a, sum;
sum = 0;
takes as input an image and
printf("\nInsert a:"); tells whether it contains a car
scanf("%d", &a);
while (a > 0) or a motorbike?
{
sum += a;
printf("\nInsert a:");
scanf("%d", &a);
}
printf("\nSum = %d", sum);
}
30
Machine Learning Paradigms
ML prediction
Model
𝑥𝑥 𝑦𝑦
𝑥𝑥 𝑓𝑓𝜃𝜃 𝑥𝑥 = 𝑦𝑦
31
Machine Learning Paradigms
𝑥𝑥 𝑓𝑓𝜃𝜃 𝑥𝑥 = 𝑦𝑦
32
Machine Learning Paradigms
Supervised Learning
ML prediction
• Classification
Model
• Regression 𝑥𝑥 𝑦𝑦
𝑥𝑥 𝑓𝑓𝜃𝜃 𝑥𝑥 = 𝑦𝑦
33
Supervised Learning
Cars Motorcycles
𝑇𝑇𝑇𝑇 = 𝑥𝑥1 , 𝑦𝑦1 , … , 𝑥𝑥𝑛𝑛 , 𝑦𝑦𝑛𝑛
• 𝑥𝑥𝑖𝑖 ∈ ℝ𝑅𝑅×𝐶𝐶×3 is the input image
• 𝑦𝑦𝑖𝑖 ∈ {"car", "motorcycle"}
35
Inference Using the Trained Classifier
Cars Motorcycles
Classifier CAR
Motorcycle
36
Supervised learning: Regression
Regressor 25000
3800 $
37
Training Set for Regression
38
Supervised learning: Regression
Regressor 25000
3800 $
39
Remarks
40
Give a few examples of
41
Machine Learning Paradigms
Supervised Learning
ML prediction
• Classification
Model
• Regression 𝑥𝑥 𝑦𝑦
Unsupervised Learning
• Clustering
• Anomaly Detection 𝑥𝑥 𝑓𝑓𝜃𝜃 𝑥𝑥 = 𝑦𝑦
• …
43
Unupervised Learning
45
Unsupervised learning: Clustering
46
Unsupervised learning: Clustering
47
Unsupervised learning: Clustering
48
Unsupervised learning: Clustering
49
Unsupervised learning: Clustering
50
Unsupervised learning: Anomaly Detection
51
To Summarize: Machine Learning Paradigms
Immagine you have a certain experience E, i.e., data, and let’s name it
52
To Summarize: Machine Learning Paradigms
Immagine you have a certain experience E, i.e., data, and let’s name it
53
Machine Learning
54
Machine Learning
Deep Learning
55
56
57
Hand-Crafted Features
How images / signals were classified before deep learning
Assume you need to automatize this process
60
Assume you need to automatize this process
61
Assume you need to automatize this process
62
An Illustrative Example: Parcel Classification
63
An Illustrative Example: Parcel Classification
64
An Illustrative Example: Parcel Classification
65
Hand Crafted Featues
Engineers:
• know what’s meaningful in an
image (e.g. a specific color/shape,
Feature Extraction
the area, the size)
• can implement algorithms to map
this information in a set of
measurements, a feature vector
66
Hand Crafted Featues
h average
Feature Extraction
area
h max h min
perimeter
ratio
𝐱𝐱 ∈ ℝ𝑑𝑑
67
This is exactly what a doctor would to to classify ECG tracings
69
The Training Set: images + labels
The Training Set: images + labels
The Training Set: features + labels
The Training Set
Training Set
𝒉𝒉 if (ℎ > 6.2cm)
false true «envelope»
𝒂𝒂
if (𝑎𝑎 < 200px)
«Parcel»
false true
«envelope» «Double»
𝐱𝐱 ∈ ℝ2
𝐼𝐼1 ∈ ℝ𝑟𝑟1 ×𝑐𝑐1
“double” “envelope” “parcel”
78
Limitations of Rule Based Classifier
Let’s resort to a data-driven model for the only task of separating feature
vectors in different classes.
79
A tree classifying image features
«envelope» «Double»
The model parameters 𝜃𝜃 (e.g. Neural Network weights) are set to minimize a loss
function (e.g., the classification error in case of discrete output or the reconstruction
error in case of continuous output)
𝜃𝜃 ∗ = argmin ℒ 𝜃𝜃, 𝑇𝑇𝑇𝑇
𝜃𝜃
Network training is an optimization process to find params minimizing the loss function.
Can definitvely boost the image classification performance
• Annotated training set is always needed
• Classification performance depends on the training set
• Generalization is not guaranteed
85
Hand Crafted Feature Extraction, data-driven Classification
mean
area
Classifier
max min “double”
per.
ratio 𝑡𝑡 ∈ Λ
𝐱𝐱 ∈ ℝ𝑑𝑑
𝐼𝐼1 ∈ ℝ𝑟𝑟1 ×𝑐𝑐1
(𝑑𝑑 ≪ 𝑟𝑟 × 𝑐𝑐)
86
Are there better classifiers?
Are there better classifiers?
… … …
…
𝐼𝐼1 ∈ ℝ𝑟𝑟1 ×𝑐𝑐1
𝐱𝐱 ∈ ℝ𝑑𝑑
input layer Hidden layer(s) Output Layer
Neural Networks Input layer: Same size of the
feature vector
𝑥𝑥1
… … …
…
𝐼𝐼1 ∈ ℝ𝑟𝑟1 ×𝑐𝑐1 𝑥𝑥𝑑𝑑
𝐱𝐱 ∈ ℝ𝑑𝑑
input layer Hidden layer(s) Output Layer
Neural Networks Output layer: Same size
as the number of
classes
… … …
…
𝑃𝑃(𝑡𝑡 = "parc. "|𝒙𝒙)
𝐼𝐼1 ∈ ℝ𝑟𝑟1 ×𝑐𝑐1
𝐱𝐱 ∈ ℝ𝑑𝑑
input layer Hidden layer(s) Output Layer
Neural Networks Hidden layers: arbitrary size
… … …
…
𝐼𝐼1 ∈ ℝ𝑟𝑟1 ×𝑐𝑐1
𝐱𝐱 ∈ ℝ𝑑𝑑
input layer Hidden layer(s) Output Layer
Image Classification by Hand Crafted Features
… … …
…
𝐼𝐼1 ∈ ℝ𝑟𝑟1 ×𝑐𝑐1
96
Hand Crafted Featues, cons:
97
What is Deep Learning after all?
Machine learns how to
take the Iris apart
Hand-crafted Learned
Features Classifier
double
Height
Area
99
What is Deep Learning after all?
Machine learns how to
take the Iris apart
Hand-crafted Learned
Features Classifier double
Height
Area
100
What is Deep Learning after all?
Machine learns how to
take the Iris apart
Hand-crafted Learned
Features Classifier
double
Height
Area
101
What is Deep Learning after all? This happens if you do
not know which features
to extract!!!
Hand-crafted Learned
Features Classifier
double
Height
Area
102
Data Driven Features
… the advent of Deep Learning
Data-Driven Features
Input image
Feature Extraction
… … …
Easier to learn!
Height
Area
109
What is Deep Learning after all? Hierarchical representation
Learn from data! optimized for the task!
110
Deep Learning
a Breakthrough in Visual Recognition
Image Classfiication on Imagenet
Krizhevsky, Alex, Ilya Sutskever, and Geoffrey E. Hinton. "Imagenet classification with deep convolutional neural networks." Advances in neural 113
information processing systems 25 (2012).
The impact of Deep Learning in Visual Recognition
Many layers!
Many layers!
J. Deng, W. Dong, R. Socher, L.-J. Li, K. Li and L. Fei-Fei, ImageNet: A Large-Scale Hierarchical Image Database. CVPR, 2009.
Parallel Computing Architectures
https://www.flickr.com/photos/nvidia/34686550412
And more recently…. Software libraries
LeCun, Y., Bottou, L., Bengio, Y., Haffner, P. “Gradient-based learning applied to document recognition” Proceedings of
the IEEE, 1998 86(11), 2278-2324. 119
Workshop Tecnico
05.07.2022
https://awards.acm.org/about/2018-turing
Advanced Visual Recognition
Problems with DL
127
128
https://github.com/alexjc/neural-enhance
129
Stile Transfer https://github.com/jcjohnson/neural-style
https://github.com/jcjohnson/fast-neural-style
https://ml4a.github.io/ml4a/style_transfer/
https://github.com/luanfujun/deep-photo-styletransfer
130
Image Captioning
"little girl is eating piece of cake." "black cat is sitting on top of suitcase."
Andrej Karpathy, Li Fei-Fei "Deep Visual-Semantic Alignments for Generating Image Descriptions" CVPR 2015
131
Generative Adversarial Networks (these people do not exist)
1322019
Tero Karras, Samuli Laine, Timo Aila «A Style-Based Generator Architecture for Generative Adversarial Networks” CVPR
Image Generation by Generative Adversarial Networks
133
134
135
Even though sometimes it fails…
Even though sometimes it fails…