summaries: The authors propose an algorithm for transferring policies across domains differing in their transition model. The idea is to "regularize" the target policy being learned to generate a trajectory distribution similar to the one induced by the source optimal policy in the respective MDP. The method is proved effective in standard simulated robotic tasks (Mujoco). This paper addresses the actively studied problem of efficiently transferring policies across domains in reinforcement learning. Authors propose a framework to transfer policies between tasks in domains with significantly different state transition. The proposed algorithm is based on a policy adaptation mechanism, with the idea that provided that a source optimal policy of a task is available, that policy is adapted to derive the optimal policy of the target task at a low sample complexity.  This paper tackles the problem of transferring a policy from source to target MDP, which differ in the state transition function. The idea is to add an additional cost that is the KL divergence between the trajectory likelihood under target policy (being learned) and target dynamics and the trajectory likelihood under the source policy (assumed optimal and deterministic) and source dynamics. The intuition is that the target policy will learn to match the state distribution of the optimal source policy. Results on MuJoCo locomotion robots with varying physics show that the proposed method performs better on target than warm-started RL or learning from scratch. 
abstractText: Efficient and robust policy transfer remains a key challenge in reinforcement learning. Policy transfer through warm initialization, imitation, or interacting over a large set of agents with randomized instances, have been commonly applied to solve a variety of Reinforcement Learning (RL) tasks. However, this is far from how behavior transfer happens in the biological world: Humans and animals are able to quickly adapt the learned behaviors between similar tasks and learn new skills when presented with new situations. Here we seek to answer the question: Will learning to combine adaptation reward with environmental reward lead to a more efficient transfer of policies between domains? We introduce a principled mechanism that can “Adapt-to-Learn”, that is adapt the source policy to learn to solve a target task with significant transition differences and uncertainties. We show through theory and experiments that our method leads to a significantly reduced sample complexity of transferring the policies between the tasks.
references.authors: Haitham B Ammar Karl Tuyls Matthew E Taylor Kurt Driessens Gerhard Weiss
references.title: Reinforcement learning transfer via sparse coding
references.venue: In Proceedings of the 11th International Conference on Autonomous Agents and Multiagent Systems-Volume
references.authors: Haitham Bou Ammar Eric Eaton Paul Ruvolo Matthew E Taylor
references.title: Unsupervised cross-domain transfer in policy gradient reinforcement learning via manifold alignment
references.venue: In Proc. of AAAI,
references.authors: Karl J Åström Björn Wittenmark
references.title: Adaptive control
references.venue: Courier Corporation,
references.authors: Karl J Åström Richard E Klein Anders Lennartsson
references.title: Bicycle dynamics and control
references.venue: IEEE Control Systems Magazine,
references.authors: Bikramjit Banerjee Peter Stone
references.title: General game learning using knowledge transfer
references.venue: In IJCAI, pp
references.authors: Andrew G Barto Richard S Sutton Charles W Anderson
references.title: Neuronlike adaptive elements that can solve difficult learning control problems
references.venue: IEEE transactions on systems, man, and cybernetics,
references.authors: Girish Chowdhary Tongbin Wu Mark Cutler Jonathan P How
references.title: Rapid transfer of controllers between uavs using learning-based adaptive control
references.venue: In Robotics and Automation (ICRA),
references.authors: Paul Christiano Zain Shah Igor Mordatch Jonas Schneider Trevor Blackwell Joshua Tobin Pieter Abbeel Wojciech Zaremba
references.title: Transfer from simulation to real world through learning deep inverse dynamics model
references.venue: arXiv preprint arXiv:1610.03518,
references.authors: Shreyansh Daftry J Andrew Bagnell Martial Hebert
references.title: Learning transferable policies for monocular reactive mav control
references.venue: In International Symposium on Experimental Robotics,
references.authors: Yan Duan Marcin Andrychowicz Bradly Stadie OpenAI Jonathan Ho Jonas Schneider Ilya Sutskever Pieter Abbeel Wojciech Zaremba
references.title: One-shot imitation learning
references.venue: In Advances in neural information processing systems,
references.authors: Mitch J Fryling Cristin Johnston Linda J Hayes
references.title: Understanding observational learning: An interbehavioral approach
references.venue: The Analysis of Verbal Behavior,
references.authors: Nicolas Heess Srinivasan Sriram Jay Lemmon Josh Merel Greg Wayne Yuval Tassa Tom Erez Ziyu Wang Ali Eslami Martin Riedmiller
references.title: Emergence of locomotion behaviours in rich environments
references.venue: arXiv preprint arXiv:1707.02286,
references.authors: Nan Jiang
references.title: Pac reinforcement learning with an imperfect model
references.venue: In Proc. of AAAI,
references.authors: Girish Joshi Girish Chowdhary
references.title: Cross-domain transfer in reinforcement learning using target apprentice
references.venue: IEEE International Conference on Robotics and Automation (ICRA),
references.authors: John W Krakauer Pietro Mazzoni
references.title: Human sensorimotor learning: adaptation, skill, and beyond
references.venue: Current opinion in neurobiology,
references.authors: Sergey Levine Vladlen Koltun
references.title: Guided policy search
references.venue: In International Conference on Machine Learning, pp
references.authors: Sergey Levine Nolan Wagener Pieter Abbeel
references.title: Learning contact-rich manipulation skills with guided policy search
references.venue: In Robotics and Automation (ICRA),
references.authors: Sergey Levine Peter Pastor Alex Krizhevsky Deirdre Quillen
references.title: Learning hand-eye coordination for robotic grasping with large-scale data collection
references.venue: In International Symposium on Experimental Robotics,
references.authors: Libin Liu Jessica Hodgins
references.title: Learning to schedule control fragments for physics-based characters using deep q-learning
references.venue: ACM Transactions on Graphics (TOG),
references.authors: Anusha Nagabandi Gregory Kahn Ronald S Fearing Sergey Levine
references.title: Neural network dynamics for model-based deep reinforcement learning with model-free fine-tuning
references.venue: IEEE International Conference on Robotics and Automation (ICRA),
references.authors: Xue Bin Peng Glen Berseth Michiel Van de Panne
references.title: Terrain-adaptive locomotion skills using deep reinforcement learning
references.venue: ACM Transactions on Graphics (TOG),
references.authors: Xue Bin Peng Marcin Andrychowicz Wojciech Zaremba Pieter Abbeel
references.title: Sim-to-real transfer of robotic control with dynamics randomization
references.venue: arXiv preprint arXiv:1710.06537,
references.authors: Xue Bin Peng Glen Berseth KangKang Yin Michiel Van De Panne
references.title: Deeploco: Dynamic locomotion skills using hierarchical deep reinforcement learning
references.venue: ACM Transactions on Graphics (TOG),
references.authors: Jan Peters Stefan Schaal
references.title: Policy gradient methods for robotics
references.venue: In Intelligent Robots and Systems,
references.authors: Jette Randlov Preben Alstrom
references.title: Learning to drive a bicycle using reinforcement learning and shaping
references.venue: In Proceedings of the Fifteenth International Conference on Machine Learning,
references.authors: Stéphane Ross Geoffrey Gordon Drew Bagnell
references.title: A reduction of imitation learning and structured prediction to no-regret online learning
references.venue: In Proceedings of the fourteenth international conference on artificial intelligence and statistics,
references.authors: John Schulman Sergey Levine Pieter Abbeel Michael Jordan Philipp Moritz
references.title: Trust region policy optimization
references.venue: In International Conference on Machine Learning,
references.authors: John Schulman Filip Wolski Prafulla Dhariwal Alec Radford Oleg Klimov
references.title: Proximal policy optimization algorithms
references.venue: arXiv preprint arXiv:1707.06347,
references.authors: Richard S Sutton David A McAllester Satinder P Singh Yishay Mansour
references.title: Policy gradient methods for reinforcement learning with function approximation
references.venue: In Advances in neural information processing systems,
references.authors: Matthew E Taylor Peter Stone
references.title: Transfer learning for reinforcement learning domains: A survey
references.venue: Journal of Machine Learning Research,
references.authors: Matthew E Taylor Peter Stone Yaxin Liu
references.title: Value functions for rl-based behavior transfer: A comparative study
references.venue: In Proceedings of the National Conference on Artificial Intelligence,
references.authors: Emanuel Todorov Tom Erez Yuval Tassa
references.title: Mujoco: A physics engine for model-based control
references.venue: In 2012 IEEE/RSJ International Conference on Intelligent Robots and Systems,
references.authors: Chang Wang Sridhar Mahadevan
references.title: Manifold alignment without correspondence
references.venue: In IJCAI,
references.authors: Markus Wulfmeier Ingmar Posner Pieter Abbeel
references.title: Mutual alignment transfer learning
references.venue: arXiv preprint arXiv:1707.07907,
references.authors: Mengyuan Yan Iuri Frosio Stephen Tyree Jan Kautz
references.title: Sim-to-real transfer of accurate grasping
references.authors: Henry Zhu Abhishek Gupta Aravind Rajeswaran Sergey Levine Vikash Kumar
references.title: eye-in-hand observations and continuous control
references.venue: arXiv preprint arXiv:1712.03303,
references.authors: Barto
references.title: We also demonstrate the crossdomain transfer capabilities using a variant of the proposed algorithm Joshi & Chowdhary (2018) and the results for Cart-Pole to Inverted Pendulum and Inverted Pendulum to Bicycle transfers are provided in the following sections
sections.heading: 1 INTRODUCTION
sections.text: Lack of principled mechanisms to quickly and efficiently transfer policies learned between domains has become the major bottleneck in Reinforcement Learning (RL). This inability to transfer or adapt policies is one major reason why RL has still not proliferated physical application like robotics. Since RL agents cannot quickly transfer policies, the agent is forced to learn every task from scratch, which is both time and sample expensive. Warm-start, a method in which weights from one neural network are transferred to another, has been reasonably successful for supervised learning. However, this method can often lead to mixed and even negative results in RL (Joshi & Chowdhary, 2018; Taylor & Stone, 2009).
  Our main contribution is an algorithm to transfer policies between tasks with significant differences in state transitions via a policy adaptation mechanism. Unlike the majority of existing work in transfer learning for RL, our approach does not merely use the transferred policy to warm start (initialize the parameter of the target network with learned source network) policy learning in the target domain. Neither does it rely on a multitude of simulations across randomly generated source domains. Instead, we combine supervised reference trajectory tracking and unsupervised reinforcement learning to adapt the source policy to the target domain directly. We show through theory and experiments that our method enjoys significantly reduced sample complexity in solving the task.
  Adapt-to-Learn is inspired by the fact that combined adaptation of behaviors and learning through experience is a primary mechanism of learning in biological creatures (Krakauer & Mazzoni, 2011; Fryling et al., 2011).Inspired by this ability of biological creatures, we seek to answer the question: Will learning to combine intrinsic adaptation reward with environment reward lead to more efficient transfer of policies between domains? Imitation Learning (IL) (Duan et al., 2017; Zhu et al., 2018) seems to play a crucial part in biological learning, and as such has been widely studied in RL. However, the key is, when presented with a new situation, animals do not just imitate, but quickly adapt existing behaviors, and improve them through further experience. In particular, an animal learning to walk on a different terrain does not just imitate its existing gait, but adapts it to the new environment.The theory behind such adaptation in reference tracking control problems has been typically restricted to deterministic dynamical systems with well-defined reference trajectories (Åström & Wittenmark, 2013; Chowdhary et al., 2013). This ability to adapt and incorporate further learning through optimization on the environment reward is one key difference between our method and ex-
  isting imitation learning and Guided Policy Search (GPS) methods (Levine & Koltun, 2013). Unlike IL and GPS, our method transfers policies between task with significant differences in the transition models. Moreover, by mixing environment reward with intrinsic adaptation rewards, we ensure that the agent quickly adapts and also learns to acquire skills beyond what the source policy can teach. We posit that the presented method can be the foundation of a broader class of RL algorithms that can choose seamlessly between learning through RL to supervised adaptive imitation. Our empirical results show that approach is capable of robustly transferring policies between tasks, even in the presence of nonlinear and time-varying differences in the dynamic model of the systems. In particular, we show that it suffices to execute adapted greedy policies to ensure −optimal behavior in the target domain.
  Related work: D-RL has recently enabled agents to learn policies for complex robotic tasks in simulation (Peng et al., 2016; 2017b; Liu & Hodgins, 2017; Heess et al., 2017). However, D-RL has been plagued by the curse of sample complexity. Therefore, the capabilities demonstrated in the simulated environment are hard to replicate in the real world. This learning inefficiency of RL has led to significant work in the field of TL (Taylor & Stone, 2009). A significant body of literature on transfer in RL is focused on initialized RL in the target domain using learned source policy; known as jump-start/warm-start methods (Taylor et al., 2005; Ammar et al., 2012; 2015). Some examples of these transfer architectures include transfer between similar tasks (Banerjee & Stone, 2007), transfer from human demonstrations (Peters & Schaal, 2006) and transfer from simulation to real (Peng et al., 2017a; Ross et al., 2011; Yan et al., 2017). Efforts have also been made in exploring accelerated learning directly on real robots, through Guided Policy Search (GPS) (Levine et al., 2015) and parallelizing the training across multiple agents using meta-learning (Levine et al., 2016; Nagabandi et al., 2018; Zhu et al., 2018). Sim-to-Real transfers have been widely adopted in the recent works and can be viewed as a subset of same domain transfer problems. Daftry et al. (Daftry et al., 2016) demonstrated the policy transfer for control of aerial vehicles across different vehicle models and environments. Christiano et al. (Christiano et al., 2016) transferred policies from simulation to real using an inverse dynamics model estimated interacting with the real robot. Through learning over an adversarial loss, the agents are trained to achieve robust policies across various environments (Wulfmeier et al., 2017). However, these and other reported architectures do not necessarily lead to improved sample efficiency, handle relatively minor changes in the transition model, and are even known to cause negative transfer. In contrast, our approach directly adapts the source policies to target with significant transition model difference while interacting with the environment. It enjoys empirically and rigorously proven sample efficiency guarantees of order O(nH), depending polynomially on the horizon length “H”.
