فيديو المحاضرة
فيديو المحاضرة
بعد الفيديو: الأمثلة والاختبار والتمارين والمشروع الصغير تحت.
رسوم متحركة
أمثلة Python
أمثلة قصيرة وبسيطة
الكود قصير والنتيجة اتجرّبت فعلاً. عدّل في المحرر واضغط شغّل.
المثال ١: بوابة
Sample output (press Run to produce your own): gate 0.01 -> [ 0.01 -0.01 0. ] gate 0.5 -> [ 1. -0.5 0.25] gate 0.99 -> [ 1.99 -0.99 0.5 ]
المثال ٢: خطوة GRU
Sample output (press Run to produce your own): z = 0.05 -> h = [0.24 0.81] z = 0.5 -> h = [ 0.6 -0.05] z = 0.95 -> h = [ 0.96 -0.91]
المثال ٣: الـ perplexity
Sample output (press Run to produce your own): loss 1.325 perplexity 3.76
اختبار قصير
اختبر فهمك
1. A gate value near 0 means:
2. In a GRU, z near 1 means:
3. Which part is extra in an LSTM?
4. Why do gates help gradients?
5. Perplexity is:
تمارين برمجة
جرّب بإيدك
التمرين 1
احسب sigmoid(0) واطبع الناتج.
Compute sigmoid(0) and print it.
(output appears here)
import numpy as np print(1 / (1 + np.exp(-0.0)))
Output
0.5
التمرين 2
خطوة GRU: z = 0.9، h_old = 1.0، candidate = -1.0. اطبع h.
One GRU step: z = 0.9, h_old = 1.0, candidate = -1.0. Print h.
(output appears here)
z, h_old, candidate = 0.9, 1.0, -1.0 print(round(z * h_old + (1 - z) * candidate, 2))
Output
0.8
مشروع صغير في آخر المحاضرة
RNN عادية مقابل RNN بتحتفظ بالقديم (leaky)
الداتا: Optical Recognition of Handwritten Digits: 1797 images of 8x8 pixels. Source: UCI Machine Learning Repository.
License / source: Ships with scikit-learn. Dataset page
الخطوات
- استخدم نفس الإعداد: صفوف الأرقام كخطوات وأوزان ثابتة.
- في النسخة الـ leaky الحالة الجديدة = (1 - leak) × القديمة + leak × الجديدة، وده شبه بوابة update ثابتة.
- درّب LogisticRegression على آخر حالة في الحالتين.
- قارن. المتوقع: العادية حوالي 0.875 والـ leaky حوالي 0.90. (ملاحظة: البوابة هنا ثابتة مش متعلّمة).
Expected output (press Run to produce your own): plain RNN : 0.875 leaky RNN : 0.9
مشروع نهاية الفصل
ملف المشروع العملي للفصل 8
ملف 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, Modern Recurrent Neural Networks.