PRODUCT

Design

Content

Publish

RESOURCES

Blog

Careers

Docs

About

Writings

The Hedonistic Neuron

The Hedonistic Neuron

享乐的神经元

Preface: By the late 1970s, computer science had forgotten that you can learn from rewards, except for one stubborn man. Following the previous #AI series and #MarvinMinsky series. This post is co-written with Claude.


The story of reinforcement learning is usually told starting from AlphaGo, or from the 2025 Turing Award: two pioneers, a lifetime of work, finally honored with computer science's highest prize. But when these two men started out, they weren't founding a field. They were hired to evaluate someone else's idea, one that most of their peers didn't take seriously. They spent years on a project nobody cared about, going back to read animal psychology from half a century earlier, and digging back up the idea Samuel had sealed inside his checkers program. Barto later recalled that the field was "not fashionable" at the time, and that they were "kind of in the wilderness."


Klopf: The Hedonistic Neuron

A. Harry Klopf, born in 1941, was a scientist at Wright-Patterson Air Force Base in Ohio, responsible for machine intelligence research in the avionics directorate. He had an idea that ran against the mainstream of his day.



In the 1960s and 70s, most people who studied adaptive systems believed that the goal of a learning system was to maintain balance. If the temperature is too high, bring it down; too low, bring it up; if the error is too big, correct it until the error is zero. This is called homeostasis. Neural network research of that era followed the same logic: give the machine a correct answer, and however wrong it is, correct it by that much, until it stops making mistakes.

Klopf thought this missed the point. Living things aren't after balance. They're after more: more food, more pleasure, less pain. He gave this state a name, "heterostasis," meaning pushing certain things as high as they will go rather than holding them in the middle. And he went a step further: it isn't just the whole animal that seeks pleasure. Every neuron in the brain is a tiny hedonist, too. It strengthens the connections that bring it a "pleasure" signal and weakens the ones that bring "pain."

This sounds a lot like Thorndike's Law of Effect, just shrunk down from a cat to a single cell. And it differed in one fundamental way from the error correction that was fashionable at the time. Error correction requires someone to tell the machine what the right answer is. Seeking pleasure only requires telling it whether the outcome was good or bad; working out what's right is up to the machine, by trial. Just as Thorndike, standing outside the puzzle box, never taught his cat which string to pull.

Klopf had no experimental evidence and no algorithm that could actually run. But he had one thing: he was inside the Air Force, and he knew how to get money for a curious idea.


1977: A Project That Only Delivered Reports

In 1977, the Air Force Office of Scientific Research began funding a project at the University of Massachusetts Amherst. Three computer science professors, Michael Arbib, William Kilmer, and Nico Spinelli, were its principal investigators. The project's mission was unusual. It wasn't to build a machine or solve a military problem, but to evaluate whether Klopf's theory had any scientific merit, comparing it against all previous research on learning and adaptive systems. The only deliverables were a report each year and a final report.

To do this, the project hired a postdoc: Andrew Barto.



Barto was born in 1948 and went to the University of Michigan as an undergraduate, where he started out studying shipbuilding, in naval architecture and engineering. Later he became interested in something else: using computers and mathematics to model the brain. In 1970 he graduated with distinction in mathematics, and in 1975 he earned a PhD in computer science at Michigan, with a dissertation on cellular automata, a mathematical model made of many simple cells that influence one another according to rules. He spent two years as an assistant professor at the State University of New York at Binghamton, then came to Amherst.

It was a strange job. The project asked for almost nothing beyond a report each year. Barto later described it as pure curiosity-driven basic research. They could spend nearly all their time on one thing: reading. Reading Klopf's ideas, reading all the literature connected to them, and then figuring out what, exactly, was new about them.


1978: A Psychology Student

Not long after Barto arrived, a young man joined the project: Richard Sutton.



Sutton was born around 1957 in Toledo, Ohio, and grew up near Chicago. At Stanford he studied not computer science but psychology, with a minor in computer science. He graduated in 1978 and had just been admitted to the computer science graduate program at Amherst. He became Barto's first doctoral student. A little later, Charles Anderson, a fresh computer science graduate from the University of Nebraska, joined as well.

A mathematician who had started out in shipbuilding and a student of psychology: the pairing happened to fit exactly what they had been asked to evaluate. Half of Klopf's idea came from animal psychology, and the other half pointed toward a machine that could compute. Sutton knew the work of Thorndike, Pavlov, and Skinner well and understood how animals learn; Barto knew how to turn an idea into mathematics.