sections.heading: 2 PRELIMINARIES
sections.text: Consider a finite horizon MDP defined as a tupleM = (S,A,P,R, ρ0, γ), where S denote set of continuous states;A is a set of continuous bounded actions, P : S ×A×S → R+ is state transition probability distribution of reaching s′ upon taking action a in s, ρ0 : S → R+ is the distribution over initial states s0 and R : S × A → R+ is deterministic reward function and H be the finite horizon of the problem.
  Let π(a|s) : S ×A → [0, 1] be stochastic policy over continuous state and action space. The action from policy is a draw from this distribution ai ∼ π(ai|si). The agent’s goal is to find a policy π? which maximize the total return. The total return starting from states s0 ∼ ρ0 under a policy π is
  ηπ(s0) = Es0,a0,... ( H∑ t=0 r(st, at) ) (1)
  where, s0 ∼ ρ0, at ∼ π(at|st) and st+1 ∼ p(st+1|st, at). We formalize the underlying problem of policy transfer by considering a source and target MDP as follows,MS = (S,A,P,R, ρ0, γ)S ,MT = (S,A,P,R, ρ0, γ)T , each with its own state, action space and transition model respectively. We will mainly focus on the problem of same domain transfer in this paper, where the state and action space are analogous S(S) = S(T ) = S ∈ Rm and A(T ) = A(S) = A ∈ Rk, but the source and target state transition models differ significantly due to unmodeled dynamics or external environment interactions. Furthermore, an example of how the method can extend to cross-domain transfer using manifold alignment (Joshi & Chowdhary,
  2018; Wang & Mahadevan, 2009) is in the supplementary. Let π∗ be a parameterized optimal stochastic policy for source MDP MS . The policy π∗ can be obtained using any available RL methods (Sutton et al., 2000; Schulman et al., 2015; 2017). In this work, we have used the Proximal Policy Optimization(PPO) (Schulman et al., 2017) algorithm to generate the source optimal policy. We will use the following definition of the state value function V π defined under any policy π
  V π(st) = Eat,st+1,at+1,... ( H∑ i=0 r(si+t, ai+t) ) The associated optimal value function fo source MDPMS is V π∗ for all s ∈ S. Let T : Rn → Rn be the Bellman update operator defined as
  (T f)(s) = max a∈A
  [ r(s, a) + γ E
  s′∼P (s,a) f(s′)
  ] (2)
  Optimal value function V π ∗ satisfies the Bellman Equation-(2) such that V π ∗ (s) = T V π∗(s),∀ s.
