├── .DS_Store ├── Bad-Student-Notes-CS294-Spring17-RL ├── .DS_Store ├── imgs │ ├── cannon.svg │ ├── linear-lqr.png │ ├── nvidia-case.png │ └── rl-imitation-learning.png └── readme.md ├── Elements-Of-RL └── readme.md ├── license.md └── readme.md /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0bserver07/Study-Reinforcement-Learning/e8d5b748939e1fbe77f67dcc83ea454b6fe6dc81/.DS_Store -------------------------------------------------------------------------------- /Bad-Student-Notes-CS294-Spring17-RL/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0bserver07/Study-Reinforcement-Learning/e8d5b748939e1fbe77f67dcc83ea454b6fe6dc81/Bad-Student-Notes-CS294-Spring17-RL/.DS_Store -------------------------------------------------------------------------------- /Bad-Student-Notes-CS294-Spring17-RL/imgs/cannon.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | image/svg+xml 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | Start 88 | 89 | End 90 | 91 | Target 92 | 93 | QuadraticDrag 94 | 95 | 96 | 97 | 98 | 99 | 100 | Cost Function: 101 | Boundry Conditions: 102 | Dynamics: 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | Find: 111 | 112 | 113 | 114 | 115 | 116 | 117 | Weight 118 | 119 | 120 | -------------------------------------------------------------------------------- /Bad-Student-Notes-CS294-Spring17-RL/imgs/linear-lqr.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0bserver07/Study-Reinforcement-Learning/e8d5b748939e1fbe77f67dcc83ea454b6fe6dc81/Bad-Student-Notes-CS294-Spring17-RL/imgs/linear-lqr.png -------------------------------------------------------------------------------- /Bad-Student-Notes-CS294-Spring17-RL/imgs/nvidia-case.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0bserver07/Study-Reinforcement-Learning/e8d5b748939e1fbe77f67dcc83ea454b6fe6dc81/Bad-Student-Notes-CS294-Spring17-RL/imgs/nvidia-case.png -------------------------------------------------------------------------------- /Bad-Student-Notes-CS294-Spring17-RL/imgs/rl-imitation-learning.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0bserver07/Study-Reinforcement-Learning/e8d5b748939e1fbe77f67dcc83ea454b6fe6dc81/Bad-Student-Notes-CS294-Spring17-RL/imgs/rl-imitation-learning.png -------------------------------------------------------------------------------- /Bad-Student-Notes-CS294-Spring17-RL/readme.md: -------------------------------------------------------------------------------- 1 | 2 | ## Notes taken from CS 294: Deep Reinforcement Learning, Spring 2017 (Berkeley) 3 | 4 | Outline: 5 | ---- 6 | 0. [lec 0](#lec0) 7 | 1. [lec 1](#lec1) 8 | 2. [lec 2](#lec2) 9 | 3. [lec 3](#lec3) 10 | 4. [lec 4](#lec4) 11 | 12 | ---- 13 | 14 | ### 0- Introduction and course overview (Levine (L), Finn (F), Schulman (S)): 15 | 16 | * L: Course information and todos: 17 | * Overall the course will cover: 18 | * supervised learning to decision making 19 | * Basic RL: Q-Learning and Policy gradients 20 | * Advanced model learning, prediction, distillation, reward learning. 21 | * DeepRL: Trust Region Policy, Actor-Critic Methods, Exploration 22 | * Open Problems 23 | + HW: 24 | + HW1: Imitation Learning (Control via supervised learning) 25 | + HW2: Basic (Sh) RL 26 | + HW3: Deep Q-Learning: 27 | + HW4: Deep Policy grads 28 | * HW5: Final Project (Research) 29 | * Using more sensory information form environment can allow the agent to navigate better towards reward and explore. 30 | * Hence, the need for vision, audio and other sensory inputs. 31 | * Problem: How do we process all these information coming from the sensory inputs? 32 | * Answer: Deep in the Deep Learning, using neural networks and function approximation to process complex inputs into the RL algorithm which can choose an action. 33 | + Let's be clear here: 34 | + Deep Learning for processing the complex information 35 | + RL to select the next action using processed inputs by NNs 36 | * Interesting work: [Reinforcement learning in the brain](https://www.princeton.edu/~yael/Publications/Niv2009.pdf) - Yael Niv 37 | * *Sutton and Barto (1990) suggested the temporal difference learning rule as a model of prediction learning in Pavlovian conditioning.* 38 | * *Basal ganglia appears to be related to reward system* 39 | + What can deep learning and RL do well now? 40 | + high degree of proficiency in domains with known rules. 41 | + learn skills with low sensory info, but a lot of repetition. 42 | + learning from human imitation. 43 | - The Hard things: 44 | - Humans (we) can learn real quick! VS RL is usually slow. 45 | - Humans (we) can reuse previous information! VS **Transfer learning in deep RL is an open problem**. 46 | - Not clear what the reward function is. 47 | - Not clear what the role of prediction should be. 48 | * Turing said: Why try rebuilding an adult brain? Try simulating a child's one. (Hence the shitty robo-cops falling into water fountains) 49 | 50 | * F: Beyond learning rewards 51 | * child's play vs rl agent in an environment. (In the real world, humans don’t get a score.) 52 | * reward funcs are essential to the structure the problem as RL. 53 | * real-world domains: reward/cost often difficult to specify: 54 | * robotic manipulation 55 | * autonomous driving 56 | * dialog systems 57 | * virtual assistants 58 | * ... 59 | - List all the forms of supervision? 60 | - imitation: autonomous-cars 61 | - inferring intentions: 62 | - Inverse RL: demonstrations 63 | - Inverse RL: learned behavior 64 | - Inverse RL: demonstrations 65 | - model-based, self-supervision: (Behavior via Prediction) 66 | - auxiliary tasks: 67 | - Sources of Auxiliary Supervision: 68 | - touch, audio, depth) 69 | - learning multiple, related tasks 70 | - task-relevant properties of the world 71 | * S: RL is a branch of ML that concerns about taking sequences of actions. 72 | * Formalized as partially observable Markov decision 73 | process (POMDP) 74 | * Observations, Actions, Rewards (this can be applied to real-world stuff, as in Business Operations) 75 | * O: current levels / score 76 | * A: number of steps to make / purchase 77 | * R: profit / reheal or something to continue 78 | + Other ML problems falling into this realm: 79 | + Classification with Hard Attention 80 | + Sequential/structured prediction, e.g., machine translation 81 | - Deep Reinforcement Learning = RL learning using NNs to ~~~ functions. 82 | - Policies (next actions) 83 | - Value Funcs (measure how good state actions-pairs are) 84 | - Dynamic Models (predict next states and rewards) 85 | * Supervised learning: 86 | * Contextual bandits: 87 | * In RL vs other ML areas: 88 | * we don't have access to the full information. 89 | * we also have to be careful, because next step is dependent on the current step taken, or current one depends on previous Xt-1. X for actions, t for Time. 90 | + TD-backgammon yester-era 91 | + Atari DeepQ, policy gradients, DAgger 92 | + policy search 93 | + AlphaGo: supervised learning + policy gradients + value functions + Monte-Carlo tree search 94 | 95 | ---- 96 | 97 | ### 1- Supervised learning and decision making (L): 98 | * Supervised Learning of Behaviors: Deep Learning, Dynamical Systems, and Behavior Cloning: 99 | * notations: (aka notation for the elements of RL) 100 | * Xt: state 101 | * Ot: observations 102 | * Ut: action 103 | * Pi = π(Ut|Ot) - Policy 104 | * c(Xt,Ut) - cost function 105 | * r(Xt,Ut) - reward function 106 | * Note (those letters should be lower-case and the "t"s should be a subscript, representing TIME) 107 | 108 | * ![img](./imgs/rl-imitation-learning.png) 109 | 110 | + Imitation Learning, 111 | + Examples: 112 | + i.e: Driving: [My-Code Nvidia's example](https://github.com/0bserver07/Nvidia-Autopilot-Keras) 113 | - we can structure the problem in this format: 114 | - Image > [Ut,Ot] >> training data >>> supervised learning to match Image + Action (Left or Right) >>>>> π(Ut|Ot) Learned 115 | - There is an inherent flaw with this process, since the expected trajectory and the real trajectory will part away, it deviates from where it should be. Hence the car driving of the cliff. 116 | - It only sees expert level and it will fail at edge cases. 117 | - We can predict this from Dynamical Systems intuition. 118 | * How can we fix this? (Nvidia's case) 119 | * ![img](./imgs/nvidia-case.png) 120 | * They stitch multiple cameras to each other? 121 | * The policy alone does not know how to fix mistakes, due to this it deviates from the working trajectory. However, if we have a distribution of the trajectories and we pick from those trajectories, then we can have a stable trajectory. 122 | * Augmenting the data by left and right. 123 | * Or using Optimal Control for correction. 124 | * p(x1,u1,x2,u2.....) p(†) or Gaussian Dist is obtained from iterative LQR. 125 | + Learning from a stabilizing controller (deep-neuro env) 126 | * One of the problems discussed is the trajectory for pData(Ot) is not necessarily close to pπø(Ot) (due to where the data comes from). 127 | * This is a root cause of the supervised learning, where we assume the training sample and testing sample data have similar distribution. 128 | * Question! Can we make pData(Ot) = pπø(Ot) ? 129 | * Somewhat YES! 130 | * DAgger (Dataset Aggregation) 131 | * This is an algorithm that can change the pData distribution to be close enough in Test/Train. 132 | * By running the Policy, 133 | 1. then DAgger will need to obtain the labels 134 | 2. run the πø to get the dataset. 135 | 3. ask a human to see if it's a good action done by Policy + DAgger collector. 136 | 4. lastly, aggregate; new + human label. 137 | 5. This works because eventually our data comes from the Policy and regulated. 138 | * Case study 1: trail following as classification 139 | * Case study 2: DAgger & domain adaptation 140 | * Case study 3: Imitation with LSTMs 141 | - Other imitation learning: 142 | * Structured prediction 143 | * Interaction & active learning 144 | * Inverse reinforcement learning 145 | * figure out the goal 146 | 147 | * cost function -> imitation? 148 | * The trouble with cost & reward functions 149 | 150 | * make sure you understood: 151 | * Notation 152 | * basic imitation learning algorithms; their strengths & weaknesses 153 | 154 | --- 155 | ### 2- Optimal Control, Trajectory Optimization, and Planning (L): 156 | 157 | * What's up? 158 | - Previously on this course: imitation learning from a human teacher. 159 | - Right Now: can the machine make its own decisions? 160 | - How can we choose actions under perfect knowledge of the system dynamics? 161 | - eg: 162 | * A couple of Optimizations and Goals: 163 | * Optimal control: 164 | * Trajectory Optimization: back-propagation through dynamical systems 165 | * [Shooting methods vs collocation](http://www.matthewpeterkelly.com/tutorials/trajectoryOptimization/terminology.html) 166 | * eg: [Source: Gradient-Based Trajectory Optimization](http://planning.cs.uiuc.edu/node795.html): "Trajectory optimization refers to the problem of perturbing the trajectory while satisfying all constraints so that its quality can be improved." Since I'm from Iraq, this is the best example I could understand: 167 | * [Cannon Example](http://www.matthewpeterkelly.com/tutorials/trajectoryOptimization/canon.html) ![img](http://www.matthewpeterkelly.com/tutorials/trajectoryOptimization/cannon.svg) - [arxiv](https://arxiv.org/abs/1707.00284) 168 | * More useful stuff here [MatthewPeterKelly - dscTutorials](https://github.com/MatthewPeterKelly/dscTutorials) 169 | * Planning: (not found here, next lec) 170 | - Next On this course: how can we learn unknown dynamics? 171 | - ALSO while you're at it ask: (How can we then also learn policies? (e.g. by imitating optimal control)) 172 | 173 | 174 | * All trajectory methods can either be described as shooting methods or collocation methods: 175 | * The key difference is that Shooting methods use explicit integration schemes whereas collocation uses implicit. 176 | 177 | 178 | * Big Question: How do we make decision under known dynamics? 179 | + often differentiate and back-prop and optimize 180 | + keep in mind the 2nd order method helps in above step (google it if you need 34 page proof) 181 | 182 | * Important equation: 183 | * Linear Case (LQR): ![lqr](./imgs/linear-lqr.png) 184 | 185 | * Examples of Trajectory optimization: 186 | * Example 1: nonlinear model-predictive control (synthesis and stabilization of complex behaviors through online trajectory) 187 | * observe the state xt 188 | * it utilizes the iLQR to optimize plan minimize cost(xt,ut) 189 | * execute action ut (discardut+1....ut+T) 190 | + Example Discrete case: Monte Carlo tree search (MCTS) 191 | + from random policy to choose rarely visited branches with best reward. 192 | * Example 2: imitation learning from MCTS: 193 | * same same, but aggregate at the last step, agg of the D = {o1,u1....} Which is domain data, aka human data doing stuff for imitation, i.e: the example of DAgger (i think). 194 | 195 | 196 | >* Linear dynamics: linear-quadratic regulator (LQR) 197 | >* The iterative Linear Quadratic Regulator algorithm ( The gist of it was at every time step linearize the dynamics, quadratize (it could be a word) the cost function around the current point in state space and compute your feedback gain off of that, as though the dynamics were both linear and consistent (i.e. didn’t change in different states). And that was pretty cool because you didn’t need all the equations of motion and inertia matrices etc to generate a control signal. You could just use the simulation you had, sample it a bunch to estimate the dynamics and value function, and go off of that.) 198 | >* The LQR, however, operates with maverick disregard for changes in the future. Careless of the consequences, it optimizes assuming the linear dynamics approximated at the current time step hold for all time. It would be really great to have an algorithm that was able to plan out and optimize a sequence, mindful of the changing dynamics of the system. 199 | >* This is exactly the iterative Linear Quadratic Regulator method (iLQR) was designed for. iLQR is an extension of LQR control, and the idea here is basically to optimize a whole control sequence rather than just the control signal for the current point in time. The basic flow of the algorithm is [source](https://studywolf.wordpress.com/2016/02/03/the-iterative-linear-quadratic-regulator-method/) 200 | 201 | * More on(trajectory stabilization and iterative linear quadratic regulator)....[Lecture](https://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-832-underactuated-robotics-spring-2009/video-lectures/lecture-10-trajectory-stabilization-and-iterative-linear-quadratic-regulator/) 202 | * Nonlinear dynamics: differential dynamic programming (DDP) & iterative LQR 203 | * Discrete systems: Monte-Carlo tree search (MCTS) 204 | 205 | * make sure you understood: 206 | * Understand the terminology and formalisms of optimal control 207 | * Understand some standard optimal control & planning algorithms 208 | 209 | 210 | 211 | ---- 212 | ### 3- Learning Dynamical System Models from Data(L) [Week 3, Lecture 1]: 213 | * What's up? 214 | - Previously x 1 on this course: learning to act by imitating a human 215 | - Previously x 2 on this course: choose good actions autonomously by back-propagating 216 | (or planning) through known system dynamics (e.g. known physics) 217 | - Right Now: what do we do if the dynamics are unknown? 218 | - Fitting global dynamics models (“model-based RL”) 219 | - Fitting local dynamics models 220 | * A couple of Optimizations and Goals: 221 | 222 | - Next On this course: putting it all together to learn to “imitate” without a human (e.g. by imitating optimal control), so that we can train deep network policies autonomously 223 | 224 | 225 | * learning the dynamics model right now, right here, in this lecture once for all: 226 | * Global models and local models 227 | * Learning with local models and trust regions 228 | 229 | * make sure you understood: 230 | * formalism of model-based RL 231 | * options for models we can use in model-based RL 232 | * practical considerations of model learning 233 | 234 | ---- 235 | ### 4- Learning Policies by Imitating Optimal Control(L): 236 | 237 | * *HW1 is out* 238 | 239 | * make sure you understood: 240 | * how to train policies using optimal control 241 | * tradeoffs between various methods 242 | 243 | 244 | ---- 245 | ### 5- Direct Collocation Methods for Trajectory Optimization and Policy Learning (Igor) guest: 246 | 247 | * Applied advice about the previous work. -------------------------------------------------------------------------------- /Elements-Of-RL/readme.md: -------------------------------------------------------------------------------- 1 | #### Elements Of Reinforcement Learning: (Derived from Barto and Sutton '17 and Li '17) 2 | 3 | * A policy defines the learning agent’s way of behaving at a given time. Roughly speaking, a policy is a mapping from perceived states of the environment to actions to be taken when in those states. 4 | * Actor-Critic 5 | * Policy Gradient 6 | * Comb Policy Grad + Off-Policy RL 7 | 8 | * A reward signal defines the goal in a reinforcement learning problem. On each time step, the environment sends to the reinforcement learning agent a single number called the reward. The agent’s sole objective is to maximize the total reward it receives over the long run. 9 | * rewards can be sparse signals 10 | * reward functions exist often times to handle the scarcity. 11 | 12 | * A value function specifies what is good in the long run. Roughly speaking, the value of a state is the total amount of reward an agent can expect to accumulate over the future, starting from that state. 13 | * Deep DQN 14 | * Double DQN 15 | * Dueling Archs 16 | 17 | * The fourth and final element of some reinforcement learning systems is a model of the environment. This is something that mimics the behavior of the environment, or more generally, that allows inferences to be made about how the environment will behave. 18 | 19 | --- 20 | 21 | Upgraded: 22 | 23 | * Planning 24 | * Exploration 25 | -------------------------------------------------------------------------------- /license.md: -------------------------------------------------------------------------------- 1 | ## creative commons 2 | 3 | # Attribution-NonCommercial-NoDerivatives 4.0 International 4 | 5 | Creative Commons Corporation (“Creative Commons”) is not a law firm and does not provide legal services or legal advice. Distribution of Creative Commons public licenses does not create a lawyer-client or other relationship. Creative Commons makes its licenses and related information available on an “as-is” basis. Creative Commons gives no warranties regarding its licenses, any material licensed under their terms and conditions, or any related information. Creative Commons disclaims all liability for damages resulting from their use to the fullest extent possible. 6 | 7 | ### Using Creative Commons Public Licenses 8 | 9 | Creative Commons public licenses provide a standard set of terms and conditions that creators and other rights holders may use to share original works of authorship and other material subject to copyright and certain other rights specified in the public license below. The following considerations are for informational purposes only, are not exhaustive, and do not form part of our licenses. 10 | 11 | * __Considerations for licensors:__ Our public licenses are intended for use by those authorized to give the public permission to use material in ways otherwise restricted by copyright and certain other rights. Our licenses are irrevocable. Licensors should read and understand the terms and conditions of the license they choose before applying it. Licensors should also secure all rights necessary before applying our licenses so that the public can reuse the material as expected. Licensors should clearly mark any material not subject to the license. This includes other CC-licensed material, or material used under an exception or limitation to copyright. [More considerations for licensors](http://wiki.creativecommons.org/Considerations_for_licensors_and_licensees#Considerations_for_licensors). 12 | 13 | * __Considerations for the public:__ By using one of our public licenses, a licensor grants the public permission to use the licensed material under specified terms and conditions. If the licensor’s permission is not necessary for any reason–for example, because of any applicable exception or limitation to copyright–then that use is not regulated by the license. Our licenses grant only permissions under copyright and certain other rights that a licensor has authority to grant. Use of the licensed material may still be restricted for other reasons, including because others have copyright or other rights in the material. A licensor may make special requests, such as asking that all changes be marked or described. Although not required by our licenses, you are encouraged to respect those requests where reasonable. [More considerations for the public](http://wiki.creativecommons.org/Considerations_for_licensors_and_licensees#Considerations_for_licensees). 14 | 15 | ## Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International Public License 16 | 17 | By exercising the Licensed Rights (defined below), You accept and agree to be bound by the terms and conditions of this Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International Public License ("Public License"). To the extent this Public License may be interpreted as a contract, You are granted the Licensed Rights in consideration of Your acceptance of these terms and conditions, and the Licensor grants You such rights in consideration of benefits the Licensor receives from making the Licensed Material available under these terms and conditions. 18 | 19 | ### Section 1 – Definitions. 20 | 21 | a. __Adapted Material__ means material subject to Copyright and Similar Rights that is derived from or based upon the Licensed Material and in which the Licensed Material is translated, altered, arranged, transformed, or otherwise modified in a manner requiring permission under the Copyright and Similar Rights held by the Licensor. For purposes of this Public License, where the Licensed Material is a musical work, performance, or sound recording, Adapted Material is always produced where the Licensed Material is synched in timed relation with a moving image. 22 | 23 | b. __Copyright and Similar Rights__ means copyright and/or similar rights closely related to copyright including, without limitation, performance, broadcast, sound recording, and Sui Generis Database Rights, without regard to how the rights are labeled or categorized. For purposes of this Public License, the rights specified in Section 2(b)(1)-(2) are not Copyright and Similar Rights. 24 | 25 | e. __Effective Technological Measures__ means those measures that, in the absence of proper authority, may not be circumvented under laws fulfilling obligations under Article 11 of the WIPO Copyright Treaty adopted on December 20, 1996, and/or similar international agreements. 26 | 27 | f. __Exceptions and Limitations__ means fair use, fair dealing, and/or any other exception or limitation to Copyright and Similar Rights that applies to Your use of the Licensed Material. 28 | 29 | h. __Licensed Material__ means the artistic or literary work, database, or other material to which the Licensor applied this Public License. 30 | 31 | i. __Licensed Rights__ means the rights granted to You subject to the terms and conditions of this Public License, which are limited to all Copyright and Similar Rights that apply to Your use of the Licensed Material and that the Licensor has authority to license. 32 | 33 | h. __Licensor__ means the individual(s) or entity(ies) granting rights under this Public License. 34 | 35 | i. __NonCommercial__ means not primarily intended for or directed towards commercial advantage or monetary compensation. For purposes of this Public License, the exchange of the Licensed Material for other material subject to Copyright and Similar Rights by digital file-sharing or similar means is NonCommercial provided there is no payment of monetary compensation in connection with the exchange. 36 | 37 | j. __Share__ means to provide material to the public by any means or process that requires permission under the Licensed Rights, such as reproduction, public display, public performance, distribution, dissemination, communication, or importation, and to make material available to the public including in ways that members of the public may access the material from a place and at a time individually chosen by them. 38 | 39 | k. __Sui Generis Database Rights__ means rights other than copyright resulting from Directive 96/9/EC of the European Parliament and of the Council of 11 March 1996 on the legal protection of databases, as amended and/or succeeded, as well as other essentially equivalent rights anywhere in the world. 40 | 41 | l. __You__ means the individual or entity exercising the Licensed Rights under this Public License. Your has a corresponding meaning. 42 | 43 | ### Section 2 – Scope. 44 | 45 | a. ___License grant.___ 46 | 47 | 1. Subject to the terms and conditions of this Public License, the Licensor hereby grants You a worldwide, royalty-free, non-sublicensable, non-exclusive, irrevocable license to exercise the Licensed Rights in the Licensed Material to: 48 | 49 | A. reproduce and Share the Licensed Material, in whole or in part, for NonCommercial purposes only; and 50 | 51 | B. produce and reproduce, but not Share, Adapted Material for NonCommercial purposes only. 52 | 53 | 2. __Exceptions and Limitations.__ For the avoidance of doubt, where Exceptions and Limitations apply to Your use, this Public License does not apply, and You do not need to comply with its terms and conditions. 54 | 55 | 3. __Term.__ The term of this Public License is specified in Section 6(a). 56 | 57 | 4. __Media and formats; technical modifications allowed.__ The Licensor authorizes You to exercise the Licensed Rights in all media and formats whether now known or hereafter created, and to make technical modifications necessary to do so. The Licensor waives and/or agrees not to assert any right or authority to forbid You from making technical modifications necessary to exercise the Licensed Rights, including technical modifications necessary to circumvent Effective Technological Measures. For purposes of this Public License, simply making modifications authorized by this Section 2(a)(4) never produces Adapted Material. 58 | 59 | 5. __Downstream recipients.__ 60 | 61 | A. __Offer from the Licensor – Licensed Material.__ Every recipient of the Licensed Material automatically receives an offer from the Licensor to exercise the Licensed Rights under the terms and conditions of this Public License. 62 | 63 | B. __No downstream restrictions.__ You may not offer or impose any additional or different terms or conditions on, or apply any Effective Technological Measures to, the Licensed Material if doing so restricts exercise of the Licensed Rights by any recipient of the Licensed Material. 64 | 65 | 6. __No endorsement.__ Nothing in this Public License constitutes or may be construed as permission to assert or imply that You are, or that Your use of the Licensed Material is, connected with, or sponsored, endorsed, or granted official status by, the Licensor or others designated to receive attribution as provided in Section 3(a)(1)(A)(i). 66 | 67 | b. ___Other rights.___ 68 | 69 | 1. Moral rights, such as the right of integrity, are not licensed under this Public License, nor are publicity, privacy, and/or other similar personality rights; however, to the extent possible, the Licensor waives and/or agrees not to assert any such rights held by the Licensor to the limited extent necessary to allow You to exercise the Licensed Rights, but not otherwise. 70 | 71 | 2. Patent and trademark rights are not licensed under this Public License. 72 | 73 | 3. To the extent possible, the Licensor waives any right to collect royalties from You for the exercise of the Licensed Rights, whether directly or through a collecting society under any voluntary or waivable statutory or compulsory licensing scheme. In all other cases the Licensor expressly reserves any right to collect such royalties, including when the Licensed Material is used other than for NonCommercial purposes. 74 | 75 | ### Section 3 – License Conditions. 76 | 77 | Your exercise of the Licensed Rights is expressly made subject to the following conditions. 78 | 79 | a. ___Attribution.___ 80 | 81 | 1. If You Share the Licensed Material, You must: 82 | 83 | A. retain the following if it is supplied by the Licensor with the Licensed Material: 84 | 85 | i. identification of the creator(s) of the Licensed Material and any others designated to receive attribution, in any reasonable manner requested by the Licensor (including by pseudonym if designated); 86 | 87 | ii. a copyright notice; 88 | 89 | iii. a notice that refers to this Public License; 90 | 91 | iv. a notice that refers to the disclaimer of warranties; 92 | 93 | v. a URI or hyperlink to the Licensed Material to the extent reasonably practicable; 94 | 95 | B. indicate if You modified the Licensed Material and retain an indication of any previous modifications; and 96 | 97 | C. indicate the Licensed Material is licensed under this Public License, and include the text of, or the URI or hyperlink to, this Public License. 98 | 99 | For the avoidance of doubt, You do not have permission under this Public License to Share Adapted Material. 100 | 101 | 2. You may satisfy the conditions in Section 3(a)(1) in any reasonable manner based on the medium, means, and context in which You Share the Licensed Material. For example, it may be reasonable to satisfy the conditions by providing a URI or hyperlink to a resource that includes the required information. 102 | 103 | 3. If requested by the Licensor, You must remove any of the information required by Section 3(a)(1)(A) to the extent reasonably practicable. 104 | 105 | ### Section 4 – Sui Generis Database Rights. 106 | 107 | Where the Licensed Rights include Sui Generis Database Rights that apply to Your use of the Licensed Material: 108 | 109 | a. for the avoidance of doubt, Section 2(a)(1) grants You the right to extract, reuse, reproduce, and Share all or a substantial portion of the contents of the database for NonCommercial purposes only and provided You do not Share Adapted Material; 110 | 111 | b. if You include all or a substantial portion of the database contents in a database in which You have Sui Generis Database Rights, then the database in which You have Sui Generis Database Rights (but not its individual contents) is Adapted Material; and 112 | 113 | c. You must comply with the conditions in Section 3(a) if You Share all or a substantial portion of the contents of the database. 114 | 115 | For the avoidance of doubt, this Section 4 supplements and does not replace Your obligations under this Public License where the Licensed Rights include other Copyright and Similar Rights. 116 | 117 | ### Section 5 – Disclaimer of Warranties and Limitation of Liability. 118 | 119 | a. __Unless otherwise separately undertaken by the Licensor, to the extent possible, the Licensor offers the Licensed Material as-is and as-available, and makes no representations or warranties of any kind concerning the Licensed Material, whether express, implied, statutory, or other. This includes, without limitation, warranties of title, merchantability, fitness for a particular purpose, non-infringement, absence of latent or other defects, accuracy, or the presence or absence of errors, whether or not known or discoverable. Where disclaimers of warranties are not allowed in full or in part, this disclaimer may not apply to You.__ 120 | 121 | b. __To the extent possible, in no event will the Licensor be liable to You on any legal theory (including, without limitation, negligence) or otherwise for any direct, special, indirect, incidental, consequential, punitive, exemplary, or other losses, costs, expenses, or damages arising out of this Public License or use of the Licensed Material, even if the Licensor has been advised of the possibility of such losses, costs, expenses, or damages. Where a limitation of liability is not allowed in full or in part, this limitation may not apply to You.__ 122 | 123 | c. The disclaimer of warranties and limitation of liability provided above shall be interpreted in a manner that, to the extent possible, most closely approximates an absolute disclaimer and waiver of all liability. 124 | 125 | ### Section 6 – Term and Termination. 126 | 127 | a. This Public License applies for the term of the Copyright and Similar Rights licensed here. However, if You fail to comply with this Public License, then Your rights under this Public License terminate automatically. 128 | 129 | b. Where Your right to use the Licensed Material has terminated under Section 6(a), it reinstates: 130 | 131 | 1. automatically as of the date the violation is cured, provided it is cured within 30 days of Your discovery of the violation; or 132 | 133 | 2. upon express reinstatement by the Licensor. 134 | 135 | For the avoidance of doubt, this Section 6(b) does not affect any right the Licensor may have to seek remedies for Your violations of this Public License. 136 | 137 | c. For the avoidance of doubt, the Licensor may also offer the Licensed Material under separate terms or conditions or stop distributing the Licensed Material at any time; however, doing so will not terminate this Public License. 138 | 139 | d. Sections 1, 5, 6, 7, and 8 survive termination of this Public License. 140 | 141 | ### Section 7 – Other Terms and Conditions. 142 | 143 | a. The Licensor shall not be bound by any additional or different terms or conditions communicated by You unless expressly agreed. 144 | 145 | b. Any arrangements, understandings, or agreements regarding the Licensed Material not stated herein are separate from and independent of the terms and conditions of this Public License. 146 | 147 | ### Section 8 – Interpretation. 148 | 149 | a. For the avoidance of doubt, this Public License does not, and shall not be interpreted to, reduce, limit, restrict, or impose conditions on any use of the Licensed Material that could lawfully be made without permission under this Public License. 150 | 151 | b. To the extent possible, if any provision of this Public License is deemed unenforceable, it shall be automatically reformed to the minimum extent necessary to make it enforceable. If the provision cannot be reformed, it shall be severed from this Public License without affecting the enforceability of the remaining terms and conditions. 152 | 153 | c. No term or condition of this Public License will be waived and no failure to comply consented to unless expressly agreed to by the Licensor. 154 | 155 | d. Nothing in this Public License constitutes or may be interpreted as a limitation upon, or waiver of, any privileges and immunities that apply to the Licensor or You, including from the legal processes of any jurisdiction or authority. 156 | 157 | > Creative Commons is not a party to its public licenses. Notwithstanding, Creative Commons may elect to apply one of its public licenses to material it publishes and in those instances will be considered the “Licensor.” Except for the limited purpose of indicating that material is shared under a Creative Commons public license or as otherwise permitted by the Creative Commons policies published at [creativecommons.org/policies](http://creativecommons.org/policies), Creative Commons does not authorize the use of the trademark “Creative Commons” or any other trademark or logo of Creative Commons without its prior written consent including, without limitation, in connection with any unauthorized modifications to any of its public licenses or any other arrangements, understandings, or agreements concerning use of licensed material. For the avoidance of doubt, this paragraph does not form part of the public licenses. 158 | > 159 | > Creative Commons may be contacted at creativecommons.org 160 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | ## Study Reinforcement Learning & (Deep RL) Guide: 2 | 3 | * Simple guide and collective to study RL/DeepRL in one to 2.5 months of time. 4 | 5 | ### Talks to check out first: 6 | ---- 7 | 8 | * [Introduction to Reinforcement Learning](http://videolectures.net/deeplearning2016_pineau_reinforcement_learning/) by Joelle Pineau, McGill University: 9 | * Applications of RL. 10 | * When to use RL? 11 | * RL vs supervised learning 12 | * What is MDP? Markov Decision Process 13 | * Components of an RL agent: 14 | - states 15 | - actions (Probabilistic effects) 16 | - Reward function 17 | - Initial state distribution 18 | ``` 19 | +-----------------+ 20 | +--------------------- | | 21 | | | Agent | 22 | | | | +---------------------+ 23 | | +----------> | | | 24 | | | +-----------------+ | 25 | | | | 26 | state | | reward | action 27 | S(t) | | r(t) | a(t) 28 | | | | 29 | | | + | 30 | | | | r(t+1) +----------------------------+ | 31 | | +-----------+ | | 32 | | | | | <-----------+ 33 | | | | Environment | 34 | | | S(t+1) | | 35 | +---------------------+ | 36 | | +----------------------------+ 37 | + 38 | 39 | * Sutton and Barto (1998) 40 | 41 | ``` 42 | 43 | * Explanation of the Markov Property: 44 | * Why Maximizing utility in: 45 | - Episodic tasks 46 | - Continuing tasks 47 | + The discount factor, gamma γ 48 | * What is the policy & what to do with it? 49 | - A policy defines the action-selection strategy at every state: 50 | * Value functions: 51 | - The value of a policy equations are (two forms of) Bellman’s equation. 52 | - (This is a dynamic programming algorithm). 53 | - Iterative Policy Evaluation: 54 | + Main idea: turn Bellman equations into update rules. 55 | * Optimal policies and optimal value functions. 56 | * Finding a good policy: Policy Iteration (Check the talk Below By Peter Abeel) 57 | * Finding a good policy: Value iteration 58 | - Asynchronous value iteration: 59 | - Instead of updating all states on every iteration, focus on important states. 60 | * Key challenges in RL: 61 | - Designing the problem domain 62 | - State representation 63 | – Action choice 64 | – Cost/reward signal 65 | - Acquiring data for training 66 | – Exploration / exploitation 67 | – High cost actions 68 | – Time-delayed cost/reward signal 69 | - Function approximation 70 | - Validation / confidence measures 71 | * The RL lingo. 72 | * In large state spaces: Need approximation: 73 | - Fitted Q-iteration: 74 | + Use supervised learning to estimate the Q-function from a batch of training data: 75 | + Input, Output and Loss. 76 | * i.e: The Arcade Learning Environment 77 | * Deep Q-network (DQN) and tips. 78 | 79 | * [Deep Reinforcement Learning](http://videolectures.net/deeplearning2016_abbeel_deep_reinforcement/) by Pieter Abbeel, EE & CS, UC Berkeley 80 | - Why Policy Optimization? 81 | - Cross Entropy Method (CEM) / Finite Differences / Fixing Random Seed 82 | - Likelihood Ratio (LR) Policy Gradient 83 | - Natural Gradient / Trust Regions (-> TRPO) 84 | - Actor-Critic (-> GAE, A3C) 85 | - Path Derivatives (PD) (-> DPG, DDPG, SVG) 86 | - Stochastic Computation Graphs (generalizes LR / PD) 87 | - Guided Policy Search (GPS) 88 | - Inverse Reinforcement Learning 89 | + Inverse RL vs. behavioral cloning 90 | 91 | - Explanation with Implementation for some of the topics mentioned in the Deep Reinforcement Learning talk, written by [Arthur Juliani](https://github.com/awjuliani) 92 | * The TF / Python implementations [can be found here](https://github.com/awjuliani/DeepRL-Agents). 93 | * [Part 0 — Q-Learning Agents](https://medium.com/emergent-future/simple-reinforcement-learning-with-tensorflow-part-0-q-learning-with-tables-and-neural-networks-d195264329d0#.kghmcex46) 94 | * [Part 1 — Two-Armed Bandit](https://medium.com/@awjuliani/super-simple-reinforcement-learning-tutorial-part-1-fd544fab149#.bqvzsrvh7) 95 | * [Part 1.5 — Contextual Bandits](https://medium.com/emergent-future/simple-reinforcement-learning-with-tensorflow-part-1-5-contextual-bandits-bff01d1aad9c#.h2c63t3om) 96 | * [Part 2 — Policy-Based Agents](https://medium.com/@awjuliani/super-simple-reinforcement-learning-tutorial-part-2-ded33892c724#.v0hnvh4tw) 97 | * [Part 3 — Model-Based RL](https://medium.com/@awjuliani/simple-reinforcement-learning-with-tensorflow-part-3-model-based-rl-9a6fe0cce99#.i8pgqg8xa) 98 | * [Part 4 — Deep Q-Networks and Beyond](https://medium.com/@awjuliani/simple-reinforcement-learning-with-tensorflow-part-4-deep-q-networks-and-beyond-8438a3e2b8df#.qecef59on) 99 | * [Part 5 — Visualizing an Agent’s Thoughts and Actions](https://medium.com/@awjuliani/simple-reinforcement-learning-with-tensorflow-part-5-visualizing-an-agents-thoughts-and-actions-4f27b134bb2a#.60nyejzep) 100 | * [Part 6 — Partial Observability and Deep Recurrent Q-Networks](https://medium.com/emergent-future/simple-reinforcement-learning-with-tensorflow-part-6-partial-observability-and-deep-recurrent-q-68463e9aeefc#.w22xh551q) 101 | * [Part 7 — Action-Selection Strategies for Exploration](https://medium.com/emergent-future/simple-reinforcement-learning-with-tensorflow-part-7-action-selection-strategies-for-exploration-d3a97b7cceaf#.vxsnvalt7) 102 | * [Part 8 — Asynchronous Actor-Critic Agents (A3C)](https://medium.com/emergent-future/simple-reinforcement-learning-with-tensorflow-part-8-asynchronous-actor-critic-agents-a3c-c88f72a5e9f2#.9nns6digz) 103 | 104 | 105 | 106 | 107 | ### Books: 108 | --- 109 | 110 | - Before starting out the books, here is a neat overview by Yuxi Li about Deep RL: 111 | - [Deep Reinforcement Learning: An Overview](https://arxiv.org/abs/1701.07274v2) 112 | - [Reinforcement Learning: An Introduction by Richard S. Sutton and Andrew G. Barto](http://webdocs.cs.ualberta.ca/~sutton/book/ebook/the-book.html) 113 | - [Algorithms for Reinforcement Learning.](https://sites.ualberta.ca/~szepesva/papers/RLAlgsInMDPs.pdf) 114 | - [Reinforcement Learning and Dynamic Programming using Function Approximators.](https://orbi.ulg.ac.be/bitstream/2268/27963/1/book-FA-RL-DP.pdf) 115 | 116 | 117 | 118 | ### Courses: 119 | --- 120 | 121 | * [Reinforcement Learning](http://www0.cs.ucl.ac.uk/staff/d.silver/web/Teaching.html) by David Silver. 122 | * Lecture 1: Introduction to Reinforcement Learning 123 | * Lecture 2: Markov Decision Processes 124 | * Lecture 3: Planning by Dynamic Programming 125 | * Lecture 4: Model-Free Prediction 126 | * Lecture 5: Model-Free Control 127 | * Lecture 6: Value Function Approximation 128 | * Lecture 7: Policy Gradient Methods 129 | * Lecture 8: Integrating Learning and Planning 130 | * Lecture 9: Exploration and Exploitation 131 | * Lecture 10: Case Study: RL in Classic Games 132 | 133 | * [CS 294: Deep Reinforcement Learning, Spring 2017](http://rll.berkeley.edu/deeprlcoursesp17/#lecture-videos) by John Schulman and Pieter Abbeel. 134 | * Instructors: Sergey Levine, John Schulman, Chelsea Finn: 135 | * [My Bad Notes](./CS294-Spring17-RL) 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | ----- 147 | 148 | ![cc](https://licensebuttons.net/l/by-nc-nd/3.0/88x31.png) 149 | --------------------------------------------------------------------------------