Introduction to Deep Learning
- A. G. Schwing & S. Fidler
University of Toronto, 2015
- A. G. Schwing & S. Fidler (UofT)
CSC420: Intro to Image Understanding 2015 1 / 39
Introduction to Deep Learning A. G. Schwing & S. Fidler - - PowerPoint PPT Presentation
Introduction to Deep Learning A. G. Schwing & S. Fidler University of Toronto, 2015 A. G. Schwing & S. Fidler (UofT) CSC420: Intro to Image Understanding 2015 1 / 39 Outline Universality of Neural Networks 1 Learning Neural
University of Toronto, 2015
CSC420: Intro to Image Understanding 2015 1 / 39
1
Universality of Neural Networks
2
Learning Neural Networks
3
Deep Learning
4
Applications
5
References
CSC420: Intro to Image Understanding 2015 2 / 39
What are neural networks? Let’s ask
Input #1 Input #2 Input #3 Input #4 Output Hidden layer Input layer Output layer
CSC420: Intro to Image Understanding 2015 3 / 39
What are neural networks? ...Neural networks (NNs) are computational models inspired by biological neural networks [...] and are used to estimate or approximate functions... [Wikipedia]
CSC420: Intro to Image Understanding 2015 4 / 39
What are neural networks? Origins: Traced back to threshold logic [W. McCulloch and W. Pitts, 1943] Perceptron [F . Rosenblatt, 1958]
CSC420: Intro to Image Understanding 2015 5 / 39
What are neural networks? Use cases Classification Playing video games Captcha Neural Turing Machine (e.g., learn how to sort) Alex Graves
http://www.technologyreview.com/view/532156/googles-secretive-deepmind-startup-unveils-a-neural-turing-machine/
CSC420: Intro to Image Understanding 2015 6 / 39
What are neural networks? Example: input x parameters w1, w2, b
CSC420: Intro to Image Understanding 2015 7 / 39
What are neural networks? Example: input x parameters w1, w2, b x ∈ R h1 b ∈ R f w1 w2
CSC420: Intro to Image Understanding 2015 7 / 39
How to compute the function? Forward propagation/pass, inference, prediction: Given input x and parameters w, b Compute (latent variables/) intermediate results in a feed-forward manner Until we obtain output function f x ∈ R h1 b ∈ R f w1 w2
CSC420: Intro to Image Understanding 2015 8 / 39
How to compute the function? Forward propagation/pass, inference, prediction: Given input x and parameters w, b Compute (latent variables/) intermediate results in a feed-forward manner Until we obtain output function f
CSC420: Intro to Image Understanding 2015 8 / 39
How to compute the function? Example: input x, parameters w1, w2, b x ∈ R h1 b ∈ R f w1 w2
CSC420: Intro to Image Understanding 2015 9 / 39
How to compute the function? Example: input x, parameters w1, w2, b x ∈ R h1 b ∈ R f w1 w2 h1 = σ(w1 · x + b) f = w2 · h1 Sigmoid function: σ(z) = 1/(1 + exp(−z))
CSC420: Intro to Image Understanding 2015 9 / 39
How to compute the function? Example: input x, parameters w1, w2, b x ∈ R h1 b ∈ R f w1 w2 h1 = σ(w1 · x + b) f = w2 · h1 Sigmoid function: σ(z) = 1/(1 + exp(−z)) x = ln 2, b = ln 3, w1 = 2, w2 = 2 h1 =? f =?
CSC420: Intro to Image Understanding 2015 9 / 39
How to compute the function? Given parameters, what is f for x = 0, x = 1, x = 2, ... f = w2σ(w1 · x + b)
CSC420: Intro to Image Understanding 2015 10 / 39
How to compute the function? Given parameters, what is f for x = 0, x = 1, x = 2, ... f = w2σ(w1 · x + b)
−5 5 0.5 1 1.5 2 x f
CSC420: Intro to Image Understanding 2015 10 / 39
Let’s mess with parameters: x ∈ R h1 b ∈ R f w1 w2 h1 = σ(w1 · x + b) f = w2 · h1 σ(z) = 1/(1 + exp(−z))
CSC420: Intro to Image Understanding 2015 11 / 39
Let’s mess with parameters: x ∈ R h1 b ∈ R f w1 w2 h1 = σ(w1 · x + b) f = w2 · h1 σ(z) = 1/(1 + exp(−z)) w1 = 1.0, b changes
CSC420: Intro to Image Understanding 2015 11 / 39
Let’s mess with parameters: x ∈ R h1 b ∈ R f w1 w2 h1 = σ(w1 · x + b) f = w2 · h1 σ(z) = 1/(1 + exp(−z)) w1 = 1.0, b changes
−5 5 0.2 0.4 0.6 0.8 1 x f b = −2 b = 0 b = 2
CSC420: Intro to Image Understanding 2015 11 / 39
Let’s mess with parameters: x ∈ R h1 b ∈ R f w1 w2 h1 = σ(w1 · x + b) f = w2 · h1 σ(z) = 1/(1 + exp(−z)) w1 = 1.0, b changes b = 0, w1 changes
−5 5 0.2 0.4 0.6 0.8 1 x f b = −2 b = 0 b = 2
CSC420: Intro to Image Understanding 2015 11 / 39
Let’s mess with parameters: x ∈ R h1 b ∈ R f w1 w2 h1 = σ(w1 · x + b) f = w2 · h1 σ(z) = 1/(1 + exp(−z)) w1 = 1.0, b changes b = 0, w1 changes
−5 5 0.2 0.4 0.6 0.8 1 x f b = −2 b = 0 b = 2 −5 5 0.2 0.4 0.6 0.8 1 x f w1 = 0 w1 = 0.5 w1 = 1.0 w1 = 100
CSC420: Intro to Image Understanding 2015 11 / 39
Let’s mess with parameters: x ∈ R h1 b ∈ R f w1 w2 h1 = σ(w1 · x + b) f = w2 · h1 σ(z) = 1/(1 + exp(−z)) w1 = 1.0, b changes b = 0, w1 changes
−5 5 0.2 0.4 0.6 0.8 1 x f b = −2 b = 0 b = 2 −5 5 0.2 0.4 0.6 0.8 1 x f w1 = 0 w1 = 0.5 w1 = 1.0 w1 = 100
Keep in mind the step function.
CSC420: Intro to Image Understanding 2015 11 / 39
How to use Neural Networks for binary classification? Feature/Measurement: x Output: How likely is the input to be a cat?
−5 5 0.2 0.4 0.6 0.8 1 x y
CSC420: Intro to Image Understanding 2015 12 / 39
How to use Neural Networks for binary classification? Feature/Measurement: x Output: How likely is the input to be a cat?
−5 5 0.2 0.4 0.6 0.8 1 x f
CSC420: Intro to Image Understanding 2015 12 / 39
How to use Neural Networks for binary classification? Feature/Measurement: x Output: How likely is the input to be a cat?
−5 5 0.2 0.4 0.6 0.8 1 x f
CSC420: Intro to Image Understanding 2015 12 / 39
How to use Neural Networks for binary classification? Feature/Measurement: x Output: How likely is the input to be a cat?
−5 5 0.2 0.4 0.6 0.8 1 x f
CSC420: Intro to Image Understanding 2015 12 / 39
How to use Neural Networks for binary classification? Shifted feature/measurement: x Output: How likely is the input to be a cat? Previous features
−5 5 0.2 0.4 0.6 0.8 1 x f
CSC420: Intro to Image Understanding 2015 13 / 39
How to use Neural Networks for binary classification? Shifted feature/measurement: x Output: How likely is the input to be a cat? Previous features Shifted features
−5 5 0.2 0.4 0.6 0.8 1 x f −5 5 0.2 0.4 0.6 0.8 1 x f
CSC420: Intro to Image Understanding 2015 13 / 39
How to use Neural Networks for binary classification? Shifted feature/measurement: x Output: How likely is the input to be a cat? Previous features Shifted features
−5 5 0.2 0.4 0.6 0.8 1 x f −5 5 0.2 0.4 0.6 0.8 1 x f
Learning/Training means finding the right parameters.
CSC420: Intro to Image Understanding 2015 13 / 39
So far we are able to scale and translate sigmoids. How well can we approximate an arbitrary function? With the simple model we are obviously not going very far. Features are good Simple classifier
−5 5 0.2 0.4 0.6 0.8 1 x f
CSC420: Intro to Image Understanding 2015 14 / 39
So far we are able to scale and translate sigmoids. How well can we approximate an arbitrary function? With the simple model we are obviously not going very far. Features are good Features are noisy Simple classifier More complex classifier
−5 5 0.2 0.4 0.6 0.8 1 x f −5 5 0.2 0.4 0.6 0.8 1 x f
CSC420: Intro to Image Understanding 2015 14 / 39
So far we are able to scale and translate sigmoids. How well can we approximate an arbitrary function? With the simple model we are obviously not going very far. Features are good Features are noisy Simple classifier More complex classifier
−5 5 0.2 0.4 0.6 0.8 1 x f −5 5 0.2 0.4 0.6 0.8 1 x f
How can we generalize?
CSC420: Intro to Image Understanding 2015 14 / 39
Let’s use more hidden variables:
x ∈ R h1 b1 h2 b2 f w1 w2 w3 w4
h1 = σ(w1 · x + b1) h2 = σ(w3 · x + b2) f = w2 · h1 + w4 · h2
CSC420: Intro to Image Understanding 2015 15 / 39
Let’s use more hidden variables:
x ∈ R h1 b1 h2 b2 f w1 w2 w3 w4
h1 = σ(w1 · x + b1) h2 = σ(w3 · x + b2) f = w2 · h1 + w4 · h2 Combining two step functions gives a bump.
−5 5 1 1.2 1.4 1.6 1.8 2 x f
w1 = −100, b1 = 40, w3 = 100, b2 = 60, w2 = 1, w4 = 1
CSC420: Intro to Image Understanding 2015 15 / 39
So let’s simplify:
x ∈ R h1 b1 h2 b2 f w1 w2 w3 w4 f Bump(x1, x2, h)
We simplify a pair of hidden nodes to a “bump” function: Starts at x1 Ends at x2 Has height h
CSC420: Intro to Image Understanding 2015 16 / 39
Now we can represent “bumps” very well. How can we generalize?
CSC420: Intro to Image Understanding 2015 17 / 39
Now we can represent “bumps” very well. How can we generalize?
f Bump(0.0, 0.2, h1) Bump(0.2, 0.4, h2) Bump(0.4, 0.6, h3) Bump(0.6, 0.8, h4) Bump(0.8, 1.0, h5) 0.5 1 −0.5 0.5 1 1.5 x f Target Approximation
More bumps gives more accurate approximation. Corresponds to a single layer network.
CSC420: Intro to Image Understanding 2015 17 / 39
Universality: theoretically we can approximate an arbitrary function So we can learn a really complex cat classifier Where is the catch?
CSC420: Intro to Image Understanding 2015 18 / 39
Universality: theoretically we can approximate an arbitrary function So we can learn a really complex cat classifier Where is the catch? Complexity, we might need quite a few hidden units Overfitting, memorize the training data
CSC420: Intro to Image Understanding 2015 18 / 39
Generalizations are possible to
CSC420: Intro to Image Understanding 2015 19 / 39
Generalizations are possible to include more input dimensions capture more output dimensions employ multiple layers for more efficient representations See ‘http://neuralnetworksanddeeplearning.com/chap4.html’ for a great read!
CSC420: Intro to Image Understanding 2015 19 / 39
How do we find the parameters to obtain a good approximation? How do we tell a computer to do that?
CSC420: Intro to Image Understanding 2015 20 / 39
How do we find the parameters to obtain a good approximation? How do we tell a computer to do that? Intuitive explanation: Compute approximation error at the output Propagate error back by computing individual contributions of parameters to error
[Fig. from H. Lee]
CSC420: Intro to Image Understanding 2015 20 / 39
Example for backpropagation of error: Target function: 5x2 Approximation: f(x, w) Domain of interest: x ∈ {0, 1, 2, 3} Error: e(w) =
(5x2 − f(x, w))2
CSC420: Intro to Image Understanding 2015 21 / 39
Example for backpropagation of error: Target function: 5x2 Approximation: f(x, w) Domain of interest: x ∈ {0, 1, 2, 3} Error: e(w) =
(5x2 − f(x, w))2 Program of interest: min
w e(w) = min w
(5x2 − f(x, w))2
How to optimize?
CSC420: Intro to Image Understanding 2015 21 / 39
Example for backpropagation of error: Target function: 5x2 Approximation: f(x, w) Domain of interest: x ∈ {0, 1, 2, 3} Error: e(w) =
(5x2 − f(x, w))2 Program of interest: min
w e(w) = min w
(5x2 − f(x, w))2
How to optimize? Gradient descent
CSC420: Intro to Image Understanding 2015 21 / 39
Gradient descent min
w e(w)
CSC420: Intro to Image Understanding 2015 22 / 39
Gradient descent min
w e(w)
Algorithm: start with w0, t = 0
1
Compute gradient gt =
∂e ∂w
2
Update wt+1 = wt − ηgt
3
Set t ← t + 1
CSC420: Intro to Image Understanding 2015 22 / 39
Chain rule is important to compute gradients: min
w e(w) = min w
(5x2 − f(x, w))2
CSC420: Intro to Image Understanding 2015 23 / 39
Chain rule is important to compute gradients: min
w e(w) = min w
(5x2 − f(x, w))2
Loss function: ℓ(x, w)
CSC420: Intro to Image Understanding 2015 23 / 39
Chain rule is important to compute gradients: min
w e(w) = min w
(5x2 − f(x, w))2
Loss function: ℓ(x, w) Squared loss Log loss Hinge loss
CSC420: Intro to Image Understanding 2015 23 / 39
Chain rule is important to compute gradients: min
w e(w) = min w
(5x2 − f(x, w))2
Loss function: ℓ(x, w) Squared loss Log loss Hinge loss Derivatives: ∂e(w) w =
∂ℓ(x, w) ∂w =
CSC420: Intro to Image Understanding 2015 23 / 39
Chain rule is important to compute gradients: min
w e(w) = min w
(5x2 − f(x, w))2
Loss function: ℓ(x, w) Squared loss Log loss Hinge loss Derivatives: ∂e(w) w =
∂ℓ(x, w) ∂w =
∂ℓ(x, w) ∂f ∂f(x, w) ∂w
CSC420: Intro to Image Understanding 2015 23 / 39
Slightly more complex example: Composite function represented as a directed a-cyclic graph ℓ(x, w) = f1(w1, f2(w2, f3(. . .))) f1(w1, f2) w1 f2(w2, f3) w2 f3(. . .)
∂f1 ∂w1 ∂f1 ∂f2 ∂f1 ∂f2 ∂f2 ∂w2 ∂f1 ∂f2 ∂f2 ∂f3
Repeated application of chain rule for efficient computation of all gradients
CSC420: Intro to Image Understanding 2015 24 / 39
Back propagation doesn’t work well for deep sigmoid networks: Diffusion of gradient signal (multiplication of many small numbers) Attractivity of many local minima (random initialization is very far from good points) Requires a lot of training samples Need for significant computational power
CSC420: Intro to Image Understanding 2015 25 / 39
Back propagation doesn’t work well for deep sigmoid networks: Diffusion of gradient signal (multiplication of many small numbers) Attractivity of many local minima (random initialization is very far from good points) Requires a lot of training samples Need for significant computational power Solution: 2 step approach Greedy layerwise pre-training Perform full fine tuning at the end
CSC420: Intro to Image Understanding 2015 25 / 39
Why go deep? Representation efficiency (fewer computational units for the same function) Hierarchical representation (non-local generalization) Combinatorial sharing (re-use of earlier computation) Works very well
[Fig. from H. Lee]
CSC420: Intro to Image Understanding 2015 26 / 39
To obtain more flexibility/non-linearity we use additional function prototypes:
CSC420: Intro to Image Understanding 2015 27 / 39
To obtain more flexibility/non-linearity we use additional function prototypes: Sigmoid Rectified linear unit (ReLU) Pooling Dropout Convolutions
CSC420: Intro to Image Understanding 2015 27 / 39
Convolutions What do the numbers mean? See Sanja’s lecture 14 for the answers...
[Fig. adapted from A. Krizhevsky]
CSC420: Intro to Image Understanding 2015 28 / 39
CSC420: Intro to Image Understanding 2015 29 / 39
CSC420: Intro to Image Understanding 2015 29 / 39
Max Pooling What is happening here?
[Fig. adapted from A. Krizhevsky]
CSC420: Intro to Image Understanding 2015 30 / 39
CSC420: Intro to Image Understanding 2015 31 / 39
Rectified Linear Unit (ReLU)
CSC420: Intro to Image Understanding 2015 32 / 39
Rectified Linear Unit (ReLU) Drop information if smaller than zero Fixes the problem of vanishing gradients to some degree
CSC420: Intro to Image Understanding 2015 32 / 39
Rectified Linear Unit (ReLU) Drop information if smaller than zero Fixes the problem of vanishing gradients to some degree Dropout
CSC420: Intro to Image Understanding 2015 32 / 39
Rectified Linear Unit (ReLU) Drop information if smaller than zero Fixes the problem of vanishing gradients to some degree Dropout Drop information at random Kind of a regularization, enforcing redundancy
CSC420: Intro to Image Understanding 2015 32 / 39
A famous deep learning network called “AlexNet.” The network won the ImageNet competition in 2012. How many parameters? Given an image, what is happening? Inference Time: about 2ms per image when processing many images in parallel on the GPU Training Time: a few days given a single recent GPU
[Fig. adapted from A. Krizhevsky]
CSC420: Intro to Image Understanding 2015 33 / 39
Demo
CSC420: Intro to Image Understanding 2015 34 / 39
Neural networks have been used for many applications: Classification and Recognition in Computer Vision Text Parsing in Natural Language Processing Playing Video Games Stock Market Prediction Captcha Demos: Russ website Antonio Places website
CSC420: Intro to Image Understanding 2015 35 / 39
Classification in Computer Vision: ImageNet Challenge
http://deeplearning.cs.toronto.edu/
Since it’s the end of the semester, let’s find the beach...
CSC420: Intro to Image Understanding 2015 36 / 39
Classification in Computer Vision: ImageNet Challenge
http://deeplearning.cs.toronto.edu/
A place to maybe prepare for exams...
CSC420: Intro to Image Understanding 2015 37 / 39
Links: Tutorials: http://deeplearning.net/tutorial/deeplearning.pdf Toronto Demo by Russ and students: http://deeplearning.cs.toronto.edu/ MIT Demo by Antonio and students: http://places.csail.mit.edu/demo.html Honglak Lee: http://deeplearningworkshopnips2010.files.wordpress.com/2010/09/nips10- workshop-tutorial-final.pdf Yann LeCun: http://www.cs.nyu.edu/ yann/talks/lecun-ranzato-icml2013.pdf Richard Socher: http://lxmls.it.pt/2014/socher-lxmls.pdf
CSC420: Intro to Image Understanding 2015 38 / 39
Videos: Video games: https://www.youtube.com/watch?v=mARt-xPablE Captcha: http://singularityhub.com/2013/10/29/tiny-ai-startup- vicarious-says-its-solved-captcha/ https://www.youtube.com/watch?v=lge-dl2JUAM#t=27 Stock exchange: http://cs.stanford.edu/people/eroberts/courses/soco/projects/neural- networks/Applications/stocks.html
CSC420: Intro to Image Understanding 2015 39 / 39