Chapter 3
Chapter 3
Key Points
Computational Intelligence
Chapter 3
Introduction to Deep Learning
Overview:
- Deep Learning, a subfield of machine learning, is designed to mimic
the human brain’s neural networks in learning complex patterns from
large datasets.
Machine Learning وهو مجال فرعي من الـ،Deep Learning الـ
human brain يف الـneural networks مصمم ًلحاكاة الـ
.large daatasets منcomplex patterns يف تعلم الـ
Computational Intelligence
Chapter 3
Deep Learning:
refers to neural networks with multiple layers, also known as deep
neural networks.
multiple layers بهاneural networks بريمز إىل
.deep neural networks معروفة باسم
Computational Intelligence
Chapter 3
Machine Learning vs Deep Learning
Computational Intelligence
Chapter 3
Key Characteristics of Deep Learning
End-to-End Learning:
Deep learning models can learn directly from raw data without
requiring manual feature extraction.
raw data ممكن تتعلم بشكل مبارش من الـDeep Leaning بتاعة الـModels الـ
.manual feature extraction بدون الحاجة إىل
Representation Learning:
Deep networks automatically learn hierarchical representations of data.
hierarchical representations of data ممكن تتعلمDeep networks الـ
بشكل أتوماتييك
Big Data and Computing Power:
Deep learning thrives on large datasets and requires significant
computational power (e.g., GPUs).
large datasets بيزدهر عىلdeep learning الـ
.significant computational power وبيتطلب
Computational Intelligence
Chapter 3
Convolutional Neural Networks
- A convolutional neural network (or ConvNet) is a type of feed
forward artificial neural network.
.feed-forward artificial neural network نوع من أنواع
- The architecture of a ConvNet is designed to take advantage of the
2D structure of an input image.
ConvNet البنية بتاعة الـ
.input image بتاع الـ2D structure تم تصميمها لالستفادة من
CNNs are a type of deep learning model
deep learning model هو نوع من أنواع الـ
primarily designed for image-related tasks.
.image-related tasks تم تصميمه من أجل
Computational Intelligence
Chapter 3
They are highly effective at recognizing spatial hierarchies in images,
such as:
- edges
- textures
- more complex features as the network depth increases.
داخل الصورspatial hierarchies هم فعالني يف التعرف عىل الـ
:مثل
- edges
- textures
- more complex features as the network depth increases.
Computational Intelligence
Chapter 3
(Basic Structure of CNNs)
- Convolutional Layers:
Perform convolution operations on input images to extract features.
input images عىلconvolution operations بتؤدي
.features للـextract من أجل عمل
- Pooling Layers:
Down-sample the feature maps to reduce spatial dimensions while
preserving important information.
spatial dimensions علشان تقلل الـfeature maps للـdown-sample بتعمل
.preserving important information أثناء
- Fully Connected Layers:
Final layers where the high-level reasoning is done, outputting
predictions or classifications.
بيتمhigh-level النهائية حيث الـlayers الـ
.predictions or classifications اليل هوoutput ويخرج الـ
Computational Intelligence
Chapter 3
How CNN works?
Computational Intelligence
Chapter 3
ConvNet Layers
CONV layer
It will compute the output of neurons that are connected to local
regions in the input, each computing a dot product between their
weights and a small region they are connected to in the input volume.
input يف الـlocal regions اًلتصلة بالـneurons بتاع الـoutput هتحسب الـ
: بنيdot product حيث يقوم كل منها بحساب حاصل
.input volume متصلة بها يف الـsmall region بتاعتها وweights الـ
Computational Intelligence
Chapter 3
RELU layer
It will apply an elementwise activation function, such as the max(0,x)
thresholding at zero.
elelmentwise activation function هتطبق
max(0,x) at zero زي الـ
This leaves the size of the volume unchanged.
. ثابت بدون تغريvolume ده بيرتك حجم الـ
POOL layer
It will perform a down sampling operation along the spatial
dimensions (width, height).
down sampling operation بتؤدي
spatial dimensions (width, height) بطول الـ
Computational Intelligence
Chapter 3
FC (i.e. fully-connected) layer
It will compute the class scores, resulting in volume of size [1x1xN],
where each of the N numbers correspond to a class score, such as
among the N categories.
class scores سيقوم بحساب الـ
]x1xN1[ بحجمvolume مام يؤدي إىل
.N categories مثل بني،class score مع الـN حيث يتوافق كل رقم من أرقام
Computational Intelligence
Chapter 3
CONV layer
الصورة بتاعتك بتبدأ تطبق عليها شوية filters
الـ filterبيبدأ يطلعلك feature extraction
Computational Intelligence
Chapter 3
Input Size (W): 9
W اليل هو حجم الصورة وبرنمزله بالرمزInput Size الـ
Filter Size (F): 3 X 3
W وبرنمزله بالرمزFilter اليل هو حجم الـFilter Size الـ
Filter/Kernel:
A small matrix that slides over the input image, multiplying and
summing values to produce a feature map.
input image الـslides over صغرية بـMatrix
feature map من أجل الوصول إىلvalues برضب وجمع الـ
Stride (S): 1
يعني هتميش كام بكسل، بتاعتكstep هو الـStride الـ
بكسل1 يبقى هتميش مبقدار1 بـstride لو الـ
s هرنمزله بالرمز
Stride:
The step size at which the filter moves across the image.
. هيتحركها خالل الصورةfilter اليل الـstep هو حجم الـ
Computational Intelligence
Chapter 3
Filters: 1
Filters ده عدد الـ
Padding: 0
بيبقى يف منتصف الصورةorigin يف الطبيعي الـ
هنكرب حجم الصورةorigin لو عايز أخيل البكسل األوالين هو الـ
بنضيف إطار حوالني الصورة
Padding:
Adding extra pixels (usually zeros) around the input image to control
the spatial dimensions of the output.
input image حول الـextra pixels (usually zeros) إضافة
.spatial dimensions of the output من أجل التحكم يف الـ
Computational Intelligence
Chapter 3
Feature Map الصورة اليل هتطلع اسمها
: بطبق القانون،لو عايز أعرف حجمها
Computational Intelligence
Chapter 3
Relu Layer
After convolution, the output is passed through an activation function.
.activation function بيتمرر خاللoutput الـ،convolution بعد الـ
The most commonly used activation function in CNNs is ReLU.
.RELU هي الـCNNs بيتم استخدامها يف الـactivation function أشهر
Computational Intelligence
Chapter 3
ReLU introduces non-linearity into the network, which helps the CNN
learn complex patterns.
،network يف الـnon-linearity بتقدمReLU الـ
.complex patterns عىل تعلم الـCNN مام يساعد
Any negative values from the convolution are set to zero, allowing the
network to focus only on positive signals.
zero بتكونconvolution من الـnegative values أي
.positive signals أنها تركز فقط عىل الـnetwork بتسمح للـ
Computational Intelligence
Chapter 3
Pooling Layer
Pooling Layer
- The pooling layer is used to reduce the spatial dimensions of feature
maps, which helps lower computational complexity and prevent
overfitting.
بتستخدمpooling layer الـ
feature maps بتاعة الـspatial dimensions لتقليل الـ
.overfitting وبتمنع الـcomputational complexity ودي بتساعد عىل الـ
- Max Pooling:
Selects the maximum value from a patch of the feature map.
.feature map بتاع الـpatch منmaximum value بتحدد الـ
- Average Pooling:
Averages the values within the patch.
.patch بتوجد متوسط القيم داخل الـ
Computational Intelligence
Chapter 3
Key Points:
- Pooling reduces the size of the feature map, allowing for faster
computation in deeper layers.
feature map بتقلل حكم الـpooling الـ
.deeper layers يفfaster computation وبتسمح لـ
- It also introduces some form of translation invariance, meaning the
network is less sensitive to small movements or distortions in the
image.
translation invariance أيضا شكل من
ً بتقدم
يفsmall movements or distortions أقل حساسية لـnetwork وتعني أن الـ
.الصورة
Computational Intelligence
Chapter 3
Pooling Filter example
Size = 2 X 2, Stride = 2
Computational Intelligence
Chapter 3
Flatten - Fully Connected Layer - Soft max
واحدvector جوهpool layer هحط الصورة اليل طالعة من الـ
Fully Connected Layer وبعدين بدخل الصورة عىل الـ
Softmax وبعدين بدخل الصورة عىل الـ
After several convolutional and pooling layers, the network flattens the
feature maps and passes them through one or more fully connected
layers.
:several convolutional and pooling layers بعد
feature maps للـflatten بتعملnetwork الـ
.Fully Connected Layers وبعدين بتمررهم خالل
These layers are responsible for making predictions or classifications.
.classifications أوpredictions دي هي اًلسئولة عن عملLayers الـ
- Flattening:
Converts the 2D feature maps into a 1D vector.
.1D vector إىل2D feature maps بتحول الـ
- Fully Connected Layer:
Every neuron in the layer is connected to every neuron in the previous
layer.
. السابقةlayer يف الـneuron بيتوصل بكلlayer يف الـneuron كل
Computational Intelligence
Chapter 3
Training Convolutional Neural Networks
Training CNNs involves the same general process as other neural
networks:
forward propagation, backpropagation, and gradient descent.
general process بيتضمن نفس الـCNNs تدريب الـ
. اآلخرىneural networks مثل الـ
.gradient descent <= backpropagation <= forward propagation
Computational Intelligence
Chapter 3
Forward Propagation
During the forward pass:
- The input image is convolved with filters.
.convolved with filters بيحصلهاinput image الـ
Computational Intelligence
Chapter 3
Loss Function
A loss function measures how far the network's predictions are from
the actual values.
network’s predictions بتقيس مدى بعد الـloss function الـ
.actual values عن الـ
Computational Intelligence
Chapter 3
Backpropagation and Gradient Descent
➜Backpropagation:
The error is propagated back through the layers of the network, and
the gradients are calculated.
.network بتاعة الـlayers خالل الـpropagated back بيحصلهerror الـ
➜Gradient Descent:
Computational Intelligence
Chapter 3
Data Augmentation
مش كفايةdata عندك
فأنت عايز تخلق من الصورة شوية صور
)overfitting بشكل كويس (علشان ميحصلشtraining علشان تعمل عليها
Computational Intelligence
Chapter 3
Dropout
Neurons ممكن توقع شوية
فهنوقع منه منه شوية، بتاعك ما هيتعلم كل حاجةModel علشان الـ
اليل عنديoverfitting لتجنب الـ
Computational Intelligence
Chapter 3
Transfer Learning
pre-trained بيكونmodel بتعمل
.يعني موديل اتعلم قبل كده عىل شوية حاجات تانية
Computational Intelligence
Chapter 3
- In transfer learning, a pre-trained model (e.g., trained on ImageNet)
is used as a starting point for a new task.
Transfer Learning يف الـ
.new task للـstarting point بيستخدم كـpre-trained model الـ
The idea is that the model has already learned useful features (edges,
shapes, textures) from a large dataset and can be fine-tuned for a new
task with limited data.
بالفعلuseful features اتعلمmodel هي أن الـidea الـ
edges, shapes, textures :زي الـ
large dataset اتعلمها من
.limited data بـtask من أجلfine-tuned وممكن يبقى
Computational Intelligence
Chapter 3
Applications of CNNs
➜ Image Classification
CNNs are widely used for image classification tasks, where the model
assigns a label to an image. Common datasets for image classification
include MNIST (handwritten digits), CIFAR-10 (small object images),
and ImageNet (large-scale object recognition).
➜ Object Detection
Computational Intelligence
Chapter 3
Challenges and Limitations of CNNs
➜Data-Hungry:
Computational Intelligence