sections.heading: 3 ALGORITHMIC CONTRIBUTION: TRANSFER THROUGH ADAPTATION
sections.heading: 3.1 ADAPTATION AS A MECHANISM FOR POLICY TRANSFER IN RL
sections.text: In this paper, we approach the problem of transfer learning for RL through adaptation of previously learned policies to related tasks. Our approach to adaptation is by enabling the agent to learn the best mixture of imitation and learning from environment reward.Our method differs from RL transfer methods that rely on jump-starts or direct imitation (Zhu et al., 2018; Duan et al., 2017) in a key way: We do not aim to emulate the source optimal policy itself in the target domain, but the source transitions under optimal policy. To make this point, we demonstrate in our empirical results that the source policy, when used directly, does not produce sensible behaviors of the agent in the target domain when transition models are significantly different.On the other hand, our method uses the source transitions projected onto the target task as reference exploration trajectories, helping to adapt and optimize the source policy to the target domain efficiently.
  In canonical reinforcement learning, the goal is to learn the optimal policy π∗ which maximizes the future cumulative reward when the reward function and the transition function of the MDP are unknown. In statistical RL, this leads to the (in)famous explore-exploit tradeoff.Yet, this learnthrough-experience approach has demonstrated significant potential to enable general solutions to control of complex physical systems for which first principles-based models are not easily obtainable. However, one of the key challenges in RL has been the high sample complexity of obtaining a reasonable policy. In other words, RL, and specifically Deep RL, require an absurdly huge amount of interactions with the environment (experience) to find reasonable policies. This high learning inefficiency is in apparent contrast with the efficient learning demonstrated by humans and many biological creatures. For examples, octopuses are known to learn to solve complex problems such as opening jars and squeezing through puzzles with just a few trials. This ability to quickly transfer and adapt learned policies between related tasks is likely a key to general intelligence that seems to be missing from RL. Our goal in the rest of this paper is to show that an algorithm that can judiciously combine adaptation to changes and learning new skills is capable of avoiding brute force random exploration to a large extent and be significantly less sample expensive.