The more they read, the more they noticed something odd. The kind of learning Klopf was describing, where no teacher supplies the correct answer and the learner is only told whether the outcome was good or bad and left to pursue long-term reward on its own, had long been common knowledge in psychology. As earlier posts in this series showed, it had also made its way into engineering and artificial intelligence: Minsky's SNARC, Samuel's checkers, Michie's matchboxes. But by the end of the 1970s, it had all but vanished from computer science. When people talked about "learning," they almost always meant something else: showing a machine the correct answers and having it learn to imitate them.

Klopf hadn't invented a new idea. He had simply, stubbornly, remembered it in an era when everyone else had forgotten.


Rereading Pavlov: Surprise Is the Teacher

The most important thing they found in psychology wasn't Thorndike. It was Pavlov.

As the first post explained, reinforcement learning needs two things: prediction and choice. Thorndike's cat stands for choice, Pavlov's dog for prediction. The earlier machines, SNARC and the matchboxes, learned choice: which move to make. But they all got stuck in the same place: the reward came too late.

Barto and Sutton realized that the answer might be hiding in the dog's half.

In the decades after Pavlov, psychologists ran a great many conditioning experiments and discovered a crucial phenomenon. Suppose an animal has already learned that when a bell rings, food follows. Now, along with the bell, a light comes on, and then the food arrives. After many repetitions, the light is shown on its own, and the animal barely reacts. It hasn't learned the connection between the light and the food.

Why? Because the food was already predicted by the bell. The light told the animal nothing new, and when the food arrived, nothing about it was a surprise.

In 1972, the psychologists Robert Rescorla and Allan Wagner captured phenomena like this in a concise model. Its core is a single sentence: how much an animal learns depends on how surprised it is. Prediction error is the gap between what actually happens and what was predicted. The bigger the gap, the more is learned; with no gap, nothing is learned at all. Surprise is the teacher. A reward that was completely expected teaches an animal nothing.

In 1981, Barto and Sutton proposed their own model of conditioning, pushing this idea a step further. Rescorla and Wagner's model looked only at the final outcome of each trial: did the food come or not? But in a real experiment, time is continuous. The moment the bell rings, the dog's prediction about the future has already changed; it doesn't wait for the food to arrive. What they wanted to describe was this kind of prediction, updated moment by moment.

Picture what happens during a single trial. The bell rings, and five seconds later, the food arrives. In Rescorla and Wagner's model, those five seconds are a single unit: each trial counts as one round, and at the end of the round, the model checks whether the food came and calculates the surprise once. What happens inside those five seconds doesn't matter to it.

But it matters to the dog. The moment the bell rings, the dog's anticipation rises and it starts to drool, and the closer the food gets, the more it drools. If the gap between the bell and the food is too long, the dog has a hard time connecting the two; if the food comes first and the bell afterward, the dog learns almost nothing. The order and the length of time are crucial to learning, and a model that only settles accounts at the end of each round can't see any of it.

There was an even stranger phenomenon, one Pavlov himself had discovered. First, the dog learns that food follows the bell. Then the training changes: first a light comes on, then the bell rings, but no food is given. After a few repetitions, when the light comes on by itself, the dog drools too. Yet the light had never once appeared together with food.



This is called second-order conditioning. Think of ordering takeout. At first, what makes you happy is the food itself. After you've ordered a few times, the knock at the door makes you happy, because the knock means the food is here. Later still, when your phone shows "Your driver is 500 meters away," that makes you happy too. But you can't eat a notification. It isn't even the knock. All it tells you is that the knock is coming soon. You're happy about good news that's on its way.

It's the same with the dog and the light. The light is the notification, the bell is the knock, and the food is the food. The light never appeared together with food; it only ever appeared together with the bell. But in the dog's mind, the bell was already a good thing, so the light that announced the bell became a good thing too.

This shows that an animal's learning signal comes not only from real rewards, but also from changes in prediction. When the bell rings after the light, the dog's expectations about the future suddenly improve, and that improvement is itself a kind of reward, enough to give the light meaning.

This is what Barto and Sutton's model set out to capture, in two parts. First, predictions aren't updated only at the end of a round; they are updated at every moment in time. Second, one prediction can learn from another: the light's value comes from the bell's value, and the bell's value comes from the food. Value is passed back like this, one step at a time.

