{"id":13762683,"date":"2020-07-21T10:59:11","date_gmt":"2020-07-21T16:59:11","guid":{"rendered":"http:\/\/hunch.net\/?p=13762683"},"modified":"2020-07-21T10:59:11","modified_gmt":"2020-07-21T16:59:11","slug":"homer-provable-exploration-in-reinforcement-learning","status":"publish","type":"post","link":"https:\/\/hunch.net\/?p=13762683","title":{"rendered":"HOMER: Provable Exploration in Reinforcement Learning"},"content":{"rendered":"\n<p>Last week at ICML 2020,&nbsp;<a href=\"http:\/\/www.mikaelhenaff.com\/\" target=\"_blank\" rel=\"noreferrer noopener\">Mikael Henaff<\/a>,&nbsp;<a href=\"https:\/\/people.cs.umass.edu\/~akshay\/\" target=\"_blank\" rel=\"noreferrer noopener\">Akshay Krishnamurthy<\/a>,&nbsp;<a href=\"https:\/\/hunch.net\/~jl\/\" target=\"_blank\" rel=\"noreferrer noopener\">John Langford<\/a>&nbsp;and I had a paper on a new reinforcement learning (RL) algorithm that solves three key problems in RL: (i) global exploration, (ii) decoding latent dynamics, and (iii) optimizing a given reward function. Our ICML poster is&nbsp;<a href=\"https:\/\/icml.cc\/virtual\/2020\/poster\/6535\" target=\"_blank\" rel=\"noreferrer noopener\">here<\/a>.<\/p>\n\n\n\n<p>The paper is a bit mathematically heavy in nature so this post is an attempt to distill the key findings. We will also be following up soon with a new codebase release (more on it later).<\/p>\n\n\n\n<h1 class=\"wp-block-heading\" id=\"27f4\"><strong>Rich-observation RL landscape<\/strong><\/h1>\n\n\n\n<p>Consider the combination lock problem shown below. The agent starts in the state s<sub>1a<\/sub> or s<sub>1b<\/sub> with equal probability. After taking h-1 actions, the agent will be in either state s<sub>ha<\/sub>, s<sub>hb<\/sub>, or s<sub>hc<\/sub>. The agent can take 10 different actions. The agent observes a high-dimensional observation (focus circle) instead of the underlying state which is latent. There is a big treasure chest that one can get after taking 100 actions. We view the states with subscript \u201ca\u201d or \u201cb\u201d as \u201c<em>good states<\/em>\u201d and one with subscript \u201cc\u201d as \u201c<em>bad states<\/em>\u201d. You can reach the treasure chest at the end only if you remain in good states. If you reach any bad state, then you can never make it to the treasure chest.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/miro.medium.com\/max\/1400\/1*PdxtcVJPhvq6fhit9Rxfig.png\" alt=\"\"\/><\/figure>\n\n\n\n<p>The environment makes it difficult to reach the big treasure chest in three ways. First, the environmental dynamics are such that if you are in good states, then only 1 out of 10 possible actions will let you reach the two good states at the next time step with equal probability (the good action changes from state to state). Every other action in good states and all actions in bad states put you into bad states at the next time step, from which it is impossible to recover. Second, it misleads myopic agents by giving a small bonus for transitioning from a good state to a bad state (small treasure chest). This means that a locally optimal policy is transitions to one of the bad states as quickly as possible. Third, the agent never directly observes which state it is in. Instead, it receives a high-dimensional, noisy observation from which it must decode the true underlying state.<\/p>\n\n\n\n<p>It is easy to see that if we take actions uniformly at random, then the probability of reaching the big treasure chest at the end is 1\/10<sup>100<\/sup>. The number 10<sup>100<\/sup> is called&nbsp;<a href=\"https:\/\/en.wikipedia.org\/wiki\/Googol\" target=\"_blank\" rel=\"noreferrer noopener\">Googol<\/a>&nbsp;and is larger than the current estimate of number of elementary particles in the universe. Furthermore, since transitions are stochastic one can show that no fixed sequence of actions performs well either.<\/p>\n\n\n\n<p>A key aspect of the rich-observation setting is that the agent receives observations instead of latent state. The observations are stochastically sampled from an&nbsp;<em>infinitely<\/em>&nbsp;large space conditioned on the state. However, observations are rich-enough to&nbsp;<em>enable decoding<\/em>&nbsp;the latent state which generates them.<\/p>\n\n\n\n<h1 class=\"wp-block-heading\" id=\"c761\"><strong>What does provable RL mean?<\/strong><\/h1>\n\n\n\n<p>A provable RL algorithm means that for any given numbers&nbsp;<strong>e<\/strong>,&nbsp;<strong>d<\/strong>&nbsp;in (0, 1); we can learn an&nbsp;<strong><em>e<\/em><\/strong><em>-optimal policy<\/em>&nbsp;with probability at least&nbsp;<strong>1-d<\/strong>&nbsp;using a number of episodes which are polynomial in relevant quantities (state size, horizon, action space, 1\/e, 1\/d, etc.). By&nbsp;<strong>e<\/strong>-optimal policy we mean a policy whose value (expected total return) is at most&nbsp;<strong>e<\/strong>&nbsp;less than the optimal return.<\/p>\n\n\n\n<p>Thus, a provable RL algorithm is capable of learning a close to optimal policy with high probability (where the word high and close can be made arbitrarily more refined), provided the assumptions it makes are satisfied.<\/p>\n\n\n\n<h1 class=\"wp-block-heading\" id=\"7fa7\"><strong>Why should I care if my algorithm is provable?<\/strong><\/h1>\n\n\n\n<p>There are two main advantages of being able to show your algorithm is provable:<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>We can only test an algorithm on a finite number of environments (in practice somewhere between 1 and 20). Without guarantees, we don\u2019t know how they will behave in a new environment. This matters especially if failure in a new environment can result in high real-world costs (e.g., in health or financial domains).<\/li><li>If a provable algorithm fails to consistently give the desired result, this can be attributed to failure of at least one of its assumptions. A developer can then look at the assumptions and try to determine which ones are violated, and either intervene to fix them or determine that the algorithm is not appropriate for the problem.<\/li><\/ol>\n\n\n\n<h1 class=\"wp-block-heading\" id=\"33fa\"><strong>HOMER<\/strong><\/h1>\n\n\n\n<p>Our algorithm addresses what is known as the&nbsp;<a href=\"https:\/\/arxiv.org\/pdf\/1901.09018.pdf\" target=\"_blank\" rel=\"noreferrer noopener\">Block MDP<\/a>&nbsp;setting. In this setting, a small number of discrete states generates a potentially infinite number of high dimensional observations.<\/p>\n\n\n\n<p>For each time step, HOMER learns a state decoder function, and a set of exploration policies. The state decoder maps high-dimensional observations to a small set of possible latent states, while the exploration policies map observations to actions which will lead the agent to each of the latent states. We describe HOMER below.<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>For a given time step, we first learn a decoder for mapping observations to a small set of values using contrastive learning. This procedure works as follows: collect a transition by following a randomly sampled exploration policy from the previous time step until that time step, and then taking a single random action. We use this procedure to sample two transitions shown below.<\/li><\/ul>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/miro.medium.com\/max\/1400\/1*mWMGmHX9R-gBH4RuPkuAZQ.gif\" alt=\"\"\/><\/figure>\n\n\n\n<ul class=\"wp-block-list\"><li>We then flip a coin; if we get heads then we store the transition&nbsp;<strong>(x1, a1, x\u20191)<\/strong>, and otherwise we store the&nbsp;<em>imposter<\/em>&nbsp;transition&nbsp;<strong>(x1, a1, x\u20192)<\/strong>. We train a supervised classifier to predict if a given transition&nbsp;<strong>(x, a, x\u2019)<\/strong>&nbsp;is real or not.<br \/>This classifier has a special structure which allows us to recover a decoder for time step h.<\/li><\/ul>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/miro.medium.com\/max\/1100\/1*_0irtizbezKiGq_XkOGmMw.png\" alt=\"\"\/><\/figure>\n\n\n\n<ul class=\"wp-block-list\"><li>Once we have learned the state decoder, we will learn an exploration policy for every possible value of the decoder (which we call&nbsp;<em>abstract state<\/em>&nbsp;as they are related to the latent state space). This step is standard can be done using many different approaches such as model-based planning, model-free methods, etc. In the paper we use an existing model-free algorithm called&nbsp;<a rel=\"noreferrer noopener\" href=\"https:\/\/www.cs.cmu.edu\/~schneide\/bagnellPSDP.pdf\" target=\"_blank\">policy search by dynamic programming (PSDP)<\/a>&nbsp;by Bagnell et al. 2004.<\/li><\/ul>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/miro.medium.com\/max\/1400\/1*TKdAjp42Uprz0ca4koTdyg.png\" alt=\"\"\/><\/figure>\n\n\n\n<ul class=\"wp-block-list\"><li>We recovered a decoder and a set of exploration policy for this time step. We then keep doing it for every time step and learn a decoder and exploration policy for the whole latent state space. Finally, we can easily optimize any given reward function using any provable planner like PSDP or a model-based algorithm. (The algorithm actually recovers the latent state space up to an inherent ambiguity by combining two different decoders; but I\u2019ll leave that to avoid overloading this post).<\/li><\/ul>\n\n\n\n<h1 class=\"wp-block-heading\" id=\"0126\"><strong>Key findings<\/strong><\/h1>\n\n\n\n<p>HOMER achieves the following three properties:<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>The contrastive learning procedure gives us the right state decoding (we recover up to some inherent ambiguity but I won\u2019t cover it here).<br \/><\/li><li>HOMER can learn a set of exploration policies to reach every latent state<br \/><\/li><li>HOMER can learn a nearly-optimal policy for&nbsp;<em>any<\/em>&nbsp;given reward function with high probability. Further, this can be done after exploration part has been performed.<\/li><\/ol>\n\n\n\n<h1 class=\"wp-block-heading\" id=\"ba71\"><strong>Failure cases of prior RL algorithms<\/strong><\/h1>\n\n\n\n<p>There are many RL algorithms in the literature and many new are proposed every month. It is difficult to do justice to this vast literature in a blog post. It is equally difficult to situate HOMER in this vast literature. However, we show that several very commonly used RL algorithms fail to solve the above problem while HOMER succeeds. One of these is the&nbsp;<a href=\"https:\/\/arxiv.org\/abs\/1707.06347\" target=\"_blank\" rel=\"noreferrer noopener\">PPO<\/a>&nbsp;algorithm, a widely used policy gradient algorithm. In spite of its popular use, PPO is not designed for challenging exploration problems and easily fails. Researchers have made efforts to alleviate this with ad-hoc proposals such as using prediction errors, counts based on auto-encoders, etc. The best alternative approach we found is called&nbsp;<a href=\"https:\/\/arxiv.org\/abs\/1810.12894\" target=\"_blank\" rel=\"noreferrer noopener\">Random Network Distillation<\/a>(RND) which measures novelty of a state based on prediction errors for a fixed randomly initialized network.<\/p>\n\n\n\n<p>Below we show how PPO+RND fails to solve the above problem while HOMER succeeds. We simplify the problem by using a grid pattern where rows represent the state (the top two represents \u201cgood\u201d states and bottom row represents \u201cbad\u201d states), and column represents timestep.<\/p>\n\n\n\n<figure class=\"wp-block-embed-youtube wp-block-embed is-type-video is-provider-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\nhttps:\/\/youtu.be\/tjxl4kpd7Uw\n<\/div><\/figure>\n\n\n\n<p>We present counter-examples for other algorithms in the paper (see Section 6&nbsp;<a href=\"https:\/\/arxiv.org\/pdf\/1911.05815.pdf\" target=\"_blank\" rel=\"noreferrer noopener\">here<\/a>). These counterexamples allow us to find limits of prior work without expensive empirical computation on many domains.<\/p>\n\n\n\n<h1 class=\"wp-block-heading\" id=\"4c49\"><strong>How can I use with HOMER?<\/strong><\/h1>\n\n\n\n<p>We will be providing the code soon as part of a new package release called cereb-rl. You can find it here:&nbsp;<a href=\"https:\/\/github.com\/cereb-rl\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/github.com\/cereb-rl<\/a>&nbsp;and join the discussion here:&nbsp;<a href=\"https:\/\/gitter.im\/cereb-rl\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/gitter.im\/cereb-rl<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Last week at ICML 2020,&nbsp;Mikael Henaff,&nbsp;Akshay Krishnamurthy,&nbsp;John Langford&nbsp;and I had a paper on a new reinforcement learning (RL) algorithm that solves three key problems in RL: (i) global exploration, (ii) decoding latent dynamics, and (iii) optimizing a given reward function. Our ICML poster is&nbsp;here. The paper is a bit mathematically heavy in nature so this &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/hunch.net\/?p=13762683\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;HOMER: Provable Exploration in Reinforcement Learning&#8221;<\/span><\/a><\/p>\n","protected":false},"author":178476,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[29,11],"tags":[],"class_list":["post-13762683","post","type-post","status-publish","format-standard","hentry","category-machine-learning","category-reinforcement"],"_links":{"self":[{"href":"https:\/\/hunch.net\/index.php?rest_route=\/wp\/v2\/posts\/13762683","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/hunch.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hunch.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hunch.net\/index.php?rest_route=\/wp\/v2\/users\/178476"}],"replies":[{"embeddable":true,"href":"https:\/\/hunch.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=13762683"}],"version-history":[{"count":14,"href":"https:\/\/hunch.net\/index.php?rest_route=\/wp\/v2\/posts\/13762683\/revisions"}],"predecessor-version":[{"id":13762701,"href":"https:\/\/hunch.net\/index.php?rest_route=\/wp\/v2\/posts\/13762683\/revisions\/13762701"}],"wp:attachment":[{"href":"https:\/\/hunch.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=13762683"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hunch.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=13762683"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hunch.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=13762683"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}