sections.heading: 3.2 ADAPT-TO-LEARN: POLICY TRANSFER
sections.text: We begin by mathematically describing adaptation for policy transfer in RL and state all the necessary assumptions in Section 3.2.1. We then develop the Adapt-to-Learn algorithm in Section 3.2.2.
sections.heading: 3.2.1 ADAPTATION
sections.text: The proposed Adapt-to-Learn (ATL) algorithm objective is to accumulate higher total returns through maximizing the likelihood of the target policies πθ, which emulate the optimal source transition behavior in the target MDP. We achieve this objective by minimizing the KL divergence between point-wise local trajectories realized using the target policy and source optimal policy in the target
  domain (Refer Figure-3 in Appendix-C). This adaptation objective can be formalized as minimizing the KL-divergence between source and target transition trajectories:
  η KL (πθ, π ∗) = E
  st,at∼τ
  ( pπθ (τ) log ( pπθ (τ)
  qπ∗(τ)
  )) , (3)
  where τ is the trajectory in the target domain under the policy πθ defined as
  τ = (s0, a0, s1, a1, . . . ),
  and probability of the trajectory pπθ (τ) under policy πθ and target transition p T (.|st, at) can be written as
  pπθ (τ) = ρ(s0) H∏ t=0 πθ(at|st)pT (st+1|st, at). (4)
  Similarly qπ∗(τ) can be defined as probability of trajectory deviations at every state st ∈ τ , when the source optimal policy π∗ is used in place of target policy πθ, and the states evolve according to the source transitions model pS(.|st, at) (Refer Figure-3 in Appendix-C):
  qπ∗(τ) = ρ(s0) H∏ t=0 π∗(a′t|st)pS(s′t+1|st, a′t). (5)
  Assumption-1: We assume that optimal source policy is available, such that the source policy variance can be assumed to be zero. That is, the action probabilities π∗(a′t|st) = 1, ∀st. This is a reasonable assumption, since optimal source policy is available it can be treated as deterministic policy and actions can be chosen greedily. We need this assumption only for deriving the expression for intrinsic reward and theoretical analysis. In the empirical evaluation of the algorithm, we treat π∗(.) as a stochastic policy.
  The transition probabilities in the KL divergence in (3) term are treated as transition likelihoods and the transitioned state st+1 as a random variable. Since s′t+1 is the optimal state reached starting in st under source transition model using π∗(a′t|st), we try to emulate this behavior in the target domain and hence evaluate the transition likelihoods of the target trajectory at {s′i}Hi=1. Using the definition of the probabilities of the trajectories under πθ and π∗ Equation-(4) & (5) the log term in the KL divergence of the trajectory (3) is simplified as follows
  log
  ( pπθ (τ)
  qπ∗(τ)
  ) = log ( ρ(s0)π(a0|s0)pT (s′1|s0, a0)π(a1|s1)pT (s′2|s1, a1) . . . ρ(s0)π∗(a′0|s0)pS(s′1|s0, a′0)π∗(a′1|s1)pS(s′2|s1, a′1) . . . ) . (6)
  Using (6) and with assumption-1 i.e. π∗(a′t|st) = 1∀st the KL term can simplified as follows
  η KL (πθ, π ∗) = E
  st,at∼τ
  ( pπθ (τ) H∑ t=0 log ( πθ(at|st)pT (s′t+1|st, at) pS(s′t+1|st, a′t) ))
  η KL (πθ, π ∗) = E
  st,at∼τ
  ( pπθ (τ) H∑ t=0 ζt ) (7)
  where ζt = log ( πθ(at|st)pT (s′t+1|st,at)
  pS(s′t+1|st,a′t)
  ) .
  If calculating the above expectation is feasible, it is possible to minimize the KL divergence and move the policy parameters in the direction of emulating source transition behavior in the target domain. However, this is not generally the case since the true expectation is intractable. Therefore a common practice is to use an empirical estimate of the expectation to do approximate planning. We minimize the trajectory KL divergence by handling the term ζt as the intrinsic adaptation reward, which captures the local deviation in trajectory in the form of the shaped reward function.
  Assumption-2: We do not assume to know the true transition distribution for source and the target, but only have access to simulator model of the source. However, we assume both source and target transition models follow a Gaussian distribution centered at the next propagated state and fixed variance “σ”.
  Assumption-2 is not very restrictive since we empirically show that for any deterministic model, a bootstrapped Gaussian transition assumption is sufficient for ATL agent to learn the task. Using the above assumption, we can approximate the KL term as
  ζt = log ( πθ(at|st)e−(st+1−s ′ t+1) 2/2σ2 ) . (8)
  The individual terms in the expectation ζt represent the distance between two transition likelihoods of landing in the next state s′t+1 starting in st and under actions at, a ′ t. The target agent is encouraged to take actions that lead to states which are close in expectation to a reference state provided by an optimal baseline policy operating on the source model. By doing so, we are providing a possible direction of search for the higher environmental rewards “rt”.
  We can, therefore, solve the following optimization problem to generate adaptive policy updates:
  π∗Tθ = arg min πθ∈Π (η KL ) . (9)
  The distance between two transition models ζt is used as an intrinsic reward to calculate the total trajectory intrinsic return, and further, any policy update algorithm can be used (Sutton et al., 2000; Schulman et al., 2017; 2015) to update the policy in direction optimizing this objective. However, it is to be noted that though we use policy gradient kind of update for adaptive policy, the optimization is more akin to supervised learning. For every state-action pair, the KL-distance is the true metric to be minimized, and unlike RL, we do not engage in optimal value search in the adaptation part of learning. Hence the algorithm is more sample efficient compared to any RL policy search methods.
sections.heading: 3.2.2 ADAPTATION AND LEARNING
sections.text: We achieve Adaption and Learning simultaneously by augmenting environment reward rt with intrinsic reward ζt. By doing so, we achieve transferred policies which try to both optimize optimal reference tracking and also maximize the cumulative future environmental reward to acquire skills beyond what source can teach. This trade-off between learning by exploration and learning by adaptation can be realized as follows:
  η KL = E st,at
  ( pπθ (τ) H∑ t=0 ((1− β)rt − βζt) ) . (10)
  Where the term β is the mixing coefficient. We make a heuristic choice for an appropriate β to start with and annealed over episodes for optimal mixing of adaptation and learning. For consistency of the reward mixing, the rewards rt, ζt are normalized to form the total reward r′t = (1− β)rt + βζt.
  Algorithm 1 Adaptive-to-Learn Policy Transfer in RL
  Require: π∗(.), pS . Inputs: Source Policy, source simulator 1: Initialize sT0 ∈ ρ0. . Draw initial state from the given distribution in target task 2: for i = 1 ≤ K do 3: while si 6= terminal do 4: a′i ∼ π∗(si) . Generate the optimal action using Source policy 5: ai ∼ πθ(si) . Generate the action using the π̂θ 6: si+1 ∼ pT (si, ai) . Propagate the target task model at state si and action ai 7: s′i+1 ∼ pS(si, a′i) . Propagate the source task model at state si and action a′i 8: ζt = πθ(ai|si)e−(si+1−s ′ i+1)
  2/2σ2 . Calculate the KL divergence intrinsic reward term 9: Zi = ({si, ri, ζi, ai, a′i}) . Incrementally store the trajectory for policy update
  10: PZn(ηKL) = 1 n ∑n i=1 (∑H t=0∇θ log πθ(ai,t|si,t) ∑∞ t=0 r ′ i,t ) . Empirical loss to optimize
  11: π̂θ = argmaxπ∈Π PZn(ηKL) . Minimize the loss to obtain a adaptive policy
sections.heading: 3.3 SAMPLE-BASED ESTIMATION OF THE GRADIENT
sections.text: The previous section proposed an optimization method to find the adaptive policy using KLdivergence as an intrinsic reward, enforcing the target transition model to mimic the source transitions. This section describes how this objective can be approximated using a Monte Carlo simulation. The adaptive policy update methods work by computing an estimator of the gradient of the
  return and plugging it into a stochastic gradient ascent algorithm.
  π̂∗Tθ = arg max πθ∈Π PZn(ηKL) (11)
  θ ← θ + αĝ. Where α is the learning rate and ĝ is the empirical estimate of the gradient (Refer Appendix-A) of the total return η
  KL . The gradient estimate over i.i.d data from the collected trajectories is computed
  as follows:
  ĝ = PZn(∇θηKL) = Êst,at∼τ ( H∑ t=0 ∇θ log πθ(at|st) ∞∑ t=0 r′t ) ,
  PZn(∇θηKL) = 1
  n n∑ i=1 ( H∑ t=0 ∇θ log πθ(ai,t|si,t) ∞∑ t=0 r′i,t ) , (12)
  where PZn is empirical distribution over the data (Zn : {si, ai, a′i}ni ).
sections.heading: 4 THEORETICAL BOUNDS ON SAMPLE COMPLEXITY
sections.text: Although there is some empirical evidence that transfer can improve performance in subsequent reinforcement-learning tasks, there are not many theoretical guarantees. Since many of the existing transfer algorithms approach the problem of transfer as a method of providing good initialization to target task RL, we can expect the sample complexity of those algorithms to still be a function of the cardinality of state-action pairs |N | = |S| × |A|. On the other hand, in supervised learning setting, the theoretical guarantees of most algorithm have no dependency on size (or dimensionality) of the input domain (which is analogous to |N | in RL domains). Having formulated a policy transfer algorithm using labeled reference trajectories derived from optimal source policy in ATL, we construct supervised learning like PAC property of the proposed method. For the sample complexity analysis we consider only the adaptation part of learning i.e. β = 1 in Equation-(16). This is because in ATL, the adaptive learning is akin to supervised learning, since the source reference trajectories provide the target states given every (st, at) pair.
  Suppose we are given the learning problem specified with training set Zn = (Z1, . . . Zn) where each Zi = ({si, ai, a′i})Hi=0 are independently drawn according to some distribution P . Given the data Zn we can compute the empirical return PZn(ηKL) for every πθ ∈ Π, and we will show that the following holds: ‖PZn(ηKL)− P (ηKL)‖ ≤ (13) with probability at least 1− δ, for some very small δ s.t 0 ≤ δ ≤ 1. We can claim that the empirical return for all πθ is a sufficiently accurate estimate of the true return function. Thus a reasonable learning strategy is to find a πθ ∈ Π that would minimize empirical estimate of the objective (10).
  Theorem 4.1 If the induced class of the policy πθ:LΠ has uniform convergence property in empirical mean; then the empirical risk minimization is PAC. s.t
  Pn(P (η KL,π̂∗ )− P (ηKL,π∗ ) ≥ ) ≤ δ (14)
  and number of trajectory samples required can be lower bounded as
  n( , δ) ≥ 2H 2C2
  2 log ( 2|Π| δ ) . (15)
  For the proof of the above theorem refer the Appendix-B.
sections.heading: 4.1 -OPTIMALITY RESULT UNDER ADAPTIVE TRANSFER-LEARNING
sections.text: Consider MDP M∗ and M̂ which differ in their transition models. For the sake of analysis, let M∗ be the MDP with ideal transition model, such that target follows source transition p∗ precisely. Let p̂ be the transition model achieved (tracked) using the estimated adapted policy learned over data interacting with the target model and the associated MDP be denoted as M̂ . We analyze the -optimality of return under adapted source optimal policy through proposed policy transfer.
  Note for the sake of analysis we are deviating from finite horizon assumption and using discout factor γ. To be consistent with previous section we can assume the horizon length H = logγ
  ( v
  2Vmax
  ) ,
  where v is truncation error in total infinite return.
  Definition 4.2 Given the value function V ∗ = V π ∗
  and model M1 and M2, which only differ in the corresponding transition models p1 and p2. Lets define ∀s, a ∈ S ×A
  dV ∗
  M1,M2 = sup s,a∈S×A ∣∣∣∣ E s′∼P1(s,a) [V ∗(s′)]− E s′∼P2(s,a) [V ∗(s′)] ∣∣∣∣ Lemma 4.3 Given M∗, M̂ and value function V π ∗
  M∗ , V π∗ M̂ the following bound holds∥∥∥V π∗M∗ − V π∗M̂ ∥∥∥∞ ≤ γ (1−γ)2
  where maxs,a ‖p̂(.|s, a)− p∗(.|s, a)‖ ≤ and p̂ and p∗ are transition of MDP M̂,M∗ respectively. The proof of this lemma is based on the simulation lemma (see Appendix-C). Similar results for RL with imperfect models were reported by (Jiang, 2018).
