فيديو المحاضرة
فيديو المحاضرة
بعد الفيديو: الأمثلة والاختبار والتمارين والمشروع الصغير تحت.
رسوم متحركة
أمثلة Python
أمثلة قصيرة وبسيطة
الكود قصير والنتيجة اتجرّبت فعلاً. عدّل في المحرر واضغط شغّل.
المثال ١: عدد الأوزان
Sample output (press Run to produce your own): 3x3 conv 1 -> 8 : 80 3x3 conv 8 -> 16 : 1168 dense 64 -> 8 : 520
المثال ٢: بلوك conv + ReLU + pooling
Sample output (press Run to produce your own): after conv: (6, 6) after pooling: (3, 3)
المثال ٣: كم يتحوّل الحجم
Sample output (press Run to produce your own): block 1 -> size 12 x 12 , channels 6 block 2 -> size 4 x 4 , channels 16 flattened: 256
اختبار قصير
اختبر فهمك
1. A conv layer with 16 filters produces:
2. A 3x3 conv from 1 to 8 channels has how many weights?
3. Typical CNN blocks make the maps:
4. What does the final fully connected layer do?
5. LeNet showed that:
تمارين برمجة
جرّب بإيدك
التمرين 1
احسب عدد أوزان conv بـ filter 5x5 من 3 channels لـ 6 channels.
Compute the number of weights of a 5x5 conv from 3 channels to 6 channels.
(output appears here)
k, c_in, c_out = 5, 3, 6 print((k * k * c_in + 1) * c_out)
Output
456
التمرين 2
طبّق max pooling ٢×٢ على مصفوفة 4×4 من 0 لـ 15 واطبع الناتج.
Apply 2x2 max pooling to the 4x4 array of 0..15 and print the result.
(output appears here)
import numpy as np x = np.arange(16).reshape(4, 4) print(x.reshape(2, 2, 2, 2).max(axis=(1, 3)))
Output
[[ 5 7] [13 15]]
مشروع صغير في آخر المحاضرة
Features بـ filters ثابتة ثم classifier على الأرقام
الداتا: Optical Recognition of Handwritten Digits: 1797 images of 8x8 pixels, 10 classes. Source: UCI Machine Learning Repository.
License / source: Ships with scikit-learn. Dataset page
الخطوات
- حمّل digits، اقسم ٨٠/٢٠.
- اعمل ٤ filters: حواف رأسية وأفقية ومائلتين.
- لكل صورة: conv ثم ReLU ثم max pooling ٢×٢، وبعدين افرد الخرج.
- درّب LogisticRegression على الـ features الجديدة وقارنها بـ pixels الخام.
Expected output (press Run to produce your own): conv features : 0.978 raw pixels : 0.964
مشروع نهاية الفصل
ملف المشروع العملي للفصل 6
ملف PDF فيه مشروع صغير بأسئلة عملية تطبّق بيها كل اللي اتعلمته في الفصل، مع حل نموذجي في الآخر.
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 (LeNet).