M
E TA -
Q
- L E A R
N
I
N G Anonymous authors
Paper under double-blind review
[Equation]
This paper introduces Meta-Q-Learning (MQL), a new off-policy algorithm for meta-Reinforcement Learning (meta-RL).
MQL builds upon three simple ideas.
First, we show that Q-learning is competitive with state of the art meta-RL algorithms if given access to a context variable that is a representation of the past trajectory.
Second, using a multi-task objective to maximize the average reward across the training tasks is an effective method to meta-train RL policies.
Third, past data from the meta-training replay buffer can be recycled to adapt the policy on a new task using off-policy updates.
MQL draws upon ideas in propensity estimation to do so and thereby ampliﬁes the amount of available data for adaptation.
Experiments on standard continuous-control benchmarks suggest that MQL compares favorably with state of the art meta-RL algorithms
[Equation]
[Figure]
Reinforcement Learning (RL) algorithms have demonstrated good performance on simulated data.
There are however two main challenges in translating this performance to real robots: (i) robots are complex and fragile which precludes extensive data collection, and (ii) a real robot may face an environment that is different than the simulated environment it was trained in.
This has fueled research into MetaReinforcement Learning (meta-RL) which develops algorithms that “meta-train” on a large number of different environments, e.g., simulated ones, and aim to adapt to a new environment with few data.
How well does meta-RL work today?
Fig.
1 shows the performance of two prototypical meta-RL algorithms on four standard continuous-control benchmarks.
1 We compared them to the following simple baseline: an off-policy RL algorithm (TD3 by Fujimoto et al.
(2018b))
and which was trained to maximize the average reward over all training tasks and modiﬁed to use a “context variable” that represents the trajectory.
All algorithms in this ﬁgure use the same evaluation protocol.
It is surprising that this simple non-meta-learning-based method is competitive with state-of-the-art meta-RL algorithms.
This is the ﬁrst contribution of our paper: we demonstrate that it is not necessary to meta-train policies to do well on existing benchmarks.
Our second contribution is an off-policy meta-RL algorithm named Meta-Q-Learning (MQL) that builds upon the above result.
MQL uses a simple meta-training procedure: it maximizes the average rewards across all meta-training tasks using off-policy updates to obtain
[Equation]
where (cid:96) k
( θ ) is the objective evaluated on the transition τ obtained from the task D k ( θ ) , e.g., 1-step temporal-difference (TD) error would set (cid:96) k
( θ ) =
TD 2 ( θ ; τ ) .
This objective, which we call the multi-task objective, is the simplest form of meta-training.
For adapting the policy to a new task, MQL samples transitions from the meta-training replay buffer that are similar to those from the new task.
This ampliﬁes the amount of data available for adaptation but it is difﬁcult to do because of the large potential bias.
We use techniques from the propensity estimation literature for performing this adaptation and the off-policy updates of MQL are crucial to doing so.
The adaptation phase of MQL solves
[Equation]
where D meta is the meta-training replay buffer, the propensity score β ( τ ; D new , D meta ) is the odds of a transition τ belonging to D new versus D meta , and (cid:100)
ESS is the Effective Sample Size between D new and
D meta that is a measure of the similarly of the new task with the meta-training tasks.
The ﬁrst term computes off-policy updates on the new task, the second term performs β ( · ) -weighted off-policy updates on old data, while the third term is an automatically adapting proximal term that prevents degradation of the policy during adaptation.
We perform extensive experiments in Sec.
4.2 including ablation studies using standard meta-RL benchmarks that demonstrate that MQL policies obtain higher average returns on new tasks even if they are meta-trained for fewer time-steps than state of the art algorithms.
B AC K G RO U N D
This section introduces notation and formalizes the meta-RL problem.
We discuss techniques for estimating the importance ratio between two probability distributions in Sec. 2.2.
Consider a Markov
Decision Processes (MDP) denoted by
[Equation]
where x t ∈ X ⊂ R d are the states and u t ∈ U ⊂ R p are the actions.
The dynamics f k is parameterized by k ∈ { 1 , . . . , n } where each k corresponds to a different task.
The distribution p k 0 denotes the initial state distribution and ξ t is the noise in the dynamics.
Given a deterministic policy u θ ( x t ) , the action-value function for γ -discounted future rewards r kt :=
r k ( x t , u θ ( x t )) over an inﬁnite time-horizon is
[Equation]
Note that we have assumed that different tasks have the same state and action space and may only differ in their dynamics f k and reward function r k .
Given one task k ∈ { 1 , . . . , n } , the standard
Reinforcement Learning (RL) formalism solves
[Equation]
Let us denote the dataset of all states, actions and rewards pertaining to a task k and policy u θ ( x ) by
[Equation]
we will often refer to D k as the “task”.
The Deterministic Policy Gradient (DPG) algorithm
(Silver et al., 2014) for solving (5) learns a ϕ -parameterized approximation q ϕ to the optimal value function q k by minimizing the Bellman error and the optimal policy u θ that maximizes this approximation by solving the coupled optimization problem
[Equation] [Equation]
The 1-step temporal difference error (TD error) is deﬁned as
[Equation] [Equation]
where we keep the dependence of TD ( · ) on ϕ implicit.
DPG, or its deep network-based variant
DDPG (Lillicrap et al., 2015), is an off-policy algorithm.
This means that the expectations in (6) are computed using data that need not be generated by the policy being optimized ( u θ ), this data can come from some other policy.
In the sequel, we will focus on the parameters θ parameterizing the policy.
The parameters ϕ of the value function are always updated to minimize the TD-error and are omitted for clarity.
2. M ETA -R EINFORCEMENT L EARNING (M ETA -RL)
Meta-RL is a technique to learn an inductive bias that accelerates the learning of a new task by training on a large of number of training tasks.
Formally, meta-training on tasks from the meta-training set
D meta =
[Equation]
.,n involves learning a policy
[Equation]
where (cid:96) k meta ( θ ) is a meta-training loss that depends on the particular method.
Gradient-based meta-RL, let us take MAML by Finn et al.
(2017) as a concrete example, sets
[Equation]
(9) for a step-size α > 0 ; (cid:96) k
( θ ) is the objective of non-meta-RL (5).
In this case (cid:96) k meta is the objective obtained on the task D k after one (or in general, more) updates of the policy on the task.
The idea behind this is that even if the policy (cid:98) θ meta does not perform well on all tasks in D meta it may be updated quickly on a new task D new to obtain a well-performing policy.
This can either be done using the same procedure as that of meta-training time, i.e., by maximizing (cid:96) newmeta ( θ ) with the policy (cid:98) θ meta as the initialization, or by some other adaptation procedure.
The meta-training method and the adaptation method in meta-RL, and meta-learning in general, can be different from each other.
2. L OGISTIC REGRESSION FOR ESTIMATING THE PROPENSITY SCORE
Consider standard supervised learning: given two distributions q ( x ) (say, train) and p ( x ) (say, test), we would like to estimate how a model’s predictions ˆ y ( x ) change across them.
This is formally done using importance sampling:
[Equation]
where y | x are the true labels of data, the predictions of the model are ˆ y ( x ) and (cid:96) ( y, ˆ y ( x )) is the loss for each datum ( x, y ) .
The importance ratio β ( x ) =
d p d q ( x ) , also known as the propensity score, is the Radon-Nikodym derivative (Resnick, 2013) of the two data densities and measures the odds of a sample x coming from the distribution p versus the distribution q .
In practice, we do not know the densities q ( x ) and p ( x ) and therefore need to estimate β ( x ) using some ﬁnite data
X q = { x 1 , . . .
, x m } drawn from q and X p = { x (cid:48) 1 , . . .
, x (cid:48) m } drawn from p .
As Agarwal et al.
(2011) show, this is easy to do using logistic regression.
Set z k
= 1 to be the labels for the data in X q and z k = − 1 to be the labels of the data in X p for k ≤ m and ﬁt a logistic classiﬁer on the combined 2 m samples by solving
[Equation]
This gives
[Equation]
Normalized Effective Sample Size ( (cid:100) ESS): A related quantity to β ( x ) is the normalized Effective
Sample Size ( (cid:100) ESS) which we deﬁne as the relative number of samples from the target distribution p ( x ) required to obtain an estimator with performance (say, variance) equal to that of the importance sampling estimator (10).
It is not possible to compute the (cid:100) ESS without knowing both densities q ( x ) and p ( x ) but there are many heuristics for estimating it.
A popular one in the Monte Carlo literature (Kong, 1992; Smith, 2013; Elvira et al., 2018) is
[Equation]
13) where X = { x 1 , . . .
, x m } is some ﬁnite batch of data.
Observe that if two distributions q and p are close then the (cid:100) ESS is close to one; if they are far apart the (cid:100) ESS is close to zero.
M Q L
This section describes the MQL algorithm.
We begin by describing the meta-training procedure of
MQL including a discussion of multi-task training in Sec. 3.1.
The adaptation procedure is described in Sec. 3.2.
3. M ETA - TRAINING
MQL performs meta-training using the multi-task objective.
Note that if one sets
[Equation]
(14) in (8) then the parameters (cid:98) θ meta are such that they maximize the average returns over all tasks from the meta-training set.
We use an off-policy algorithm named TD3 (Fujimoto et al., 2018b) as the building block and solve for
[Equation]
(15) where TD ( · ) is deﬁned in (7).
As is standard in TD3, we use two action-value functions parameterized by ϕ 1 and ϕ 2 and take their minimum to compute the target in (7).
This trick known as “doubleQ-learning” reduces the over-estimation bias.
Let us emphasize that (14) is a special case of the procedure outlined in (8).
The following remark explains why MQL uses the multi-task objective as opposed to the meta-training objective used, for instance, in existing gradient-based meta-RL algorithms.
Remark 1.
Let us compare the critical points of the m -step MAML objective (9) to those of the multi-task objective which uses (14).
As is done by the authors in Nichol et al.
(2018), we can perform a Taylor series expansion around the parameters θ to obtain
[Equation]
Note that all critical points (cid:8) θ : ∇ (cid:96) k
( θ ) = 0 (cid:9) also have ∇ (cid:96) k meta ( θ ) = 0 .
Further, note that ∇ (cid:96) k meta in (16) is also the gradient of the loss
[Equation]
up to ﬁrst order.
This lends a new interpretation that MAML is attracted towards regions in the loss landscape that under-ﬁt on individual tasks: parameters with large (cid:107)∇ (cid:96) k (cid:107) 2 will be far from the local maxima of (cid:96) k
( θ ) .
The parameters α and m control this under-ﬁtting.
Larger the number of gradient steps, larger the under-ﬁtting effect.
This remark suggests that the adaptation speed of gradient-based meta-learning comes at the cost of under-ﬁtting on the tasks.
3.1. D ESIGNING CONTEXT
As discussed in Sec. 1 and 4.4, the identity of the task in meta-RL can be thought of as the hidden variable of an underlying partially-observable MDP.
The optimal policy on the entire trajectory of the states, actions and the rewards.
We therefore design a recurrent context variable z t that depends on { ( x i , u i , r i ) } i ≤ t .
We set z t to the hidden state at time t of a Gated Recurrent Unit (GRU by Cho et al.
(2014)) model.
All the policies u θ ( x ) and value functions q ϕ ( x, u ) in MQL are conditioned on the context and implemented as u θ ( x, z ) and q ϕ ( x, u, z ) .
Any other recurrent model can be used to design the context; we used a GRU because it offers a good trade-off between a rich representation and computational complexity.
Remark 2 (MQL uses a deterministic context that is not permutation invariant).
We have aimed for simplicity while designing the context.
The context in MQL is built using an off-the-shelf model like GRU and is not permutation invariant.
Indeed, the direction of time affords crucial information about the dynamics of a task to the agent, e.g., a Half-Cheetah running forward versus backward has arguably the same state trajectory but in a different order.
Further, the context in MQL is a deterministic function of the trajectory.
Both these aspects are different than the context used by Rakelly et al.
(2019) who design an inference network and sample a probabilistic context conditioned on a moving window.
RL algorithms are quite complex and challenging to reproduce.
Current meta-RL techniques which build upon them further exacerbate this complexity.
Our demonstration that a simple context variable is enough is an important contribution.
3. A DAPTATION TO A NEW TASK
We next discuss the adaptation procedure which adapts the meta-trained policy (cid:98) θ meta to a new task
D new with few data.
MQL optimizes the adaptation objective introduced in (2) into two steps.
Vanilla off-policy adaptation: The ﬁrst step is to update the policy using the new data as [Equation] ( θ ) (cid:105) − λ [Equation]
(cid:107) θ
[Equation]
(cid:98) θ meta (cid:107)
[Equation]
(cid:27) [Equation] The quadratic penalty (cid:107) θ − (cid:98) θ meta (cid:107) 2 keeps the parameters close to (cid:98) θ meta .
This is crucial to reducing the variance of the model that is adapted using few data from the new task (Reddi et al., 2015).
Off-policy learning is critical in this step because of its sample efﬁciency.
We initialize θ to (cid:98) θ meta while solving (18).
Importance-ratio corrected off-policy updates: The second step of MQL
exploits the metatraining replay buffer.
Meta-training tasks D meta are disjoint from D new but because they are expected to come from the same task distribution, transitions collected during meta-training can potentially be exploited to adapt the policy.
This is difﬁcult to do on two counts.
First, the meta-training transitions do not come from D new .
Second, even for transitions from the same task, it is non-trivial to update the policy because of extrapolation error (Fujimoto et al., 2018a): the value function has high error on states it has not seen before.
Our use of the propensity score to reweigh transitions is a simpler version of the conditional generative model used by Fujimoto et al.
(2018a) in this context.
MQL ﬁts a logistic classiﬁer on a mini-batch of transitions from the meta-training replay buffer and the transitions collected from the new task in step 1.
The context variable z t is the feature for this classiﬁer.
The logistic classiﬁer estimates the importance ratio β
( τ ; D new , D meta ) and can be used to reweigh data from the meta-training replay buffer for taking updates as
[Equation]
We have again included a quadratic penalty (cid:107) θ − (cid:98) θ meta (cid:107) 2 that keeps the new parameters close to (cid:98) θ meta .
Estimating the importance ratio involves solving a convex optimization problem on few samples (typically, 200 from the new task and 200-400 from the meta-training tasks).
This classiﬁer allows
MQL to exploit the large amount of past data.
In practice, we perform as many as 100 × more weight updates using (19) than (18).
Remark 3 (Picking the coefﬁcient λ ).
Following Fakoor et al.
(2019), we pick
[Equation]
ESS for both the steps (18–19).
This relaxes the quadratic penalty if the new task is similar to the metatraining tasks ( (cid:100) ESS is large) and vice-versa.
While λ could be tuned as a hyper-parameter, our empirical results show that adapting it using (cid:100) ESS is a simple and effective heuristic.
Remark 4 (Details of estimating the importance ratio).
It is crucial to ensure that the logistic classiﬁer for estimating β generalizes well if we are to reweigh transitions in the meta-training replay buffer that are different than the ones the logistic was ﬁtted upon.
We do so in two ways: (i) the regularization co-efﬁcient in (11) is chosen to be relatively large, that way we prefer false negatives than risk false positives; (ii) transitions with very high
β are valuable for updating (19) but cause a large variance in stochastic gradient descent-based updates, we clip β before taking the update in (19).
The clipping constant is a hyper-parameter and is given in Sec. 4.
MQL requires having access to the meta-training replay buffer during adaptation.
This is not a debilitating requirement and there are a number of clustering techniques that can pick important transitions from the replay-buffer if a robotic agent is limited by available hard-disk space.
The meta-training replay buffer is at most 3 GB for the experiments in Sec. 4.
E X P E R I M E N T S
This section presents the experimental results of MQL.
We ﬁrst discuss the setup and provide details the benchmark in Sec. 4.1.
This is followed by empirical results and ablation experiments in Sec.
4. S ETUP
Tasks and algorithms: We use the MuJoCo (Todorov et al., 2012) simulator with
OpenAI Gym (Brockman et al., 2016) on continuous-control meta-RL benchmark tasks.
These tasks have different rewards, randomized system parameters (Walker-2D-Params) and have been used in previous papers such as Finn et al.
; Rothfuss et al.
; Rakelly et al.
We compare against standard baseline algorithms, namely MAML (TRPO (Schulman et al., 2015) variant)
(Finn et al., 2017),
RL2 (Duan et al., 2016), ProMP (Rothfuss et al., 2018) and PEARL (Rakelly et al., 2019).
We obtained the training curves and hyper-parameters for all the three algorithms from the published code by Rakelly et al.
We will compare the above algorithms against: (i) vanilla TD3 (Fujimoto et al., 2018a) without any adaptation on new tasks, (ii) TD3-context:
TD3 with GRU-based context Sec.
3.1.1 without any adaptation, and (iii) MQL:
TD3 with context and adaptation on new task using the procedure in Sec. 3.2.
All the three variants use the multi-task objective for meta-training (15).
We use Adam (Kingma & Ba, 2014) for optimizing all the loss functions in this paper.
Evaluation: Current meta-RL benchmarks lack a systematic evaluation procedure.
For each environment, Rakelly et al.
(2019) constructed a ﬁxed set of meta-training tasks ( D meta ) and a validation set of tasks D new that are disjoint from the metatraining set.
To enable direct comparison with published empirical results, we closely followed the evaluation code of Rakelly et al.
(2019) to create these tasks.
We also use the exact same evaluation protocol as that of these authors, e.g., 200 time-steps of data from the new task, or the number of evaluation episodes.
We report the undiscounted return on the validation tasks with statistics computed across 5 random seeds.
4. R ESULTS
Our ﬁrst result, in Fig. 2, is to show that vanilla off-policy learning with context, without any adaptation is competitive with state of the art meta-RL algorithms.
We used a standard implementation of TD3 and train on the meta-training tasks using the multi-task objective (15).
Hyper-parameters for these tasks are provided in Appendix D.
This result is surprising and had gone unnoticed in the experiments and comparing current literature.
Policies that have access to the context can easily generalize to the validation tasks and achieve performance that is comparable to more sophisticated meta-RL algorithms.
We next evaluate MQL against existing meta-RL benchmarks on all environments.
The results are shown in Fig.
We see that for all environments except Walker-2D-Params and Ant-Goal-2D,
MQL obtains comparable or better returns on the validation tasks.
In most cases, in particular for the challenging Humanoid-Direc-2D environment, MQL converges faster than existing algorithms.
MAML and ProMP require about 100M time-steps to converge to returns that are signiﬁcantly worse than the returns of off-policy algorithms like MQL and PEARL.
Compare the training curve for
TD3-context for the Ant-Goal-2D environment in Fig.
2 with that of the same environment in Fig.
3: the former shows a prominent dip in performance as meta-training progresses; this dip is absent in Fig.
3 and can be attributed to the adaptation phase of MQL.
4. A BLATION EXPERIMENTS
We conduct a series of ablation studies to analyze the different components of the MQL algorithm.
We use two environments for this purpose, namely Half-Cheetah-Fwd-Back and Ant-Fwd-Back.
Fig.
4a shows that the adaptation in MQL in (18) and (19) improves performance.
Also observe that
MQL has a smaller standard deviation in the returns as compared to TD3-context which does not perform any adaptation; this can be seen as the adaptation phase making up for the lost performance of the meta-trained policy on a difﬁcult task.
Next, we evaluate the importance of the additional data from the replay buffer in MQL.
Fig.
4b compares the performance of MQL with and without updates in (19).
We see that the old data, even if it comes from different tasks, is useful to improve the performance on top of (18).
Fig.
4c shows the effectiveness of setting λ = 1 − (cid:100) ESS as compared to a ﬁxed value of λ = 0 .
We see that modulating the quadratic penalty with (cid:100)
ESS helps, the effect is minor for Sec. 4.3.
The ideal value of λ depends on a given task and using 1 − (cid:100) ESS can help to adjust to different tasks without the need to do hyper-parameter search per task.
Finally, Fig. 5 shows the evolution of λ and β ( z ) during meta-training.
The coefﬁcient λ is about 0.55 and β ( z ) is 0.
for a large fraction of the time.
The latter indicates that propensity score estimation is successful in sampling transitions from the meta-training replay buffer that are similar to the validation tasks.
The value of λ remains relatively unchanged during training.
This value indicates the fraction of transitions in the old data that are similar to those from the new tasks; since there are two distinct tasks in Ant-Fwd-Back, the value λ = 0.55 is appropriate. [Figure]
4. R ELATED WORK
Learning to learn: The idea of building an inductive bias for learning a new task by training on a large number of related tasks was established in a series of works (Utgoff, 1986; Schmidhuber, 1987; Baxter, 1995; Thrun, 1996;
Thrun & Pratt, 2012).
These papers propose building a base learner that ﬁts on each task and a meta-learner that learns properties of the base learners to output a new base learner for a new task.
The recent literature instantiates this idea in two forms: (i) the meta-learner directly predicts the base-learner (Wang et al., 2016;
Snell et al., 2017) and (ii) the meta-learner learns the updates of the baselearner (Bengio et al., 1992; Hochreiter et al., 2001;
Finn et al., 2017).
Meta-training versus multi-task training: Metatraining aims to train a policy that can be adapted efﬁciently on a new task. Conceptually, the improved efﬁciency of a meta-learner comes from two things: (i) building a better inductive bias to initialize the learning (Schmidhuber et al., 1997; Baxter, 1995; 2000; Mitchell, 1980), or (ii) learning a better learning procedure (Bengio et al., 1997; Lee et al., 2019). The two notions of meta-learning above are complementary to each other and in fact, most recent literature using deep neural networks, e.g., MAML (Finn et al., 2017) and Prototypical Networks (Snell et al., 2017) conﬁrms to the ﬁrst notion of building a better inductive bias.
The multi-task training objective in MQL is the simplest possible instantiation of this idea: it maximizes the average reward on all tasks and learns a better prior without explicitly training for improving adaptation. This aspect of MQL coincides with a recent trend in meta-learning for image classiﬁcation where it has been observed that modiﬁcations to episodic meta-training (Snell et al., 2017; Gidaris & Komodakis, 2018; Chen et al., 2018), or even foregoing meta-training completely (Dhillon et al., 2019) performs better. We speculate two reasons for this phenomenon: (i) meta-training methods are complex to implement and tune, and (ii) powerful function classes such as deep neural networks may have leftover capacity to adapt to a new task even if they are not explicitly trained for adaptation. Context-based approaches: Both forms of meta-learning above have been employed relatively successfully for image classiﬁcation (Snell et al., 2017; Ravi & Larochelle, 2016;
Finn et al., 2017). It has however been difﬁcult to replicate that empirical performance in RL: sensitivity to hyperparameters (Henderson et al., 2018) precludes directly predicting the base-learner while long-range temporal dependencies make it difﬁcult to learn the updates of the base learner (Nichol et al., 2018).
Recent methods for meta-RL instead leverage context and learn a policy that depends on just on the current state x t but on the previous history.
This may be done in a recurrent fashion (Heess et al., 2015; Hausknecht & Stone, 2015) or by learning a latent representation of the task (Rakelly et al., 2019).
Context is a powerful construct: as Fig. 1 shows, even a simple vanilla RL algorithm (TD3) when combined with context performs comparably to state-of-the-art meta-RL algorithms.
However, context is a meta-training technique, it does not suggest a way to adapt a policy to a new task.
For instance, Rakelly et al.
(2019) do not update parameters of the policy on a new task.
They rely on the latent representation of the context variable generalizing to new tasks.
This is difﬁcult if the new task is different from the training tasks; we discuss this further in Sec.
Policy-gradient-based algorithms versus off-policy methods
: Policy-gradient-based methods have high sample complexity (Ilyas et al., 2018).
This is particularly limiting for meta-RL (Finn et al., 2017; Rothfuss et al., 2018;
Houthooft et al., 2018) where one (i) trains on a large number of tasks and, (ii) aims to adapt to a new task with few data.
Off-policy methods offer substantial gains in sample complexity.
This motivates our use of off-policy updates for both meta-training and adaptation.
Off-policy updates allow using past data from other policies.
MQL exploits this substantially, it takes up to 100 × more updates using old data than new data during adaptation.
Off-policy algorithms are typically very sensitive to hyper-parameters (Fujimoto et al., 2018a)
but we show that
MQL is robust to such sensitivity because it adapts automatically to the distribution shift using the
Effective Sample Size (ESS).
Propensity score estimation has been extensively studied in both statistics (Robert & Casella, 2013;
Quionero-Candela et al., 2009) and RL (Dud´ık et al., 2011; Jiang & Li, 2015; Kang et al., 2007;
Bang & Robins, 2005).
It is typically used to reweigh data from the proposal distribution to compute estimators on the target distribution.
MQL uses propensity scores in a novel way: we ﬁt a propensity score estimator on a subset of the meta-training replay buffer and use this model to sample transitions from the replay buffer that are similar to the new task.
The off-policy updates in MQL are essential to exploiting this data.
The coefﬁcient of the proximal term in the adaptation-phase objective (18–19) using the effective sample size (ESS) is inspired from the recent work of Fakoor et al.
D I S C U S S I O N
The algorithm proposed in this paper, namely MQL, builds upon on three simple ideas.
First, Qlearning with context is sufﬁcient to be competitive on current meta-RL benchmarks.
Second, maximizing the average reward of training tasks is an effective meta-learning technique.
The meta-training phase of MQL is signiﬁcantly simpler than that of existing algorithms and yet it achieves comparable performance to the state of the art.
This suggests that we need to re-think meta-learning in the context of rich function approximators such as deep networks.
Third, if one is to adapt to new tasks with few data, it is essential to exploit every available avenue.
MQL recycles data from the meta-training replay buffer using propensity estimation techniques.
This data is essentially free and is completely neglected by other algorithms.
This idea can potentially be used in problems outside RL such as few-shot and zero-shot image classiﬁcation.
Finally, this paper sheds light on the nature of benchmark environments in meta-RL.
The fact that even vanilla Q-learning with a context variable—without meta-training and without any adaptation— is competitive with state of the art algorithms indicates that (i) training and validation tasks in the current meta-RL benchmarks are quite similar to each other and (ii) current benchmarks may be insufﬁcient to evaluate meta-RL algorithms.
Both of these are a call to action and point to the need to invest resources towards creating better benchmark problems for meta-RL that drive the innovation of new algorithms A [Equation] E U D O
[Equation]
D E
The pseudo-code for MQL during training and adaption are given in Algorithm 1 and Algorithm 2.
After MQL is trained for a given environment as described in Algorithm 1, it returns the meta-trained policy θ and replay buffer containing train tasks.
Next, Algorithm 2 runs the adaptation procedure which adapts the meta-trained policy to a test task D with few data.
To do so, MQL optimizes the adaptation objective into two steps.
After gathering data from a test task D , MQL ﬁrst updates the policy using the new data (line 4).
MQL then ﬁts a logistic classiﬁer on a mini-batch of transitions from the meta-training replay buffer and the transitions collected from the test task and then estimates (cid:100) ESS (lines 5-6).
Finally, the adaptation step runs for n iterations (lines 7 - 10) in which MQL can exploit past data in which it uses propensity score to decide whether or not a given sample is related to the current test task.
B O U T - O F - D I S T R I B U T I O N T A S K S
MQL is designed for explicitly using data from the new task along with off-policy data from old, possibly very different tasks.
This is on account of two things: (i) the loss function of MQL does not use the old data if it is very different from the new task, β is close to zero for all samples, and (ii) the ﬁrst term in (18) makes multiple updates using data from the new task.
To explore this aspect, we create an out-of-distribution task using the “Half-Cheetah-Vel” environment wherein we use disjoint sets of velocities for meta-training and testing.
The setup is as follows:
• Half-Cheetah-Vel-OOD-Medium: target velocity for a training task is sampled uniformly randomly from [0 , 2 . 5] while that for test task is sampled uniformly randomly from [2 . 5 , 3 . 0] .
This is what we call “medium” hardness task because although the distributions of train and test velocities is disjoint, they are close to each other.
• Half-Cheetah-Vel-OOD-Hard: target velocity for a training task is sampled uniformly randomly from [0 , 1 . 5] while that for test task is sampled uniformly randomly from [2 . 5 , 3 . 0] .
This is a “hard” task because the distributions of train and test velocities are far away from each other.
Fig.
6a shows that MQL signiﬁcantly outperforms PEARL when the train and test target velocities come from disjoint sets.
We used the published code of PEARL (Rakelly et al., 2019) for this experiment.
This shows that the adaptation in MQL is crucial to generalizing to new situations which are not a part of the meta-training process.
Fig.
6b shows the evolution of the proximal penalty coefﬁcient λ
and the propensity score β ( z ) during meta-training for the medium-hard task.
We see that λ ≈ 0 .
while β ( z ) ≈ 0 . 2 throughout training.
This indicates that MQL automatically adjusts its test-time adaptation to use only few samples in (19) if the test task provides transitions quite different than those in the replay buffer.
We next discuss results on the harder task Half-Cheetah-Vel-OOD-Hard .
There is a very large gap between training and test target velocities in this case.
Fig.
7a shows the comparison with the same test protocol as the other experiments in this paper.
In particular, we collect 200 time-steps from the new task and use it for adaptation in both MQL and TD3-context.
Since this task is particularly hard, we also ran an experiment where 1200 time-steps (6 episodes) are given to the two algorithms for adaptation.
The results are shown in Fig.
7b.
In both cases, we see that MQL is better than
TD3-context by a large margin (the standard deviation on these plots is high because the environment is hard).
Note that since we re-initialize the hidden state of the context network at the beginning of each episode, TD3-context cannot take advantage of the extra time-steps.
MQL on the other hand updates the policy explicitly and can take advantage of this extra data.
For sake of being thorough, we collected 800 time-steps from the new task from the same episode, the results are shown in Fig.
8a.
We again notice that MQL results in slightly higher rewards than
TD3-context in spite of the fact that both the algorithms suffer large degradation in performance as compared to Figs.
7a and 7b.
Figs.
7c, 7d and 8b show that the proximal penalty coefﬁcient λ ≈ 1 and the propensity score β ( z ) ≈ 0 for a large fraction of training.
This proves that MQL is able to automatically discard samples unrelated to the new test during the adaptation phase.
C M O R E A B L AT I O N S T U D I E S
We conduct a series of additional ablation studies to analyze the different components of the MQL algorithm.
We use two environments for this purpose, namely Half-Cheetah-Vel and Walker-2DParams.
Fig.
9 and Fig.
10 show the result of these experiments.
These experiments show that adaptation phase is more useful for Half-Cheetah-Vel than Walker-2D-Params as test and training
[Figure]
outperforms demonstrates automatically
[Figure]
[Figure]
[Figure]
We see that modulating the quadratic penalty with (cid:100)
ESS helps, the effect is minor for Sec.
of λ depends on a given task using 1 − (cid:100) ESS can help to adjust to different tasks without the need to do
hyper- search per task
[Figure]
tasks are very similar in Walker-2D-Params which helps TD3-context achieves strong performance that leaves no window for improvement with adaptation.
[Equation]
R E S U LT S
[Table]
[Table]