sections.heading: 5 POLICY TRANSFER IN SIMULATED ROBOTIC LOCOMOTION TASKS
sections.text: To evaluate Adapt-to-Learn Policy Transfer in reinforcement learning, we design our experiments using sets of tasks based on the continuous control environments in MuJoCo simulator (Todorov et al., 2012). Our experimental results demonstrate that ATL can adapt to significant changes in transition dynamics. Therefore, we perturb the parameters of the simulated target models for the policy transfer experiments (see Table-1 for original and perturbed parameters of the target mode). To create a challenging training environment, we changed the parameters of the model such that the optimal source policy alone without any learning cannot produce any stable results (see source policy performance in Figure-1). We compare our results against two baselines: (a) Initialized Reinforcement learning (initialized PPO) (Jumpstart-RL (Wang & Mahadevan, 2009)) (b) standalone reinforcement policy learning (PPO) (Schulman et al., 2017).
  We experiment with the ATL algorithm on Hopper, Walker2d, and HalfCheetah Environments. The states of the robots are their generalized positions and velocities, and the actions are joint torques. High dimensionality, non-smooth dynamics due to contacts and being under-actuated systems make these tasks very challenging. We use deep neural networks to represent the source and target policy, the details of which are in the Table-2 Appendix-D. The following models are included in our evaluation:
  Slippery Hopper: is defined through 11-dimensional state space and 3-dimension action space, with reward function defined as r(t) = (st+1 − st)/dt − 10−3‖a‖2, and a bonus of +1 for being in a non-terminal state. The simulation is terminated upon reaching 1000 steps or hopper toppling. The target model differs in the floor friction and foot joint damping.
  Slippery Fat-Walker2d: is defined through 17-dimensional state space and 6-dimension action space, with reward function and termination condition defined same as Hopper. The target model differs in the model density and floor friction.
  Fat HalfCheetah: is defined through 17-dimensional state space and 6-dimension action space, with reward function defined as r(t) = (st+1 − st)/dt − 0.1‖a‖2. The simulation is terminated upon reaching 1000 steps. The target model differs in the floor friction coefficient, gravity, and mass.
  To establish a standard baseline, we also included the classic cart-pole and Inverted pendulum balancing tasks, based on the formulation (Barto et al., 1983). We also demonstrate the cross-domain transfer capabilities using a model-based variant of the proposed algorithm. The results of policy transfer for Cart-Pole to Inverted Pendulum and Inverted Pendulum to Bicycle transfers are provided in the Appendix-D. Learning curves showing the total reward averaged across three runs of each algorithm are provided in Figure-1. Adapt-to Learn policy transfer solved all the three tasks, yielding quicker learning compared to other baseline methods. These results provide empirical evidence of our hypothesis. Using trajectory KL divergence as intrinsic adaptation reward to adapt source policy to the target, we achieve a more robust and sample efficient policy transfer between two tasks,
  compared to using a warm-start or standalone RL method. Note that the target domain perturbations introduced are significant enough such that source policy alone without any adaptation in the target domain produced no meaningful results (Figure-1). This notion of adaptation in the face of uncertainty is a key advancement over traditional policy transfer, meta-learning, or adversarial RL methods aiming to improve performance by learning a policy over a set of lightly perturbed tasks.
sections.heading: 6 CONCLUSION
sections.text: We introduced a new transfer learning technique for RL: Adapt-to-Learn, that utilizes adaptation of the source policy to target tasks. We demonstrated on nonlinear and continuous robotic locomotion tasks that learning to adapt source policy to the target domain leads to a significant reduction in sample complexity over the prevalent jump-start based approaches. We further also proved theoretical guarantees on the reduced sample complexity of our proposed architecture. There are many exciting directions for future work. A network of policies that can generalize across multiple tasks could be learned based on each new adapted policies. How to train this end-to-end is an important question for meta-learning. The ability of Adapt-to-Learn to handle significant perturbations to the
  transition model indicates that it should naturally extend to sim-to-real transfer. Indeed we argue that such adaptation is necessary for real-world robotics, as has been established previously in classical domains like flight control. Another exciting direction is to extend the work to other combinatorial domains (e.g., multiplayer games). We expect, therefore follow on work will find other exciting ways of exploiting such adaptation in RL and machine learning.
sections.heading: A TOTAL RETURN GRADIENT WITH RESPECT TO POLICY PARAMETERS
sections.text: The total return which we aim to maximize in adapting the source policy to target is the mixture of environmental rewards and Intrinsic KL divergence reward as follows,
  η KL (πθ, π ∗) = E
  st,at∼τ
  ( pπθ (τ) H∑ t=0 r′t ) (16)
  he adaptive policy update methods work by computing an estimator of the gradient of the return and plugging it into a stochastic gradient ascent algorithm.
  π̂∗Tθ = arg max πθ∈Π PZn(ηKL) (17)
  θ = θ + αĝ
  where α is the learning rate and ĝ is the empirical estimate of the gradient of the total discounted return η
  KL . The derivation of the gradient term is exactly same as for policy gradient methods.
  Taking the derivative of the total return term
  ∇θ(ηKL) = E st,at∼τ
  ( ∇θpπθ (τ) H∑ t=0 r′t ) .
  Consider the term ∇θpπθ (τ) and evaluate the derivative. Lets consider the term log pπθ (τ). Using the definition of pπθ (τ) and we can write the log term as
  log pπθ (τ) = log(ρ0πθ(a0|s0)pT (s1|s0, a0) . . .)
  log pπθ (τ) = log(ρ0) + H∑ t=0 log πθ(at|st) + H∑ t=0 pT (st+1|st, at).
  Taking the derivative wrto θ we can write,
  ∇θ log pπθ (τ) = H∑ t=0 ∇θ log πθ(at|st)
  ∇θpπθ (τ) pπθ (τ) = H∑ t=0 ∇θ log πθ(at|st).
  Therefore we can write
  ∇θpπθ (τ) = pπθ (τ) H∑ t=0 ∇θ log πθ(at|st)
  Substituting the above expression we can write the total gradient as,
  ∇θ(ηKL) = Epπθ ( H∑ t=0 ∇θ log πθ(at|st) H∑ t=0 r′t ) .
