Convolutional Neural Networks_Ex
1
2/21/2023
Dr. Dinesh Kumar Vishwakarma�Professor, Department of Information Technology�Delhi Technological University, Delhi
Email: dinesh@dtu.ac.in
Web page: http://www.dtu.ac.in/Web/Departments/InformationTechnology/faculty/dkvishwakarma.php
Biometric Research Laboratory
http://www.dtu.ac.in/Web/Departments/InformationTechnology/lab_and_infra/bml/
What is CNN?
2
2/21/2023
CNN Benefits
3
2/21/2023
Representation by active neurons
image
Translated representation
translated image
Courtesy: Geoffrey Hinton CSC2535
How CNN Works?
4
2/21/2023
Possible Case
5
2/21/2023
How CNN Works?
6
2/21/2023
How CNN Works?
7
2/21/2023
How CNN Works?
8
2/21/2023
Gives an idea
How CNN Works?
9
2/21/2023
First Filter
Second Filter
Third Filter
How CNN Works?
10
2/21/2023
How CNN Works?
11
2/21/2023
Convolutional Layer
12
2/21/2023
Operations Involved in Convolution Layer
13
2/21/2023
Similarly
Operations Involved in Convolution Layer…
14
2/21/2023
O/P of Conv Layer for first filter
Output of Convolutional Layer
15
2/21/2023
Activation Layer: ReLU
16
2/21/2023
ReLU: Removes the Negative Values
17
2/21/2023
First Feature
1st Feature
2nd Feature
3rd Feature
Pooling Layer
18
2/21/2023
Max Pooling of size: 2x2, Stride : 2
19
2/21/2023
7x7
4x4
.77
Max Pooling of size: 2x2, Stride : 2
20
2/21/2023
.77
7x7
7x7
7x7
4x4
4x4
4x4
Stacking of Layers
21
2/21/2023
i-th layer of CNN
Convolutional Layer
Practical CNN Model
22
2/21/2023
2x2
2x2
2x2
Fully Connected Layer
23
2/21/2023
Flattened the final output layer
Output
24
2/21/2023
“1” at
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
Prediction
25
2/21/2023
Now Network is training and gives prediction for a Test sample
Is is “X” or “O”?
Lets Compare
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
Prediction: Compare with ‘X’ and ‘O’
26
2/21/2023
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
For ‘X’
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
Prediction: Compare with ‘X’ and ‘O’
27
2/21/2023
For ‘O’
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
Result: Compare with ‘X’ and ‘O’
28
2/21/2023
Classified as “X”
What is result?
CNN for Edge Detection
29
2/21/2023
Implementation of CNN
The CIFAR-10 dataset: This dataset consists of 60000 32x32 colour images in 10 classes, with 6000 images per class.
30
2/21/2023
Model of CNN
31
2/21/2023
Implementation in TensorFlow
def createModel():
model = Sequential()
# The first two layers with 32 filters of window size 3x3
model.add(Conv2D(32, (3, 3), padding='same', activation='relu', input_shape=input_shape))
model.add(Conv2D(32, (3, 3), activation='relu'))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Dropout(0.25))
model.add(Conv2D(64, (3, 3), padding='same', activation='relu'))
model.add(Conv2D(64, (3, 3), activation='relu'))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Dropout(0.25))
model.add(Conv2D(64, (3, 3), padding='same', activation='relu'))
model.add(Conv2D(64, (3, 3), activation='relu'))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Dropout(0.25))
model.add(Flatten())
model.add(Dense(512, activation='relu'))
model.add(Dropout(0.5))
model.add(Dense(nClasses, activation='softmax'))
return model
32
2/21/2023
References
33
2/21/2023