1
EC 500 A1: �Foundation of learning - 2
Today
2
Example: image classification (ideal case)
3
Dog
Bird
Neural Network
(encoder)
Feature vector
……
Has four legs
Has wing
……
1
0
……
0
1
Example: image classification (training)
4
Dog
Neural Network
(encoder)
Feature vector
……
……
……
Bird
?
Case study – 2: classification
[Figure credit: A. Torralba, P. Isola, and W. T. Freeman, Foundations of Computer Vision.]
……
Case study – 2: classification
[Figure credit: A. Torralba, P. Isola, and W. T. Freeman, Foundations of Computer Vision.]
……
Case study – 2: classification
[Figure credit: A. Torralba, P. Isola, and W. T. Freeman, Foundations of Computer Vision.]
Basic gradient descent
[Figure credit: A. Torralba, P. Isola, and W. T. Freeman, Foundations of Computer Vision.]
Surrogate loss function
[Figure credit: A. Torralba, P. Isola, and W. T. Freeman, Foundations of Computer Vision.]
10
Questions?
Today
11
Stochastic gradient descent (SGD)
[Figure credit: A. Torralba, P. Isola, and W. T. Freeman, Foundations of Computer Vision.]
Stochastic gradient descent (SGD)
[Figure credit: A. Torralba, P. Isola, and W. T. Freeman, Foundations of Computer Vision.]
Modern optimizers
“Homework” for you
Today
16
Empirical risk minimization (ERM)
[Figure credit: A. Torralba, P. Isola, and W. T. Freeman, Foundations of Computer Vision.]
Training vs. testing
18
x
y
In training, we only see training data!
Choosing a more complicated hypothesis class does not necessarily lead to lower test errors!
Under-fitting vs. over-fitting
Under-fitting vs. over-fitting
K too small: simple
K too large: complicated
training error = 0
20
[Slides: from USC CSCI567]
Under-fitting vs. over-fitting
21
[Slides: from USC CSCI567]
Under-fitting vs. over-fitting
Training data
Train
Val
Treating “Val” as the “pseudo” test data!
[Figure credit: A. Torralba, P. Isola, and W. T. Freeman, Foundations of Computer Vision.]
Data distribution
24
Questions?
Regularization
[Figure credit: A. Torralba, P. Isola, and W. T. Freeman, Foundations of Computer Vision.]
Finding a good regularizer is not always easy
[Figure credit: A. Torralba, P. Isola, and W. T. Freeman, Foundations of Computer Vision.]
Occam’s razor principle
27
All things being equal,
the simplest explanation is usually the best!
Three tools in the search for Truth
More data, less over-fitting
[Figure: Bishop, PRML]
Green: true data distribution
Blue: training data
Red: learned model
30
Questions?
Today
31
The progress of deep learning for classification
32
ImageNet-1K (ILSVRC)
Metric: Top-k accuracy
The progress of deep learning for classification
[Simonyan et al., 2015]
[Szegedy et al., 2015]
[Huang et al., 2017]
[He et al., 2016]
[Krizhevsky et al., 2012]
Top-5 error rate
General formulation for all these variants
34
Image (pixels)
Recap: classification
[Figure credit: A. Torralba, P. Isola, and W. T. Freeman, Foundations of Computer Vision.]
Deep neural networks (DNN)
Convolution
A special computation between layers
37
Convolution: properties
38
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
Top-left, Top right: has ears
Middle: has eyes
Convolutional neural networks (CNN)
39
Shared weights
Vectorization + FC layers
Max pooling + down-sampling
Training a DNN for classification
40
100: elephant
Minimize the empirical risk
41
Questions?
Four factors behind deep learning developments
Accessibility to large amount of data
43
Flexible neural networks for modeling
Visual transformers
[Liu et al., 2021]
[Battaglia et al., 2018]
Graph neural networks
[Qi et al., 2017]
PointNet
ConvNet
[Huang et al., 2017]
[Gu et al., 2024]
Recurrent neural networks
Powerful algorithms + losses to learn from data
Bi-level optimization
[Finn et al., 2017]
Adversarial learning
[Ganin et al., 2016]
[He et al., 2020]
Contrastive learning
Diffusion (denoising)
[Ho et al., 2020]
Autoregressive
[El-Nouby et al., 2024]
Preference learning
[Rafailov et al., 2023]
Computational resource
47
Questions?
Perceptron
[Figure credit: A. Torralba, P. Isola, and W. T. Freeman, Foundations of Computer Vision.]
Perceptron
[Figure credit: A. Torralba, P. Isola, and W. T. Freeman, Foundations of Computer Vision.]
Perceptron
[Figure credit: A. Torralba, P. Isola, and W. T. Freeman, Foundations of Computer Vision.]
Perceptron
[Figure credit: A. Torralba, P. Isola, and W. T. Freeman, Foundations of Computer Vision.]
Perceptron as classifiers
[Figure credit: A. Torralba, P. Isola, and W. T. Freeman, Foundations of Computer Vision.]
Learning a classifier
[Figure credit: A. Torralba, P. Isola, and W. T. Freeman, Foundations of Computer Vision.]
54
Questions?
Multi-layer perceptron (MLP)
[Figure credit: A. Torralba, P. Isola, and W. T. Freeman, Foundations of Computer Vision.]
Element-wise
Activations vs. Parameters
[Figure credit: A. Torralba, P. Isola, and W. T. Freeman, Foundations of Computer Vision.]
Why do we need activation?
Deep Nets
[Figure credit: A. Torralba, P. Isola, and W. T. Freeman, Foundations of Computer Vision.]
Deep learning: learning with neural nets
[Figure credit: A. Torralba, P. Isola, and W. T. Freeman, Foundations of Computer Vision.]
What are neural nets? What is deep learning?
Layers
[Figure credit: A. Torralba, P. Isola, and W. T. Freeman, Foundations of Computer Vision.]
Layers
[Figure credit: A. Torralba, P. Isola, and W. T. Freeman, Foundations of Computer Vision.]
Deep Nets
[Figure credit: A. Torralba, P. Isola, and W. T. Freeman, Foundations of Computer Vision.]
Deep Nets
[Figure credit: A. Torralba, P. Isola, and W. T. Freeman, Foundations of Computer Vision.]
Deep Nets
[Figure credit: A. Torralba, P. Isola, and W. T. Freeman, Foundations of Computer Vision.]
Deep Nets
[Figure credit: A. Torralba, P. Isola, and W. T. Freeman, Foundations of Computer Vision.]
Deep learning: learning with neural nets
[Figure credit: A. Torralba, P. Isola, and W. T. Freeman, Foundations of Computer Vision.]
67
Questions?
Data structure (in training)
[Figure credit: A. Torralba, P. Isola, and W. T. Freeman, Foundations of Computer Vision.]
Data structure (in training)
[Figure credit: A. Torralba, P. Isola, and W. T. Freeman, Foundations of Computer Vision.]
Data structure (in training)
[Figure credit: A. Torralba, P. Isola, and W. T. Freeman, Foundations of Computer Vision.]
Data structure (in training)
[Figure credit: A. Torralba, P. Isola, and W. T. Freeman, Foundations of Computer Vision.]
Data structure (in training)
[Figure credit: A. Torralba, P. Isola, and W. T. Freeman, Foundations of Computer Vision.]
Stochastic Gradient Descent
Data structure (in training)
[Figure credit: A. Torralba, P. Isola, and W. T. Freeman, Foundations of Computer Vision.]
Stochastic Gradient Descent
Data structure (in training)
[Figure credit: A. Torralba, P. Isola, and W. T. Freeman, Foundations of Computer Vision.]
Batch size = 3
Data structure (in training)
[Figure credit: A. Torralba, P. Isola, and W. T. Freeman, Foundations of Computer Vision.]
Batch size = 3
Reading
Today
77
Why are neural networks powerful?
[Figure credit: A. Torralba, P. Isola, and W. T. Freeman, Foundations of Computer Vision.]
Geometric “transformation” perspective
Function
Data transformation
Data mapping
[Figure credit: A. Torralba, P. Isola, and W. T. Freeman, Foundations of Computer Vision.]
What is this function?
[Figure credit: A. Torralba, P. Isola, and W. T. Freeman, Foundations of Computer Vision.]
What is this function?
[Figure credit: A. Torralba, P. Isola, and W. T. Freeman, Foundations of Computer Vision.]
What is this function?
[Figure credit: A. Torralba, P. Isola, and W. T. Freeman, Foundations of Computer Vision.]
What is this function?
[Figure credit: A. Torralba, P. Isola, and W. T. Freeman, Foundations of Computer Vision.]
Put together
[Figure credit: A. Torralba, P. Isola, and W. T. Freeman, Foundations of Computer Vision.]
2D examples
[Figure credit: A. Torralba, P. Isola, and W. T. Freeman, Foundations of Computer Vision.]
Observation?
2D examples
[Figure credit: A. Torralba, P. Isola, and W. T. Freeman, Foundations of Computer Vision.]
Which one is more “diverse”?
What does a neural network classifier want to do?
Visualizing a neural network classifier (binary)
[Figure credit: A. Torralba, P. Isola, and W. T. Freeman, Foundations of Computer Vision.]
Visualizing a neural network classifier (binary)
[Figure credit: A. Torralba, P. Isola, and W. T. Freeman, Foundations of Computer Vision.]
How is a neural network trained?
[Figure credit: A. Torralba, P. Isola, and W. T. Freeman, Foundations of Computer Vision.]
Today
91
Convolutional neural networks (CNN)
92
Vectorization + FC layers
A simple CNN classifier
93
A simple CNN classifier
94
A simple CNN classifier
95
A simple CNN classifier
96
A simple CNN classifier
97
A simple CNN classifier
98
99
Questions?
What if the image size changes?
100
Vectorization + FC layers
Revisit the bird image
101
How to apply?
Convolutional neural networks (CNN) for detection
102
Convolutional neural networks (CNN) for segmentation
103
Spatial output
104
A simple CNN classifier
105
Spatial output
106
107
Questions?
Popular CNN architectures
108
Popular CNN architectures
109
Popular CNN architectures
110
111
Questions?
Besides translation, CNNs need to tackle object scale
112
Feature pyramid networks
113
[Feature Pyramid Networks for Object Detection, CVPR 2017]