sections.heading: B PROOF OF THEOREM-4.1
sections.text: Theorem B.1 If the induced class LΠ has uniform convergence in empirical mean property then empirical risk minimization is PAC.
  For notation simplicity we drop the superscript T (for Target domain) and subscript θ (policy parameters) in further analysis. Unless stated we will using following simplifications π̂∗ = π̂∗Tθ and π∗ = π∗Tθ .
  Proof Fix , δ > 0 we will show that for sufficiently large n ≥ n( , δ) Pn(P (η
  KL,π̂∗ )− P (ηKL,π∗ ) ≥ ) ≤ δ (18)
  Let π∗ ∈ Π be the minimizer of true return P (η KL
  ), further adding and subtracting the terms PZn(ηKL,π̂∗ ) and PZn(ηKL,π∗ ) we can write
  P (η KL,π̂∗ )− P (ηKL,π∗ ) =
  P (η KL,π̂∗ )− PZn(ηKL,π̂∗ ) + PZn(ηKL,π̂∗ )− PZn(ηKL,π∗ ) + PZn(ηKL,π∗ )− P (ηKL,π∗ )
  (19)
  We can divide the above expression in three terms
  1. P (η KL,π̂∗ )− PZn(ηKL,π̂∗ )
  2. PZn(ηKL,π̂∗ )− PZn(ηKL,π∗ )
  3. PZn(ηKL,π∗ )− P (ηKL,π∗ )
  Lets consider the term PZn(ηKL,π̂∗ )−PZn(ηKL,π∗ ) in the above expression is always negative semidefinite, since π̂∗ is a maximizer wrto PZn(ηKL), hence PZn(ηKL,π̂∗ ) ≤ PZn(ηKL,π∗ ) always, i.e
  PZn(ηKL,π̂∗ )− PZn(ηKL,π∗ ) ≤ 0 Next the 1st term can be bounded as
  P (η KL,π̂∗ )− PZn(ηKL,π̂∗ ) ≤ sup π∈Π [PZn(ηKL)− P (ηKL)] ≤ sup π∈Π ‖PZn(ηKL)− P (ηKL)‖
  Similarly upper bound can be written for the 3rd term Therefore we can upper bound the above expression as
  P (η KL,π̂∗ )− P (ηKL,π∗ ) ≤ 2 sup π∈Π ‖PZn(ηKL)− P (ηKL)‖ (20)
  From Equation-(18) we have
  sup π∈Π ‖PZn(ηKL)− P (ηKL)‖ ≥ /2 (21)
  Using McDiarmids inequality and union bound, we can state the probability of this event as
  Pn(‖PZn(ηKL)− P (ηKL)‖ ≥ /2) ≤ 2|Π|e − n 2 2C2H2 (22)
  whereC is bound on state space S andH is horizon length. The finite difference boundC is obtained assuming transition pT , pS follow a Gaussian distributions and the i.i.d trajectories collected are of maximumH length. Equating the RHS of the expression to δ and solving for n we get
  n( , δ) ≥ 2H 2C2
  2 log ( 2|Π| δ ) (23)
  for n ≥ n( , δ) the probability of receiving a bad sample is less than δ. The total number of observed transition is of order O(nH). Refer supplementary document for details of the proof.
sections.heading: C PROOF OF LEMMA-4.3
sections.text: Lemma C.1 Given M∗, M̂ and value function V π ∗ M∗ , V π∗ M̂ the following bound holds∥∥∥V π∗M∗ − V π∗M̂ ∥∥∥∞ ≤ γ (1−γ)2 .
  Here maxs,a ‖p̂(.|s, a)− p∗(.|s, a)‖ ≤ and p̂ and p∗ are transition of MDP M̂,M∗ respectively. Note we are deviating from finite horizon assumption and using γ. To be consistent with previous section we can assume the horizon length H = logγ ( v
  2Vmax
  ) . Where v is truncation error in total
  infinite return.
  Proof For any s ∈ S
  |V π ∗
  M̂ (s)− V π
  ∗
  M∗(s)|∞ = |r(s, a) + γ 〈 p̂(s′|s, a), V π ∗ M̂ (s′) 〉 − r(s, a)− γ 〈 p∗(s′|s, a), V π ∗ M∗(s ′) 〉 |∞
  Add and subtract the term γ 〈 p∗(s′|s, a), V π∗ M̂ (s′) 〉
  = |γ 〈 p̂(s′|s, a), V π ∗ M̂ (s′) 〉 − γ 〈 p∗(s′|s, a), V π ∗ M̂ (s′) 〉 + γ 〈 p∗(s′|s, a), V π ∗ M̂ (s′) 〉 − γ 〈 p∗(s′|s, a), V π ∗ M∗(s ′) 〉 |∞
  ≤ γ| 〈 p̂(s′|s, a), V π ∗ M̂ (s′) 〉 − 〈 p∗(s′|s, a), V π ∗ M̂ (s′) 〉 |+ γ| 〈 p∗(s′|s, a), V π ∗ M̂ (s′) 〉 − γ 〈 p∗(s′|s, a), V π ∗ M∗(s ′) 〉 |∞ ≤ γ|p̂(s′|s, a)− p∗(s′|s, a)|∞|V π ∗ M̂ (s′)|∞ + γ|V π ∗ M̂ (s)− V π ∗ M∗(s)|∞
  Using the definition of in above expression, we can write
  |V π ∗
  M̂ (s)− V π
  ∗ M∗(s)|∞ ≤ γ |V π ∗ M̂ (s′)|∞ + γ|V π ∗ M̂ (s)− V π ∗ M∗(s)|∞
  Therefore
  |V π ∗
  M̂ (s)− V π
  ∗ M∗(s)|∞ ≤ γ |V π∗ M̂ (s′)|∞
  1− γ
  Now we solve for expression |V π∗ M̂ (s′)|∞. We know that this term is bounded as
  |V π ∗ M̂ (s′)|∞ ≤ Rmax 1− γ
  where Rmax = 1, therefore we can write the complete expression as
  |V π ∗
  M̂ (s)− V π
  ∗ M∗(s)|∞ ≤ γ
  (1− γ)2
