prioritied replay buffer / 2016

intro

priority replay buffer提出于2016年。当时Deepmind的Tom Schaul等人对DQN中vanilla replay buffer不满意,于是在原来的ReplayBuffer基础上作出改进。prioritied relay buffer出现后,取代vanilla replay buffer成为强化学习领域的default replay buffer。

痛批vanilla replay buffer有哪些不好?

它使用了均匀采样,replay buffer中每个transition被采样到的概率是相等的。即我们的采样概率是uniform-distribution。而schmidhuber在1991年的研究中也证明了----transition对agent的重要性不是uniform的,

Some transitions may not be immediately useful to the agent, but might become so when the agent competence increases

所以这个uniform distribution需要被革命,我得让它的取样概率是不均匀的,即让有的transition被取样的概率高一些,让有的transition被取样的概率低一些。

prioritied replay buffer的核心思想

为replay buffer中的每个transition配备优先级。优先级高的transition被采样到的概率更高。
这个优先级由每个transition给我agent造成的“surprising, redundant, or task-relevant”感受的程度来衡定。

prioritied replay buffer的实现方法

优先级机制

这个优先级机制是基于TD error的大小来实现的。

每采样得到一个transition后我们将它append到buffer池中,做append操作的同时,计算TD error并更新它的优先级\(p_i\)


ASSUMPTION 针对某一个transition,用\(p_i\)它的优先级,用\(|δ_i|\)表示它的TD error。


作者给出了两个优先级实现方法:

proportional prioritization \(p_i = |δ_i| + \epsilon\)

rank-based prioritization \(p_i = 1/rank(i)\) , where \(rank(i)\) is the rank of transition i when the replay memory is sorted according to \(|δ_i|\)

采样概率分布

有了前面的优先级设定,接下来就可以确定每个transition被采样的概率。

\(P(i) = \frac{p_{i}^{a}}{\sum_{k} p_{k}^{a}}\)

其中a是我们预先设定好的超参数,当a为0时就是均匀分布了。

为了annealing the bias而引入重要性采样权重(IS weights)

如果单纯用prioritied replay buffer取代 uniform replay buffer的话,必然会导致一个问题---high error的transition有着更高的优先级,它们被采样被用来更新agent的概率会高很多,那梯度就会很大(high error * many times -> large gradients)。就和vanilla policy gradient出现了同样的弊端,即会出现大梯度(gradient magnitude),这会导致迭代过程极其不稳定(poor stationary)。

为了解决这个问题,prioritied replay buffer要与IS weights搭配使用。

这里为每个transistion配备一个 重要性采样权重值(importance-sampling weight)。计算公式为:

\(w_i = (N * P(i))^{-\beta}\)

这里的\beta是一个超参数,在实践中会让它从initial value逐渐变小(linear decay)最后定于1, 类似\(\epsilon\)-greedy让\(\epsilon\)逐渐衰减。

IS weight用于从buffer池采样之后更新agent的时候。用于调整TD error的大小。如下:

\(Gradient = \sum_{i}^{batch size} w_i * δ_i * ∇_{θ}Q(S_{j−1}, A_{j−1})\)

Double DQN使用direct priorited relay buffer:

赞美之言

Experience replay liberates online learning agents from processing transitions in the exact order they are experienced. Prioritized replay further liberates agents from considering transitions with
the same frequency that they are experienced.

posted @ 2020-11-19 11:38  dynmi  阅读(632)  评论(0编辑  收藏  举报