0% found this document useful (0 votes)
36 views33 pages

8 CNN Example

The document discusses convolutional neural networks (CNNs). CNNs are a type of neural network that can process data with a known, grid-like topology such as image data. CNNs apply successive layers of convolution and pooling operations to extract hierarchical features from input data. The document outlines the key components of CNNs including convolutional layers, activation layers, pooling layers, and fully connected layers. It also provides an example of implementing a CNN using TensorFlow to classify images from the CIFAR-10 dataset.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views33 pages

8 CNN Example

The document discusses convolutional neural networks (CNNs). CNNs are a type of neural network that can process data with a known, grid-like topology such as image data. CNNs apply successive layers of convolution and pooling operations to extract hierarchical features from input data. The document outlines the key components of CNNs including convolutional layers, activation layers, pooling layers, and fully connected layers. It also provides an example of implementing a CNN using TensorFlow to classify images from the CIFAR-10 dataset.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 33

Convolutional Neural

Networks_Ex
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/

3/7/2023 1
What is CNN?

3/7/2023 2
CNN Benefits
• Equivariant activities: Replicated features do not make the neural
activities invariant to translation. The activities are equivariant.

Representation Translated
by active representation
neurons

translated
image
image

• Invariant Knowledge: If a feature is useful in some locations during


training, detectors for that feature will be available in all locations during
testing.
3/7/2023 Courtesy: Geoffrey Hinton CSC2535 3
How CNN Works?

3/7/2023 4
Possible Case

3/7/2023 5
How CNN Works?

3/7/2023 6
How CNN Works?

3/7/2023 7
How CNN Works?

Gives an idea

3/7/2023 8
How CNN Works?

First Filter

Second Filter

Third Filter

3/7/2023 9
How CNN Works?

3/7/2023 10
How CNN Works?

3/7/2023 11
Convolutional Layer

3/7/2023 12
Operations Involved in Convolution Layer
• Move filter over the image at every possible position.
• Multiply each image pixel by corresponding feature pixel.

Similarly

3/7/2023 13
Operations Involved in Convolution Layer…
O/P of
Conv
Layer
for first
filter
• Adding all the multiplied values of filter at every move.
• Divide the sum by total number of pixels.

3/7/2023 14
Output of Convolutional Layer

3/7/2023 15
Activation Layer: ReLU

3/7/2023 16
ReLU: Removes the Negative Values

3rd Feature 2nd Feature 1st Feature


First Feature

3/7/2023 17
Pooling Layer

3/7/2023 18
Max Pooling of size: 2x2, Stride : 2

4x4
.77
7x7
3/7/2023 19
Max Pooling of size: 2x2, Stride : 2

.77

7x7 4x4

7x7 4x4

4x4
7x7
3/7/2023 20
Stacking of Layers
Convolutional Layer

i-th layer of CNN

3/7/2023 21
Practical CNN Model
• Most of the practical CNN models have more number of
layers.

2x2

2x2

2x2

3/7/2023 22
Fully Connected Layer
• Actual Classification Occurs at FC layer

Flattened the
final output
layer

3/7/2023 23
Output

1 1
2 2
3 3
4 4
5 5
6 6
7
“1” at
7
8 8
9 9
10 10
11 11
12 12

3/7/2023 24
Prediction

1
Now Network
2

3
is training
4
and gives
5
prediction for
6 a Test sample
7

10 Is is “X” or “O”?
11

12
Lets Compare
3/7/2023 25
Prediction: Compare with ‘X’ and ‘O’
1 1

2 2

3 3

4 4

5 5

6 6

7 7

8 8

9 9

10 10

11 11

12 12

For ‘X’

3/7/2023 26
Prediction: Compare with ‘X’ and ‘O’
1 1

2 2

3 3

4 4

5 5

6 6

7 7

8 8

9 9

10 10

11 11

12 12

For ‘O’

3/7/2023 27
Result: Compare with ‘X’ and ‘O’

What is result?

Classified
as “X”

3/7/2023 28
CNN for Edge Detection

3/7/2023 29
Implementation of CNN
The CIFAR-
10 dataset:
This dataset
consists of
60000 32x32
colour images
in 10 classes,
with 6000
images per
class.

3/7/2023 30
Model of CNN

3/7/2023 31
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

3/7/2023 32
References
• https://www.youtube.com/watch?v=umGJ30-15_A

3/7/2023 33

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy