LSTM- und GRU-Gates
Behalten Sie Abhängigkeiten über große Distanzen bei.
LSTM- und GRU-Gates ist eine kostenlose Deep Learning Academy-Lektion auf CoddyKit. Dies ist Lektion 3 von 4. Du kannst die komplette Lektion unten kostenlos lesen – dann übst du sie direkt im Browser mit einem integrierten Code-Editor und einem KI-Tutor rund um die Uhr. Sie ist Teil des Deep Learning Academy-Lernpfads, und dein Fortschritt wird über Web und CoddyKit-App synchronisiert. Der Deep Learning Academy-Kurs umfasst insgesamt 4 Lektionen.
Teile dieser Lektion wurden noch nicht übersetzt und werden auf Englisch angezeigt.
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. ✅
Häufig gestellte Fragen
Ist die Lektion „LSTM- und GRU-Gates“ kostenlos?
Ja — der vollständige Text von „LSTM- und GRU-Gates“ ist hier im Web kostenlos zu lesen. Um sie interaktiv zu üben (integrierter Code-Editor und 24/7 KI-Tutor) und den Rest des Deep Learning Academy-Kurses freizuschalten, upgrade auf CoddyKit PRO. Der Deep Learning Academy-Kurs umfasst insgesamt 4 Lektionen.
Was lerne ich in „LSTM- und GRU-Gates“?
Behalten Sie Abhängigkeiten über große Distanzen bei. Du übst Deep Learning Academy mit praktischem Code, den du direkt im Browser ausführst, und ein 24/7 KI-Tutor beantwortet deine Fragen während du die Lektion bearbeitest.
Brauche ich Erfahrung, um Deep Learning Academy zu starten?
Keine Vorkenntnisse erforderlich. Deep Learning Academy auf CoddyKit ist für Anfänger bis fortgeschrittene Lernende strukturiert, sodass du hier starten oder von Anfang an beginnen und in deinem eigenen Tempo voranschreiten kannst. Dies ist Lektion 3 von 4.
Wie lange dauert die Lektion „LSTM- und GRU-Gates“?
Die meisten CoddyKit-Lektionen dauern etwa 5–10 Minuten. Jede ist kompakt und interaktiv, sodass du stetig Fortschritte machst und genau dort weitermachst, wo du aufgehört hast – im Web und in der App.
Kann ich in dieser Deep Learning Academy-Lektion Code schreiben und ausführen?
Ja. Jede Deep Learning Academy-Lektion enthält einen integrierten Code-Editor, sodass du echten Code direkt in deinem Browser schreibst und ausführst und sofort KI-Feedback erhältst — ohne lokale Einrichtung erforderlich.
Alle Lektionen in diesem Kurs
- Warum Sequenzen ein Gedächtnis brauchen
- Die einfache RNN-Zelle
- LSTM- und GRU-Gates
- Sequenzen packen und Padding verarbeiten