This is exactly what the Bellman equation says: the value of a situation equals the reward right now, plus the value of the next situation. Only this time it wasn't written on paper by a mathematician. It was worked out by a dog in a laboratory.

This problem is the same as the one in Samuel's checkers program. Every time Samuel's program made a move, it updated its judgment of the position; every time Pavlov's dog heard a signal, it updated its expectation of food. One was a program an engineer wrote at IBM, the other was animal behavior a psychologist observed in a lab, and they were doing the same thing.


1983: The Actor and the Critic

In 1983, Barto, Sutton, and Anderson published a paper titled "Neuronlike Adaptive Elements That Can Solve Difficult Learning Control Problems." The problem they chose was the very one Michie's BOXES had tackled fifteen years earlier: balancing a pole on a cart.




The cart, the pole, and the track were all simulated on a computer, just as in BOXES. The rules were the same too: at every moment, the cart could only be pushed left or right with a fixed force, and the states of the cart and pole were chopped into cells. The hardest part was this: the only signal the machine ever received came at the moment the pole fell. Before that, whether it was pushing well or badly, nobody told it anything. And the fall of the pole was often sealed dozens of steps earlier. This is the credit assignment problem in its purest form.

Their solution was to split the machine in two.

One part was called the "actor." Its job was to make decisions: in each cell, push left or push right. This is the half that belongs to Thorndike's cat: learning to choose.

The other part was called the "critic." It made no decisions at all. It did only one thing: predict. For each cell, it had to learn to judge, with the cart and pole in that state, how far they were from falling. This is the half that belongs to Pavlov's dog: learning to predict.

The key was how the two worked together. At every step, the critic took a look: after that push, did things get better or worse? If its prediction for the new state was more optimistic than its prediction for the old one, that meant the actor had just pushed well, and the critic gave the actor a little "pleasure." If it was more pessimistic, it gave a little "pain."

This way, the actor didn't have to wait for the pole to fall. It got feedback from the critic with every step. And where did the critic's own predictions come from? It learned them the same way: it used the next moment's prediction to correct this moment's prediction. The moment the pole fell simply nailed a definite answer onto the end of the chain.

This was Samuel's "first impression and second thought," lifted out of checkers and turned into a separate component.

The result was that the machine made of an actor and a critic learned to balance the pole faster and more reliably than Michie's BOXES. The paper got few citations at first, but later became one of the most cited papers in the field. The "actor-critic" design is still one of the most widely used structures in reinforcement learning today.

In 1984, Sutton finished his doctoral dissertation, and its title named the very problem this series has been following: "Temporal Credit Assignment in Reinforcement Learning." In 1986, Anderson's dissertation combined this approach with multilayer neural networks, letting the machine learn on its own how to divide up the states instead of having a person chop them into cells in advance. It was one of the earliest forerunners of today's deep reinforcement learning.


1988: Temporal Difference Learning

By 1988, Sutton was working at GTE Laboratories in Massachusetts. That year, he published a paper titled "Learning to Predict by the Methods of Temporal Differences." It took the ideas of the past decade off the pole, out of the dog, and out of the checkers program, and wrote them down as a general rule that could be applied to any problem. Temporal difference learning is using the next moment's prediction to correct this moment's prediction.



Take an example everyone has lived through. Sutton and Barto later used a similar one in their textbook: driving home from work. At 6:00, you leave the office. You glance at the time and the weather and figure you'll be home in thirty minutes. At 6:05, you get in the car and notice it's started to rain. Traffic is worse in the rain, so you change your estimate to forty minutes. At 6:20, you get on the highway, and it's moving better than you expected. You change your estimate again, to thirty-five minutes. At 6:30, you exit the highway and get stuck behind a slow truck. At 6:43, you get home. The question is: how should that 6:00 estimate of thirty minutes be corrected?

One way is to wait. Wait until you get home, see that it actually took forty-three minutes, and then look back and tell yourself: next time I leave at six, I should guess longer. That's the matchbox method: wait until the whole game is over, then settle the accounts.

The other way is not to wait. At 6:05, when you notice the rain and change your estimate from thirty to forty, you already know at that moment that the 6:00 estimate was too optimistic. You don't have to wait until you get home; you can immediately use the new 6:05 estimate to correct the old 6:00 one. All the way home, every estimate gets corrected by the one that comes after it, and the moment you walk through the door simply nails a real number onto the last stretch.

