0% found this document useful (0 votes)
19 views2 pages

Document 1

Uploaded by

tom.bjorn.bacon
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views2 pages

Document 1

Uploaded by

tom.bjorn.bacon
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

Class Notes: Building a Convolutional Neural Network (CNN) - Part 1

1. Introduction to CNNs
Convolutional Neural Networks (CNNs) are a specialized type of neural network used
primarily for image processing, classification, and other spatial data tasks. CNNs
are designed to automatically and adaptively learn spatial hierarchies of features
from input images. They are particularly well-suited for tasks such as image
recognition, object detection, and more.

2. Key Components of CNNs


a. Convolutional Layers:

Function: Detect features such as edges, textures, and patterns in the input image.
Operation: Convolves a filter (or kernel) over the input image to produce feature
maps. Each filter detects a specific feature.
Mathematics: Convolution operation involves sliding a filter over the image and
computing dot products between the filter and local image patches.
b. Activation Functions:

Function: Introduce non-linearity to the model, allowing it to learn more complex


patterns.
Common Activation Function: ReLU (Rectified Linear Unit) is commonly used in CNNs.
It outputs zero for negative values and the input itself for positive values.
c. Pooling Layers:

Function: Reduce the spatial dimensions (height and width) of the feature maps
while retaining the most important information.
Types: Max pooling (takes the maximum value in a patch) and average pooling (takes
the average value).
d. Fully Connected Layers:

Function: Flatten the feature maps into a one-dimensional vector and perform
classification or regression tasks based on the learned features.
Operation: Each neuron in a fully connected layer is connected to every neuron in
the previous layer.
3. Constructing a Simple CNN
Step-by-Step Example:

Input Layer: Accepts an image of size


32
×
32
×
3
32×32×3 (height, width, channels).
Convolutional Layer 1: Apply 32 filters of size
3
×
3
3×3, resulting in 32 feature maps.
Activation Function: Apply ReLU activation.
Pooling Layer 1: Apply max pooling with a
2
×
2
2×2 window, reducing feature map size.
Convolutional Layer 2: Apply 64 filters of size
3
×
3
3×3, resulting in 64 feature maps.
Activation Function: Apply ReLU activation.
Pooling Layer 2: Apply max pooling with a
2
×
2
2×2 window.
Flattening: Convert the 2D feature maps into a 1D vector.
Fully Connected Layer: Add a dense layer for classification with the number of
neurons equal to the number of classes.
Output Layer: Softmax activation for multi-class classification.
4. Implementation
Use popular libraries like TensorFlow or PyTorch to build CNNs. For instance, in
TensorFlow/Keras:

python
Copy code
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Conv2D, MaxPooling2D, Flatten, Dense

model = Sequential([
Conv2D(32, (3, 3), activation='relu', input_shape=(32, 32, 3)),
MaxPooling2D((2, 2)),
Conv2D(64, (3, 3), activation='relu'),
MaxPooling2D((2, 2)),
Flatten(),
Dense(64, activation='relu'),
Dense(10, activation='softmax')
])

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