A Distributional Perspective on Reinforcement Learning β part 2/6
Cleaned-text code points [15049, 29161). Bibliography omitted here; source.md includes it.
We view the reward function as a random vector R β π΅ R\in\mathcal{Z} , and define the transition operator P Ο : π΅ β π΅ P^{\pi}:\mathcal{Z}\to\mathcal{Z} P Ο β Z β ( x , a ) \displaystyle P^{\pi}Z(x,a) : β£ = π· Z ( X β² , A β² ) \displaystyle\overset{D}{:=}Z(X^{\prime},A^{\prime}) (4) X β² \displaystyle X^{\prime} βΌ P ( β
| x , a ) , A β² βΌ Ο ( β
| X β² ) , \displaystyle\sim P(\cdot\,|\,x,a),\,A^{\prime}\sim\pi(\cdot\,|\,X^{\prime}), where we use capital letters to emphasize the random nature of the next state-action pair ( X β² , A β² ) (X^{\prime},A^{\prime}) . We define the distributional Bellman operator π― Ο : π΅ β π΅ \mathcal{T}^{\pi}:\mathcal{Z}\to\mathcal{Z} as π― Ο Z ( x , a ) : β£ = π· R ( x , a ) + Ξ³ P Ο Z ( x , a ) . \mathcal{T}^{\pi}Z(x,a)\overset{D}{:=}R(x,a)+\gamma P^{\pi}Z(x,a). (5) While π― Ο \mathcal{T}^{\pi} bears a surface resemblance to the usual Bellman operator ( 2 ), it is fundamentally different. In particular, three sources of randomness define the compound distribution π― Ο β Z \mathcal{T}^{\pi}Z : a) The randomness in the reward R R ,
b) The randomness in the transition P Ο P^{\pi} , and
c) The next-state value distribution Z β‘ ( X β² , A β² ) Z(X^{\prime},A^{\prime}) .
In particular, we make the usual assumption that these three quantities are independent. In this section we will show that ( 5 ) is a contraction mapping whose unique fixed point is the random return Z Ο Z^{\pi} .
#### 3.3.1 Contraction in d Β― p \bar{d}_{p}
Consider the process Z k + 1 := π― Ο β Z k Z_{k+1}:=\mathcal{T}^{\pi}Z_{k} , starting with some Z 0 β π΅ Z_{0}\in\mathcal{Z} . We may expect the limiting expectation of { Z k } \{Z_{k}\} to converge exponentially quickly, as usual, to Q Ο Q^{\pi} . As we now show, the process converges in a stronger sense: π― Ο \mathcal{T}^{\pi} is a contraction in d Β― p \bar{d}_{p} , which implies that all moments also converge exponentially quickly.
###### Lemma 3 .
π― Ο : π΅ β π΅ \mathcal{T}^{\pi}:\mathcal{Z}\to\mathcal{Z} is a Ξ³ \gamma -contraction in d Β― p \bar{d}_{p} .
Using Lemma 3 , we conclude using Banachβs fixed point theorem that π― Ο \mathcal{T}^{\pi} has a unique fixed point. By inspection, this fixed point must be Z Ο Z^{\pi} as defined in ( 1 ). As we assume all moments are bounded, this is sufficient to conclude that the sequence { Z k } \{Z_{k}\} converges to Z Ο Z^{\pi} in d Β― p \bar{d}_{p} for 1 β€ p β€ β 1\leq p\leq\infty .
To conclude, we remark that not all distributional metrics are equal; for example, Chung & Sobel (1987) have shown that π― Ο \mathcal{T}^{\pi} is not a contraction in total variation distance. Similar results can be derived for the Kullback-Leibler divergence and the Kolmogorov distance.
#### 3.3.2 Contraction in Centered Moments
Observe that d 2 β ( U , V ) d_{2}(U,V) (and more generally, d p d_{p} ) relates to a coupling C β‘ ( Ο ) := U β‘ ( Ο ) β V β‘ ( Ο ) C(\omega):=U(\omega)-V(\omega) , in the sense that d 2 2 β ( U , V ) \displaystyle d_{2}^{2}(U,V) β€ πΌ [ ( U β V ) 2 ] = π β‘ ( C ) + ( πΌ C ) 2 . \displaystyle\leq\expect[(U-V)^{2}]=\mathbb{V}\big(C\big)+\big(\expect C\big)^{2}. As a result, we cannot directly use d 2 d_{2} to bound the variance difference | π β‘ ( π― Ο β Z β ( x , a ) ) β π β‘ ( Z Ο β ( x , a ) ) | |\mathbb{V}(\mathcal{T}^{\pi}Z(x,a))-\mathbb{V}(Z^{\pi}(x,a))| . However, π― Ο \mathcal{T}^{\pi} is in fact a contraction in variance ( Sobel, 1982 , see also appendix) . In general, π― Ο \mathcal{T}^{\pi} is not a contraction in the p t β h p^{th} centered moment, p > 2 p>2 , but the centered moments of the iterates { Z k } \{Z_{k}\} still converge exponentially quickly to those of Z Ο Z^{\pi} ; the proof extends the result of RΓΆsler (1992) .
### 3.4 Control
Thus far we have considered a fixed policy Ο \pi , and studied the behaviour of its associated operator π― Ο \mathcal{T}^{\pi} . We now set out to understand the distributional operators of the control setting β where we seek a policy Ο \pi that maximizes value β and the corresponding notion of an optimal value distribution. As with the optimal value function, this notion is intimately tied to that of an optimal policy. However, while all optimal policies attain the same value Q β Q^{*} , in our case a difficulty arises: in general there are many optimal value distributions.
In this section we show that the distributional analogue of the Bellman optimality operator converges, in a weak sense, to the set of optimal value distributions. However, this operator is not a contraction in any metric between distributions, and is in general much more temperamental than the policy evaluation operators. We believe the convergence issues we outline here are a symptom of the inherent instability of greedy updates, as highlighted by e.g. Tsitsiklis (2002) and most recently Harutyunyan et al. (2016) .
Let Ξ β \Pi^{*} be the set of optimal policies. We begin by characterizing what we mean by an optimal value distribution .
###### Definition 1 (Optimal value distribution) .
An optimal value distribution is the v.d. of an optimal policy. The set of optimal value distributions is π΅ β := { Z Ο β : Ο β β Ξ β } \mathcal{Z}^{*}:=\{Z^{\pi^{*}}:\pi^{*}\in\Pi^{*}\} .
We emphasize that not all value distributions with expectation Q β Q^{*} are optimal: they must match the full distribution of the return under some optimal policy.
###### Definition 2 .
A greedy policy Ο \pi for Z β π΅ Z\in\mathcal{Z} maximizes the expectation of Z Z . The set of greedy policies for Z Z is π’ Z := { Ο : β a Ο ( a | x ) πΌ Z ( x , a ) = max a β² β π πΌ Z ( x , a β² ) } . \mathcal{G}_{Z}:=\{\pi:\sum\nolimits_{a}\pi(a\,|\,x)\expect Z(x,a)=\max_{a^{\prime}\in\mathcal{A}}\expect Z(x,a^{\prime})\}.
Recall that the expected Bellman optimality operator π― \mathcal{T} is π― β Q β ( x , a ) = πΌ R β ( x , a ) + Ξ³ β πΌ P β max a β² β π β‘ Q β‘ ( x β² , a β² ) . \mathcal{T}Q(x,a)=\expect R(x,a)+\gamma\expect\nolimits_{P}\max_{a^{\prime}\in\mathcal{A}}Q(x^{\prime},a^{\prime}). (6) The maximization at x β² x^{\prime} corresponds to some greedy policy. Although this policy is implicit in ( 6 ), we cannot ignore it in the distributional setting. We will call a distributional Bellman optimality operator any operator π― \mathcal{T} which implements a greedy selection rule, i.e. π― β Z = π― Ο β Z β for some β Ο β π’ Z . \mathcal{T}Z=\mathcal{T}^{\pi}Z\text{ for some }\pi\in\mathcal{G}_{Z}. As in the policy evaluation setting, we are interested in the behaviour of the iterates Z k + 1 := π― β Z k Z_{k+1}:=\mathcal{T}Z_{k} , Z 0 β π΅ Z_{0}\in\mathcal{Z} . Our first result is to assert that πΌ Z k \expect Z_{k} behaves as expected.
###### Lemma 4 .
Let Z 1 , Z 2 β π΅ Z_{1},Z_{2}\in\mathcal{Z} . Then β πΌ π― Z 1 β πΌ π― Z 2 β β β€ Ξ³ β πΌ Z 1 β πΌ Z 2 β β , \left\|\expect\mathcal{T}Z_{1}-\expect\mathcal{T}Z_{2}\right\|_{\infty}\leq\gamma\left\|\expect Z_{1}-\expect Z_{2}\right\|_{\infty}, and in particular πΌ Z k β Q β \expect Z_{k}\to Q^{*} exponentially quickly.
By inspecting Lemma 4 , we might expect that Z k Z_{k} converges quickly in d Β― p \bar{d}_{p} to some fixed point in π΅ β \mathcal{Z}^{*} . Unfortunately, convergence is neither quick nor assured to reach a fixed point. In fact, the best we can hope for is pointwise convergence, not even to the set π΅ β \mathcal{Z}^{*} but to the larger set of nonstationary optimal value distributions .
###### Definition 3 .
A nonstationary optimal value distribution Z β β£ β Z^{**} is the value distribution corresponding to a sequence of optimal policies. The set of n.o.v.d. is π΅ β β£ β \mathcal{Z}^{**} .
###### Theorem 1 (Convergence in the control setting) .
Let π³ \mathcal{X} be measurable and suppose that π \mathcal{A} is finite. Then lim k β β inf Z β β£ β β π΅ β β£ β d p β ( Z k β ( x , a ) , Z β β£ β β ( x , a ) ) = 0 β x , a . \lim_{k\to\infty}\inf_{Z^{**}\in\mathcal{Z}^{**}}d_{p}(Z_{k}(x,a),Z^{**}(x,a))=0\quad\forall x,a. If π³ \mathcal{X} is finite, then Z k Z_{k} converges to π΅ β β£ β \mathcal{Z}^{**} uniformly. Furthermore, if there is a total ordering βΊ \prec on Ξ β \Pi^{*} , such that for any Z β β π΅ β Z^{*}\in\mathcal{Z}^{*} , π― β Z β = π― Ο β Z β β with β Ο β π’ Z β , Ο βΊ Ο β² β β Ο β² β π’ Z β β { Ο } . \mathcal{T}Z^{*}=\mathcal{T}^{\pi}Z^{*}\;\text{with}\;\pi\in\mathcal{G}_{Z^{*}},\;\pi\prec\pi^{\prime}\;\;\forall\pi^{\prime}\in\mathcal{G}_{Z^{*}}\setminus\{\pi\}. Then π― \mathcal{T} has a unique fixed point Z β β π΅ β Z^{*}\in\mathcal{Z}^{*} .
Comparing Theorem 1 to Lemma 4 reveals a significant difference between the distributional framework and the usual setting of expected return. While the mean of Z k Z_{k} converges exponentially quickly to Q β Q^{*} , its distribution need not be as well-behaved! To emphasize this difference, we now provide a number of negative results concerning π― \mathcal{T} .
###### Proposition 1 .
The operator π― \mathcal{T} is not a contraction.
Consider the following example (Figure 2 , left). There are two states, x 1 x_{1} and x 2 x_{2} ; a unique transition from x 1 x_{1} to x 2 x_{2} ; from x 2 x_{2} , action a 1 a_{1} yields no reward, while the optimal action a 2 a_{2} yields 1 + Ο΅ 1+\epsilon or β 1 + Ο΅ -1+\epsilon with equal probability. Both actions are terminal. There is a unique optimal policy and therefore a unique fixed point Z β Z^{*} . Now consider Z Z as given in Figure 2 (right), and its distance to Z β Z^{*} : d Β― 1 β ( Z , Z β ) = d 1 β ( Z β‘ ( x 2 , a 2 ) , Z β β ( x 2 , a 2 ) ) = 2 β Ο΅ , \bar{d}_{1}(Z,Z^{*})=d_{1}(Z(x_{2},a_{2}),Z^{*}(x_{2},a_{2}))=2\epsilon,\\ where we made use of the fact that Z = Z β Z=Z^{*} everywhere except at ( x 2 , a 2 ) (x_{2},a_{2}) . When we apply π― \mathcal{T} to Z Z , however, the greedy action a 1 a_{1} is selected and π― β Z β ( x 1 ) = Z β‘ ( x 2 , a 1 ) \mathcal{T}Z(x_{1})=Z(x_{2},a_{1}) . But d 1 β ( π― β Z , π― β Z β ) \displaystyle d_{1}(\mathcal{T}Z,\mathcal{T}Z^{*}) = d 1 β ( π― β Z β ( x 1 ) , Z β β ( x 1 ) ) \displaystyle=d_{1}(\mathcal{T}Z(x_{1}),Z^{*}(x_{1})) = 1 2 β | 1 β Ο΅ | + 1 2 β | 1 + Ο΅ | > 2 β Ο΅ \displaystyle=\tfrac{1}{2}|1-\epsilon|+\tfrac{1}{2}|1+\epsilon|>2\epsilon for a sufficiently small Ο΅ \epsilon . This shows that the undiscounted update is not a nonexpansion: d Β― 1 β ( π― β Z , π― β Z β ) > d Β― 1 β ( Z , Z β ) \bar{d}_{1}(\mathcal{T}Z,\mathcal{T}Z^{*})>\bar{d}_{1}(Z,Z^{*}) . With Ξ³ < 1 \gamma<1 , the same proof shows it is not a contraction. Using a more technically involved argument, we can extend this result to any metric which separates Z Z and π― β Z \mathcal{T}Z .
x 1 x 2 , a 1 x 2 , a 2 Z β Ο΅ Β± 1 0 Ο΅ Β± 1 Z Ο΅ Β± 1 0 β Ο΅ Β± 1 π― β Z 0 0 Ο΅ Β± 1 \begin{array}[c]{lccc}\hfil\hfil\lx@intercol&\lx@intercol\hfil x_{1}\hfil\lx@intercol&\lx@intercol\hfil x_{2},a_{1}\hfil\lx@intercol&\lx@intercol\hfil x_{2},a_{2}\hfil\lx@intercol\\ \hline\cr Z^{*}&\pagecolor{lightsunflower}\epsilon\pm 1&0&\pagecolor{lightsunflower}\epsilon\pm 1\\ \hline\cr\hline\cr Z&\epsilon\pm 1&0&\pagecolor{lightsunflower}-\epsilon\pm 1\\ \hline\cr\mathcal{T}Z&\pagecolor{lightsunflower}{0}&0&\epsilon\pm 1\\ \hline\cr\hline\cr\end{array}
###### Proposition 2 .
Not all optimality operators have a fixed point Z β = π― β Z β Z^{*}=\mathcal{T}Z^{*} .
To see this, consider the same example, now with Ο΅ = 0 \epsilon=0 , and a greedy operator π― \mathcal{T} which breaks ties by picking a 2 a_{2} if Z β‘ ( x 1 ) = 0 Z(x_{1})=0 , and a 1 a_{1} otherwise. Then the sequence π― β Z β β ( x 1 ) , ( π― ) 2 β Z β β ( x 1 ) , β¦ \mathcal{T}Z^{*}(x_{1}),(\mathcal{T})^{2}Z^{*}(x_{1}),\,\dots alternates between Z β β ( x 2 , a 1 ) Z^{*}(x_{2},a_{1}) and Z β β ( x 2 , a 2 ) Z^{*}(x_{2},a_{2}) .
###### Proposition 3 .
That π― \mathcal{T} has a fixed point Z β = π― β Z β Z^{*}=\mathcal{T}Z^{*} is insufficient to guarantee the convergence of { Z k } \{Z_{k}\} to π΅ β \mathcal{Z}^{*} .
Theorem 1 paints a rather bleak picture of the control setting. It remains to be seen whether the dynamical eccentricies highlighted here actually arise in practice. One open question is whether theoretically more stable behaviour can be derived using stochastic policies, for example from conservative policy iteration ( Kakade & Langford, 2002 ) .
## 4 Approximate Distributional Learning
In this section we propose an algorithm based on the distributional Bellman optimality operator. In particular, this will require choosing an approximating distribution. Although the Gaussian case has previously been considered ( Morimura et al., 2010a ; Tamar et al., 2016 ) , to the best of our knowledge we are the first to use a rich class of parametric distributions.
### 4.1 Parametric Distribution
We will model the value distribution using a discrete distribution parametrized by N β β N\in\mathbb{N} and V min , V max β β V_{\textsc{min}},V_{\textsc{max}}\in\mathbb{R} , and whose support is the set of atoms { z i = V min + i β β³ β z : 0 β€ i < N } \{z_{i}=V_{\textsc{min}}+i\triangle z:0\leq i<N\} , β³ β z := V max β V min N β 1 \triangle z:=\tfrac{V_{\textsc{max}}-V_{\textsc{min}}}{N-1} . In a sense, these atoms are the βcanonical returnsβ of our distribution. The atom probabilities are given by a parametric model ΞΈ : π³ Γ π β β N \theta:\mathcal{X}\times\mathcal{A}\to\mathbb{R}^{N} Z ΞΈ β ( x , a ) = z i w.p. β p i β ( x , a ) := e ΞΈ i β ( x , a ) β j e ΞΈ j β ( x , a ) . Z_{\theta}(x,a)=z_{i}\quad\text{w.p. }\;p_{i}(x,a):=\frac{e^{\theta_{i}(x,a)}}{\sum\nolimits_{j}e^{\theta_{j}(x,a)}}. The discrete distribution has the advantages of being highly expressive and computationally friendly ( Van den Oord et al., 2016 , see e.g.) .
### 4.2 Projected Bellman Update
Using a discrete distribution poses a problem: the Bellman update π― β Z ΞΈ \mathcal{T}Z_{\theta} and our parametrization Z ΞΈ Z_{\theta} almost always have disjoint supports. From the analysis of Section 3 it would seem natural to minimize the Wasserstein metric (viewed as a loss) between π― β Z ΞΈ \mathcal{T}Z_{\theta} and Z ΞΈ Z_{\theta} , which is also conveniently robust to discrepancies in support. However, a second issue prevents this: in practice we are typically restricted to learning from sample transitions, which is not possible under the Wasserstein loss (see Prop. 5 and toy results in the appendix).