Artificial Intelligence Convolution Neural Networks
Artificial Intelligence Convolution Neural Networks
Artificial Intelligence Convolution Neural Networks
Machine Learning
Data
Computer Program
Output
06/01/2021 Artificial Intelligence for Data Analytics 3
06/01/2021 Artificial Intelligence for Data Analytics 4
Supervised Learning
• Labeled data
• Predict Outcome/Future
• It infers a function from
labeled training data
consisting of a set of training
examples
• A supervised learning
algorithm takes a known set of
input data and known
responses to the data (output)
and trains a model to generate
reasonable predictions for the
response to new data
• No labels
• Find hidden structure in data
• Used to draw inferences from
datasets consisting of input data
without labeled responses
29
Convolutional Neural Nets Background
30
31
Applications of CNNs
32
Applications of CNNs
33
Structure of a CNN
34
CNN Structure
● Traditional neural networks are made up of an input layer, a series of hidden layers,
and an output layer
● Convolutional neural networks have convolutional layers, pooling layers, and fully
connected layers
35
What we see What Computers see
32 x 32 x 3
36
37
Convolutional Layer
38
A convolutional layer
A CNN is a neural network with some convolutional layers
(and some other layers). A convolutional layer has a number
of filters that does convolutional operation.
Curve detector
A filter
40
Convolutional Layer
● Filters, from a high level, can be thought of as feature identifiers.
41
Convolutional Layer
● Convolutional layers compute element wise multiplications between the values of
the input and the values of the filter.
Sample Image (5x5x1) Sample Filter (3x3x1)
1 1 1 0 0 1 0 1
0 1 1 1 0 0 1 0
0 0 1 1 1 1 0 1
0 0 1 1 0
0 1 1 0 0
42
Convolutional Layer
43
Convolutional Layer
44
Convolutional Layer
● Multiply values in filter with the original pixel values of the image
45
Convolutional Layer
● Let’s see the results after moving the filter
46
47
48
Hyperparameters
◉ Depth – Number of filters
◉ Strides – Takes values 1, 2,3……
◉ Zero Padding – Reduce overfitting
49
Strides OUTPUT SIZE:
N
(N-F)/stride+1
F
N
F
N=7, F=3
Stride=1 O/P=?
Stride=2 O/P=?
Stride=3 O/P=?
50
Padding
◉ Common to Zero Pad the border
◉ Ex: 7 x 7 Input , 3 x 3 Filter, stride=1
◉ Pad with one pixel border, O/P=?
0 0 0 0 0 0 0 0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0 0 0 0 0 0 0 0
51
Padding
◉ OUTPUT WILL BE THE SAME SIZE AS INPUT
◉ Common to see Convolution Layers with stride 1.
◉ Filters of size F x F and zero padding with (F-1)/2
◉ Preserve the size spatially
◉ Ex: F=3 => Zero pad with 1
F=5 => Zero pad with 2
F=7 => Zero pad with 3
Limits too fast shrinking of Image volume.
52
Convolutional Layer
Calculating the output size for any given conv layer
O = Output height/length
W = Input height/length
P = Padding
S = Stride
K = Filer size
53
QUESTION
54
QUESTION
55
QUESTION
56
Summary of Convolution layer
58
Convolutional Layer
● Examples of higher level features
○ Semicircles (combination of a curve and a straight edge)
○ Squares (combination of several straight edges)
● As we go through more and more conv layers, outputs will represent more
and more complex features
59
60
61
Pooling Layer
◉Pooling layer lies in-between successive Convolution layers in a
Conv.Net architecture.
◉Progressively reduce the spatial size of the representation to
reduce the amount of parameters and computation in the
network and control overfitting.
62
Nonlinear Layer
● After each conv layer, we apply a nonlinear layer (or activation layer)
● Purpose is to introduce nonlinearity to a system that has just been computing
linear operations during the conv layers
● ReLU is the most popular activation function, followed by sigmoid and tanh
● ReLU stands for rectified linear unit, and is a type of activation function.
Mathematically, it is defined as y = max(0, x)
63
Non-linear Activation Function
64
Dropout Layer
● This layer “drops out” a random set of activations by setting them to zero
● Purpose is to force the network to be robust and to alleviate problem of overfitting
● The network should be able to provide the right classification for a specific example
even when some activations are dropped
● Makes sure network isn’t getting too “fitted” to the training data
65
Fully Connected Layer
● Final layer[s] in the network
● Exactly the same as the hidden layers we saw last week
● Takes in output volume of preceding layer and outputs N dimensional vector where
N is the number of classes.
66
Putting it all Together
67
CNN ARCHITECTURE
68
69
70
71
72
73
74
75
76
THANKS FOR YOUR
PATIENCE LISTENING
77