The gap between two successive predictions is the "temporal difference." It's the same thing as the prediction error Rescorla and Wagner described, except that instead of comparing a prediction with the final outcome, you compare this moment's prediction with the next moment's.

This has three advantages.

First, you learn early. You don't have to wait for something to end; you learn a little with every step. And if something never ends, like a person's life, this is the only way.

Second, you learn precisely. A lot happens on the way home: the rain, the open highway, the truck. If you only look at the final forty-three minutes, you can't tell which stretch caused the problem. Temporal difference spreads the responsibility across each stretch: how much the estimate changed when the rain started, how much when you got stuck behind the truck. This is the answer to the credit assignment problem.

Third, you don't need a map. Bellman's equation also works out the value of one situation from the value of the next, but it requires knowing the entire map in advance: how long each road is, how likely it is to rain. Temporal difference doesn't. All it needs is for you to actually drive home.

Bellman defined value. Samuel was the first to approximate it from experience, in checkers. Rescorla and Wagner saw prediction error in animals. Barto and Sutton put them together in the same machine. Sutton's 1988 paper finally wove these threads into a single rule.

Ninety years had passed since Thorndike put his first cat in a puzzle box.


One Rule

Temporal difference learning, in 1988, was just a rule. It worked on the cart and pole, and on a few simple prediction problems. Whether it could accomplish something truly hard, like beating the best humans at a complex game, nobody yet knew.



Klopf's "hedonistic neuron" became a book in 1982. His theory itself was never borne out. But the "evaluation project" he had persuaded the Air Force to fund ended up, without meaning to, rescuing a field that was close to being forgotten. He died in the late 1990s and never saw what it became.

The year after Sutton's paper, a doctoral student at Cambridge turned in his dissertation, titled "Learning from Delayed Rewards." Three years after that, a researcher at IBM took Sutton's rule and had a program play itself at backgammon more than a million times. Some thirty years earlier, at IBM's lab in Poughkeepsie, Samuel's checkers program had played itself the very same way. 🧪


Sources:

Preface:到了七十年代末,计算机科学几乎忘了"从奖励中学习"这件事,只有一个人还固执地记得。接续之前的 #AI 系列和 #MarvinMinsky 系列。本文与 Claude 合写。


强化学习今天的故事,通常从 AlphaGo 讲起,或者从 2025 年的图灵奖讲起:两位先驱,一生的工作,终于得到了计算机科学的最高荣誉。可这两个人开始的时候,并不是在开创一个领域。他们被雇来,是为了检验另一个人的想法,一个大多数同行都不当真的想法。他们在一个没人关心的项目里工作了好几年,重新去读半个世纪前的动物心理学,把 Samuel 封在跳棋程序里的那个想法重新挖了出来。Barto 后来回忆说,那时这个方向"不时髦",他们"有点像在荒野里"。


Klopf:享乐主义的神经元

A. Harry Klopf 1941 年出生,是俄亥俄州赖特-帕特森空军基地的一名科学家,在航空电子部门负责机器智能的研究。他有一个和当时的主流格格不入的想法。

1960 年代到 70 年代,研究自适应系统的人大多相信,一个会学习的系统,目标是维持平衡。体温太高就降,太低就升;误差太大就纠正,直到误差归零。这叫稳态。那个时代的神经网络研究也是这个思路:给机器一个标准答案,它错了多少,就改多少,直到不再出错。

Klopf 认为这抓错了重点。生物不是在追求平衡,而是在追求更多:更多食物,更多快乐,更少痛苦。他给这种状态起了一个名字,叫"异态"(heterostasis),意思是把某些东西尽可能推到最大,而不是保持在中间。他还往前推了一步:不只是整个动物在追求快乐,大脑里的每一个神经元,也是一个小小的享乐主义者。它会加强那些让它得到"快乐"信号的连接,削弱那些带来"痛苦"的连接。

这听上去很像 Thorndike 的效果律,只是从一只猫,缩小到了一个细胞。它和当时流行的"纠正误差"有一个根本的不同:纠正误差,需要有人告诉机器正确答案是什么;追求快乐,只需要告诉它结果好不好,至于怎样才是对的,它得自己去试。正如迷箱外的 Thorndike 从来没有教过猫拉哪根绳子。

Klopf 拿不出实验证据,也没有一个能跑起来的算法。但他有一样东西:他在空军内部,知道怎么让一个好奇的想法拿到钱。


1977:只交报告的项目

