เกตที่ควบคุมหน่วยความจำ
LSTM ตัดสินใจว่าจะเก็บอะไรไว้อย่างไร
เกตที่ควบคุมหน่วยความจำ เป็นบทเรียน NLP Academy ฟรีบน CoddyKit นี่คือบทเรียนที่ 1 จากทั้งหมด 4 บทเรียน คุณสามารถอ่านบทเรียนทั้งหมดด้านล่างฟรี — จากนั้นลองปฏิบัติด้วยตัวคุณเองในเบราว์เซอร์พร้อมตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7 บทเรียนนี้เป็นส่วนหนึ่งของเส้นทางการเรียน NLP Academy และความก้าวหน้าของคุณจะซิงค์ข้ามเว็บและแอป CoddyKit คอร์ส NLP Academy มีบทเรียนทั้งหมด 4 บทเรียน
บางส่วนของบทเรียนนี้ยังไม่ได้รับการแปล และแสดงเป็นภาษาอังกฤษ
Plain RNNs Forget
A simple RNN struggles to remember things from far back. The LSTM was built to fix that by carefully managing what it keeps and forgets. 🧠
The Cell State
An LSTM carries a special cell state, a memory line that runs straight through every step so important signals survive long sequences.
Gates Are the Trick
The magic is in the gates: tiny learned switches that decide what to add, keep, or drop from memory at each time step.
How a Gate Works
Each gate uses a sigmoid to output values from 0 to 1, acting like a dimmer that lets some information through and blocks the rest.
gate = sigmoid(W @ x + U @ h + b) # values in [0, 1]The Forget Gate
The forget gate looks at the new input and decides how much of the old memory to erase. A 0 wipes it; a 1 keeps it fully.
The Input Gate
The input gate controls how much fresh information gets written into the cell state, so only useful new signals are stored.
The Candidate Values
A candidate vector proposes what new content could enter memory. The input gate then scales how much of it actually gets added.
candidate = tanh(W @ x + U @ h + b)Updating Memory
The new cell state blends old memory kept by the forget gate with fresh candidate values let in by the input gate.
c = forget * c_prev + input * candidateThe Output Gate
The output gate decides what part of the cell state becomes the visible hidden state passed to the next step and the layer above.
Why Gates Beat Forgetting
Because gates keep the cell state mostly additive, gradients flow back many steps without vanishing. That is how an LSTM remembers long context.
Three Gates, One Cell
So an LSTM has three gates guarding one memory line: forget, input, and output, each learned from data during training.
Quick Check
Test your grip on LSTM gates.
Recap
An LSTM protects a cell state with forget, input, and output gates. Those switches keep long-range memory alive where plain RNNs fail. ✅
คำถามที่พบบ่อย
บทเรียน “เกตที่ควบคุมหน่วยความจำ” ฟรีหรือไม่
ใช่ — ข้อความเต็มของ “เกตที่ควบคุมหน่วยความจำ” ฟรีให้อ่านที่นี่บนเว็บ เพื่อปฏิบัติแบบโต้ตอบ (ตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7) และปลดล็อคส่วนที่เหลือของคอร์ส NLP Academy ให้อัปเกรดเป็น CoddyKit PRO คอร์ส NLP Academy มีบทเรียนทั้งหมด 4 บทเรียน
คุณจะเรียนรู้อะไรในบทเรียน “เกตที่ควบคุมหน่วยความจำ”
LSTM ตัดสินใจว่าจะเก็บอะไรไว้อย่างไร คุณปฏิบัติ NLP Academy ด้วยโค้ดที่ใช้งานได้จริงที่คุณเรียกใช้โดยตรงในเบราว์เซอร์ และติวเตอร์ AI ตลอด 24/7 ตอบคำถามของคุณขณะที่คุณไปผ่านบทเรียน
คุณต้องมีประสบการณ์ก่อนที่จะเริ่มเรียน NLP Academy หรือไม่
ไม่จำเป็นต้องมีประสบการณ์มาก่อน NLP Academy บน CoddyKit ออกแบบมาสำหรับผู้เริ่มต้นไปจนถึงผู้เรียนขั้นสูง คุณสามารถเริ่มต้นที่นี่หรือเริ่มจากตัวแรกและเรียนด้วยความเร็วของคุณเอง นี่คือบทเรียนที่ 1 จากทั้งหมด 4 บทเรียน
บทเรียน “เกตที่ควบคุมหน่วยความจำ” ใช้เวลานานแค่ไหน
บทเรียน CoddyKit ส่วนใหญ่ใช้เวลาประมาณ 5–10 นาที แต่ละบทเรียนจึงสั้นและเป็นแบบโต้ตอบ คุณสามารถก้าวหน้าอย่างต่อเนื่องและกลับมาเรียนต่อจากตรงที่เพิ่งหยุดบนเว็บและแอปได้เลย
ฉันเขียนและรันโค้ดในบทเรียน NLP Academy นี้ได้ไหม
ได้ บทเรียน NLP Academy ทุกบทมีตัวแก้ไขโค้ดในตัว คุณจึงเขียนและรันโค้ดจริงได้เลยในเบราว์เซอร์ และได้รับข้อเสนอแนะจาก AI ในทันที — ไม่ต้องติดตั้งในเครื่องของคุณ
บทเรียนทั้งหมดในหลักสูตรนี้
- เกตที่ควบคุมหน่วยความจำ
- GRU: ทางเลือกที่กระชับกว่า
- ฝึกตัวจำแนก LSTM
- ชั้นแบบสองทิศทางและซ้อนกัน