为什么要从 DQN 的回放中随机抽样?

Why random sample from replay for DQN?

我试图获得对深度强化学习的直观理解。在深度 Q 网络 (DQN) 中,我们将所有 actions/environments/rewards 存储在一个内存数组中,并在剧集结束时,"replay" 通过我们的神经网络存储它们。这是有道理的,因为我们正在尝试构建我们的奖励矩阵,看看我们的剧集是否以奖励结束,通过我们的矩阵将其缩小。

我认为导致奖励状态的动作序列是重要的捕捉 - 这一系列动作(而不是独立的动作)是导致我们进入奖励状态的原因。

Atari-DQN paper by Mnih之后的很多教程中我们看到了从内存数组中随机采样和训练的做法。所以如果我们有一个记忆:

(action a, state 1) --> (action b, state 2) --> (action c, state 3) --> (action d, state 4) --> reward!

我们可以训练一个小批量的:

[(action c state 3), (action b, state 2), reward!]

给出的原因是:

Second, learning directly from consecutive samples is inefficient, due to the strong correlations between the samples; randomizing the samples breaks these correlations and therefore reduces the variance of the updates.

或从这个pytorch tutorial:

By sampling from it randomly, the transitions that build up a batch are decorrelated. It has been shown that this greatly stabilizes and improves the DQN training procedure.

我的直觉告诉我,序列是强化学习中最重要的。大多数剧集都有延迟奖励,因此大多数 action/states 没有奖励(也没有 "reinforced")。将奖励的一部分带入这些先前状态的唯一方法是追溯地在整个序列中打破奖励(通过 Q 算法中的 future_reward reward + reward * learning_rate(future_reward))

内存库的随机采样打断了我们的序列,当您尝试回填 Q(奖励)矩阵时,这有何帮助?

也许这更类似于每个状态都应被视为独立的马尔可夫模型?我的直觉错在哪里?

谢谢!

"The sequence is what is most important in reinforcement learning." 否:根据马尔可夫 属性,给定当前状态你可以 "ignore" 所有过去的状态并且仍然能够学习。

您遗漏的一件事是元组不仅是 (state, action),而且是 (state, action, next state)。例如,在 DQN 中,当您更新 Q 网络时,您会计算 TD 误差,并且在这样做时,您会考虑下一个状态的 Q 值。这允许您仍然 "backpropagate" 通过 Q 值延迟奖励,即使样本是随机的。
(如果reward因为稀疏而延迟太久,还是会出现问题,但理论上还是可以学习的)