S TOCHASTIC L ATENT A CTOR -C RITIC : D EEP R EINFORCEMENT L EARNING WITH A L ATENT V ARIABLE M ODEL
Anonymous authors
Paper under double-blind review
A BSTRACT
Deep reinforcement learning (RL) algorithms can use high-capacity deep networks to learn directly from image observations.
However, these kinds of observation spaces present a number of challenges in practice, since the policy must now solve two problems: a representation learning problem, and a task learning problem.
In this paper, we aim to explicitly learn representations that can accelerate reinforcement learning from images.
We propose the stochastic latent actor-critic (SLAC) algorithm: a sample-efﬁcient and high-performing RL algorithm for learning policies for complex continuous control tasks directly from high-dimensional image inputs.
SLAC learns a compact latent representation space using a stochastic sequential latent variable model, and then learns a critic model within this latent space.
By learning a critic within a compact state space, SLAC can learn much more efﬁciently than standard RL methods.
The proposed model improves performance substantially over alternative representations as well, such as variational autoencoders.
In fact, our experimental evaluation demonstrates that the sample efﬁciency of our resulting method is comparable to that of model-based
RL methods that directly use a similar type of model for control.
Furthermore, our method outperforms both model-free and model-based alternatives in terms of ﬁnal performance and sample efﬁciency, on a range of difﬁcult image-based control tasks.
Our code and videos of our results are available at our website.
I NTRODUCTION
Deep reinforcement learning (RL) algorithms can automatically learn to solve certain tasks from raw, low-level observations such as images.
However, these kinds of observation spaces present a number of challenges in practice: on one hand, it is difﬁcult to directly learn from these high-dimensional inputs, but on the other hand, it is also difﬁcult to tease out a compact representation of the underlying task-relevant information from which to learn instead.
For these reasons, deep RL directly from low-level observations such as images remains a challenging problem.
Particularly in continuous domains governed by complex dynamics, such as robotic control (Tassa et al., 2018; Brockman et al., 2016), standard approaches still require separate sensor setups to monitor details of interest in the environment, such as the joint positions of a robot or speciﬁc pose information of objects of interest.
To instead be able to learn directly from the more general and rich modality of vision would greatly advance the current state of our learning systems, so we aim to study precisely this.
Standard model-free deep RL aims to use direct end-to-end training to explicitly unify these tasks of representation learning and task learning.
However, solving both problems together is difﬁcult, since an effective policy requires an effective representation, but in order for an effective representation to emerge, the policy or value function must provide meaningful gradient information using only the model-free supervision signal (i.e., the reward function).
In practice, learning directly from images with standard RL algorithms can be slow, sensitive to hyperparameters, and inefﬁcient.
In contrast to end-to-end learning with RL, predictive learning can beneﬁt from a rich and informative supervision signal before the agent has even made progress on the task or received any rewards.
This leads us to ask: can we explicitly learn a latent representation from raw low-level observations that makes deep
RL easier, through learning a predictive latent variable model?
Predictive models are commonly used in model-based RL for the purpose of planning (Deisenroth &
Rasmussen, 2011; Finn & Levine, 2017; Nagabandi et al., 2018; Chua et al., 2018; Zhang et al., 2019) or generating cheap synthetic experience for RL to reduce the required amount of interaction with the real environment (Sutton, 1991; Gu et al., 2016).
However, in this work, we are primarily concerned with their potential to alleviate the representation learning challenge in RL.
We devise a stochastic predictive model by modeling the high-dimensional observations as the consequence of a latent process, with a Gaussian prior and latent dynamics, as illustrated in Figure 1.
A model with an entirely stochastic latent state has the appealing interpretation of being able to properly represent uncertainty about any of the state variables, given its past observations.
We demonstrate in our work that fully stochastic state space models can in fact be learned effectively: With a well-designed stochastic network, such models outperform fully deterministic models, and contrary to the observations in prior work (Hafner et al., 2019; Buesing et al., 2018), are actually comparable to partially stochastic models.
Finally, we note that this explicit representation learning, even on low-reward data, allows an agent with such a model to make progress on representation learning even before it makes progress on task learning.
Equipped with this model, we can then perform RL in the learned latent space of the predictive model.
We posit—and conﬁrm experimentally—that our latent variable model provides a useful representation for RL.
Our model represents a partially observed Markov decision process (POMDP), and solving such a POMDP exactly would be computationally intractable (Astrom, 1965; Kaelbling et al., 1998; Igl et al., 2018).
We instead propose a simple approximation that trains a Markovian critic on the (stochastic) latent state and trains an actor on a history of observations and actions.
The resulting stochastic latent actor-critic (SLAC) algorithm loses some of the beneﬁts of full POMDP solvers, but it is easy and stable to train.
It also produces good results, in practice, on a range of challenging problems, making it an appealing alternative to more complex POMDP solution methods.
The main contributions of our SLAC algorithm are useful representations learned from our stochastic sequential latent variable model, as well as effective RL in this learned latent space.
We show experimentally that our approach substantially improves on both model-free and model-based RL algorithms on a range of image-based continuous control benchmark tasks, attaining better ﬁnal performance and learning more quickly than algorithms based on (a) end-to-end deep RL from images, (b) learning in a latent space produced by various alternative latent variable models, such as a variational autoencoder (VAE) (Kingma & Welling, 2014), and (c) model-based RL based on latent state-space models with partially stochastic variables (Hafner et al., 2019).
R ELATED W ORK
Representation learning in RL.
End-to-end deep RL can in principle learn representations directly as part of the RL process (Mnih et al., 2013).
However, prior work has observed that RL has a “representation learning bottleneck”: a considerable portion of the learning period must be spent acquiring good representations of the observation space (Shelhamer et al., 2016).
This motivates the use of a distinct representation learning procedure to acquire these representations before the agent has even learned to solve the task.
The use of auxiliary supervision in RL to learn such representations has been explored in a number of prior works (Lange & Riedmiller, 2010; Finn et al., 2016; Jaderberg et al., 2017; Higgins et al., 2017; Ha & Schmidhuber, 2018; Nair et al., 2018; Oord et al., 2018; Gelada et al., 2019; Dadashi et al., 2019).
In contrast to this class of representation learning algorithms, we explicitly learn a latent variable model of the POMDP, in which the latent representation and latent-space dynamics are jointly learned.
By modeling covariances between consecutive latent states, we make it feasible for our proposed algorithm to perform Bellman backups directly in the latent space of the learned model.
Partial observability in RL.
Our work is also related to prior research on RL under partial observability.
Prior work has studied exact and approximate solutions to POMDPs, but they require explicit models of the POMDP and are only practical for simpler domains (Kaelbling et al., 1998). Recent work has proposed end-to-end RL methods that use recurrent neural networks to process histories of observations and (sometimes) actions, but without constructing a model of the POMDP (Hausknecht & Stone, 2015; Foerster et al., 2016; Zhu et al., 2018).
Other works, however, learn latent-space dynamical system models and then use them to solve the POMDP with model-based RL (Watter et al., 2015; Wahlström et al., 2015; Karl et al., 2017; Zhang et al., 2019; Hafner et al., 2019).
In contrast to these works, our approach beneﬁts from the good asymptotic performance of model-free RL, while at the same time leveraging the improved latent space representation for sample efﬁciency.
Other works have also trained latent variable models and used their representations as the inputs to model-free RL algorithms. They use representations encoded from latent states sampled from the forward model (Buesing et al., 2018), belief representations obtained from particle ﬁltering (Igl et al., 2018), or belief representations obtained directly from a learned belief-space forward model (Gregor et al., 2019). Our approach is closely related to these prior methods, in that we also use model-free
RL with a latent state representation that is learned via prediction. However, instead of using belief representations, our method learns a critic directly on latent states samples. Sequential latent variable models.
Several previous works have explored various modeling choices to learn stochastic sequential models (Krishnan et al., 2015; Archer et al., 2015; Karl et al., 2016; Fraccaro et al., 2016; 2017; Doerr et al., 2018a).
In the context of using sequential models for RL, previous works have typically observed that partially stochastic state space models are more effective than fully stochastic ones (Buesing et al., 2018; Igl et al., 2018; Hafner et al., 2019).
In these models, the state of the underlying MDP is modeled with the deterministic state of a recurrent network (e.g., LSTM (Hochreiter & Schmidhuber, 1997) or GRU (Cho et al., 2014)), and optionally with some stochastic random variables.
As mentioned earlier, a model with a latent state that is entirely stochastic has the appealing interpretation of learning a representation that can properly represent uncertainty about any of the state variables, given past observations.
We demonstrate in our work that fully stochastic state space models can in fact be learned effectively and, with a well-designed stochastic network, such models perform on par to partially stochastic models and outperform fully deterministic models.
R EINFORCEMENT L EARNING AND M ODELING
This work addresses the problem of learning maximum entropy policies from high-dimensional observations in POMDPs, by simultaneously learning a latent representation of the underlying MDP state using variational inference and learning the policy in a maximum entropy RL framework.
In this section, we describe maximum entropy RL (Ziebart, 2010; Haarnoja et al., 2018a; Levine, 2018) in fully observable MDPs, as well as variational methods for training latent state space models for
POMDPs.
3. M AXIMUM E NTROPY RL IN F ULLY O BSERVABLE MDP S
In a Markov decision process (MDP), an agent at time t takes an action a t ∈
A from state s t ∈ S and reaches the next state s t +1 ∈ S according to some stochastic transition dynamics p ( s t +1 | s t , a t ) .
The initial state s 1 comes from a distribution p ( s 1 ) , and the agent receives a reward r t on each of the transitions.
Standard RL aims to learn the parameters φ of some policy π φ ( a t
| s t )
such that the expected sum of rewards is maximized under the induced trajectory distribution ρ π .
This objective can be modiﬁed to incorporate an entropy term, such that the policy also aims to maximize the expected entropy H ( π φ ( ·| s t )) under the induced trajectory distribution ρ π .
This formulation has a close connection to variational inference (Ziebart, 2010; Haarnoja et al., 2018a; Levine, 2018), and we build on this in our work.
The resulting maximum entropy objective is
[Equation]
where r is the reward function, and α is a temperature parameter that controls the trade-off between optimizing for the reward and for the entropy (i.e., stochasticity) of the policy.
Soft actor-critic (SAC) (Haarnoja et al., 2018a) uses this maximum entropy RL framework to derive soft policy iteration, which alternates between policy evaluation and policy improvement within the described maximum entropy framework.
SAC then extends this soft policy iteration to handle continuous action spaces by using parameterized function approximators to represent both the Q-function Q θ (critic) and the policy π φ (actor).
The soft Q-function parameters θ are optimized to minimize the soft Bellman residual,
[Equation]
where D is the replay buffer, γ is the discount factor, and ¯ θ are delayed parameters.
The policy parameters φ are optimized to update the policy towards the exponential of the soft Q-function,
[Equation]
Results of this stochastic, entropy maximizing RL framework demonstrate improved robustness and stability.
SAC also shows the sample efﬁciency beneﬁts of an off-policy learning algorithm, in conjunction with the high performance beneﬁts of a long-horizon planning algorithm.
Precisely for these reasons, we choose to extend the SAC algorithm in this work to formulate our SLAC algorithm.
3. S EQUENTIAL L ATENT V ARIABLE M ODELS AND A MORTIZED V ARIATIONAL I NFERENCE IN POMDP S
To learn representations for RL, we use latent variable models trained with amortized variational inference.
The learned model must be able to process a large number of pixels that are present in the entangled image x , and it must tease out the relevant information into a compact and disentangled representation z .
To learn such a model, we can consider maximizing the probability of each observed datapoint x from some training set D under the entire generative process p ( x )
=
(cid:82) p ( x | z ) p ( z )
d z .
This objective is intractable to compute in general due to the marginalization of the latent variables z .
In amortized variational inference, we utilize the following bound on the log-likelihood (Kingma &
Welling, 2014),
[Equation]
We can maximize the probability of the observed datapoints (i.e., the left hand side of Equation (5)) by learning an encoder q ( z | x ) and a decoder p ( x | z ) , and then directly performing gradient ascent on the right hand side of the equation.
In this setup, the distributions of interest are the prior p ( z ) , the observation model p ( x | z ) , and the posterior q ( z | x ) .
Although such generative models have been shown to successfully model various types of complex distributions (Kingma & Welling, 2014) by embedding knowledge of the distribution into an informative latent space, they do not have a built-in mechanism for the use of temporal information when performing inference.
In the case of partially observable environments, as we discuss below, the representative latent state z t corresponding to a given non-Markovian observation x t needs to be informed by past observations.
Consider a partially observable MDP (POMDP), where an action a t ∈ A from latent state z t ∈ Z results in latent state z t +1 ∈ Z and emits a corresponding observation x t +1 ∈ X .
We make an explicit distinction between an observation x t and the underlying latent state z t , to emphasize that the latter is unobserved and the distribution is not known a priori.
Analogous to the fully observable
MDP, the initial state distribution is p ( z 1 ) , the transition probability distribution is p ( z t +1 | z t , a t ) , and the reward is r t .
In addition, the observation model is given by p ( x t | z t ) .
As in the case for VAEs, a generative model of these observations x t can be learned by maximizing the log-likelihood.
In the POMDP setting, however, we note that x t alone does not provide all necessary information to infer z t , and thus, prior temporal information must be taken into account.
This brings us to the discussion of sequential latent variable models.
The distributions of interest are the priors p ( z 1 ) and p ( z t +1 | z t , a t ) , the observation model p ( x t | z t ) , and the approximate posteriors q ( z 1 | x 1 ) and q ( z t +1 | x t +1 , z t , a t ) .
The log-likehood of the observations can then be bounded, similarly to the
VAE bound in Equation (5), as
[Equation]
Prior work (Hafner et al., 2019; Buesing et al., 2018; Doerr et al., 2018b) has explored modeling such non-Markovian observation sequences, using methods such as recurrent neural networks with deterministic hidden state, as well as probabilistic state-space models.
In this work, we enable the effective training of a fully stochastic sequential latent variable model, and bring it together with a maximum entropy actor-critic RL algorithm to create SLAC: a sample-efﬁcient and highperforming RL algorithm for learning policies for complex continuous control tasks directly from high-dimensional image inputs.
J OINT M ODELING AND C ONTROL AS I NFERENCE
[Figure]
Our method aims to learn maximum entropy policies from high-dimensional, non-Markovian observations in a POMDP, while also learning a model of that POMDP.
The model alleviates the representation learning problem, which in turn helps with the policy learning problem.
We formulate the control problem as inference in a probabilistic graphical model with latent variables, as shown in Figure 1.
For a fully observable MDP, the control problem can be embedded into a graphical model by introducing a binary random variable O t , which indicates if time step t is optimal.
When its distribution is chosen to be p ( O t = 1 | s t , a t ) =
exp( r ( s t , a t )) , then maximization of p ( O 1: T ) via approximate inference in that model yields the optimal policy for the maximum entropy objective (Levine, 2018).
In a POMDP setting, the distribution can analogously be given by p ( O t = 1 |
z t , a t ) = exp( r ( z t , a t )) .
Instead of maximizing the likelihood of the optimality variables alone, we jointly model the observations (including the observed rewards of the past time steps) and learn maximum entropy policies by maximizing the marginal likelihood p ( x 1: τ +1 , O τ +1: T | a 1: τ ) .
This objective represents both the likelihood of the observed data from the past τ steps, as well as the optimality of the agent’s actions for future steps.
We factorize our variational distribution into a product of recognition terms q ( z 1 | x 1 ) and q ( z t +1 | x t +1 , z t , a t ) , dynamics terms p ( z t +1 | z t , a t ) , and policy terms π ( a t | z t ) :
[Equation]
The variational distribution uses the dynamics for future time steps to prevent the agent from controlling the transitions and from choosing optimistic actions (Levine, 2018).
The posterior over the actions represents the agent’s policy π .
Although this derivation uses a policy that is conditioned on the latent state, our algorithm, which will be described in the next section, learns a parametric policy that is directly conditioned on observations and actions. This approximation allows us to directly execute the policy without having to perform inference on the latent state at run time.
We use the posterior from Equation (7) to obtain the evidence lower bound (ELBO) of the marginal likelihood,
[Equation]
where p ( a t ) is the action prior.
The full derivation of the ELBO is given in Appendix A.
This derivation assumes that the reward function, which determines p ( O t | z t , a t ) , is known.
However, in many RL problems, this is not the case.
In that situation, we can simply append the reward to the observation, and learn the reward along with p ( x t | z t ) .
This requires no modiﬁcation to our method other than changing the observation space, and we use this approach in all of our experiments.
We do this to learn latent representations that are more relevant to the task, but we do not use predictions from it.
Instead, the RL objective uses rewards from the agent’s experience, as in model-free RL.
S TOCHASTIC L ATENT A CTOR C RITIC
We now describe our stochastic latent actor critic (SLAC) algorithm, which approximately maximizes the ELBO using function approximators to model the prior and posterior distributions. The ELBO objective in Equation (8) can be split into a model objective and a maximum entropy RL objective.
The model objective can directly be optimized, while the maximum entropy RL objective can be solved via message passing.
We can learn Q-functions for the messages, and then we can rewrite the RL objective to express it in terms of these messages.
Additional details of the derivation of the
SLAC objectives are given in Appendix A.
Latent Variable Model :
The ﬁrst part of the ELBO corresponds to training the latent variable model to maximize the likelihood of the observations, analogous to the ELBO in Equation (6) for the sequential latent variable model.
The distributions of the latent variable model are diagonal Gaussian distributions, where the means and variances are outputs of neural networks.
The distribution parameters ψ of this model are optimized to maximize the ﬁrst part of the ELBO. The model loss is
[Equation]
We use the reparameterization trick to sample from the ﬁltering distribution q ψ ( z 1: τ +1 | x 1: τ +1 , a 1: τ ) .
Critic and Actor : The second part of the ELBO corresponds to the maximum entropy RL objective.
As in the fully observable case from Section 3.1 and as described by Levine (2018), this optimization can be solved via message passing of soft Q-values, except that we use the latent states z rather than the true states s .
For continuous state and action spaces, this message passing is approximated by minimizing the soft Bellman residual, which we use to train our soft Q-function parameters θ ,
[Equation]
where ¯ θ are delayed parameters, obtained as exponential moving averages of θ .
Notice that the latents z τ and z τ +1 , which are used in the Bellman backup, are sampled from the same joint, i.e. z τ +1 ∼ q ψ ( z τ +1 | x τ +1 , z τ , a τ ) .
The RL objective, which corresponds to the second part of the ELBO, can be rewritten in terms of the soft Q-function. The policy parameters φ are optimized to maximize this objective, analogously to soft actor-critic (Haarnoja et al., 2018a). The policy loss is then
[Equation]
We assume a uniform action prior, so p ( a t ) is a constant term that we omit from the policy loss.
We use the reparameterization trick to sample from the policy, and the policy loss only uses the last sample z τ +1 of the sequence for the critic.
Although the policy used in our derivation is conditioned in the latent state, our learned parametric policy is conditioned directly on the past observations and actions, so that the learned policy can be executed at run time without requiring inference of the latent state.
Finally, we note that for the expectation over latent states in the Bellman residual in
Equation (10), rather than sampling latent states z ∼ Z , we sample latent states from the ﬁltering distribution q ψ ( z 1: τ +1 | x 1: τ +1 , a 1: τ ) .
This design choice allows us to minimize the critic loss for samples that are most relevant for Q , while also allowing the critic loss to use the Q-function in the same way as implied by the policy loss in Equation (11).
SLAC is outlined in Algorithm 1.
The actor-critic component follows prior work, with automatic tuning of the temperature α and two Q-functions to mitigate underestimation (Fujimoto et al., 2018;
Haarnoja et al., 2018a;b).
SLAC can be viewed as a variant of SAC (Haarnoja et al., 2018a) where the critic is trained on the stochastic latent state of our sequential latent variable model.
The backup for the critic is performed on a tuple ( z τ , a τ , r τ , z τ +1 ) , sampled from the posterior q ( z τ +1 ,
z τ | x 1: τ +1 , a 1: τ ) .
The critic can, in principle, take advantage of the perfect knowledge of the state z t , which makes learning easier.
However, the parametric policy does not have access to z t , and must make decisions based on a history of observations and actions.
SLAC is not a model-based algorithm, in that in does not use the model for prediction, but we see in our experiments that SLAC can achieve similar sample efﬁciency as a model-based algorithm.
Algorithm 1 Stochastic Latent Actor-Critic (SLAC)
Require: E , ψ , θ 1 , θ 2 , φ (cid:46) Environment and initial parameters for model, actor, and critic x 1 ∼ E reset ()
(cid:46) Sample initial observation from the environment
D ← ( x 1 ) (cid:46) Initialize replay buffer with initial observation for each iteration do for each environment step do a t ∼ π φ (
[Equation]
t |
[Equation]
: t , a 1: t − 1 ) (cid:46) Sample action from the policy r t , x t +1 ∼ E step ( a t ) (cid:46)
Sample transition from the environment
D ← D ∪ ( a t , r t , x t +1 ) (cid:46) Store the transition in the replay buffer for each gradient step do ψ ← ψ − λ [Equation] ∇ ψ J M ( ψ ) (cid:46) Update model weights θ i ← θ i − λ Q ∇ θ i J Q ( θ i ) for i ∈ { 1 ,
[Equation]
(cid:46) Update the Q-function weights
[Equation] (cid:46) Update policy weights [Equation] (cid:46) Update target critic network weights
L ATENT V ARIABLE M ODEL
We brieﬂy summarize our full model architecture here, with full details in Appendix B. Motivated by the recent success of autoregressive latent variables in VAEs (Razavi et al., 2019; Maaloe et al., 2019), we factorize the latent variable z t into two stochastic layers, z 1 t and z 2 t , as shown in Figure 2.
This factorization results in latent distributions that are more expressive
[Equation]
and it allows for some parts of the prior and posterior distributions to be shared.
We found this design to produce high quality reconstructions and samples
[Equation]
and utilize it in all of our experiments. The generative model p and the inference model q are given by
[Equation]
[Figure] [Figure] [Equation]
[Figure]
[Equation]
[Figure]
Note that we choose the variational distribution q over z 2 t to be the same as the model p .
Thus, the
KL divergence in J M simpliﬁes to the divergence between q and p over z 1 t .
We use a multivariate standard normal distribution for p ( z 11 ) , since it is not conditioned on any variables, i.e. z 11 ∼ N ( 0 , I ) .
The conditional distributions of our model are diagonal
Gaussian, with means and variances given by neural networks.
Unlike models from prior work (Hafner et al., 2019; Buesing et al., 2018; Doerr et al., 2018b), which have deterministic and stochastic paths and use recurrent neural networks, ours is fully stochastic, i.e. our latent state is a Markovian latent random variable formed by the concatenation of z 1 t and z 2 t .
Further details are discussed in Appendix B.
E XPERIMENTAL E VALUATION
We evaluate SLAC on numerous image-based continuous control tasks from both the DeepMind
Control Suite (Tassa et al., 2018) and OpenAI Gym (Brockman et al., 2016), as illustrated in Figure 3.
Full details of SLAC’s network architecture are described in Appendix B. Aside from the value of action repeats (i.e. control frequency) for the tasks, we kept all of SLAC’s hyperparameters constant across all tasks in all domains.
Training and evaluation details are given in Appendix C, and image samples from our model for all tasks are shown in Appendix D. Additionally, visualizations of our results and code are available on the project website.
7. C OMPARATIVE E VALUATION ON C ONTINUOUS C ONTROL B ENCHMARK T ASKS
To provide a comparative evaluation against prior methods, we evaluate SLAC on four tasks (cheetah run, walker walk, ball-in-cup catch, ﬁnger spin) from the DeepMind Control Suite (Tassa et al., 2018), and four tasks (cheetah, walker, ant, hopper) from OpenAI Gym (Brockman et al., 2016).
Note that the Gym tasks are typically used with low-dimensional state observations, while we evaluate on them with raw image observations.
We compare our method to the following state-of-the-art model-based and model-free algorithms:
SAC (Haarnoja et al., 2018a):
This is an off-policy actor-critic algorithm, which represents a comparison to state-of-the-art model-free learning.
We include experiments showing the performance of SAC based on true state (as an upper bound on performance) as well as directly from raw images.
MPO (Abdolmaleki et al., 2018b;a):
This is an off-policy actor-critic algorithm that performs an expectation maximization form of policy iteration, learning directly from raw images.
D4PG (Barth-Maron et al., 2018):
This is also an off-policy actor-critic algorithm, learning directly from raw images.
The results reported in the plots below are the performance after 10 8 training steps, as stated in the benchmarks from (Tassa et al., 2018).
PlaNet (Hafner et al., 2019):
This is a model-based RL method for learning from images, which uses a partially stochastic sequential latent variable model, but without explicit policy learning.
Instead, the model is used for planning with model predictive control (MPC), where each plan is optimized with the cross entropy method (CEM).
DVRL (Igl et al., 2018):
This is an on-policy model-free RL algorithm that also trains a partially stochastic latent-variable POMDP model.
DVRL uses the full belief over the latent state as input into both the actor and critic, as opposed to our method, which trains the critic with the latent state and the actor with a history of actions and observations.
Our experiments on the DeepMind Control Suite in Figure 4 show that the sample efﬁciency of
SLAC is comparable or better than both model-based and model-free alternatives.
This indicates that overcoming the representation learning bottleneck, coupled with efﬁcient off-policy RL, provides for fast learning similar to model-based methods, while attaining ﬁnal performance comparable to fully model-free techniques that learn from state.
SLAC also substantially outperforms DVRL.
This difference can be explained in part by the use of an efﬁcient off-policy RL algorithm, which can better take advantage of the learned representation.
We also evaluate SLAC on continuous control benchmark tasks from OpenAI Gym in Figure 5.
We notice that these tasks are much more challenging than the DeepMind Control Suite tasks, because the rewards are not as shaped and not bounded between 0 and 1, the dynamics are different, and the episodes terminate on failure (e.g., when the hopper or walker falls over).
PlaNet is unable to solve [Figure] [Figure] the last three tasks, while for the cheetah task, it learns a suboptimal policy that involves ﬂipping the cheetah over and pushing forward while on its back.
To better understand the performance of ﬁxed-horizon MPC on these tasks, we also evaluated with the ground truth dynamics (i [Figure] e., the true simulator), and found that even in this case, MPC did not achieve good ﬁnal performance, suggesting that inﬁnite horizon policy optimization, of the sort performed by SLAC and model-free algorithms, is important to attain good results on these tasks [Figure]
Our experiments show that SLAC successfully learns complex continuous control benchmark tasks from raw image inputs.
On the DeepMind Control Suite, SLAC exceeds the performance of PlaNet on three of the tasks [Figure] and matches its performance on the walker task.
However, on the harder image-based OpenAI Gym tasks, SLAC outperforms PlaNet by a large margin.
In both domains,
SLAC substantially outperforms all prior model-free methods.
We note that the prior methods that we tested generally performed poorly on the image-based OpenAI Gym tasks, despite considerable hyperparameter tuning.
7. E VALUATING THE L ATENT V ARIABLE M ODEL
[Figure] We next study the tradeoffs between different design choices for the latent variable model.
We compare our fully stochastic model, as described in Section 6, to a standard non-sequential VAE model (Kingma & Welling, 2014), which has been used in multiple prior works for representation learning in RL (Higgins et al., 2017;
Ha & Schmidhuber, 2018; Nair et al., 2018), the partially stochastic model used by PlaNet (Hafner et al., 2019), as well as three variants of our model: a simple ﬁltering model that does not factorize the latent variable into two layers of stochastic units, a fully deterministic model that removes all stochasticity from the hidden state dynamics, and a partially stochastic model that has both deterministic and stochastic transitions, similar to the PlaNet model, but with our architecture. Both the fully deterministic and partially stochastic models use the same architecture as our fully stochastic model, including the same two-level factorization of the latent variable.
In all cases, we use the RL framework of SLAC and only vary the choice of model for representation learning.
As shown in the comparison in Figure 6, our fully stochastic model outperforms prior models as well as the deterministic and simple variants of our own model.
The partially stochastic variant of our model matches the performance of our fully stochastic model but, contrary to the conclusions in prior work (Hafner et al., 2019; Buesing et al., 2018), the fully stochastic model performs on par, while retaining the appealing interpretation of a stochastic state space model.
7. Q UALITATIVE P REDICTIONS FROM THE L ATENT V ARIABLE M ODEL
We show example image samples from our learned sequential latent variable model for the cheetah task in Figure 7, and we include the other tasks in Appendix D. Samples from the posterior show the images x t as constructed by the decoder p ψ ( x t | z t ) , using a sequence of latents z t that are encoded and sampled from the posteriors, q ψ ( z 1 | x 1 ) and q ψ ( z t +1 | x t +1 , z t , a t ) .
Samples from the prior, on the other hand, use a sequence of latents where z 1 is sampled from p ( z 1 ) and all remaining latents z t are from the propagation of the previous latent state through the latent dynamics p ψ ( z t +1 | z t , a t ) .
Note that these prior samples do not use any image frames as inputs, and thus they do not correspond to any ground truth sequence.
We also show samples from the conditional prior, which is conditioned on the ﬁrst image from the true sequence: for this, the sampling procedure is the same as the prior, except that z 1 is encoded and sampled from the posterior q ψ ( z 1 | x 1 ) , rather than being sampled from p ( z 1 ) .
We notice that the generated images samples can be sharper and more realistic by using a smaller variance for p ψ ( x t | z t ) when training the model, but at the expense of a representation that leads to lower returns.
Finally, note that we do not actually use the samples from the prior for training.
C h ee t a h r un
G r ound T r u t h
P o s t
e r i
o r
S a m p l e
C ond iti on a l
P r i o r
S a m p l e
P r i o r S a m p l e
D ISCUSSION
We presented SLAC, an efﬁcient RL algorithm for learning from high-dimensional image inputs that combines efﬁcient off-policy model-free RL with representation learning via a sequential stochastic state space model.
Through representation learning in conjunction with effective task learning in the learned latent space, our method achieves improved sample efﬁciency and ﬁnal task performance as compared to both prior model-based and model-free RL methods.
While our current SLAC algorithm is fully model-free, in that predictions from the model are not utilized to speed up training, a natural extension of our approach would be to use the model predictions themselves to generate synthetic samples.
Incorporating this additional synthetic modelbased data into a mixed model-based/model-free method could further improve sample efﬁciency and performance.
More broadly, the use of explicit representation learning with RL has the potential to not only accelerate training time and increase the complexity of achievable tasks, but also enable reuse and transfer of our learned representation across tasks. A D ERIVATION OF THE E VIDENCE L OWER B OUND AND SLAC O BJECTIVES
In this appendix, we discuss how the SLAC objectives can be derived from applying a variational inference scheme to the control as inference framework for reinforcement learning (Levine, 2018) .
In this framework, the problem of ﬁnding the optimal policy is cast as an inference problem, conditioned on the evidence that the agent is behaving optimally.
While Levine (2018) derives this in the fully observed case, we present a derivation in the POMDP setting.
We aim to maximize the marginal likelihood p ( x 1: τ +1 ,
O τ +1: T | a 1: τ ) , where τ is the number of steps that the agent has already taken. This likelihood reﬂects that the agent cannot modify the past τ actions and they might have not been optimal, but it can choose the future actions up to the end of the episode, such that the chosen future actions are optimal. Notice that unlike the standard control as inference framework, in this work we not only maximize the likelihood of the optimality variables but also the likelihood of the observations, which provides additional supervision for the latent representation. This does not come up in the MDP setting since the state representation is ﬁxed and learning a dynamics model of the state would not change the model-free equations derived from the maximum entropy RL objective.
For reference, we restate the factorization of our variational distribution:
[Equation]
As discussed by Levine (2018), the agent does not have control over the stochastic dynamics, so we use the dynamics p ( z t +1 | z t , a t ) for t ≥ τ + 1 in the variational distribution in order to prevent the agent from choosing optimistic actions.
The joint likelihood is
[Equation]
We use the posterior from Equation (12) and Jensen’s inequality to obtain the ELBO of the marginal likelihood,
[Equation]
[Equation]
Notice that the dynamics terms log p ( z t +1 | z t , a t ) for t ≥ τ + 1 from the posterior and the prior cancel each other out in the ELBO.
The ﬁrst part of the ELBO corresponds to the model objective.
When using the parametric function approximators, the negative of it corresponds directly to the model loss in Equation (9).
The second part of the ELBO corresponds to the maximum entropy RL objective.
We assume a uniform action prior, so the log p ( a t ) term is a constant term that can be omitted when optimizing this objective.
We use message passing to optimize this objective, with messages deﬁned as
[Equation]
Then
[Equation]
the maximum entropy RL objective can be expressed in terms of the messages as
[Equation]
where the ﬁrst equality is obtained from dynamic programming (see Levine (2018) for details)
[Equation]
the second equality holds from the deﬁnition of KL divergence
[Equation]
and exp ( V ( z t )) is the normalization factor for exp ( Q ( z t , a t )) with respect to a t .
Since the KL divergence term is minimized when its two arguments represent the same distribution, the optimal policy is given by
[Equation]
Noting that the KL divergence term is zero for the optimal action, the equality from Equation (18) can be used in Equation (15) to obtain
[Equation]
This equation corresponds to the standard Bellman backup with a soft maximization for the value function.
As mentioned in Section 5, our algorithm conditions the parametric policy in the history of observations and actions, which allows us to directly execute the policy without having to perform inference on the latent state at run time.
When using the parametric function approximators, the negative of the maximum entropy RL objective, written as in Equation (17), corresponds to the policy loss in
Equation (11).
Lastly, the Bellman backup of Equation (20) corresponds to the Bellman residual in
Equation (10) when approximated by a regression objective.
We showed that the SLAC objectives can be derived from applying variational inference in the control as inference framework in the POMDP setting.
This leads to the joint likelihood of the past observations and future optimality variables, which we aim to optimize by maximizing the ELBO of the log-likelihood.
We decompose the ELBO into the model objective and the maximum entropy RL objective.
We express the latter in terms of messages of Q-functions, which in turn are learned by minimizing the Bellman residual.
These objectives lead to the model, policy, and critic losses.
B N ETWORK A RCHITECTURES
z··· z 2 τ z 2 τ + z··· z 1 τ z 1 τ + xx τ x τ + aa τ
Recall that our full sequential latent variable model has two layers of latent variables, which we denote z 1 t and z 2 t .
We found this design to provide a good balance between ease of training and expressivity, producing good reconstructions and generations and, crucially, providing good representations for reinforcement learning.
For reference, we reproduce the model diagram from the main paper in Figure 8.
Note that this diagram represents the Bayes net corresponding to our full model.
However, since all of the latent variables are stochastic, this visualization also presents the design of the computation graph.
Inference over the latent variables is performed using amortized variational inference, with all training done via reparameterization.
Hence, the computation graph can be deduced from the diagram by treating all solid arrows as part of the generative model and all dashed arrows as part of approximate posterior.
The generative model consists of the following probability distributions, as described in the main paper:
[Equation]
The initial distribution p ( z 11 ) is a multivariate standard normal distribution N ( 0 , I ) .
All of the other distributions are conditional and parameterized by neural networks with parameters ψ .
The networks for p ψ ( z 21 | z 11 ) , p ψ ( z 1 t +1 | z 2 t , a t ) , p ψ ( z 2 t +1 | z
1 t +1 , z
2 t , a t ) , and p ψ ( r t | z 1 t , z 2 t , a t , z 1 t +1 , z 2 t +1 ) consist of two fully connected layers, each with 256 hidden units, and a Gaussian output layer.
The Gaussian layer is deﬁned such that it outputs a multivariate normal distribution with diagonal variance, where the mean is the output of a linear layer and the diagonal standard deviation is the output of a fully connected layer with softplus non-linearity.
The observation model p ψ ( x t | z 1 t , z 2 t ) consists oftransposed convolutional layers (256 4 × 4 , 128 3 × 3 , 64 3 × 3 , 32 3 × 3 , and 3 5 × 5 ﬁlters, respectively, stride 2 each, except for the ﬁrst layer).
The output variance for each image pixel is ﬁxed to 0 . 1 .
The variational distribution q , also referred to as the inference model or the posterior, is represented by the following factorization:
[Equation]
Note that the variational distribution over z 21 and z 2 t +1 is intentionally chosen to exactly match the generative model p , such that this term does not appear in the KL-divergence within the ELBO, and a separate variational distribution is only learned over z 11 and z 1 t +1 .
This intentional design decision simpliﬁes the inference process.
The networks representing the distributions q ψ ( z 1 1 | x 1 ) and q ψ ( z 1 t +1 | x t +1 , z 2 t , a t ) both consist of 5 convolutional layers (32 5 × 5 , 64 3 × 3 , 128 3 × 3 , 256 3 × 3 , and 256× 4 ﬁlters, respectively, stride 2 each, except for the last layer), 2 fully connected layers (256 units each), and a Gaussian output layer.
The parameters of the convolution layers are shared among both distributions.
The latent variables have 32 and 256 dimensions, respectively, i.e. z 1 t ∈ R 32 and z 2 t ∈ R 256 .
For the image observations, x t ∈ [0 , 1] 64 × 64 × 3 .
All the layers, except for the output layers, use leaky
ReLU non-linearities.
Note that there are no deterministic recurrent connections in the network—all networks are feedforward, and the temporal dependencies all ﬂow through the stochastic units z 1 t and z 2 t
For the reinforcement learning process, we use a critic network Q θ consisting of 2 fully connected layers (256 units each) and a linear output layer.
The actor network π φ consists of 5 convolutional layers, 2 fully connected layers (256 units each), a Gaussian layer, and a tanh bijector, which constrains the actions to be in the bounded action space of [ − 1 , 1] .
The convolutional layers are the same as the ones from the latent variable model, but the parameters of these layers are not updated by the actor objective.
The same exact network architecture is used for every one of the experiments in the paper. [Table]
C T RAINING AND E VALUATION D ETAILS
The control portion of our algorithm uses the same hyperparameters as SAC (Haarnoja et al., 2018a), except for a smaller replay buffer size of 100000 environment steps (instead of a million) due to the high memory usage of image observations.
All of the parameters are trained with the Adam optimizer (Kingma & Ba, 2015), and we perform one gradient step per environment step.
The
Q-function and policy parameters are trained with a learning rate of 0.0003 and a batch size of 256.
The model parameters are trained with a learning rate of 0.0001 and a batch size of 32.
We use sequences of length τ = 8 for all the tasks.
Note that the sequence length can be less than τ for the ﬁrst t steps ( t < τ ) of each episode.
We use action repeats for all the methods, except for D4PG for which we use the reported results from prior work (Tassa et al., 2018).
The number of environment steps reported in our plots correspond to the unmodiﬁed steps of the benchmarks.
Note that the methods that use action repeats only use a fraction of the environment steps reported in our plots.
For example, 3 million environment steps of the cheetah task correspond to 750000 samples when using an action repeat of 4.
The action repeats used in our experiments are given in Table 1.
Unlike in prior work (Haarnoja et al., 2018a;b), we use the same stochastic policy as both the behavioral and evaluation policy since we found the deterministic greedy policy to be comparable or worse than the stochastic policy.
D A DDITIONAL P REDICTIONS FROM THE L ATENT V ARIABLE M ODEL
We show additional samples from our model in Figure 9 and Figure 10.
Samples from the posterior show the images x t as constructed by the decoder p ψ ( x t | z t ) , using a sequence of latents z t that are encoded and sampled from the posteriors, q ψ ( z 1 | x 1 ) and q ψ ( z t +1 | x t +1 , z t , a t ) .
Samples from the prior, on the other hand, use a sequence of latents where z 1 is sampled from p ( z 1 ) and all remaining latents z t are from the propagation of the previous latent state through the latent dynamics p ψ ( z t +1 | z t , a t ) .
These samples do not use any image frames as inputs, and thus they do not correspond to any ground truth sequence.
We also show samples from the conditional prior, which is conditioned on the ﬁrst image from the true sequence: for this, the sampling procedure is the same as the prior, except that z 1 is encoded and sampled from the posterior q ψ ( z 1 | x 1 ) , rather than being sampled from p ( z 1 ) .
W a l k er w a l k
G r ound T r u t h
P o s t
e r i
o r
S a m p l e
C ond iti on a l
P r i o r
S a m p l e
P r i o r S a m p l e
B a ll - i n - c up c a t c h
G r ound T r u t h
P o s t
e r i
o r
S a m p l e
C ond iti on a l
P r i o r
S a m p l e
P r i o r S a m p l e
F i n g er s p i n
G r ound T r u t h
P o s t
e r i
o r
S a m p l e
C ond iti on a l
P r i o r
[Figure]
H a l f C h ee t a h - v
G r ound T r u t h
P o s t
e r i
o r
S a m p l e
C ond iti on a l
P r i o r
S a m p l e P r i o r S a m p l e W a l k er 2 dv G r ound T r u t h
P o s t e r i o r
S a m p l e C ond iti on a l P r i o r S a m p l e
P r i o r S a m p l e
H o pp erv
G r ound T r u t h
P o s t
e r i
o r
S a m p l e
C ond iti on a l
P r i o r
S a m p l e
P r i o r S a m p l e
A n tv G r ound T r u t h P o s t e r i
o r
S a m p l e
C ond iti on a l
P r i o r
S a m p l e
[Figure]