0Pricing
Deep Learning Academy · درس

بوابات LSTM وGRU

تذكّر الاعتماديات بعيدة المدى

بوابات LSTM وGRU درس مجاني في Deep Learning Academy على CoddyKit. هذا هو الدرس 3 من أصل 4. يمكنك قراءة الدرس كاملاً أدناه مجاناً — ثم تمرن عليه مباشرة في المتصفح باستخدام محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7. هذا الدرس جزء من مسار التعلم في Deep Learning Academy، وتقدمك يتزامن عبر الويب وتطبيق CoddyKit. تتضمن دورة Deep Learning Academy 4 دروس في المجموع.

بعض أجزاء هذا الدرس لم تُترجم بعد وتظهر باللغة الإنجليزية.

The Long-Memory Problem

Vanilla RNNs forget early clues over long sequences. Gated cells fix this by deciding what to keep, update, or throw away.

Meet the LSTM

The LSTM adds a separate cell state, a memory highway that runs straight across time with only small, controlled edits.

Gates Are Soft Switches

A gate is a sigmoid layer outputting values from 0 to 1. Zero blocks information, one lets it pass, and in between mixes the two.

gate = torch.sigmoid(W @ x + U @ h)

The Forget Gate

The forget gate looks at the input and memory and chooses which parts of the old cell state to erase before adding anything new.

The Input Gate

The input gate decides how much of the fresh candidate information should be written into the cell state at this step.

The Output Gate

The output gate controls how much of the updated cell state becomes the visible hidden state passed to the next step. 🚪

Why Gates Help Gradients

Because the cell state changes gently, gradients flow back across many steps without vanishing, so the model learns long-range patterns.

Meet the GRU

The GRU is a lighter cousin: it merges gates and drops the separate cell state, giving similar power with fewer parameters.

GRU's Two Gates

A GRU uses just two gates, a reset gate and an update gate, to balance old memory against new input each step.

Drop-In in PyTorch

Both are one-liners in PyTorch. Swap nn.LSTM or nn.GRU for nn.RNN and keep almost the same training code.

lstm = nn.LSTM(input_size=10, hidden_size=20)

Which to Choose?

GRUs are faster and often match LSTMs; LSTMs can edge ahead on the hardest long sequences. Try both and let your validation score decide.

Quick Check

What is the job of the forget gate in an LSTM?

Recap

LSTMs and GRUs use gates to control memory, letting gradients survive long sequences and capturing far-apart dependencies. ✅

الأسئلة الشائعة

هل درس «بوابات LSTM وGRU» مجاني؟

نعم — نص درس «بوابات LSTM وGRU» كامل متاح مجاناً هنا على الويب. لتمرينه بشكل تفاعلي (محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7) وفتح باقي دورة Deep Learning Academy، انتقل إلى CoddyKit PRO. تتضمن دورة Deep Learning Academy 4 دروس في المجموع.

ماذا ستتعلم في «بوابات LSTM وGRU»؟

تذكّر الاعتماديات بعيدة المدى تتمرن على Deep Learning Academy مع أكواد عملية تشغلها مباشرة في المتصفح، ومدرس ذكاء اصطناعي متاح 24/7 يجيب على أسئلتك أثناء عملك.

هل أحتاج إلى خبرة سابقة لأبدأ Deep Learning Academy؟

لا تُشترط خبرة سابقة. Deep Learning Academy على CoddyKit منظم للمبتدئين حتى المتقدمين، لذا يمكنك البدء من هنا أو من البداية والتقدم بسرعتك الخاصة. هذا هو الدرس 3 من أصل 4.

كم من الوقت يستغرق درس «بوابات LSTM وGRU»؟

معظم دروس CoddyKit تستغرق حوالي 5–10 دقائق. كل منها موجز وتفاعلي، لذا تحرز تقدماً مستمراً وتستأنف من حيث توقفت عبر الويب والتطبيق.

هل يمكنني كتابة وتشغيل أكواد في درس Deep Learning Academy هذا؟

نعم. كل درس في Deep Learning Academy يتضمن محرر أكواد مدمج، لذا تكتب وتشغل أكواداً حقيقية مباشرة في متصفحك وتحصل على تعليقات فورية من الذكاء الاصطناعي — بدون إعداد محلي.

جميع الدروس في هذه الدورة

  1. لماذا تحتاج التسلسلات إلى ذاكرة
  2. خلية RNN التقليدية
  3. بوابات LSTM وGRU
  4. تجميع التسلسلات والتعامل مع Padding
← العودة إلى Deep Learning Academy