1977 年,美国空军科学研究办公室开始资助麻省大学阿默斯特分校的一个项目。三位计算机科学教授 Michael Arbib、William Kilmer 和 Nico Spinelli 挂名负责。项目的任务很特别:不是造一台机器,也不是解决一个军事问题,而是评估 Klopf 的理论到底有没有科学价值,把它和以前所有关于学习和自适应系统的研究放在一起比较。项目唯一的交付,是每年一份报告,外加一份最终报告。

为了做这件事,项目雇了一个博士后,Andrew Barto。

Barto 1948 年生,在密歇根大学读本科,最初学的是造船,学的是船舶工程。后来他对一件事产生了兴趣:用计算机和数学去模拟大脑。1970 年他以优异成绩拿到数学学位,1975 年在密歇根拿到计算机科学博士,论文写的是元胞自动机,一种由很多简单格子按规则互相影响的数学模型。他在纽约州立大学宾汉姆顿分校当了两年助理教授,然后来到了阿默斯特。

这是一个奇怪的工作。项目几乎没有别的要求,只要每年交一份报告。Barto 后来把它形容为纯粹由好奇心驱动的基础研究。他们几乎可以全职去做一件事:读。读 Klopf 的想法,读所有和它有关的文献,然后想清楚它到底新在哪里。


1978:学心理学的学生

Barto 到了不久,项目里来了一个年轻人,Richard Sutton。

Sutton 1957 年前后出生于俄亥俄州托莱多,在芝加哥附近长大。他在斯坦福读的不是计算机,而是心理学,辅修计算机科学,1978 年毕业,刚被阿默斯特的计算机科学研究生项目录取。他成了 Barto 的第一个博士生。稍晚一些,内布拉斯加大学计算机专业刚毕业的 Charles Anderson 也加入了。

一个学造船出身的数学家,一个学心理学的学生,这个组合恰好对上了他们要评估的东西。Klopf 的想法有一半来自动物心理学,另一半指向一台能计算的机器。Sutton 对 Thorndike、Pavlov 和 Skinner 的工作很熟,知道动物是怎么学的;Barto 知道怎么把一个想法写成数学。

他们读得越多,越发现一件奇怪的事。Klopf 说的那种学习,不是由老师给出正确答案,而是只告诉学习者结果好不好,让它自己去追求长期的回报,在心理学里早就是常识。正如这个系列前几篇写到的,它也曾经进入过工程和人工智能:Minsky 的 SNARC,Samuel 的跳棋,Michie 的火柴盒。但到了 1970 年代末,它已经几乎从计算机科学里消失了。人们在谈"学习"时,指的几乎都是另一件事:给机器看正确答案,让它学着去模仿。

Klopf 并没有发明一个新的想法。他只是在一个所有人都已经把它忘掉的年代,固执地把它记得。


重读 Pavlov:意外才是老师

他们从心理学里找到的最重要的东西,不是 Thorndike,而是 Pavlov。

第一篇讲过,强化学习需要两样东西:预测和选择。Thorndike 的猫代表选择,Pavlov 的狗代表预测。前面几台机器,SNARC 和火柴盒,学的都是选择:哪一步该走。但他们都卡在同一个地方:奖励来得太晚。

Barto 和 Sutton 意识到,答案可能就藏在狗那一半里。

Pavlov 之后的几十年,心理学家对条件反射做了大量实验,发现了一个关键的现象。假设一只动物已经学会了,铃声响起就会有食物。这时候再在响铃的同时亮一盏灯,然后给食物。重复很多次之后,单独亮灯,动物却几乎没有反应。它并没有学会灯和食物之间的关系。

为什么?因为食物已经被铃声预测到了。灯没有告诉它任何新东西,食物到来时也没有任何意外。

1972 年,心理学家 Robert Rescorla 和 Allan Wagner 把这类现象写成了一个简洁的模型。它的核心只有一句话:动物学到多少,取决于它有多意外。

预测误差:实际发生的,和事先预测的,之间的差距。差距越大,学得越多;没有差距,就什么也学不到。

意外才是老师。完全预料之中的奖励,教不会动物任何东西。

Barto 和 Sutton 在 1981 年提出了他们自己的条件反射模型,把这个想法往前推了一步。Rescorla 和 Wagner 的模型只看每一次实验的最终结果:食物来没来。但在真实的实验里,时间是连续的。铃声响起的那一刻,狗对未来的预测就已经变了,而不是等到食物端上来才变。他们想描述的,是这种一刻一刻、不断更新的预测。

