[course site]
Javier Ruiz Hidalgo
javier.ruiz@upc.edu
Associate Professor
Universitat Politecnica de Catalunya
Technical University of Catalonia
Methodology
Day 6 Lecture 2
#DLUPC
Outline
● Data
○ training, validation, test partitions
○ Augmentation
● Capacity of the network
○ Underfitting
○ Overfitting
● Prevent overfitting
○ Dropout, regularization
● Strategy
2
Outline
3
It’s all about the data...
4
Figure extracted from Kevin Zakka's Blog: “Nuts and Bolts of Applying Deep Learning” https://kevinzakka.github.io/2016/09/26/applying-deep-learning/
well, not only data...
● Computing power: GPUs
5
Source, NVIDIA 2017
well, not only data...
● Computing power: GPUs
● New learning architectures
○ CNN, RNN, LSTM, DBN, GNN,
6
End-to-end learning: speech recognition
7
Slide extracted from Andrew Ng NIPS 2016 Tutorial
End-to-end learning: autonomous driving
8
Slide extracted from Andrew Ng NIPS 2016 Tutorial
Network capacity
● Space of representable functions that a network can
potencially learn:
○ Number of layers / parameters
9
Figure extracted from Stanford CS class CS231n: Convolutional Neural Networks for Visual Recognition.
Generalization
The network needs to
generalize beyond the
training data to work on new
data that it has not seen yet
10
Underfitting vs Overfitting
● Overfitting: network fits training data too well
○ Performs badly on test data
○ Excessively complicated model
● Underfitting: network does not fit the data well
enough
○ Excessively simple model
● Both underfitting and overfitting lead to poor
predictions on new data and they do not generalize
well 11
Underfitting vs Overfitting
graph with under/over
12
Figure extracted from Deep Learning by Adam Gibson, Josh Patterson, O'Reilly Media, Inc., 2017
Split your data into two sets: training and test
Data partition
13
How do we measure the generalization instead of
how well the network does with the memorized data?
TRAINING
60%
TEST
20%
Underfitting vs Overfitting
14
Test error
Training error
Figure extracted from Deep Learning by Ian Goodfellow and Yoshua Bengio and Aaron Courville, MIT Press, 2016
Data partition revisited
● Test set should not be used to tune your network
○ Network architecture
○ Number of layers
○ Hyper-parameters
● Failing to do so will overfit the network to your test set!
○ https://www.kaggle.com/c/higgs-boson/leaderboard
15
● Add a validation set!
● Lock away your test set and use it only as a last
validation step
Data partition revisited (2)
16
TRAINING
60%
VALIDATION
20%
TEST
20%
Data sets distribution
● Take into account the distribution of training
and test sets
17
TRAINING
60%
VALIDATION
20%
TEST
20%
TRAINING
60%
VAL. TRAIN
20%
TEST
10%
VAL.
TEST
10%
The bigger the better?
● Large networks
○ More capacity / More data
○ Prone to overfit
● Smaller networks
○ Lower capacity / Less data
○ Prone to underfit
18
The bigger the better?
● In large networks, most local minima are equivalent and yield similar
performance.
● The probability of finding a “bad” (high value) local minimum is
non-zero for small networks and decreases quickly with network size.
● Struggling to find the global minimum on the training set (as opposed
to one of the many good local ones) is not useful in practice and may
lead to overfitting.
Better large capacity networks and prevent overfitting
19
Anna Choromanska et.al. “The Loss Surfaces of Multilayer Networks”, https://arxiv.org/pdf/1412.0233.pdf
Prevent overfitting
● Early stopping
● Loss regularization
● Data augmentation
● Dropout
● Parameter sharing
● Adversarial training
20
Figure extracted from Deep Learning by Ian Goodfellow and Yoshua Bengio and Aaron Courville, MIT Press, 2016
Early stopping
21
Validation error
Training error
Training steps
Early stopping
Loss regularization
● Limit the values of parameters in the network
○ L2 or L1 regularization
22Figure extracted from Cristina Scheau, Regularization in Deep Learning, 2016
Data augmentation (1)
● Alterate input samples artificially to increase the
data size
● On-the-fly while training
○ Inject Noise
○ Transformations
○ ...
23
Alex Krizhevsky, ImageNet Classification with Deep Convolutional Neural Networks, NIPS 2012
Data augmentation (2)
● Image
○ Random crops
○ Translations
○ Flips
○ Color changes
● Audio
○ Tempo perturbation, speed
● Video
○ Temporal displacement
24
Data augmentation (3)
● Synthetic data: Generate new input samples
25
A. Palazzi, Learning to Map Vehicles into Bird’s Eye View, ICIAP 2017
DeepGTAV plugin: https://github.com/ai-tor/DeepGTAV
Data augmentation (4)
● GANs (Generative Adversarial Networks)
○
○
26
P. Ferreira,et.al., Towards data set augmentation with GANs, 2017.
L. Sixt, et.al., RenderGAN: Generating Realistic labeled data, ICLR 2017.
Dropout (1)
● At each training iteration, randomly remove some nodes
in the network along with all of their incoming and
outgoing connections (N. Srivastava, 2014)
27Figure extracted from Cristina Scheau, Regularization in Deep Learning, 2016
Dropout (2)
● Why dropout works?
○ Nodes become more
insensitive to the weights of
the other nodes → more
robust.
○ Averaging multiple models
→ ensemble.
○ Training a collection of 2n
thinned networks with
parameters sharing
28Figure extracted from Deep Learning by Ian Goodfellow and Yoshua Bengio and Aaron Courville, MIT Press, 2016
Dropout (3)
● Dense-sparse-dense training (S. Han 2016)
a. Initial regular training
b. Drop connections where weights are under a particular threshold.
c. Retrain sparse network to learn weights of important connections.
d. Make network dense again and retrain using small learning rate, a step
which adds back capacity.
29
Parameter sharing
Multi-task Learning
30
CNNs
Figure extracted from Leonardo Araujo, Artificial Intelligence, 2017
Figure extracted from Sebastian Ruder, An Overview of Multi-Task Learning in Deep Neural Networks, 2017
Adversarial training
● Search for adversarial examples that network misclassifies
○ Human observer cannot tell the difference
○ However, the network can make highly different predictions.
31I. Goodfellow, et.al., Explaining and Harnessing Adversarial Examples, ICLR, 2015
Strategy for machine learning (1)
Human-level performance can serve as a very
reliable proxy which can be leveraged to
determine your next move when training your
model.
32
Strategy for machine learning (2)
Human level error . . 1%
Training error . . . 9%
Validation error . . 10%
Test error . . . . . 11%
33
TRAINING
60%
VALIDATION
20%
TEST
20%
Avoidable bias
Strategy for machine learning (3)
Human level error . . 1%
Training error . . . 1.1%
Validation error . . 10%
Test error . . . . . 11%
34
TRAINING
60%
VALIDATION
20%
TEST
20%
Overfitting training
Strategy for machine learning (4)
Human level error . . 1%
Training error . . . 1.1%
Validation error . . 2%
Test error . . . . . 11%
35
TRAINING
60%
VALIDATION
20%
TEST
20%
Overitting validation
Strategy for machine learning (5)
Human level error . . 1%
Training error . . . 1.1%
Validation error . . 1.2%
Test error . . . . . 1.2%
36
TRAINING
60%
VALIDATION
20%
TEST
20%
Strategy for machine learning (5)
37
High Train error?
Bigger Network
Train longer (hyper-parameters)
New architecture
Yes
High Validation
error?
Regularization
More data (augmentation)
New architecture
Yes
No
High Test error? More validation data
Yes
No
DONE!
No
References
38
Nuts and Bolts of Applying Deep Learning by Andrew Ng
https://www.youtube.com/watch?v=F1ka6a13S9I
Thanks! Questions?
39
https://imatge.upc.edu/web/people/javier-ruiz-hidalgo

