Back to tree

🔁 循环神经网络:带着记忆往前走🔁 RNN: Walking Forward with Memory

上一片里,放大镜小队横扫整张图,一眼把画面看全。可有些东西是按顺序来的——一句句的话、一段段的语音,看成“同时出现的一堆”,顺序就丢了。这片叶子给机器人一块记忆。 Last leaf, the squad of magnifying glasses swept a whole image at a glance. But some things arrive in order — words in a sentence, sounds in speech. Treat them as one simultaneous pile, and the order is lost. This leaf hands the robot a memory.

第 1 步:看一眼就走,还是一步一步走Step 1: One glance, or one step at a time

先看普通网络碰上“顺序”时,缺了什么。First, see what a plain network misses when order matters.

小机器人抱着笔记本,把记忆纸条传给下一步
普通网络把整句话当成一张大照片:所有词同时塞进去,一眼看完。可同样的几个词,“狗咬人”和“人咬狗”它分不出。RNN(循环神经网络)像传话接力:一次只读一个词,读完把要点写进“记忆纸条”,再连同下一个词一起交给下一步。顺序,从此有了意义。 A plain network treats a whole sentence like one big photo: every word goes in at once, one glance, done. But "dog bites man" and "man bites dog" use the same words — it can't tell which is which. An RNN (recurrent neural network) works like a relay: it reads one word, jots the gist on a memory note, and hands that note plus the next word to the next step. Now order finally means something.

一次读一个词——那每一步都要配一套新旋钮吗?One word at a time — does every step need its own brand-new knobs?

第 2 步:同一个盒子,反复用Step 2: One box, reused at every step

同一个盒子反复用:三个相同盒子由记忆带相连
不用。RNN 从头到尾只有一副“身体”:同一个盒子、同一套旋钮,在每个时刻反复使用。第 1 步用它,第 5 步还是它。句子再长也不怕:词有多少个,就把它跑多少遍。旋钮不随长度变多——这就是它能应付任意长度句子的秘密。 No. An RNN has just one body from start to finish: one box, one set of knobs, reused at every single step. Step 1 uses it; step 5 uses it again. Length is no problem — run it once per word. The knobs don't multiply with sentence length. That's the secret behind its tiny parameter count and its ability to handle any length.

纸条一路往下传,岂不是越记越多、什么都不会忘?If the note keeps travelling forward, doesn't it remember everything?

第 3 步:记性有限,太久就忘Step 3: A short memory — too far back, forgotten

记性有限:笔记本越记越薄,远处词牌被雾遮住
恰恰相反。纸条每传一步,就被重新抄写一遍。抄着抄着,前面的字就模糊了。传到第 10 个词时,第 1 个词几乎看不见了——这叫长期依赖问题(long-term dependency)。所以 RNN 接得住“我喜欢猫”,却接不住“小时候奶奶家养过一只……所以我喜欢猫”。后面登场的注意力机制,就是来补这块短板的。 Quite the opposite. Every step, the note is copied over again — and copies fade. By the tenth word, the first word has almost vanished. This is the long-term dependency problem. So an RNN easily connects "I like cats", yet drops the thread of "when I was little I kept one at my grandma's... so I like cats". The attention mechanism, arriving later, exists to patch exactly this weak spot.

🎮 你来当传话员(30 秒)🎮 Your turn: carry the message (30 seconds)

讲完了。点“下一步”,让 5 个词一个个走进机器人,看记忆条一步步变厚;走完以后,帮它猜出下一个词。Theory done. Press "Next step" to walk 5 words into the robot and watch the memory bar thicken — then help it guess the word that comes next.

一句话记住它:RNN = 带着记忆纸条往前走的网络:一次读一个词,同一个盒子反复用,走到哪记到哪。 Remember it in one line: an RNN = a network that walks forward with a memory note: one word at a time, one box reused, writing as it goes.
普通网络一眼看完;RNN 每步读入“新词+上一步的记忆”,所以懂顺序A plain network glances once; an RNN reads "new word + last step's memory", so order matters 同一套旋钮在每个时刻复用——句子多长都跑得动The same knobs are reused at every step — any sentence length works 记性有限:传得太久会淡忘(长期依赖),后面靠注意力机制来救Memory fades over long gaps (long-term dependency) — attention comes to the rescue later

← 浏览全部 302 个知识点← Browse all 302 topics

内容参考 OpenStax 等公开教材,多来源核对 · AI 生成、人工审核 · 发现错误欢迎指正,帮这片叶子长得更好。 Based on OpenStax and other open textbooks, cross-checked across sources · AI-generated, human-reviewed · Spotted a mistake? Tell us — help this leaf grow.