设想一次实验里发生的事。铃声响起,五秒钟后,食物端上来。在 Rescorla 和 Wagner 的模型里,这五秒钟是一个整体:一次实验算一个回合,回合结束时看食物来没来,然后计算一次意外。它不关心这五秒钟之内发生了什么。

但狗关心。铃声一响,狗的期待就升起来了,它开始流口水;离食物端上来的时间越近,口水流得越多。如果铃声和食物之间隔得太久,狗就很难把两者联系起来;如果食物先来,铃声后响,狗几乎学不到任何东西。时间的先后和长短,对学习至关重要,而一个只在回合末尾算账的模型,根本看不到这些。

还有一个更奇怪的现象,Pavlov 自己当年就发现了。先让狗学会:铃声之后有食物。然后换一种训练:先亮一盏灯,再响铃,但不给食物。重复几次之后,单独亮灯,狗也会流口水。可是灯从来没有和食物一起出现过。

这叫二级条件反射。拿点外卖来打个比方。一开始,让你开心的是饭本身。点过几次之后,听到敲门声你就开心了,因为敲门意味着饭到了。再后来,手机上弹出"骑手距你 500 米",你也开心了。可那条推送不能吃,它甚至不是敲门,它只是告诉你:敲门声快来了。你为一个"快要来的好消息"而开心。

狗和灯也是这样。灯就是那条推送,铃声就是敲门声,食物就是饭。灯从来没有和食物一起出现过,它只和铃声一起出现过。但铃声在狗心里已经是一个好东西,所以预告铃声的灯,也跟着变成了好东西。

这说明,动物的学习信号,不只来自真正的奖励,也来自预测的变化。灯亮之后铃声响起,狗对未来的预期突然变好了,这一下"变好",本身就是一种奖励,足以让灯变得有意义。

Barto 和 Sutton 的模型想捕捉的,就是这两件事。第一,预测不是在回合末尾才更新,而是在时间的每一刻都在更新。第二,一个预测可以从另一个预测里学到东西:灯的价值,来自铃声的价值;铃声的价值,又来自食物。价值就这样一级一级地往前传。

这就是 Bellman 方程里的那句话:一个处境的价值,等于眼前的回报,加上下一个处境的价值。只不过这一次,它不是由数学家在纸上写出来的,而是一只狗在实验室里做出来的。

这个问题,和 Samuel 的跳棋程序一模一样。Samuel 的程序每走一步,对局面的判断就更新一次;Pavlov 的狗每听到一个信号,对食物的预期就更新一次。一个是工程师在 IBM 写的程序,一个是心理学家在实验室里观察到的动物行为,它们在做同一件事。


1983:演员和评论家

1983 年,Barto、Sutton 和 Anderson 发表了一篇论文,题为《能解决困难学习控制问题的类神经元自适应元件》。他们选的问题,正是 Michie 的 BOXES 十五年前做过的那一个:在一辆小车上平衡一根杆子。

小车、杆子和轨道都是在计算机里模拟的,和 BOXES 一样。规则也一样:每一刻只能用固定的力把小车往左推或往右推,小车和杆子的状态被切成一个个格子。最难的地方在于:机器得到的唯一信号,是杆子倒下的那一刻。在那之前,不管它推得对不对,都没有任何人告诉它。而杆子倒下,往往是几十步之前就已经注定的。这是功劳分配问题最纯粹的版本。

他们把机器拆成两个部分。一个叫"演员"。它的工作是做决定:在每一个格子里,往左推还是往右推。这是 Thorndike 的猫那一半:学习选择。另一个叫"评论家"。它不做任何决定,只做一件事:预测。对每一个格子,它要学会判断小车和杆子处在这个状态时,距离倒下还有多远。这是 Pavlov 的狗那一半:学习预测。

评论家在每一步都会看一眼:刚才这一推之后,局面变好了还是变坏了?如果它对新状态的预测,比对旧状态的预测更乐观,就说明演员刚才推得不错,它就给演员一点"快乐";如果更悲观,就给一点"痛苦"。这样一来,演员不必等到杆子倒下,每走一步都能从评论家那里收到反馈。而评论家自己的预测从哪里来?也是用同样的办法学的:它拿下一刻的预测,去纠正这一刻的预测。杆子倒下的那一刻,只是给这条链子的末端钉上一个确定的答案。