Methodology (DLAI D6L2 2017 UPC Deep Learning for Artificial Intelligence)

  • 1.
    [course site] Javier RuizHidalgo javier.ruiz@upc.edu Associate Professor Universitat Politecnica de Catalunya Technical University of Catalonia Methodology Day 6 Lecture 2 #DLUPC
  • 2.
    Outline ● Data ○ training,validation, test partitions ○ Augmentation ● Capacity of the network ○ Underfitting ○ Overfitting ● Prevent overfitting ○ Dropout, regularization ● Strategy 2
  • 3.
  • 4.
    It’s all aboutthe data... 4 Figure extracted from Kevin Zakka's Blog: “Nuts and Bolts of Applying Deep Learning” https://kevinzakka.github.io/2016/09/26/applying-deep-learning/
  • 5.
    well, not onlydata... ● Computing power: GPUs 5 Source, NVIDIA 2017
  • 6.
    well, not onlydata... ● Computing power: GPUs ● New learning architectures ○ CNN, RNN, LSTM, DBN, GNN, 6
  • 7.
    End-to-end learning: speechrecognition 7 Slide extracted from Andrew Ng NIPS 2016 Tutorial
  • 8.
    End-to-end learning: autonomousdriving 8 Slide extracted from Andrew Ng NIPS 2016 Tutorial
  • 9.
    Network capacity ● Spaceof representable functions that a network can potencially learn: ○ Number of layers / parameters 9 Figure extracted from Stanford CS class CS231n: Convolutional Neural Networks for Visual Recognition.
  • 10.
    Generalization The network needsto generalize beyond the training data to work on new data that it has not seen yet 10
  • 11.
    Underfitting vs Overfitting ●Overfitting: network fits training data too well ○ Performs badly on test data ○ Excessively complicated model ● Underfitting: network does not fit the data well enough ○ Excessively simple model ● Both underfitting and overfitting lead to poor predictions on new data and they do not generalize well 11
  • 12.
    Underfitting vs Overfitting graphwith under/over 12 Figure extracted from Deep Learning by Adam Gibson, Josh Patterson, O'Reilly Media, Inc., 2017
  • 13.
    Split your datainto two sets: training and test Data partition 13 How do we measure the generalization instead of how well the network does with the memorized data? TRAINING 60% TEST 20%
  • 14.
    Underfitting vs Overfitting 14 Testerror Training error Figure extracted from Deep Learning by Ian Goodfellow and Yoshua Bengio and Aaron Courville, MIT Press, 2016
  • 15.
    Data partition revisited ●Test set should not be used to tune your network ○ Network architecture ○ Number of layers ○ Hyper-parameters ● Failing to do so will overfit the network to your test set! ○ https://www.kaggle.com/c/higgs-boson/leaderboard 15
  • 16.
    ● Add avalidation set! ● Lock away your test set and use it only as a last validation step Data partition revisited (2) 16 TRAINING 60% VALIDATION 20% TEST 20%
  • 17.
    Data sets distribution ●Take into account the distribution of training and test sets 17 TRAINING 60% VALIDATION 20% TEST 20% TRAINING 60% VAL. TRAIN 20% TEST 10% VAL. TEST 10%
  • 18.
    The bigger thebetter? ● Large networks ○ More capacity / More data ○ Prone to overfit ● Smaller networks ○ Lower capacity / Less data ○ Prone to underfit 18
  • 19.
    The bigger thebetter? ● In large networks, most local minima are equivalent and yield similar performance. ● The probability of finding a “bad” (high value) local minimum is non-zero for small networks and decreases quickly with network size. ● Struggling to find the global minimum on the training set (as opposed to one of the many good local ones) is not useful in practice and may lead to overfitting. Better large capacity networks and prevent overfitting 19 Anna Choromanska et.al. “The Loss Surfaces of Multilayer Networks”, https://arxiv.org/pdf/1412.0233.pdf
  • 20.
    Prevent overfitting ● Earlystopping ● Loss regularization ● Data augmentation ● Dropout ● Parameter sharing ● Adversarial training 20 Figure extracted from Deep Learning by Ian Goodfellow and Yoshua Bengio and Aaron Courville, MIT Press, 2016
  • 21.
    Early stopping 21 Validation error Trainingerror Training steps Early stopping
  • 22.
    Loss regularization ● Limitthe values of parameters in the network ○ L2 or L1 regularization 22Figure extracted from Cristina Scheau, Regularization in Deep Learning, 2016
  • 23.
    Data augmentation (1) ●Alterate input samples artificially to increase the data size ● On-the-fly while training ○ Inject Noise ○ Transformations ○ ... 23 Alex Krizhevsky, ImageNet Classification with Deep Convolutional Neural Networks, NIPS 2012
  • 24.
    Data augmentation (2) ●Image ○ Random crops ○ Translations ○ Flips ○ Color changes ● Audio ○ Tempo perturbation, speed ● Video ○ Temporal displacement 24
  • 25.
    Data augmentation (3) ●Synthetic data: Generate new input samples 25 A. Palazzi, Learning to Map Vehicles into Bird’s Eye View, ICIAP 2017 DeepGTAV plugin: https://github.com/ai-tor/DeepGTAV
  • 26.
    Data augmentation (4) ●GANs (Generative Adversarial Networks) ○ ○ 26 P. Ferreira,et.al., Towards data set augmentation with GANs, 2017. L. Sixt, et.al., RenderGAN: Generating Realistic labeled data, ICLR 2017.
  • 27.
    Dropout (1) ● Ateach training iteration, randomly remove some nodes in the network along with all of their incoming and outgoing connections (N. Srivastava, 2014) 27Figure extracted from Cristina Scheau, Regularization in Deep Learning, 2016
  • 28.
    Dropout (2) ● Whydropout works? ○ Nodes become more insensitive to the weights of the other nodes → more robust. ○ Averaging multiple models → ensemble. ○ Training a collection of 2n thinned networks with parameters sharing 28Figure extracted from Deep Learning by Ian Goodfellow and Yoshua Bengio and Aaron Courville, MIT Press, 2016
  • 29.
    Dropout (3) ● Dense-sparse-densetraining (S. Han 2016) a. Initial regular training b. Drop connections where weights are under a particular threshold. c. Retrain sparse network to learn weights of important connections. d. Make network dense again and retrain using small learning rate, a step which adds back capacity. 29
  • 30.
    Parameter sharing Multi-task Learning 30 CNNs Figureextracted from Leonardo Araujo, Artificial Intelligence, 2017 Figure extracted from Sebastian Ruder, An Overview of Multi-Task Learning in Deep Neural Networks, 2017
  • 31.
    Adversarial training ● Searchfor adversarial examples that network misclassifies ○ Human observer cannot tell the difference ○ However, the network can make highly different predictions. 31I. Goodfellow, et.al., Explaining and Harnessing Adversarial Examples, ICLR, 2015
  • 32.
    Strategy for machinelearning (1) Human-level performance can serve as a very reliable proxy which can be leveraged to determine your next move when training your model. 32
  • 33.
    Strategy for machinelearning (2) Human level error . . 1% Training error . . . 9% Validation error . . 10% Test error . . . . . 11% 33 TRAINING 60% VALIDATION 20% TEST 20% Avoidable bias
  • 34.
    Strategy for machinelearning (3) Human level error . . 1% Training error . . . 1.1% Validation error . . 10% Test error . . . . . 11% 34 TRAINING 60% VALIDATION 20% TEST 20% Overfitting training
  • 35.
    Strategy for machinelearning (4) Human level error . . 1% Training error . . . 1.1% Validation error . . 2% Test error . . . . . 11% 35 TRAINING 60% VALIDATION 20% TEST 20% Overitting validation
  • 36.
    Strategy for machinelearning (5) Human level error . . 1% Training error . . . 1.1% Validation error . . 1.2% Test error . . . . . 1.2% 36 TRAINING 60% VALIDATION 20% TEST 20%
  • 37.
    Strategy for machinelearning (5) 37 High Train error? Bigger Network Train longer (hyper-parameters) New architecture Yes High Validation error? Regularization More data (augmentation) New architecture Yes No High Test error? More validation data Yes No DONE! No
  • 38.
    References 38 Nuts and Boltsof Applying Deep Learning by Andrew Ng https://www.youtube.com/watch?v=F1ka6a13S9I
  • 39.