sections.heading: D ADDITIONAL RESULTS AND DETAILS OF EXPERIMENTAL DOMAIN
sections.text: To establish a standard baseline, we also include the results for classic cart-pole and Inverted pendulum balancing tasks, based on the formulation Barto et al. (1983). We also demonstrate the crossdomain transfer capabilities using a variant of the proposed algorithm Joshi & Chowdhary (2018) and the results for Cart-Pole to Inverted Pendulum and Inverted Pendulum to Bicycle transfers are provided in the following sections.
  D.1 INVERTED PENDULUM (IP) TO TIME-VARYING IP
  We demonstrate our approach for a continuous state domain, Inverted Pendulum (IP) swing-up and balance Figure-4. The source task is the conventional IP domain. The target task differs from the source task in the transition model. The target task is a non-stationary inverted pendulum, where the length and mass of the pendulum are continuously time varying with function Li = L0 +0.5cos(πi50 ) and Mi = M0 + 0.5cos(πi50 ), where L0 = 1, M0 = 1 and i = 1 . . . N . The state variables describing the system are angle and angular velocity {θ, θ̇} ∈ [−π, π]. The RL objective is to swing-up and balance the pendulum upright such that θ = 0, θ̇ = 0. The reward function is selected as R(θ, θ̇) = −10|θ|2− 5|θ̇|2, which yields maximum value at upright position and minimum at the down-most position. The continuous action space is bounded by T ∈ [−1, 1]. Note that the domain is tricky, since full throttle action is assumed to not generate enough torque to be able to swing the pendulum to the upright position, hence, the agent must learn to swing the pendulum back and forth and leverages angular momentum to go to the upright position.
  D.2 ROBUSTNESS TO NEGATIVE TRANSFER
  We demonstrate that the proposed transfer is robust to negative transfers, that is, cases in transfer learning where naive initialization of the target using source policy could be detrimental. We demonstrate this through an inverted pendulum upright balance task with the sign of control flipped. That is, we use an inverted pendulum model as both source and target systems, but the target is the inverse of the source model with the sign of the control action flipped. It should be noted that dealing with a change of sign in control has been considered a highly challenging problem in adaptive control Chowdhary et al. (2013). We demonstrate that ATL is immune to negative transfers. Figure
  5a and 5b demonstrate convergence to average maximum reward with lesser training samples for proposed ATL method compared to Initialized-RL(UMA-TL) and standalone-RL methods. It is to be observed that UMA-TL method suffers from a negative transfer phenomenon. The agent under UMA-TL converges to a much lower average reward by getting stuck in local minima and never achieves the upright balance of the pendulum.
  Also, the samples observed by UMA-TL in learning the task is much higher compared to no transfer (RL) and proposed ATL methods. If the source and target are not sufficiently related or the features of source task do not correspond to the target, the transfer may not improve or even decrease the performance in target task leading to negative transfer. We show that the UMA-TL suffers from a negative transfer in these results, whereas the performance of presented ATL is much superior compared to UMA-TL and RL(learning from scratch).
sections.heading: E CROSS DOMAIN TRANSFER
sections.text: E.1 CART-POLE TO BICYCLE:
  Bicycle balancing is a challenging physical problem, especially when the bicycle velocity is below the critical velocity Vc = 4m/s to 5m/s. We set the bicycle velocity to be V < Vc i.e., V = 2.778m/s such that the bicycle becomes unstable, and active control is required to maintain stability. The simulation itself is very high fidelity and realistic, which was designed for studying the physics of the bicycle.
  The states of the bicycle task are angle and angular velocity of the handlebar and the bike from vertical (θ, θ̇, ω, ω̇) respectively. For the given state the agent is in, it chooses a continuous action of applying torque to the handlebar, T ∈ [−2Nm, 2Nm] trying to keep the bike upright. The details of bicycle dynamics are beyond the scope of this paper; interested readers are referred to Randlov & Alstrom (1998); Åström et al. (2005), and references therein.
  We use the Cart-Pole as source task for learning to balance a bicycle. The bicycle balance problem in principle is similar to that of cart-pole, since the objective is to keep the unstable system upright. The objective of balance is achieved in both the systems by moving in the direction of fall, which is termed as a non-minimum phase behavior in the controls system literature. The control in the cart pole affects the angle of the pole, by moving the cart such that it is always under the pole. In the bicycle, the control is to move the handlebar in the direction of fall. However, balancing the bike is not straightforward, to turn the bike under itself, one must first steer in the other direction before turning in the direction of fall; this is called counter-steering Åström et al. (2005). We observe that both cart pole and bicycle have this commonality in their dynamical behaviors, as both the system have a non-minimum phase that is the presence of unstable zero. This similarity qualifies the cartpole system as an appropriate choice of source model for bicycle balance task.
  Cart pole is characterized by state vector [x, ẋ, θ, θ̇], i.e., position, the velocity of cart and angle, angular velocity of the pendulum. The action space is the force applied to the cart F ∈ [−1N, 1N ]. For the mapping between the state space of bicycle and cart pole model, we use Unsupervised Manifold Alignment(UMA) to obtain this mapping Wang & Mahadevan (2009). We do not report
  the training time to learn the intertask mapping since it is common to both ATL and UMA-TL methods. Figure 7b and 8 shows the quality of transfer for ATL through faster convergence to average maximum reward with lesser training samples compared to UMA-TL and RL methods.
  E.2 MOUNTAIN CAR (MC) TO INVERTED PENDULUM (IP)
  We also demonstrate the cross-domain transfer between mountain car to an inverted pendulum. The source and target task are characterized by different state and action space. The source task MC is a benchmark RL problem of driving an underpowered car up a hill. The dynamics of MC are described by two continuous state variables (x, ẋ) where x ∈ [−1.2, 0.6] and ẋ ∈ [−0.07, 0.07] and one continuous action F ∈ [−1, 1]. The reward function is proportional to the negative of the squared distance of the car from goal position. The target task is conventional IP with state (θ, θ̇) ∈ (−π, π) and action T ∈ [−1, 1]. We present the performance of transfer methods based on sample efficiency in learning the target task and speed of convergence to the maximum average reward. Similar to the bicycle domain transfer Figure 9a and 9b shows the quality of transfer for ATL through faster convergence to average maximum reward with lesser training samples compared to UMA-TL and RL methods.