الرئيسية / مقرر Deep Learning / الفصل 6 الجزء 1

الفصل 6 (الجزء 1): Convolutional Neural Networks

Convolution, padding, stride and pooling

على طول: إزاي filter صغير بيمسح الصورة ويطلّع features.

فيديو المحاضرة

فيديو المحاضرة

بعد الفيديو: الأمثلة والاختبار والتمارين والمشروع الصغير تحت.

رسوم متحركة

الـ filter بيمسح الصورة

أمثلة Python

أمثلة قصيرة وبسيطة

الكود قصير والنتيجة اتجرّبت فعلاً. عدّل في المحرر واضغط شغّل.

المثال ١: Convolution بإيدينا

Sample output (press Run to produce your own):
[[3. 3. 0.]
 [3. 3. 0.]
 [3. 3. 0.]]

المثال ٢: حجم الخرج

Sample output (press Run to produce your own):
8x8, filter 3        : 6
8x8, filter 3, pad 1 : 8
8x8, filter 3, stride 2: 3

المثال ٣: Max pooling

Sample output (press Run to produce your own):
[[ 0  1  2  3]
 [ 4  5  6  7]
 [ 8  9 10 11]
 [12 13 14 15]]
2x2 max pooling:
[[ 5  7]
 [13 15]]

افتح الفصل المقابل في كتاب d2l.ai

اختبار قصير

اختبر فهمك

1. Why does a convolution use few weights?

2. For an input of 8, filter 3, no padding, stride 1, the output size is:

3. What does padding with zeros do?

4. Max pooling:

5. In a CNN, the filter values are:

تمارين برمجة

جرّب بإيدك

التمرين 1

احسب حجم الخرج لمدخل 28 وfilter 5 وpadding 2 وstride 1.

Compute the output size for input 28, filter 5, padding 2, stride 1.

(output appears here)

التمرين 2

طبّق filter أفقي [[-1,-1,-1],[0,0,0],[1,1,1]] على patch 3x3 واحد وحدّد الناتج.

Apply the horizontal edge filter [[-1,-1,-1],[0,0,0],[1,1,1]] to this single 3x3 patch and print the result.

(output appears here)

مشروع صغير في آخر المحاضرة

اكشف الحواف في صورة رقم حقيقي

الداتا: Optical Recognition of Handwritten Digits: 1797 images of 8x8 pixels. Source: UCI Machine Learning Repository.

License / source: Ships with scikit-learn. Dataset page

الخطوات

  1. حمّل digits وخد أول صورة للرقم 1.
  2. اكتب دالة conv2d (بدون padding) بحلقتين.
  3. طبّق filter حواف رأسية وفلتر حواف أفقية.
  4. اطبع مجموع القيم المطلقة لكل خرج: أنهي filter قوي أكتر على الرقم 1؟
Expected output (press Run to produce your own):
vertical   edge strength: 67.56
horizontal edge strength: 14.12

Credits: the topic order follows the book "Dive into Deep Learning" (d2l.ai) by Zhang, Lipton, Li and Smola, whose text is licensed CC BY-SA 4.0. The explanations, diagrams and code in this lecture are our own and are not copied from the book. Reference: d2l.ai, Convolutional Neural Networks.