爲什麼Q learning,DQN,DPG,DDPG不需要importance sampling?

最近有同學問我爲什麼Qlearning,DQN,DDPG等off policy的算法不需要importance sampling。

我看了一下網上的資料很少,僅有的資料雖然解釋得還算清晰,但是基本上也是隻有懂的人才看得懂,不懂的人還是得消化很久。從ADEPT(Analogy / Diagram / Example / Plain / Technical Definition)的學習規律出發,本人嘗試一下給出直觀理解、數學方法、圖形表達、簡單例子和文字解釋。

 

首先爲什麼需要off policy,off policy是什麼,大家可以看一下我之前的回答,這裏就直入正題。

強化學習1:徹底分清On-Policy&Off-Policy

強化學習2:Q-learning與Saras?流程圖逐步解釋

 

我們先看一下Q learning的update公式:

很明顯可以知道,這裏之所以是off policy,我們選得next action不是通過behavior policy來選擇的,而是直接從target policy 選擇的(即greedy/argmax)。那麼這裏需要imporce sampling的ratio來矯正差異嗎?

 

一、1-step TD with off policy

Q learning其實是1-step TD with off policy。(即更新時只包括了1步的reward)

下圖我用白色表示跟policy無關的數據,紅色表示的是根據target policy得到的數據,而藍色是根據behavior policy得到的數據。

有的同學覺得既然St,At是根據behavior policy來的,爲什麼我用白色表示Q(St,At)和R(St,At)呢?其實這裏跟哪個policy來的沒關係,因爲在這裏我們其實可以理解爲是人爲指定了要更新St,At pair。

首先具體解釋一下前者,因爲我們更新Q(St,At)時,它對自己的更新不會因爲它是來自target or behavior policy而存在任何影響;而R(St,At)當我們指定更新哪個St,At pair的時候,就只取決於環境如何定義R了,於是R也已經確定下來了,同樣也是跟來自target or behavior policy無關。

那麼至於後面的紅色部分,因爲greedy是我們的target policy,所以這裏通過greedy選擇了Q在St+1下對應最大價值的At+1,所以這一塊的數據是不用加入importance sampling的。


綜上,當1-step Qlearning,不需要用到Q learning,而更新時得到的就是target policy。

 

End.

參考資料:

  1. https://www.quora.com/Why-doesn-t-DQN-use-importance-sampling-Dont-we-always-use-this-method-to-correct-the-sampling-error-produced-by-the-off-policy/answer/James-MacGlashan

  2. https://stats.stackexchange.com/questions/335396/why-dont-we-use-importance-sampling-for-one-step-q-learning

  3. R. S. Sutton and A. G. Barto. Reinforcement learning: An introduction. IEEE Transactions on Neural Networks, 9(5):1054–1054, 2018.

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章