Cnn
Cnn
Nandita Bhaskhar
Content adapted from CS231n and past CS229 teams
April 29th, 2022
Overview
● Motivation for deep learning
● Areas of Deep Learning
● Convolutional neural networks
● Recurrent neural networks
● Deep learning tools
2
Classical Approaches
Saturate!
● Computer vision is especially hard for
conventional image processing
techniques
● Humans are just intrinsically better at
perceiving the world!
https://xkcd.com/1425/
3
What about the MLPs we learnt in class?
Recall:
● Input Layer
● Hidden layer
● Activations
● Outputs
Does not exploit the order and local relations in the data!
64x64x3=12288 parameters
We also want many layers
5
Overview
● Motivation for deep learning
● Areas in Deep Learning
● Convolutional neural networks
● Recurrent neural networks
● Deep learning tools
6
What are different pillars of deep learning?
Convolutional NN Recurrent NN
Image Time Series
Graph NN
Networks/Relational
Deep RL
Control System
7
Overview
● Motivation for deep learning
● Areas of Deep Learning
● Convolutional neural networks
● Recurrent neural networks
● Deep learning tools
8
Convolutional Neural Networks
Convolutional
Neural Network
10
2D Convolution
11
Pic Credit: Apple, Chip Huyen
Sharpening
Convolving Filters
https://ai.stanford.edu/~syyeung/cvweb/tutorials.html
0 -1 0 -1 -1 -1
-1 4 -1 -1 8 -1
0 -1 0 -1 -1 -1
12
https://ai.stanford.edu/~syyeung/cvweb/tutorials.html
Convolving Filters
● Why not extract features using
filters?
● Learnable filters!!
13
Convolution on multiple channels
● Images are generally RGB !!
14
Slide Credit: CS231n 15
Slide Credit: CS231n 16
Slide Credit: CS231n 17
Slide Credit: CS231n 18
Slide Credit: CS231n 19
Slide Credit: CS231n 20
21
Slide Credit: CS231n
22
Slide Credit: CS231n
Slide Credit: CS231n 23
Slide Credit: CS231n 24
Slide Credit: CS231n 25
Slide Credit: CS231n 26
Slide Credit: CS231n 27
Slide Credit: CS231n 28
Slide Credit: CS231n 29
Parameter Sharing
30
Translational invariance
Since we are training filters to
detect cats and the moving
these filters over the data, a
differently positioned cat will
also get detected by the same
set of filters.
31
Filteres? Layers of filters?
Images that maximize filter outputs at certain How deeper layers can learn deeper
layers. We observe that the images get more embeddings. How an eye is made up of multiple
complex as filters are situated deeper curves and a face is made up of two eyes.
32
How do we use convolutions?
34
How do we learn?
To learn:
● Just do gradient descent and backpropagate the error derivates
35
How do we learn?
Instead of
36
Mini-batch Gradient Descent
Expensive to compute gradient for large dataset
Memory size
Compute time
37
Is deeper better?
Deeper networks seem to be
more powerful but harder to train.
38
Solution
Connect the layers, create a gradient highway or information
highway.
ResNet (2015)
39
Image credit: He et al. (2015)
Initialization
● Can we initialize all neurons to zero? ● Relu units once knocked out and
their output is zero, their gradient
● If all the weights are same we will not flow also becomes zero.
be able to break symmetry of the
network and all filters will end up ● We need small random numbers at
learning the same thing. initialization.
41
Tricks for training
● Data augmentation if your data set is
smaller. This helps the network
generalize more.
42
Overview
● Motivation for deep learning
● Areas of Deep Learning
● Convolutional neural networks
● Recurrent neural networks
● Deep learning tools
43
CNN sounds like fun!
What are some deep learning pillars?
Recurrent NN
Time Series
45
To address sequential dependency?
Use recurrent neural network (RNN)
Latent Output Unrolling an RNN
Previous output
I love CS ! 47
There are 2 types of RNN cells
Store in “long term memory” Response to current input Reset gate Update gate
Response to
current input
No hard dependency
50
More? Take CS230, CS236, CS231N, CS224N
Convolutional NN Recurrent NN
Image Time Series
Graph NN
Networks/Relational
Deep RL
Control System
51
Not today, but take CS234 and CS224W
Convolutional NN Recurrent NN
Image Time Series
Graph NN
Networks/Relational
Deep RL
Control System
52
Overview
● Motivation for deep learning
● Areas of Deep Learning
● Convolutional neural networks
● Recurrent neural networks
● Deep learning tools
53
Tools for deep learning Specialized
Groups
Popular Tools
54
Where can I get free stuff?
Google Colab
Azure Notebook
Free (limited-ish) GPU access
Kaggle kernel???
Works nicely with Tensorflow
Amazon SageMaker?
Links to Google Drive
56