这就是 Samuel 的"第一印象和想过之后",只不过从跳棋里拿了出来,变成了一个独立的部件。结果是,这台由演员和评论家组成的机器,学平衡杆子学得比 Michie 的 BOXES 更快,也更稳。这篇论文发表之初没什么人引用,后来却成了这个领域被引用最多的论文之一。"演员-评论家"这个结构,今天仍然是强化学习里最常用的设计之一。

1984 年,Sutton 完成了博士论文,题目就是这个系列一直在讲的那个问题:《强化学习中的时间性功劳分配》。1986 年,Anderson 在他的博士论文里把这套方法和多层神经网络结合在了一起,让机器自己学会怎么划分状态,不再需要人事先切好格子。这是今天深度强化学习最早的雏形之一。


1988:时序差分学习

1988 年,Sutton 已经在麻州的 GTE 实验室工作。那一年,他发表了一篇论文,题为《用时序差分方法学习预测》。它把这十年里的想法,从杆子上、从狗身上、从跳棋里拿了下来,写成了一条可以用在任何问题上的通用规则。时序差分学习(temporal difference learning):用下一刻的预测,去纠正这一刻的预测。

用一个每个人都经历过的例子来说。Sutton 和 Barto 后来在教科书里也用了类似的例子:下班开车回家。六点整,你离开办公室。你看了一眼时间和天气,估计三十分钟到家。六点零五分,你上了车,发现开始下雨了。下雨天路上更堵,你把估计改成了四十分钟。六点二十分,你上了高速,比预想的顺。你又把估计改成了三十五分钟。六点三十分,你下了高速,却卡在了一辆慢吞吞的卡车后面。六点四十三分,你到家了。

问题是:六点整那个"三十分钟"的估计,该怎么修正?

一种办法是等。等到到家,发现实际用了四十三分钟,再回头对自己说:下次六点出发,该估得久一点。这是火柴盒的办法:等整盘棋下完,再算账。

另一种办法是不等。六点零五分,你发现下雨了,把估计从三十改成四十,那一刻你就已经知道:六点整的估计太乐观了。你用不着等到到家,立刻就可以拿六点零五分的新估计去修正六点整的旧估计。一路上,每一次估计都拿下一次估计来修正,到家的那一刻,只是给最后一段钉上一个真实的数字。

两次预测之间的差距,就是"时序差分"。它和 Rescorla 与 Wagner 说的预测误差是同一个东西,只不过不再是拿预测去和最终结果比,而是拿这一刻的预测,去和下一刻的预测比。

这有三个好处。

第一,学得早。不必等到一件事结束,每走一步就学一步。如果一件事永远不会结束,比如一个人的一生,这是唯一的办法。

第二,学得准。一路上发生的事情很多,下雨、顺畅、堵车,如果只看最后的四十三分钟,就分不清是哪一段出了问题。时序差分把责任分到了每一段:下雨那一刻改了多少,堵车那一刻又改了多少。这就是功劳分配问题的答案。

第三,不需要地图。Bellman 的方程也是用下一个处境的价值推出这一个,但他需要事先知道整张地图:每条路多长、下雨的概率多大。时序差分不需要,它只需要你真的开一趟车。

Bellman 给出了价值的定义,Samuel 在跳棋里第一次用经验去逼近它,Rescorla 和 Wagner 在动物身上看到了预测误差,Barto 和 Sutton 把它们放进了同一台机器。Sutton 1988 年的论文,终于把这几条线织成了一条规则。

距离 Thorndike 把第一只猫放进迷箱,已经过去了九十年。


规则

1988 年的时序差分学习,只是一条规则。它在小车和杆子上管用,在几个简单的预测问题上管用。它能不能做成一件真正难的事,比如在一个复杂的游戏里,打败最好的人类,还没有人知道。

Klopf 的"享乐主义神经元"在 1982 年写成了一本书。他的理论本身,后来并没有被证实;但他当年说服空军去资助的那个"评估项目",却在无意中救活了一个快要被遗忘的领域。他于 1990 年代末去世,没有看到它后来的样子。

就在 Sutton 发表论文的第二年,剑桥大学的一个博士生交出了他的论文,题目叫《从延迟的奖励中学习》。又过了三年,IBM 的一位研究员拿着 Sutton 的规则,让一个程序和自己下了上百万盘西洋双陆棋。三十多年前,波基普西的 IBM 实验室里,Samuel 的跳棋程序也曾经这样和自己下过棋。🧪


来源: