فيديو المحاضرة
فيديو المحاضرة
بعد الفيديو: الأمثلة والاختبار والتمارين والمشروع الصغير تحت.
رسوم متحركة
أمثلة Python
أمثلة قصيرة وبسيطة
الكود قصير والنتيجة اتجرّبت فعلاً. عدّل في المحرر واضغط شغّل.
المثال ١: Backward لطبقة الخرج
Sample output (press Run to produce your own): dZ2: [[ 0.7 -0.8 0.1]] dW2: [[ 0.7 -0.8 0.1] [ 1.4 -1.6 0.2]]
المثال ٢: gradient check
Sample output (press Run to produce your own): backprop: -3.45104 nudging : -3.45104
المثال ٣: شبكة صغيرة بتتعلّم XOR
Sample output (press Run to produce your own): [0. 1. 1. 0.]
اختبار قصير
اختبر فهمك
1. For softmax with cross-entropy, the output error dZ2 is:
2. The hidden error dH is computed as:
3. The ReLU derivative is:
4. A gradient check compares backprop with:
5. Why not start all weights at zero?
تمارين برمجة
جرّب بإيدك
التمرين 1
احسب مشتقة الـ ReLU على Z = [-1, 2, 0.5, -3] (١ لو موجب، ٠ غير كده) واطبعها.
Compute the ReLU derivative for Z = [-1, 2, 0.5, -3] (1 if positive, else 0). Print it.
(output appears here)
import numpy as np Z = np.array([-1.0, 2.0, 0.5, -3.0]) print((Z > 0).astype(float))
Output
[0. 1. 1. 0.]
التمرين 2
احسب dZ2 لو P = [0.1, 0.6, 0.3] والفئة الصح 2 (one-hot [0, 0, 1]).
Compute dZ2 for P = [0.1, 0.6, 0.3] and true class 2 (one-hot [0, 0, 1]).
(output appears here)
import numpy as np P = np.array([0.1, 0.6, 0.3]) Y = np.array([0.0, 0.0, 1.0]) print(P - Y)
Output
[ 0.1 0.6 -0.7]
مشروع صغير في آخر المحاضرة
درّب MLP من الصفر (backprop بإيدك) على الأرقام
الداتا: 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، اقسم ٨٠/٢٠، واقسم الـ pixels على 16.
- اعمل W1 (64, 32) و W2 (32, 10) بأوزان عشوائية صغيرة.
- درّب ٣٠٠ خطوة: forward بـ ReLU وsoftmax، وbackward بإيدك، وlr = 0.5.
- اطبع دقة الـ test.
Expected output (press Run to produce your own): test accuracy: 0.958
مشروع نهاية الفصل
ملف المشروع العملي للفصل 3
ملف 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, Forward Propagation, Backward Propagation, and Computational Graphs.