فيديو المحاضرة
فيديو المحاضرة
بعد الفيديو: الأمثلة والاختبار والتمارين والمشروع الصغير تحت.
رسوم متحركة
أمثلة Python
أمثلة قصيرة وبسيطة
الكود قصير والنتيجة اتجرّبت فعلاً. عدّل في المحرر واضغط شغّل.
المثال ١: Residual block
Sample output (press Run to produce your own): x: [[ 0.13 -0.13 0.64 0.1 ]] y: [[ 0.13 -0.13 0.64 0.1 ]]
المثال ٢: الـ gradient عبر 30 طبقة
Sample output (press Run to produce your own): plain gradient size after 30 layers: 7.91e-16 residual gradient size after 30 layers: 23.6
المثال ٣: Transfer learning صغير
Sample output (press Run to produce your own): reused features: 0.805 raw pixels : 0.871
اختبار قصير
اختبر فهمك
1. A residual block computes:
2. Why do skip connections help training deep nets?
3. Transfer learning means:
4. When fine-tuning, what learning rate is usually used?
5. Transfer learning helps most when:
تمارين برمجة
جرّب بإيدك
التمرين 1
احسب خرج residual block: x = [1, 2] و F(x) = [0.5, -1].
Compute the output of a residual block: x = [1, 2] and F(x) = [0.5, -1].
(output appears here)
import numpy as np x = np.array([1.0, 2.0]) F = np.array([0.5, -1.0]) print(x + F)
Output
[1.5 1. ]
التمرين 2
لو الـ hidden layer فيها 32 وزن لكل unit و4 units مجمّدة، كام وزن بيتدرّب في classifier جديد بـ 5 فئات فوق الـ 32 unit؟
A frozen hidden layer gives 32 features. How many weights (with biases) does a new 5-class classifier on top of it train?
(output appears here)
features, classes = 32, 5 print((features + 1) * classes)
Output
165
مشروع صغير في آخر المحاضرة
Transfer learning: استخدم شبكة متدرّبة على ٠-٤ لتصنيف ٥-٩
الداتا: Optical Recognition of Handwritten Digits: 1797 images of 8x8 pixels. Source: UCI Machine Learning Repository.
License / source: Ships with scikit-learn. Dataset page
الخطوات
- قسّم الأرقام: مصدر (٠-٤) ومهمة جديدة (٥-٩).
- درّب MLP صغيرة (32 unit) على المصدر.
- خد الـ hidden layer كـ feature extractor.
- درّب LogisticRegression على ٦٠ مثال بس من ٥-٩ بالـ features دي وبالـ pixels الخام وقارن الدقة. (ملاحظة: النتيجة هنا مش في صالح الـ transfer، لأن ٠-٤ مختلفة عن ٥-٩ والـ pixels الخام أحسن. الـ transfer بيفيد لما المهمتين قريبتين والداتا الجديدة قليلة جداً.)
Expected output (press Run to produce your own): reused features: 0.785 raw pixels : 0.865
مشروع نهاية الفصل
ملف المشروع العملي للفصل 7
ملف 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, Residual Networks (ResNet) and ResNeXt.