Convolutional Neural Network
Convolutional Neural Network
Let’s see why we cannot use fully connected networks for image classifications
Why Not Fully Connected Networks
Image with Number of weights in the
28 x 28 x3 first hidden layer will be
Pixels 2352
Image with
200 x200 x 3 Number of weights in
pixels the first hidden layer
will be 120,000
Why Convolutional Neural
Networks?
Convolution
ReLU Layer
Pooling
X
Fully Connected
CNN
CNN
0
Trickier Case
Here, we will have some problems because X and 0 images won’t always have the same images.
There can be certain deformations. Consider the diagrams show below:
X
0
How CNN Works?
=
=
How CNN Works?
A Computer understands an image using numbers at each pixels.
In out example, we have considered that a black pixel will have a value of 1 and a white pixel will
have -1 value.
How CNN Works?
Using normal techniques, computers compare these images as:
+ =
How CNN Works?
CNN Compares the images piece by piece. The pieces that it look for are called features .
By finding rough feature matches, in roughly the same position in two images, CNN gets a lot
better at seeing similarity that whole-image schemes.
=
=
=
How CNN works?
We will be taking three features or filters, as shown below:
How CNN Works?
These are small pieces of the bigger image. We chose a feature and
put it on the input image, if it matches then the image is classified
correctly.
Convolution Layer
Steps involved in Convolution Layer
Here we will move the feature/filter to every possible position on the image.
Step - 1 Step - 2
Line up the feature and the image. Multiply each image pixel by the
corresponding feature pixel.
Multiplying the corresponding Pixel Values
1x1=1
Steps involved in Convolution Layer
Here we will move the feature/filter to every possible position on the image.
Step - 1 Step - 2
Line up the feature and the image. Multiply each image pixel by the
corresponding feature pixel.
Step - 3 Step - 4
Rectified Linear unit (ReLU) transform function only activates a node if the input is above a
certain quantity, while the input is below zero, the input zero, but when the input rises above a
certain threshold, it has a linear relationship with the dependent variable.
X F(x)=x F(x)
-3 F(-3)=0 0
-5 F(-5)=0 0
3 F(3)=3 3
5 F(5)=5 5
Removing Negative Values
Removing Negative Values
Output for one feature
Output for All Features
Pooling Layer
Pooling Layer
In this we shrink the image stack into a smaller size steps:
Sum Sum
4.56
/ 4.56
0.91
Sum Sum
2.07
/ 4
0.51
.91 .51
Training
DOG
Input
Implementing the Use-Case
Download Function to encode Resize the image to 50x50 pixel Split the data, 24,500 images for
the dataset the labels and read as greyscale training and 500 for testing
Calculate loss
function, it is Reshape the data appropriately
categorical cross Build Model
for Tensor Flow
entropy
Adam as optimizer
with learning rate Train the Deep Neural Net for
set to 0.001. 10 epochs
Make predictions
Thank You