0Pricing
Deep Learning Academy · บทเรียน

เกตของ LSTM และ GRU

จดจำความสัมพันธ์ระยะไกล

เกตของ LSTM และ GRU เป็นบทเรียน Deep Learning Academy ฟรีบน CoddyKit นี่คือบทเรียนที่ 3 จากทั้งหมด 4 บทเรียน คุณสามารถอ่านบทเรียนทั้งหมดด้านล่างฟรี — จากนั้นลองปฏิบัติด้วยตัวคุณเองในเบราว์เซอร์พร้อมตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 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” ฟรีให้อ่านที่นี่บนเว็บ เพื่อปฏิบัติแบบโต้ตอบ (ตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7) และปลดล็อคส่วนที่เหลือของคอร์ส Deep Learning Academy ให้อัปเกรดเป็น CoddyKit PRO คอร์ส Deep Learning Academy มีบทเรียนทั้งหมด 4 บทเรียน

คุณจะเรียนรู้อะไรในบทเรียน “เกตของ LSTM และ GRU”

จดจำความสัมพันธ์ระยะไกล คุณปฏิบัติ Deep Learning Academy ด้วยโค้ดที่ใช้งานได้จริงที่คุณเรียกใช้โดยตรงในเบราว์เซอร์ และติวเตอร์ AI ตลอด 24/7 ตอบคำถามของคุณขณะที่คุณไปผ่านบทเรียน

คุณต้องมีประสบการณ์ก่อนที่จะเริ่มเรียน Deep Learning Academy หรือไม่

ไม่จำเป็นต้องมีประสบการณ์มาก่อน Deep Learning Academy บน CoddyKit ออกแบบมาสำหรับผู้เริ่มต้นไปจนถึงผู้เรียนขั้นสูง คุณสามารถเริ่มต้นที่นี่หรือเริ่มจากตัวแรกและเรียนด้วยความเร็วของคุณเอง นี่คือบทเรียนที่ 3 จากทั้งหมด 4 บทเรียน

บทเรียน “เกตของ LSTM และ GRU” ใช้เวลานานแค่ไหน

บทเรียน CoddyKit ส่วนใหญ่ใช้เวลาประมาณ 5–10 นาที แต่ละบทเรียนจึงสั้นและเป็นแบบโต้ตอบ คุณสามารถก้าวหน้าอย่างต่อเนื่องและกลับมาเรียนต่อจากตรงที่เพิ่งหยุดบนเว็บและแอปได้เลย

ฉันเขียนและรันโค้ดในบทเรียน Deep Learning Academy นี้ได้ไหม

ได้ บทเรียน Deep Learning Academy ทุกบทมีตัวแก้ไขโค้ดในตัว คุณจึงเขียนและรันโค้ดจริงได้เลยในเบราว์เซอร์ และได้รับข้อเสนอแนะจาก AI ในทันที — ไม่ต้องติดตั้งในเครื่องของคุณ

บทเรียนทั้งหมดในหลักสูตรนี้

  1. เหตุใดลำดับจึงต้องอาศัยหน่วยความจำ
  2. เซลล์ RNN แบบพื้นฐาน
  3. เกตของ LSTM และ GRU
  4. จัดแพ็กลำดับและรับมือกับแพดดิง
← กลับไปที่ Deep Learning Academy