Full text
Luís Aníbal Barbosa de Araújo Generalization in Reinforcement Learning: Theory, Methods, and Grid-World Applications June 2024 UMinho | 2024 Luís Araújo Generalization in Reinforcement Learning Theory, Methods, and Grid-World Applications University of Minho School of Sciences
University of Minho School of Sciences Luís Aníbal Barbosa de Araújo Generalization in Reinforcement Learning Theory, Methods, and Grid-World Applications Master’s Dissertation in Mathematics and Computation Dissertation supervised by Professor Doutor Gaspar José Machado Professor Doutor Stéphane Louis Clain June 2024
Copyright and Terms of Use for Third Party Work This dissertation reports on academic work that can be used by third parties as long as the internationally accepted standards and good practices are respected concerning copyright and related rights. This work can thereafter be used under the terms established in the license below. Readers needing authorization conditions not provided for in the indicated licensing should contact the author through the RepositóriUM of the University of Minho. License granted to users of this work: CC BY-NC-SA https://creativecommons.org/licenses/by-nc-sa/4.0/ [Esta licença permite que outros remisturem, adaptem e criem a partir do seu trabalho para fins não comerciais, desde que lhe atribuam a si o devido crédito e que licenciem as novas criações ao abrigo de termos idênticos.] i
Acknowledgements This dissertation is the culmination of over six years of work, beginning with my Computer Science degree, which rekindled my love for mathematics and opened the door to the world of machine learning during my Master’s in Mathematics and Computation. First and foremost, I would like to thank my mother, Dulce, and my father, Zé, for their unwavering support and the freedom they gave me to pursue my passions. I also want to thank my family, especially my cousins, for shaping my personality. I am deeply grateful for the unbounded and blindly trustworthy friendship of my dear friends from Barcelos. In Braga, I met some of the best people I know, who have become my second family. Without their support, this chapter of my life would never have been completed. I would also like to extend my heartfelt thanks to my supervisors, Professor Stéphane Clain and Professor Gaspar Machado. Their guidance and weekly support over the past year and a half have been invaluable. They gave me the freedom to explore my interests within this fascinating field and showed tremendous interest in my research. A special thanks to Professor Stéphane for introducing me to the world of Reinforcement Learning, which has now become my main area of academic interest. Additionally, I am grateful to all the teachers I have had throughout my educational journey for their knowledge and inspiration. We are not merely the ”average of the five people we spend the most time with”; rather, we are the weighted average of every human who has ever lived, with greater weight given to those who have ever cared most about us and even more to those we care most about. My gratitude to all those. ”This work is supported by national funds, through the Operational Competitiveness and Internationalization Programme (COMPETE 2020) [Project nº 179826; Funding Reference: SIFN-01-9999-FN-179826].” ii
“Discovery is a child’s privilege. I mean, the small child, the child who is not afraid to be wrong, to look silly, to not be serious, and to act differently from everyone else.” Alexander Grothendieck iii
Statement of Integrity I hereby declare having conducted this academic work with integrity. I confirm that I have not used plagiarism or any form of undue use of information or falsification of results along the process leading to its elaboration. I further declare that I have fully acknowledged the Code of Ethical Conduct of the University of Minho. University of Minho, Braga, June 2024 Luís Aníbal Barbosa de Araújo iv
Abstract Reinforcement Learning is a Machine Learning subfield which studies sequential decision making problems, where an agent must solve tasks by making decision in a given environment. The primary objective of this dissertation is to establish a comprehensive theoretical foundation by defining the mathematical formalisms which underpin classical Reinforcement Learning algorithms, and then review state of the art techniques, which use recent advances in Deep Learning to target Generalization problems that arise when the decision making tasks get more complex. Applying algorithms to games is a standard practice in Reinforcement Learning academic research due to the ease of experiment reproducibility and the safe, well-controlled environment they provide. A contribution of this work is the development of a custom Grid-world car game, where an agent must solve game maps by driving a car as fast as possible. This game will be a simple yet effective benchmark, which together with some Procedural Generative algorithms also proposed, can evaluate the generalization capabilities of the algorithms. The classical Reinforcement Learning techniques are studied from the theoretical standpoint, and also by developing the algorithms, and comparing their performance in the game environment. Furthermore, we explore recent advancements in Reinforcement Learning, particularly methods relying on Function Approximation. The game environment is used to test these advanced methods, showcasing their practical applications and limitations, by solving thousands of game maps and studying various learning techniques. Keywords Reinforcement Learning, Sequential Decision Making, Deep Learning, Transfer Learning, Curriculum Learning v
Resumo Aprendizagem por Reforço é uma subárea de Aprendizagem Máquina que estuda problemas de tomada de decisão sequencial, onde um agente deve resolver tarefas tomando decisões num determinado ambiente. O objetivo principal desta dissertação é estabelecer uma base teórica abrangente, através da definição dos formalismos matemáticos que sustentam os algoritmos clássicos de Aprendizagem por Reforço, para depois realizar uma revisão de técnicas estado-da-arte, que utilizem avanços recentes em Aprendizagem Profunda, de forma a abordar problemas de Generalização que surgem quando as tarefas de tomada de decisão se tornam mais complexas. A aplicação de algoritmos a jogos é uma prática padrão na pesquisa académica de Aprendizagem por Reforço devido à facilidade de reprodutibilidade das experiências e ao ambiente seguro e bem controlado que eles proporcionam. Uma contribuição deste trabalho é o desenvolvimento de um jogo de carros Grid-world, onde um agente deve resolver mapas do jogo conduzindo um carro o mais rápido possível. Este jogo será um benchmark simples, mas eficaz, que, juntamente com alguns algoritmos de Geração Procedural também propostos, pode avaliar as capacidades de generalização dos algoritmos. As técnicas clássicas de Aprendizagem por Reforço são estudadas do ponto de vista teórico e também através do desenvolvimento dos algoritmos, comparando os diferentes desempenhos no ambiente de jogo. Além disso, exploramos avanços recentes em Aprendizagem por Reforço, particularmente métodos que dependem de Aproximação de Funções. O ambiente de jogo é utilizado para testar esses métodos avançados, demonstrando as aplicações práticas e limitações, resolvendo milhares de mapas do jogo e estudando várias técnicas de aprendizagem. Palavras-chave Aprendizagem por Reforço, Tomada de Decisão Sequencial, Aprendizagem Profunda, Aprendizagem por Transferência, Aprendizagem Curricular vi
Figure 1: Human decision-making loop. tations we call states (or observations), and finally, a reward which should characterize an impact of the actions in the environment. Classic RL theory has a strong and specific mathematical background, which is also considerably different from other ML frameworks. Nevertheless, whenever we target complex problems through the lens of RL, the modern applications also use techniques from other AI subfields, namely Deep Learning, whose combination with classic RL opened very specific theoretical questions and practical issues. 1.2 Contributions and Outline This dissertation focuses on studying various RL techniques, emphasizing their mathematical properties and formalisms, towards recent research topics. The primary objective is to provide a comprehensive theoretical foundation, beginning with formal definitions of the different components mentioned above in a common framework, which underpin both classical and modern RL algorithms, so that later in the text it will be possible to understand and apply state-of-the-art methods. The contributions of this dissertation can be summarized as follows: 1. Theoretical Foundations: • Detailed exposition of Markov Decision Processes as the main formalism supporting RL Theory. • Introduction and analysis of classical RL algorithms, highlighting their theoretical properties. 2. Custom Grid-world Environment: 2
• Development of a Grid-world-like car game designed as a contribution to the RL community. • The game is used as a simple benchmark for classical RL techniques. 3. Function Approximation, Generalization, and Other Techniques in RL: • Exploration of more recent advancements in RL, particularly methods that rely on function approximation. • Presentation and analysis of state-of-the-art techniques that leverage deep learning for function approximation, demonstrating their effectiveness and potential for future research. • Application of the studied techniques to the developed game environment. By addressing these areas, this dissertation aims to enhance the understanding of RL techniques, provide a game as a useful benchmark tool for the research community, contribute to the study of more robust and adaptable RL algorithms, and review recent theoretical formalisms regarding generalization in RL. 3
Chapter 2 Reinforcement Learning The pursuit of building models capable of adapting to an environment and performing tasks within it, is the primary goal of Reinforcement Learning (RL). RL has become a rapidly growing field within Artificial Intelligence (AI), but its scientific roots lie in Psychology (specifically the field of animal learning ) and Control Theory Sutton and Barto (2018). The former provided key concepts related to how animals learn by interacting with their environment, while the latter contributed important mathematical methods and formalisms. In many scenarios, such as video games, robotics, and autonomous driving, we encounter decisionmakers seeking specific goals within an environment governed by certain rules. To build agents capable of solving such problems, it is essential to formalize their habitat and develop methods that guide them towards long-term objectives without neglecting immediate necessities . RL addresses this by formalizing the concept of goal attainment through the abstract idea of signal maximization , characterizing RL as a hedonistic system. The purpose of these signals is to differentiate between various configurations of the environment to represent the higher-level, more abstract concept of a goal . The interaction between an agent seeking a goal in an environment , and adapting its strategy through interactions is a fundamental aspect of learning . This process, in the context of RL, is arguably more intuitive than in other Machine Learning (ML) approaches. The tension between the agent’s goal-seeking behavior and the environmental constraints mirrors natural learning processes observed in biological systems. 2.1 Markov Decision Processes In order to formalize a problem under an RL perspective, we need a mathematical framework able to capture not only the environment, agent and goal concepts, but also the dynamics that happen between them over time, and there is where the idea of Markov Decision Process (MDP) comes in. Most of the 4
MDP theory focus on a discrete time description of a system or, at least, of a system where the process of decision making by the agent occurs in discrete points in time [Puterman (2014)]. Nevertheless, the core ideas that an MDP captures can also be extended to the case in which the also called decision-epochs (time-steps) [Puterman (2014)] could be described by a continuum. Definition 2.1.1. Adiscrete-time Markov Chain (MC) is a tuple M= (S, p): •Sis a countable set of states. Stwill denote the state random variable at time t∈N. •p:S × S −→ [0,1] is the transition probability function that receives as arguments the states s′, s ∈ S and returns the probability of transitioning to the state s′given the current state s: p(s′, s) = P(St+1 =s′|St=s). In an MC it is assumed that each state has the Markov Property ( Markovian states), that captures the concept of the future being independent from the past, given the present. Formally, for all s, s′∈ S and t∈N: P(St+1|St=s, St−1=st−1, St−2=st−2, . . . , S0=s0) = p(s′, s) for every possible sequence st−1, st−2, . . . , s0∈ St. An MC can describe the evolution of an RL environment, but does not formalize the concepts of actions and goals in it. An MDP is an extension of an MC that adds this two concepts, and which results in the main mathematical framework behind RL theory. Definition 2.1.2. AMarkov Decision Process (MDP) is an MC with decisions ( i.e. , actions) and rewards M= (S,A, p, r, γ, ρ0)where: •Atis the set of available actions to be taken by the agent at time-step t∈N. For simplicity, it is usual to just write Aif the actions set is the same at every time-step. •p:S × A × S −→ [0,1] is the transition probability function , but also considering the decision . Receives as arguments a state s′∈ S, an action a∈ A and another state s∈ S, and returns the probability of taking the action afrom the state sand achieving the state s′. So, for all s, s′∈ S and a∈ A: p(s′a, s) = PSt=s′At−1=a, St−1=s. If the environment is completely deterministic, this function does not need the probability and can simply be defined as a function from states and actions to states p:S × A −→ S. 5
•r:S × A −→ Ris the reward function that indicates the expected reward after taking some action ain a state s: r(s, a) = ERt+1St=s, At=a. •γ∈[0,1] is the discount factor and determines how much future rewards should be taken into consideration by an agent. The lower the value, the more the agent tries to maximize immediate rewards. •ρ0:S −→ [0,1] is the initial state distribution, that determines the probability for each state to be the initial one. Similarly to St,Rtand Atdenote the reward and action random variables at time t, respectively. Definition 2.1.3 (Finite MDP).Given an MDP M= (S,A, p, r, γ), if Sand Aare finite and therefore ris a finite-valued function ,Mis called a finite MDP. In this case it usual to define the set of rewards R ⊂ Rthat is the codomain of r:S ×A −→ R. Given that ris finite-valued ,Ris a finite subset of R. Thus, the random variables Rt, Stand Atare all discrete random variables. Additionally, the transition probability function pcan be easily refined into a four argument function that also considers the rewards: p(s′, r|s, a) = P(St=s′, Rt=r|St−1=s, At−1=a). Remark: for the rest of the text, unless otherwise stated, when referring to an MDP or its underlying concepts will always be referring to a finite MDP. To define what learning actually means in RL it is useful to distinguish between two types of tasks that an MDP may formalize. On the one hand, a task may have a well defined ending that can be represented by a terminal state, if so, it is called an episodic or finite-horizon task, where the relevant set of terminal states is denoted by T ⊂ S. Alternatively, the task may not have a clear ending and could potentially go on forever, in which case it is named a continuing or infinite-horizon task. In the first case, given that the sequence will end after a finite number of time-steps, the goal is to maximize the sum of that sequence of rewards: Definition 2.1.4. The return (as cumulative undiscounted reward ) from time-step tdenoted Gtrepresents the sum of the sequence of rewards following the action Atand state St: Gt=Rt+1 +Rt+2 +Rt+3 +Rt+4 +· · · +RN, where Nis the last time-step. 6
Considering the definition 2.1.4 of return Gt, the weight of a particular reward Rk, k ∈ {t, t + 1, . . . , N}(given the action Ak−1) is ultimately determined by the sum, because it is always finite. With this formulation, every reward has the same “importance” in a given sequence. So, in an episodic task, in order to have a better long-term performance, an agent should aim to maximize the expected return ( i.e. , the average total reward over multiple episodes). In the infinite-horizon case some nuances arise. Given that the sequence of rewards can be infinite, the return can also be infinite. Thus, two clearly different infinite sequences of rewards could have exactly the same return. Example 2.1.1. Consider an infinite-horizon task that has two possible actions, say LEFT and RIGHT that always originate a reward Rleft = 1 and Rright = 2, respectively, this would originate the same return if worst action is considered (P∞ k=0 1) or the best action (P∞ k=0 2), since both sums diverge, resulting in a problem of action-reward importance characterization. s1s2 s3+1 +2 +2 +1 Figure 2: Infinite-horizon MDP example. This is where the discount factor referenced in the definition of a MDP comes in: Definition 2.1.5. The return (as total discounted reward ) from time-step tdenoted ˆ Gtrepresents the sum of the sequence of rewards following the action Atand state St: ˆ Gt=Rt+1 +γRt+2 +γ2Rt+2 +γ3Rt+2 +· · · = ∞ X k=0 γkRt+k+1. The undiscounted return for episodic tasks 2.1.4 is a particular case of the total discounted reward 2.1.5, where γ= 1, and the sum is finite1. The discount factor γdetermines how the rewards are taken into account, given their time-steps. If γ= 0 then ˆ Gt=Rt+1, meaning that the agent will only be concerned in choosing Atin order to exclusively maximize Rt+1 ( i.e. , immediate rewards). The greater the value of γthe more importance will be given to future rewards. If the exact same task from the example 2is considered, and γ=1 2, now the returns have finite and distinct values: ∞ X k=0 γk1!= 2 <4 = ∞ X k=0 γk2!. 1In Sutton and Barto (2018), it is discussed a unified notation for finite and infinite-horizon tasks, ( e.g. considering null rewards after the terminal time-step in an episodic task) 7
2.2 Policies and Value Functions An MDP gives the rules that model the dynamics between an agent and its environment, but actions alone do not capture this fundamental idea of behavior . In order to have a generic formalization that can represent any possible way of behaving within an MDP, it is used a mapping from states to actions, or a probability distribution over actions given states, which we call policy. Definition 2.2.1 (Deterministic Policy).A deterministic policy π:S × N−→ A is a function that maps states and time-steps to actions. So, π(s, t)defines the action At, for a given time-step tand a state s∈ S. For short, it is useful to write πt(s). This first definition of policy only depends on a state and a time-step to determine completely deterministically the actions of an agent, but it is also useful to consider a stochastic way of behaving 2.2.2. Definition 2.2.2 (Stochastic Policy).A stochastic policy π:S × A × N−→ [0,1] is a function that determines a probability distribution over actions, given states for certain time-steps. So, π(a, s, t)define the probability of choosing the action a, for a given time-step tand given the state s∈ S, for a more intuitive probabilistic notation it is common to write: πt(a|s) = P(At=a|St=s). While this two previous policy definitions are useful in many scenarios, they often depend on the specific time-step t, making them time-variant. However, in many practical applications, it is beneficial to consider policies that do not change over time. These are known as stationary policies . In fact the goal within RL is to find very specific stationary policies, as we will see later. Definition 2.2.3 (Stationary policy).Given any possible state s∈ S and a deterministic policy π, if it is true that, for a given state s∈ S,πt(s)returns the same action for every possible time-step t∈N, we call πa stationary deterministic policy . Analogously, given any possible state s∈ S, any possible action a∈ A and a stochastic policy πif we observe that πt(a|s)returns the same probability for every possible time-step t∈N, we call πa stationary stochastic policy . This class of policies, represent an agent that behaves same way in a given state, regardless of the time-step. In the deterministic case, “behaving the same way”, means the same action in the same state, and in the stochastic case means sampling action from the same probability distribution for a given state, regardless of the time-step. 8
Given that the goal of an agent is to maximize the expected return E[ˆ Gt]it is interesting to analyze this concept. By the linearity of expectation property: E[ˆ Gt] = ∞ X k=0 γkE[Rt+k+1], where each individual expectation operator (inside the sum) is by definition: E[Rt+k+1] = X r∈R r·pR(r), where pRis the probability mass function of Rt+k+1: pR(r) = P(Rt+k+1 =r). The problem here is that pRis not known, because in the context of an MDP (as the reward function suggests) the expected value of a reward Rtdepends on the action At−1and state St−1: r(s, a) = E[Rt|St−1=s, At−1=a] =X r∈R rX s′∈S P(St=s′, Rt=r|St−1=s, At−1=a) =X r∈R rX s′∈S p(s′, r|s, a). This second equality is possible because by definition of the transition probability function p, the probability of the next state s′and reward rare jointly determined given the previous action aand state s. So, to study expected future rewards, we must also know which actions will be chosen in the future. Since a policy πdetermines how actions are chosen, it is useful to study E[Gt], given that the sequence of rewards is conditioned by π, meaning that new states and rewards are conditioned by previous states and actions “chosen” by π. This is the idea behind the so called value functions. Definition 2.2.4. Given a policy πand an arbitrary state s∈ S, a state-value function vπ(s)is defined as vπ(s) = Eπ[Gt|St=s]. The subscript in Eπand vπmeans that the decision-making, starting from s, needed to yield Gt, is determined by π. When the context is explicit, the usage of this subscripts is often neglected. A similar function, but also considering an initial action can also be defined: Definition 2.2.5. The action-value function qπ(s, a)represents the expected return when starting from state s∈ S, taking action a∈ A and following policy πafterwards: qπ(s, a) = Eπ[Gt|St=s, At=a]. 9
Both this functions conceptualize one of the most important notions in MDP and RL theory, which is the problem of forecasting the Gt(the expected return) when following a particular policy π, also known as the prediction problem. Since a policy represents a particular behavior, solving the prediction problem is determining “how good” an arbitrary state is, by predicting how much total reward is expected if the an agent follows that behavior ( i.e. , policy). The value functions are closely related, and their definitions can be written in terms of each other: vπ(s) = E[Gt|St=s] =X a∈A π(a|s)·E[Gt|St=s, At=a] =X a∈A π(a|s)·qπ(s, a) and qπfrom vπ: qπ(s, a) = E[Gt|St=s, At=a] =E[Rt+1 +γGt+1|St=s, At=a] =E[Rt+1|St=s, At=a] + E[γGt+1] ="X s′∈S X r∈R p(s′, r|s, a)·r#+E[γGt+1] ="X s′∈S X r∈R p(s′, r|s, a)·r#+X s′∈S X r∈R p(s′, r|s, a)·E[γGt+1|St+1 =s′] =X s′∈S X r∈R p(s′, r|s, a)·"r+E[γGt+1|St+1 =s′]# =X s′∈S X r∈R p(s′, r|s, a)·"r+γvπ(s′)#. (2.1) If we observe the third equality, the conditions in the expectation were removed because the reward Rt+2 only depends on the state and actions at time t+1 ( Markov Property ). Given that the four-argument probability transition function pcompletely determines the probabilities of next reward rand state s′, given previous state sand action a: X r∈R X s′∈S p(s′, r|s, a) = 1, the expectation can be conditioned E[γGt+1](from third equality) over the possibilities of St+1 (in the fourth equality). Finally, in the second equality, was introduced a recursion, that can be observed by 10
expanding the definition of discounted return Gt Gt=Rt+1 +γRt+2 +γ2Rt+3 +γ3Rt+4 +· · · =Rt+1 +γ(Rt+2 +γRt+3 +γ2Rt+4 +· · · ) =Rt+1 +γGt+1. (2.2) Since vand qcan be defined in terms of each other, it also becomes clear that a recursion must arise within their definitions. So, given a policy π: vπ(s) = X a∈A π(a|s)·qπ(s, a) =X a∈A π(a|s)·"X s′∈S X r∈R p(s′, r|s, a)·r+γvπ(s′)#. (2.3) This equality is the well known Bellman Equation for vπnamed after Richard Bellman [Bellman (1957)], and it relates the value of a given state and the values of states to be visited afterwards. The Bellman Equation for qπcan also be derived from the previous equality: qπ(s, a) = X s′∈S X r∈R p(s′, r|s, a)·"r+γvπ(s′)# =X s′∈S X r∈R p(s′, r|s, a)·"r+γX a′∈A π(a′|s′)·qπ(s′, a′)#. (2.4) Bellman equations underlie most RL algorithms used to solve the prediction problem , as will be seen in the next chapter, by acting as the core of the update rules used. This fundamental approach not only aids in predicting future rewards but also sets the stage for discussing the concept of optimality, which will be explored in the following section. 2.3 Optimality Given that the goal of an agent is to maximize the rewards, and that vand qvalue functions determine the expected return, we can define quality relationships between policies. Given two policies π1and π2, under a finite MDP, if vπ1(s)≥vπ2(s),∀s∈ S, then the policy π1leads to a greater or equal expected return then π2, therefore it must lead to a better (or as good as) performance then π2. However, it can also be the case that one policy can be considered neither better nor worse than another in general terms, for instance, when one policy yields better returns 11
The vector Vπis a fixed-point (3.1) for Bπ, which is the target of the Policy Evaluation algorithm, that arises as an iterative approach to solve for larger state spaces. The idea is to start with a vector arbitrarily initialized V0and iteratively updating it by applying the Bellman operator Vk+1 =Bπ(Vk). This process is guaranteed to converge to Vπ, as the number of updates approaches infinity. With a process to determine a value function for a policy, the question to ask is whether or not it is improvable, or in other words, if is there a way to tweak it in order to achieve “better” state-values . Given a deterministic stationary policy π, the idea of Policy Improvement is to update πby choosing actions that yield better (or as good as) state-action values than the previously evaluated . Theorem 3.1.1 (Policy Improvement). Let π be an arbitrary stationary policy under a finite MDP and let π+ be a deterministic policy defined as π+(s) = arg max a∈A X s′∈S X r∈R p(s′, r|s, a)·[r+γvπ(s′)] for every s∈ S (3.4) with ties broken arbitrarily. It is guaranteed that Vπ+≥Vπ, where Vπ+ and Vπ denotes the vectors with the values associated to each state, for each policy. Corollary 3.1.1. Given a deterministic stationary policy π , if for every state s there is no action that yields a better state-action value than the action π(s) , then π must be optimal. Corollary 3.1.2. Policy improvement yields a better policy if and only if the policy to be improved is not yet optimal. These Policy Improvement formalisms give a pretty straightforward update rule for a policy, when its value function is known. Both Policy evaluation and Policy improvement may be applied interchangeably, where improvement steps create a new target (new policy π+) for evaluation, unless optimality is achieved, such algorithm is called Policy Iteration and it is guaranteed to converge in finite MDPs, within a finite number of steps. One question that naturally arises is that of computational complexity growth implied by larger state spaces, given that the evaluation step require full weeps trough those states until the fixed point is reached (or a predefined estimation error). To address this problem there is the idea of Value Iteration , that substitutes complete policy evaluation steps by partial steps, where the fixed-point does not need to be reached. While looping trough each state, this procedure just updates its value by applying the 18
Bellman Policy Operator one time ( i.e. , single policy evaluation step), and performing policy improvement thereafter, until a optimal policy is achieved (or an error estimation stopping condition). Value Iteration is also guaranteed to converge under the same conditions. 3.2 Model-Free Prediction Dynamic programming methods assume the strong condition of having full knowledge of the environment, which is seldom the case in real-world problems. In this section the prediction problem will be addressed by dropping such assumption, where several algorithms from two important families of methods will be presented. Firstly, we will see how Monte Carlo methods can be used to find state-values for episodic environments by calculating full returns, and lastly how temporal difference learning can be used to solve either episodic or continuing tasks by doing online updates that bootstrap on previous value estimates. 3.2.1 Monte Carlo prediction The Monte Carlo (MC) approaches to solve both prediction and control problems are connected with the idea of sampling environment transitions. This methods clearly obey the condition of not requiring the total or partial knowledge of the transition probability function of the MDP. The core idea is precisely calculating the Returns for a given sample, and averaging over several of them. Going deeper in the concept of sampling environment transitions, and keeping the assumption that the transition probability function may be unknown, the finiteness (in practice) of this process impose a limitation in calculating discounted returns between samples due to discontinuity. Given this, becomes clear that in a general way, this sampling techniques are naturally only suitable for episodic tasks, and naturally each sample is an episode. To solve the prediction problem, for a given state s, it is necessary to find the expected return following π, starting from s. If many episodes are sampled (following π), by considering the episodes where s occurs, and calculating, for each of them, the actual received (discounted or not) return after that first occurrence, we can calculate an empirical mean of the return following π, starting from s. Since each episode is independent, so is each sample return; Since a stationary policy πis being followed (after s), each sample return is identically distributed. Once guaranteed these two conditions, by the law of the large numbers , the sample average of the return (starting from s) converges to its expected value, as the number of samples/episodes goes to infinity. By doing this to every state s∈ S, we can calculate estimations of vπ. 19
This first-visit idea has some clear limitations and assumptions needed to work. Firstly, always keeping track of previous sample returns, is not suitable for the majority of real problems (memory and compute wise), but that’s easily solvable with incremental updates. Let’s say vπ,N (s)(vNfor simplicity) is an estimation of vπ(s)with Nsamples, and Gi(s)(Gifor simplicity) is the sample return for a given state sin the i-th episode, where Gi(s) = 0 if sis not visited in the i-th episode: vN=1 N· N X i=1 Gi =1 NGN+ N−1 X i=1 Gi =1 N·GN+ (N−1) ·vN−1 =1 N·GN+vN−1−1 N·vN−1 =vN−1+1 N·GN−vN−1. The recursive formulation that arose from the derivation 3.2.1 allows the calculation of the average to be made episode by episode without the need to store every single sample return, leading to the First-visit Monte Carlo incremental algorithm 1. Algorithm 1 First-visit incremental MC Require: A policy π V(s)←random x∈R, for all s∈ S C(s)←0, for all s∈ S while True do E←[S0, A0, R1, S1, A1, . . . , ST−1, AT−1, RT]generate episode following π G←0 for t←T−1to 0do G←G+Rt+1 if St/∈[S0, S1, . . . , ST−1]then C(St)←C(St)+1 V(St)←V(St) + 1 C(St)G−V(St) end if end for end while Another well-known similar algorithm is the every-visit MC . The major difference is that the average cal- 20
culation includes every occurrence of a state within each episode. The problem with both these algorithms (which usually becomes clear in the latter case) is the limitation to deal with non-stationary settings, where some earlier estimations may become “outdated” and some bias is introduced. This is often the reality in RL because the process of finding the optimal policy is associated with iteratively changing a policy and therefore having a non-stationary behavior in the learning process, as will be clarified in the next section. The update rule V(St)←V(St) + 1 C(St)G−V(St), does not have the ability to “forget” (at some degree) or to give different importance to previous estimations, since it attributes the same weight to each of them. In a non-stationary setting, past rewards should be taken less into consideration ( i.e. , a smaller weight). If instead of calculating the usual incremental mean, one changes the term 1 C(St)by a constant step-size α∈]0,1], it results in a weighted average, where the closer αis to 1, the less past rewards will be taken into account: V(St)←V(St) + α·G−V(St),(3.5) which is the value function estimation update for constantα Every-Visit MC algorithm. The algorithms Algorithm 2 constant-αEvery-Visit MC. Require: A policy πand a constant α∈]0,1] V(s)←random x∈R, for all s∈ S C(s)←0, for all s∈ S while True do E←[S0, A0, R1, S1, A1, . . . , ST−1, AT−1, RT]generate episode following π G←0 for t←T−1to 0do G←G+Rt+1 C(St)←C(St)+1 V(St)←V(St) + α·G−V(St) end for end while from this class of methods require complete transition sequences to properly calculate the Returns, and despite this prerequisite, they still need to wait for an episode to finish to calculate the Return. The next section will cover a major class of RL methods that break this need. 21
3.2.2 Temporal-Difference prediction Observing the value function estimation update for Every-Visit MC, the return Gtacts as a target for the update rule, meaning that at each update adjusts the value V(St)estimation towards the proper return obtained, by adding the error term G−V(St)(subtracting the previous estimation to the Return) by a factor of the given step-size α.Temporal Difference (TD) Learning removes the necessity of waiting for the proper return, replacing the target Gtby an estimation that takes advantage of the recursive property of the Bellman equation V(St)←V(St) + α·hRt+1 +γV (St+1)−V(St)i,(3.6) where Rt+1 +γV (St+1)is called TD target and the whole subtraction term is called TD Error. It is easy to see that to perform this update one only needs the immediate reward Rt+1 received after taking an action at state Stand a previous estimation for the value of the achieved state St+1, enabling what is called online learning , meaning that the process of learning (in this case learning vπ) occurs immediately when new information is received ( i.e. , States and Rewards) , which by one hand is like MC because there is no knowledge of the MDP and on the other is like DP since previous value estimations are immediately updated once a given state is reached. Algorithm 3 One-Step TD Learning Require: A policy πand a constant α∈]0,1] V(s)←random x∈R, for all s∈ S+ V(s)←0, for all s∈ T while True do Observe initial S while S/∈ T do Choose action Afollowing π Receive reward Rand observe new state S′, after taking A V(S)←V(S) + α·hR+γV (S′)−V(St)i S←S′ end while end while 22
3.3 Model-Free Control The previous section was about estimating the expected returns when following a specific policy , but the ultimate goal of solving an MDP is to find the best way to behave in every situation. Essentially, solving the control problem is the same as finding π∗,v∗or q∗. In Model-free control, where the the existence of a model is not assumed, the techniques applied in the methods previously covered will be used to direct behavior towards optimality, always by sampling experience. 3.3.1 Monte Carlo Control Recalling the Policy Iteration from DP , one natural question to ask is if it is possible to simply replace Policy Evaluation steps by First-Visit MC for example. There are two related issues with this straightforward implementation: one is about exploration and the other about Model knowledge . DP sweeps the whole state space and uses the knowledge of the transition function to perform updates, but in MC case there is no guarantee that every state will be explored, since the updates are experience oriented. The second one is the need of knowledge of the Transition Probability function to apply the improvement step, which is a neglected assumption when going Model-Free . One easy way to overcome this latter problem is by simply making a policy greedy with respect to its state-action values, for every s∈ S, π+(s) = arg max a∈A X s′∈S X r∈R p(s′, r|s, a)·[r+γvπ(s′)] =arg max a∈A qπ(s, a), (3.7) allowing the policy improvement step to be Model-Free , since is over qπ. But this change implies that qπis known, which is easily achievable by doing MC prediction over qπinstead of over vπ. The first problem of exploration is also affected by the improvement step. Since the policy is becoming greedy, the trajectories are being limited possibly resulting in non-explored states. One simple idea to continue exploring is ϵ -greedy exploration . Definition 3.3.1 (ϵ-Greedy Policy).Let πbe a stationary policy, a small ϵ∈]0,1[ and qπbe the stateaction value function for π.πϵis a stochastic stationary policy defined as πϵ(a|s) = ϵ |S| + 1 −ϵif a∈Wπ s, ϵ |S| otherwise, (3.8) where Wπ s=arg maxaqπ(s, a). 23
Theorem 3.3.1 (ϵ-Greedy improvement). Let π be ϵ -Greedy policy under a finite MDP and let πϵ its ϵ -Greedy Policy, for any given ϵ∈]0,1[ , it is guaranteed that Vπϵ≥Vπ, where Vπϵ and Vπ denotes the vectors with the values associated to each state, for each policy. The definition of such policy allows to build a Model-Free algorithm that guarantees that in the limit (when the number of iterations approaches infinity) every state value will continue to be evaluated and improved. This framework abstracted from DP Policy Iteration earned the name of Generalized Policy Iteration (GPI) . A classic GPI algorithm for MC Control is On-policy first-visit MC control, in which the Algorithm 4 On-policy first-visit MC control Require: Aϵ-greedy policy π Q(s, a)←random x∈R, for all s∈ S and a∈ A C(s, a)←0, for all s∈ S while True do E←[S0, A0, R1, S1, A1, . . . , ST−1, AT−1, RT]generate episode following π G←0 for t←T−1to 0do G←G+Rt+1 if St, At/∈Ethen C(St)←C(St)+1 Q(St, At)←Q(St, At) + 1 C(St)G−Q(St, At) for a∈ A do π(St|a)←πϵ(St|a) end for end if end for end while updated improved policy at each step directs the experience to be made in the successor step. 3.3.2 Temporal-Difference Control To build a TD control algorithm the natural idea is to implement the same concepts seen in MC control but with TD techniques. This allows the learning process to be made online since there is no need to collect 24
complete transition sequences, which also allows to solve for infinite-horizon tasks by continual learning. Like in One-Step TD for Prediction, the updates can be done immediately when new information is available, but this time aiming for state-action values. A simple idea is to start with such pair St, At, sample an environment transition, receiving a reward Rt+1 and ending up in a new state St+1, and finally taking an action in that state At+1 (following a given ϵ-Greedy policy). This sequence (St, At, Rt+1, St+1, At+1) gave the name to the SARSA algorithm. Algorithm 5 SARSA (On-policy) Require: An ϵ-greedy policy π,α∈]0,1] Q(s, a)←random x∈R, for all s∈ S+and a∈ A Q(s, a)←0, for all s∈ T and a∈ A while True do Sample initial state S A∼π(S) while S/∈ T do Take Aand observe R, S′ A′∼π(S′) Q(S, A)←Q(S, A) + α·[R+γQ(S′, A′)−Q(S, A)] S←S′ A←A′ end while end while SARSA is an On-Policy learning algorithm, where the policy is being implicitly improved by Qupdates and at each time-step the same policy that is evaluated is also used to sample experience. Another key RL idea is the Q-learning algorithm [Watkins (1989)], which is an off-policy method where the previous target R+γQ(S′, A′)is not sampled from the same policy which led to the state S′, but rather by a greedy policy with regard to the previous Qestimation. This allows for a method using one behavior ϵ-Greedy policy (responsible for generating single transitions) and an implicit target greedy policy, which should converge to the optimal one. Both of them improve, since both depend on the Q estimation that should converge to q∗. 25
Algorithm 6 Q-learning (Off-policy) Require: α∈]0,1] Q(s, a)←random x∈R, for all s∈ S+and a∈ A Q(s, a)←0, for all s∈ T and a∈ A while True do Sample initial state S while S/∈ T do choose Aaccording to ϵ-greedy exploration Take Aand observe R, S′ Q(S, A)←Q(S, A) + α·[R+γmax a∈A Q(S′, a)−Q(S, A)] S←S′ end while end while An interesting problem that can arise in TD algorithms is the maximization bias . Since these methods rely on maximizing over the state-action value space, in order to sample actions and compute the update target, but during learning the values can be overestimated comparing to ground-truth values, and causing a positive bias [Sutton and Barto (2018)]. This is especially common in Q-learning , because it maximizes the values of visited states over actions, at each time-step , in order to perform its update rule, and stochastically in the behavior policy. Maximization bias can happen because of the way the table used to store value estimations was initialized before training, or simply by MDP dynamics chance ( e.g. if a negative-valued state occasionally yields positive rewards), which is a practical problem since it can delay convergence. One way of tackling this problem is the idea of double learning. The two given examples of Off-policy and On-policy algorithms have a subtle difference that at first glance may not seem very relevant, but which has a lot of theoretical, philosophical and practical importance. 3.4 Model-Free Training Metrics Despite the theoretical convergence guarantees of the presented algorithms, in practice, due to limited computational resources and a finite amount of time, there is a need for metrics that quantify and qualify the training performance. Given that the nature of an RL problem may vary a lot, it is useful to have a generic framework of metrics suitable for every environment and Model-Free tabular approach. The 26
metrics that will be presented are appropriate for both continuous and episodic tasks, even though some of them are more natural for the latter case, they can be easily adaptable by simply considering a sliding window of steps, instead of a well-defined episode. The most trivial performance metric for RL is precisely the fundamental quantity an agent should maximize: the return Gt. Regardless of the environment, the sum or the mean of the accumulated rewards (discounted or undiscounted) during training should be maximized over time. Naturally, following the return, it is obviously a need to observe the state-action value function evolution. Analyzing and understanding the value function convergence is not straightforward, given that the learning process is a dynamic combination of policy evaluation and policy improvement steps (in a broader sense), and the evolution of the state values is not typically monotonic in function of the learning time-steps, meaning that observing a trajectory with low reward peaks is not only natural but sometimes may result in a better exploration. This non-trivial dynamics between exploration and exploitation is a core problem in practical Model-Free RL. Definition 3.4.1 (Training sequence).Given an MDP M= (S,A, p, r, γ), a sequence of state-action pairs visited during a training sequence is defined as τ=(st, at)T t=1 . In the case s⊤∈ T or if the training sequence ends in a state, then a⊤=ϵrepresenting an action not already defined. |τ|=Tis notation for the length of the sequence. Definition 3.4.2 (Sequence of Q’s).Given a training sequence τ, the sequence of q∗approximations estimated through τis defined as τQ= (Q1, Q2, . . . , Q|τ|), where each Qtis a complete point-to-point tabular representation. Qt(s)∈R|A| is a vector of action-values approximations for the state sand Qt(s, a)∈Ris the specific approximation in that state for action a. 3.4.1 Exploration Although qualitative metrics could measure and verify an increase in performance during training ( e.g. increasing in total reward), this does necessarily imply a good exploration or a reliable-enough exploration for specific tasks. Therefore, measuring the exploration level of an agent in a direct quantitative way is often more trustworthy. The simplest approach to do this is by counting visits to a subset of the state space, to individual states or, even more exhaustive, to state-action pairs. Definition 3.4.3 (State visits counter).Given a training sequence τ, let S′⊂ S be a nonempty subset of the state space S.S′(τ)is the sub-sequence of pairs from τwhose states belong to S′. The counter for the number of times each state from S′was visited is simply |S′(τ)|. 27
4.2 Intermediate Model The intermediate Model is similar to the first in terms of dynamics of the system. It is still deterministic, but includes the possibility of changing the car’s speed. This means that the agent should be able to accelerate and decelerate, but the environment should also be able to handle these new types of transitions. For this changes to be taken into account, the state space should also include a new variable of speed, so that the transitions between states could be calculated correctly and the maximum and minimum speed properly defined. The car’s speed can be increased or decreased by one square, with a minimum of 1 per time-step and a maximum of 3 per time-step . Definition 4.2.1 (Intermediate Model — State Space).Let S+be the set of non-terminal states, Sbe the whole state space, and T ⊂ S is the set of terminal states. S=ZN×ZN×Z3 T={(x, y, v)∈ S | Tx,y = 3} S+=S/T The action space has just a simple new component that considers accelerating, braking or maintaining the same speed. Definition 4.2.2 (Intermediate Model — Action Space).The action space Ais defined as the product: A=n0,π 4, . . . , 7π 4o× {−1,0,1} Lastly, the formulation of the transition function is pretty similar, but now also considers transitions to squares that are not adjacent depending on the agent’s speed. The only relevant exception is that whenever the agent’s speed is not at a minimum, the previous formulation could allow it to pass through the wall, so this must be handled by verifying if there is no wall square along its trajectory, which is equivalent to verifying if there was any smaller initial velocity that would lead to a wall square (collision), and if so, the car’s new position in the grid is the closest non-wall square in that trajectory. Definition 4.2.3 (Intermediate Model — Transition Function).The transitions between states are described by the the function p:S+× A −→ S: p(s, a) = x, y, vif ∃v′< v :mv(x, y, v′), o, 0= (i, j, v′)∧Ti,j = 4, x, y, v′if x′, y′≥Nor x′, y′<0, x′, y′, v′otherwise, 34
with s= (x, y, v),a= (o, m), where mv is the movement function defined as mv(s, o, m) = x′=x+v′·round(cos o), y′=y+v′·round(sin o), and the new speed v′= vif m= 0, min(v+ 1,3) if m= 1, max(v−1,1) if m=−1. 4.3 Stochastic Environment Model The stochastic model is a non-deterministic version of the previous model, that allows for the existence of iced squares . If the car reaches such squares, the environment, instead of moving deterministically, will update the car’s position according to a probability distribution over states and actions. The state-space set has no changes, apart from the matrix that represents a specific map, and must also represent the iced squares . Definition 4.3.1 (Stochastic State Space).Let S+be the set of non-terminal states, Sis the whole state space, T ⊂ S is the set of terminal states S=ZN×ZN×Z3, T=(x, y, s)∈ S | Tx,y = 3, S+=S \ T , where Tis the N×Nmatrix where each entry Ti,j ∈ {0,1,2,3,4}represents the nature of each square, that is, Ti,j = 2if (i, j)is the initial square, 0if (i, j)is in-track, 1if (i, j)is off-track, 3if (i, j)is a terminal square, 4if (i, j)is a wall, 5if (i, j)is an iced square, for every (i, j)∈ZN×ZN. 35
With regard to system dynamics, whenever the agent is in an iced square and chooses an action, only one out of four times the new orientation of the car will be the chosen one, on the other hand, the new orientation will be a random sample from an uniform distribution over orientations. The new transition function defines a conditional probability distribution of new states given previous state and action. In the case the previous state is non-iced , the function simply maps to 1if the new state is the same as obtained deterministically and 0 otherwise. When the given previous state represents an iced square , then the function maps to 1 4if the new state is the same as obtained deterministically; it maps to 3 4·7if the new state is the same as obtained deterministically but considering an action with any other possible rotation (7possibilities) and same speed as the given; it maps to zero 0otherwise. Definition 4.3.2 (Probabilistic Transition Function).The transitions between states are described by the the function p:S × S+× A −→ [0,1]: p(s′|s, a) = 1 2if Tx,y = 4, s′=t(s, a) 1 14 if Tx,y = 4, s′=t(s, a′), a′ 1=a1, a′ 2=a2, 1if s′=t(s, a), 0otherwise, with a= (a1, a2)and a′= (a′ 1, a′ 2). The first two transition functions can be seen as a special case of this probabilistic one, where the codomain is the set {0,1} ⊂ [0,1]. It is also crucial to note that every transition function operates deterministically, always producing the same output from the same input. This is distinct from the game dynamics being deterministic; in this last case, they are not. 4.4 Asymptotic comparison with DP As a first benchmark, one can measure how complex is to solve an instance of the simple MDP model. To do so, We have used Value Iteration as a reference of number of iterations needed to reach the optimal policy and compare it to the classical TD algorithms, by considering simple MDPs with just in-track squares, and an increasing number of states |S| ∈ {52,102,152,202, . . . , 802}. The initial and terminal states are the first and last elements of the main diagonal 6. Example 4.4.1 (Void track example).The matrix 2was the smallest used to test the simple MDP. The other maps used follow the same structures but for larger matrix dimensions. 36
00003 00000 00000 00000 20000 Table 2: Void map matrix. Figure 4: Void map example. The Figure 5reflects the results of running Q-Learning,Double Q-Learning and SARSA against Value Iteration, without any fine-tuning, using the fixed set of parameters γ= 0.99, ϵ= 0.25, α= 0.9, and a simple reward function that only attains the main goal of reaching the terminal state in the least number of frames possible, that is −1reward per time-step: r(s, a) = −1∀s, a ∈ S × A. The episode maximum length was set to N·50 time-steps. Meaning that episode termination, in practice, is imposed either by that threshold or by reaching the terminal state. The VI algorithm was run until the fixed point was reached ( i.e. , when the optimal policy was found) and the TD algorithms used that optimal policy as a reference for halting. Given an optimal return starting from the initial state G∗and the return Gyielded by the greedy policy associated with a q∗estimation, the stopping criteria was: G∗ G≥85%, where at each 20 episodes each tabular estimation was evaluated using the greedy policy, and stopped if such condition was true. To ensure a robust analysis, each TD algorithm ran with three different seeds. The tabular value estimations of all four methods were initialized to zero. Another interesting analysis that can be done is regarding variation in wall/track ratio. Given a fixed map size, in this study’s case N= 40, the amount of track squares can be iteratively increased, to 37
Figure 5: Scaling state space analysis. observe how each algorithm behaves. Keeping the same initial and terminal states, the idea is to increase the width of the initial path (main diagonal), by replacing wall squares by in-track squares: for each main diagonal element at position (x, y)of the matrix, the elements at position (x+i, y)k i=0 and (x, y +i)k i=0 were replaced by in-track squares ( i.e. , value 0) for each k∈ {0,4,8, . . . , 40}. In the figure 6are the examples of the first three path widths tested. Figure 6: Observable space growth. Since wall squares are not reachable in the game, it makes sense to tweak the Dynamic Programming 38
VI in order to ignore value estimations starting from those states, and therefore reducing computational effort. The main idea behind this second benchmark was to study how exploration behaves against brute force calculation of Dynamic Programming, with respect to the “shrinking” of observable space. Figure 7: Observable state space scaling analysis. In the first MDP, Q-learning and SARSA were able to achieve close to optimal policies in fewer iterations then Value Iteration , but for the scale of the studies, Dynamic Programming was still usable and probably a better approach, assuming that it was guaranteed to yield the optimal policy. The paradigm changes in the intermediate level MDP, that by adding one more component to the state vector, has a clear computational impact. The exact same initial test was made, but this time for the second level MDP with the speed component 8. In tests conducted on maps of size 40 by 40 or larger, every TD algorithm tested, for each different seed, consistently required fewer iterations to achieve the optimal halting condition compared to VI. This indicates that TD algorithms are more efficient and scalable in handling larger state spaces, proving to be computationally more tractable than VI in expansive and complex environments of this game instance. As an important remark, in the non deterministic environment, this computational effort would get worse, because of the extra cost of computing transition probabilities of iced squares. So, in the next 39
Figure 8: Scaling state space size analysis. section only TD methods will be used to solve intermediate and complex game environment instances. 4.5 Solving level 2 and level 3 MDPs The initial studies were made without any fine-tuning of parameters. To solve complex environments, it is essential to find a set of parameters that performs well. To achieve this, each TD algorithm was tested with three different seeds on two 30 by 30 maps: one level 2 and the other level 3 (Figure 9). First, the αparameter was evaluated for one million time-steps with α∈ {0.1,0.3,0.5,0.7,0.9}, and using a linearly decaying ϵ-greedy with initial ϵ= 0.6. Using the best performing parameters, another study was carried out for 3 intermediate maps 11 for 1 Million time-steps each. The metrics defined in the previous chapter were used to evaluate performance. During training, at each time-step, the value estimates and state entropy were recorded, and episodically, the total episode return G, the number of episode steps ,the global entropy of the matrix and the values evolution variance were the metrics used. 40
Figure 9: Fine-tuning level 2 and level 3 maps. Figure 10: Fine-tuning step-size analysis. The metrics’ values were averaged over windows of size 2000, in order to have smoother plot lines. The tabular representations were initialized with pseudo-random values sampled from a normal distribution Q∼ N(0,1), and since rewards are only negative, so are the non-terminal state values, which results in a training period were the value estimations only decrease. The Q-learning algorithm was able to reach 41
Figure 11: Level 2 maps used for training and testing. Figure 12: Level 2 maps — step metrics. lower value estimations, but then finding a plateau. It is possible to see an interesting symmetry between the entropy and the value estimations, more clear in the final plateau region of Q-learning , that reflects the fact that when the optimal policy estimation is getting closer to greedy ( i.e. , the softmax of any state vector estimation is 0-valued for every action except for one.), the value estimations for the same state converge to the same (optimal) value. It seems that the same patterns still arise for SARSA and Double Q-learning , but the convergence was slower. For episode metrics, it was used a moving average window of size 5, and since the training halting criteria was the number of time-steps, the number of episodes for each run was different, even for the same algorithm with a different random seed. Plot lines with less values (Double Q-learning in every run) mean that the training episodes were longer, which does not necessarily mean worst policies after training. For example, in the third map, while epsilon values were higher and therefore action-selection more random, Double Q-learning early training episodes were indeed longer then the other two methods, but it was still 42
Figure 13: Level 2 maps — episode metrics. able to yield better returns at the end of the training, even in overall fewer episodes. Double Q also had much more variance until later training stages which also made the episodes longer on average. Since the reward is R=−1for every step, the return is symmetric to the number of episode steps. Figure 14: Level 3 maps used for training and testing. To evaluate the level 3 environment, were used two 40 ×40 maps and one 81 ×81 map (14). Once again, a 2000-step moving average window was used. The algorithms ran for 4 million steps in the first 2 maps, and 10 million in the last. This time, none of the three algorithms were able to reach a plateau for value estimation. Every curve shows that the methods probably needed a few more iteration to properly estimate optimal values. The range of entropy values is small, which also might have happened because of low exploitation period, 43
Algorithm 7 Sierpinski Carpet procedural track generator 1: function SierpinskiCarpet(k) 2: if k= 0 then 3: return h5i▷Base case: single cell filled with 5 4: end if 5: Initialize carpet of size 3k×3kwith zeros 6: prevCarpet ←SierpinskiCarpet(k−1) 7: for each position (i, j)except the center (1,1) in a 3×3grid do 8: Copy prevCarpet into carpet at (i·3k−1, j ·3k−1) 9: end for 10: for all cells (x, y)in carpet where carpet[x, y] = 0 and xis odd do 11: Set carpet[x, y]←4▷Modify odd-indexed rows within empty cells 12: end for 13: return carpet 14: end function distance of no more than two states, ensuring that a path between initial state and final state always exists. In many cases in-track states are “islands” in the middle of iced-states, but if the agent ensures a proper acceleration, it can reach another in-track states without being affected by the stochasticity of the ice, which is similar to jumping between in-track squares. 5.2.2 BFS generation The previous algorithm ensures a way of creating maps of different widths, but procedural generation typically addresses the goal of generating different game tasks for a specific screen resolution, and therefore a well defined state-space size, in the RL context. So, in order to generate different maps to evaluate RL generalization, we came up with the idea of using the classical Breadth-first search (BFS) algorithm to connect pseudo-randomly generated points to build paths. Given a square matrix with an arbitrary order n∈Nand all entries with value 4 ( i.e. , a wall square), the idea is to choose distinct submatrices, and then pick a single entry in each one of those submatrices, and finally connect the entries using BFS, as well as with an initial and final state, therefore ensuring a valid path. The algorithm 8is a simple implementation of the previously described procedure, where one initial state and one terminal state are created in the same matrix positions for a given input N(bottom left 50
(a) Order 2: 9×9matrix. (b) Order 3: 27 ×27 matrix. (c) Order 4: 81 ×81 matrix. (d) Order 5: 243 ×243 matrix. Figure 18: Sierpinski maps. and bottom right respectively), after that, 4 pseudo-random matrix entries are generated in 4 different submatrices. The position of the submatrices is important to create non-overlapping and simple paths, where in algorithm 8, the submatrices were chosen following the structure from figure 19. Finally the random points are connected with BFS, following the suggested order also from Figure 19, which results in inverse “U” shaped paths. This algorithm generates maps with a fixed initial and terminal state, and a single path with a width of one square between them. Even for such simple configuration, the number of unique maps scales 51
Algorithm 8 Path Generation in an N×NMatrix 1: function GeneratePaths(N) 2: map ←Nby Nmatrix filled with 4’s ▷Map only with wall squares. 3: start ←(N−2,1) ▷Initial point at bottom left. 4: end ←(N−1, N −1) ▷Terminal point at bottom right. 5: p1∼U{(x, y)|x≤N 2, y ≥N 2,0≤x, y < N}▷Bottom left submatrix. 6: p2∼U{(x, y)|x≤N 2, y ≤N 2,0≤x, y < N}▷Top left submatrix. 7: p3∼U{(x, y)|x≥N 2, y ≤N 2,0≤x, y < N}▷Top right submatrix. 8: p4∼U{(x, y)|x≥N 2, y ≥N 2,0≤x, y < N}▷Bottom right submatrix. 9: map[p1],map[p2],map[p3],map[p4]←0▷Mark chosen points. 10: paths ←[BFS(start, p1),BFS(p1, p2), ..., BFS(p4,end)] ▷Generate BFS paths. 11: for pathhin paths do 12: for (x, y)in path do 13: map[x, y]←0▷Every path entry is an in-track square. 14: end for 15: end for 16: //Initial and terminal states must be marked to be distinguished: 17: map[start]←2 18: map[end]←3 19: return map 20: end function Figure 19: Random point selection in submatrices. 52
exponentially with the input N∈N( i.e. , the order of the generated map matrix). Figure 20: Number of unique valid maps by width. Figure 20 shows that even for the simple 30 by 30 matrices, there are 10 million unique maps, which is already infeasible for tabular RL methods, both in terms of representation and exploration. It is important to note that this algorithm is easily modifiable, for example, by sampling more points instead of just 4 ( i.e. , more submatrices), and therefore creating more complicated track paths. It is also easy to vary the track width, for example by turning the matrix entries, which are adjacent to BFS path entries, into in-track squares. Finally, it is even possible to add the other two missing types of entries (grass and iced states), by randomly changing matrix entries, for example. In fact, all these ideas have been applied in practice, and some variations of these algorithm were used to create a large number of maps. Those are even more complex and high dimensional tasks, and increase even more the possible valid tracks to the plot 20. These problems will be studied and addressed in detail in the next chapter. 5.3 Generalization formalism Until now, generalization in RL has been referred to in a broad sense, but to properly study it, we need a formal definition. In the previous chapters, we used a set of singleton environments for both training and evaluation. However, the standard MDP definition does not uniquely characterize different tasks, such as different track maps in our running example. Recently, the idea of a Contextual Markov Decision Process (CMDP) has gained popularity in the literature [Kirk et al. (2023); Ghosh et al. (2021); Hallak et al. (2015)]. A CMDP is a mathematical framework that captures the variations within levels in a game or 53
across different tasks by incorporating context variables into the traditional MDP structure. This formalism has not yet found a consensus in the still young RL literature, but generally it allows for a more precise characterization of task differences and provides a structured way to approach generalization. By defining a family of MDPs parameterized by context variables, CMDPs enable us to study how RL agents can generalize across tasks that share similar structural properties but differ in specific details. 5.3.1 Partially Observable Markov Decision Processes Before introducing the CMPDs there is another important well known definition that is broadly used in RL, which are the Partially Observable Markov Decision Processes (POMDP). Generally, when modeling and solving a real-world problem as an MDP, not only is it rare to have full knowledge of the dynamics of the environment, but it is also rare to have access to all the information present in the states ( i.e. , the states are not directly observed). In the DiscreteCarEnv an example would be if an agent received pixels of the game frames instead of the position and speed directly. Definition 5.3.1 (Partially Observable Markov Decision Process (POMDP)).A POMDP is a generalization of an MDP, which is defined as a tuple (S,A, p, r, γ, ρ0,O,Z): •S,A, p, r, γ, ρ0are defined as in a standard MDP. •Ois a finite set of observations, which is what an agent receives instead of states. •Z:S ×A −→ ∆(O)is the observation function, that specifies the probability of an observation being received, after taking an action and landing in a particular new state Z(s′, a, o′) = P(Ot+1 =o′|St+1 =s′, At=a). At each time-step, an agent takes an action and receives an observation and reward, meaning that the process’ evolution is determined by the underlying dynamics of the true MDP, but the agent must act under uncertainty. Ultimately, the objective of solving a POMDP is analogous to that of solving an MDP, in the sense of maximising the return, but using policies that map observations to actions instead. 5.3.2 Contextual Markov Decision Processes To formally define generalization across different environments, specifically between a training and a test environment as in a Supervised Learning setting, we must have a framework to specify different sets of tasks. In Hallak et al. (2015) it was introduced the idea of a Contextual Markov Decision Process (CMDP), 54
that extends the idea of an MDP to include underlying parameters that group different dynamics of the same state and action spaces. Definition 5.3.2 (Contextual Markov Decision Process (CMDP) — adapted from Hallak et al. (2015)).A CMDP is a tuple (C,S,A,M, φ0), where: •Cis a finite set of contexts. •Sand Aare the state and action spaces as in a typical MDP. •M:C −→ M(S,A)is a function that maps a context c∈ C to an MDP M(c) = (S,A, pc, rc, ρc 0), where: –M(S, A)is the space of all MDPs that can be defined over the state space Sand action space A. •φ0:C −→ [0,1] is the initial probability distribution over contexts. Similarly to how an initial state s0is sampled from s0∼ρ0, the context used for an episode of a CMDP is sampled from c∼φ0, therefore determining which underlying MDP M(c)will drive the dynamics. This initial formalization groups environments with potentially different dynamics, but which share the same space of states and actions, to also share the same framework. One natural question to ask is whether a CMDP is always an MDP, since it allows an agent to receive a full state of an underlying MDP, differently from the POMDP setup, but it is easy to see that the definition presented does not necessarily indicate if the states explicitly characterize the contexts ( i.e. ,Cis not necessarily a factor of S), meaning that although individual episodes are markovian, the system has a whole also depends on contexts which might be hidden. In fact, more recent literature has been defining a CMDP explicitly as special POMDPs [Doshi-Velez and Konidaris (2013); Kirk et al. (2023)]. 5.4 Zero-Shot Generalization For any given CMDP (C,S,A,M, φ0)with 2≤ |C|, it is possible to split it into several individual CMDPs. For example, given a subset of contexts C′⊆ C, the tuple (C′,S,A,M, φ′ 0)with: φ′ 0(c) = φ0(c) Pc′∈C′φ0(c′) (ensuring that φ′ 0is a valid probability distribution) is also a proper CMDP. This fact shows that an arbitrary CMDP with two or more contexts can be factored specifically into a training and test environments. In the 55
running example of the DiscreteCarEnv , a training and test CMDP can be factored in terms of: game levels, simply associating different maps to different contexts; or as it is usual to do in benchmarking, a context can be a set of seeds used as an input to a procedural generation algorithm [Kirk et al. (2023)]. As in regular MDPs, we can also define the expected return of a specific policy under a CMDP 5.4.1. Definition 5.4.1 (CMDP expected return).Given a CMDP Θ = (C,S,A,M, φ0), the expected CMDP return jπ(Θ) is defined as jπ(Θ) = Ec∼φ0Rπ, M(c), where R(π, M(c)) is the expected return over trajectories of the MDP M(c)when following the policy π. This cost function definition finally leads to a first formalization of the generalization problem, namely the Zero-Shot Policy transfer [Kirk et al. (2023)]: Definition 5.4.2 (Zero-Shot Policy transfer).Given a CMDP Θ = (C,S,A,M, φ0)and two other CMDPs factored from Θ, namely Θtrain = (Ctrain,S,A,M, φ0)and Θtest = (Ctest,S,A,M, φ0), representing both training and test environments Ctest,Ctrain ⊆ C, the problem of Zero-Shot Policy transfer boils down to finding a non-markovian policy that maximizes returns in the test CMDP max πjπ(Θtest), with the restriction of solving such optimization problem only through interaction with Θtrain. The policy that we seek in 5.4.2 is non-markovian ( i.e. , history dependent) because recent work [Ghosh et al. (2021)] have shown that acting optimally at test time with the restriction imposed of training in a different CMDP induces partial observability, and that there are non-markovian policies which provably yield better returns at test time than a deterministic policy found during training. Such problem is tipically addressed in the literature from a Bayesian interpretation of Reinforcement learning (Bayesian RL), which has several useful theoretical formalisms both to study the generalization problem within RL and already well studied methods from Bayesian statistics to approach them [Ghosh et al. (2021)]. Generalization in this section depends on the vague concept of a task, which has mild conditions to be defined within a CMDP. However, the tabular methods studied so far aim for the restrictive goal of finding a deterministic optimal policy π. While this is guaranteed to exist in simple MDPs, it is not suitable for generalization. This limitation exacerbates the intractability issues already present when scaling state spaces. As we move beyond tabular methods, the need for more advanced techniques becomes evident, leading us to the next crucial topic: function approximation. Function approximation allows us to 56
generalize across large or continuous state spaces by approximating the value functions or policies using parameterized models, thereby addressing the limitations of tabular methods. 57
Chapter 6 RL with Function Approximation In Supervised Learning, the idea of function approximation or estimation [Goodfellow et al. (2016)] has been central to the development of the field. The goal in SL is to build a predictive model that is able to find a function f(that is assumed to exist), given an input dataset of labelled vectors (x, y)∈ D (training data) such that f(x) = y. Furthermore, it is expected that the model is able to generalize the relation that fdescribes beyond the training input vectors and labels, to unseen ones, given that the whole input space is not present in the training data. In contrast to the vague assumption of existence of a function ffor most SL setups, the RL framework, with the guarantees of optimal policy existence given an MDP, encourages the usage of function approximation to deal with high-dimensional state-spaces. However, the mapping that RL seeks to approximate is far more complex due to the sequential decision-making process involved. Major breakthroughs in SL, with Deep Learning (DL) as a subfield feature relying on multi-layer neural networks as universal function approximators [Hornik et al. (1989)], have echoed across the entire ML field. These advancements have significantly influenced RL, leading to the development of powerful methods capable of addressing the challenges posed by high-dimensional and complex environments. This chapter will explore various methods of function approximation in RL, focusing on their application in solving the control problem in complex environments and enhancing generalization capabilities. The algorithms Deep Q-Networks (DQN) and Proximal Policy Optimization (PPO) will be explained as they are milestones in RL and are great representatives of the two main families of methods for RL with function approximation: value-based and policy gradient algorithms, respectively. Both were used to solve the DiscreteCar game with a big number of maps, but relying in only one policy, instead of one for each map. 58
6.1 Deep Q-Learning Deep Q-Networks (DQN) marked a significant milestone in the application of deep learning to reinforcement learning. DQN combines Q-learning with deep neural networks, enabling the agent to learn value functions for high-dimensional state spaces. In this section we will see the fundamental ideas that lead to this method, starting from the theory behind using function approximation together with value functions. In the end we will apply it to the DiscreteveCarEnv , as before. 6.1.1 Value-function Approximation The methods studied in Chapter 2 all relied in a full representation of a value function, but one natural idea is to replace tables by a parameterized function ( e.g. , neural networks, polynomials, decision trees, etc.), allowing for a more compact model that not only reduces the amount of memory used to store the values, but ideally also reducing the amount of exploration and computation needed to find good policies, in environments whose state and/or action spaces are too big to either represent or explore through tabular methods. The goal of Value Function Approximation (VFA) is generalization with respect to states and actions, in the sense that instead of having individual approximations for every state-action pair, it is expected to find a function dependent on a parameter vector w∈Rd, which is obviously much smaller than the state-action space ( i.e. , with d≪ |S × A|). Figure 21: Value function approximation. Prediction with VFA For a given policy π, the prediction problem poses the question of what is the expected return when following that policy, or in other words, what is the value of that policy for every state. Such problem has 59
Figure 26: DQN baseline — networks comparison. length of the episode is symmetric to the reward, but always positive. It is possible to see that interestingly the number of output features of the CNNs has quite some impact. One good hypothesis for this is the fact that adding more features, gives more weight to the map matrix and less to the state vector (x, y, speed), in the final representation of the concatenated vector. This difference seems to be more noticeable for smaller CNNs. As a second benchmark, we have chosen one of the best performing architectures, namely the medium size CNN with 5 features, to test different batch sizes (32,64 and 128) together with multiple environments or workers. This concept of multiple workers is really useful in practice when we can leverage running multiple environment instances in parallel. This earned the name of Vectorized Environments , within the RL community, and instead of having a single MDP, we have 1< n ∈Nindependent instances of the same original MDP, where trajectories are vectors of the form1: τ= (s1 0, s2 0, . . . , sn 0),(s1 1, s2 1, . . . , sn 1), . . . , (s1 T, s2 T, . . . , sn T). It is important to note that since vectorized environments (VecEnvs) consist of multiple independent MDPs, each component can terminate at different time steps and not necessarily at the same time step T, meaning that the definition of a final state is not trivial anymore. For example, we could simply define a final state when at least one component is in a final state: the state (s1 0, s2 0, . . . , sn 0)is terminal if and only if there is only one terminal component, and another option is when every state is terminal: the state (s1 0, s2 0, . . . , sn 0)is terminal if and only if every component is terminal. The problem with the first terminal-state definition is that the sampling is always defined by the component with the shortest trajectory, and the second implies that there is a mechanism that fills the 1Action and rewards have been omitted for readability 66
components that terminated with some new state. We used the Stable Baselines 3 (SB3)(https:// stable-baselines3.readthedocs.io/en/master/guide/vec_envs.html) implementation of the Vectorized Environments, which has a variant of this second mechanism that transition individual components that reached a terminal state, to a new initial state, by automatically resetting terminated or truncated environment components. This means that this kind of vectorized environment turns a normal MDP with a non-empty set of terminal states, into a “bigger” continuous task MDP. We will use this kind of setup for the rest up the thesis to speed up training, when possible. Figure 27: DQN best net — batch size and number of workers comparison. In plot 27 it is possible to see that simply increasing batch size in DQN obviously reduces variance across seeds, and very slightly improves performance for the singleton worker model. The parameters used can be seen in table 4. Apart from that, training with multiple workers seems to have a negative impact in DQN. Since the amount of transitions collected per time-step scales linearly with the parallel environments, this means that the replay buffer is filled much faster, and therefore making the training less and less off-policy. On the edge, if we initialize a replay buffer with size n, equal to the number of parallel workers, we would be reintroducing the sample correlation time-step problem, because all the transitions of the buffer, even though they’re different, were all collected stochastically by the same policy. Another thing is that every observed transition is only guaranteed to be updated one time, and therefore reducing exploration and potentially “forgetting” about how to behave in states that are seen less and less, because with function approximation the knowledge estimates are not produced individually for each state. 67
Figure 28: Number of maps — solving capacity comparison. Nevertheless, increasing the number of environments still provides an incredible training time speed up, which together with a few more training steps and a bigger batch size can mitigate some performance issues. Another technique that can be used to improve DQN sample efficiency with parallel workers, is to perform more than one gradient steps by mini-batch, and therefore reassuring that each visited state is properly used for parameter updates. In figure 28, this technique is compared with a DQN model without parallel workers, for solving more than one map for the first time. The MDP setup also changes quite a bit, and instead of a having a static initial state s0, the problem gets even more complicated because at the beginning of each episode it is sampled a random map. In this final benchmark, the proposed models were tested on MDPs with 10,20, and 40 simple maps. As a result, we can see that single environment DQN is always able to find a close to optimal policy, and finishing the training in a convergence trajectory, but at the cost of taking quite a while to finish the training (more than two hours on average to finish the 20 maps MDP). While the model with 4 workers and 2 gradient steps per mini-batch, took almost a third of the time to finish every training session on average, and performing equally well with 10 and 20 maps, it starts to have some difficulties solving the last task with 40 maps, performing asymptotically worst i.e., the other model. 68
Figure 29: DQN training loss. As a final note in this section, since we are performing SGD updates for the DQN loss, we can also plot 29 the loss evolution as in standard supervised problems. The difference here is that since the target moves dynamically over time, the loss by itself is a poor metric, and in fact monotonic decreases in loss, are quite rare in DQN training, which can even be a sign of divergence from the main RL goal, that is to find an optimal policy. Nevertheless, if the we manage to approach an optimal policy, the loss function should indeed decrease as the approximation becomes more and more deterministic. 6.2 Control with Policy Optimization Up to this point, all the methods discussed have tackled both the prediction and control problems by utilizing some representation of value functions. Specifically, to find an optimal policy, we employed stateaction value functions, from which actions with the maximum estimated value are derived. These methods rely heavily on the accurate estimation of these value functions to guide the decision-making process. In this section, we will explore another family of methods known as Policy Gradient. Unlike valuebased methods, Policy Gradient methods learn an optimal policy directly by optimizing the parameters of a function that approximates it, by maximizing expected rewards. This approach has several advantages, such as naturally handling high-dimensional action spaces and enabling the use of stochastic policies, which can lead to more robust exploration strategies. Policy Gradient methods have gained significant popularity, especially when combined with Deep Learning techniques. We will explore the fundamental principles of Policy Gradient methods, review their algorithmic implementations, and discuss their practical applications and benefits. In particular, we will focus on one of the most widely used Deep RL algorithms called Proximal Policy Optimization (PPO), and 69
apply it to solve the DiscreteCarEnv. 6.2.1 Policy Gradient Policy gradients are a foundational concept in direct Policy Optimization, whose goal is to start with a parameterized policy π(a|s, θ), with θ∈Rd, and gradually shape the probability distributions over actions so that the expected return is maximized. The optimization is typically performed using a cost function J(θ), whose gradient provides the direction for learning: θt+1 =θt+α· ∇J(θt),(6.8) where θtis the parameter vector at a given learning time-step t, and αis the learning rate. The core of policy gradient methods lies in performing this update of policy parameters through stochastic gradient ascent [Sutton et al. (1999)]. The choice of the cost function can vary depending on whether the tasks are episodic or continuing. For episodic tasks, a classic definition of the cost function is the value of the initial state vπθ(s0)2. Definition 6.2.1 (Episodic cost function for policy gradient).Given a differentiable parameterized policy πθwith θ∈Rd, the episodic cost function for policy gradient is defined as the expected return starting from the initial state s0∈ S. J(θ) = vπθ(s0)(6.9) =Eπθ[G0],(6.10) where G0represents the return starting from the initial state s0under the policy πθ. In model-free RL, we assume that the environment dynamics are unknown, but in this case our parameters θdefine the policy πθ, and therefore affect the state distribution, which is determined by the MDP transition function p(s′|s, a). This means that the gradient of our cost function also depends on how parameter updates would change the state distribution itself. RL theory has a really important result called Policy Gradient Theorem 6.2.1 that addresses this problem, which establishes a relationship between the gradient of the episodic cost function and an expression that only calculates the parameterized policy gradient. 2In practice, the initial state can be sampled from a probability distribution over states, but for simplicity, it is often represented as vπθ(s0)as mentioned in Sutton and Barto (2018) (pg. 324) 70
Theorem 6.2.1 (Policy gradient Theorem). The gradient of the value function πθ(s0) with respect to its parameters θ , can be written as ∇θJ(θ) = ∇vπθ(s0)(6.11) =∇θX s∈S dπθ(s)X a∈A qπθ(s, a)πθ(a|s)(6.12) ∝X s∈S dπθ(s)X a∈A qπθ(s, a)∇πθ(a|s),(6.13) where dπθ is the on-policy episodic state distribution under the policy π , which determines the expected fraction of an episode to be spent in each state s , when following πθ dπθ(s) = ηπθ(s) Ps′∈S ηπθ(s′), where ηπ(s) determines the expected number of time-steps spent on state s , when following π , as defined in the Tabular metrics section 3.4.4. A proof for this theorem can be found in subsection 13.2 of Sutton and Barto (2018). The policy gradient theorem provides a way of performing gradient updates only over the parameters θ, but as it is easy to see there are two components that policy gradient does not directly assume to be given. Firstly the on-policy state distribution dπθ, which gives the probability distribution of time-spent in each state, we can simply turn it into an expectation EπθX a∈A qπθ(St, a)∇πθ(a|St), which can now be used directly in the gradient step θt+1 =θt+αX a∈A qπθ(St, a)∇πθ(a|St). Since we are doing policy optimization, we have a second problem, which is the term qπθ(St, a)from the expression is not given. The qstate-action value function could be also approximated, but there is another possible derivation, which lead to the famous REINFORCE algorithm: ∇θJ(θ)∝EπθX a∈A qπθ(St, a)∇πθ(a|St)(6.14) =Eπθqπθ(St, At)·∇πθ(At|St) πθ(At|St)(6.15) =EπθGt·∇πθ(At|St) πθ(At|St)(6.16) =EπθGt·ln(πθ(At|St)).(6.17) 71
In this derivation, the second equality 6.15 is possible because the initial expression is multiplied by πθ(a|St) πθ(a|St), and then, since we have an expectation, the action acan be be sampled from π( i.e. , replaced by the random variable At), and lastly because πis a probability distribution: Pa∈A πθ(a|St) = 1. The third equality 6.16 is justified by the definition of the qvalue function 2.1. Finally, the third equality is simply due to the definition of the gradient of the natural logarithm. The REINFORCE algorithm simply does Monte Carlo as in the algorithm 2, by firstly performing and recording full episodes following πθ, and then updating the parameters for each step of the episode θt+1 =θt+αGt·lnπθ(At, St). Another popular idea in Policy Gradient methods are the baselines. Given the gradient of the cost function, we can add or subtract any function only dependent only on the state s ∇θ(θ)∝X s∈S dπθ(s)X a∈A qπθ(s, a)−b(s)· ∇θπθ(a|s).(6.18) This happens because, once again, πθis a probability distribution and therefore ∇X a∈A πθ(a|s) = ∇1 = 0. The introduction of such term is useful because in the context of RL there are several functions that can be added to reduce the variance. One candidate is simply a value function approximation vπθ, which we discarded initially. In fact algorithms that use value functions as baselines are called actor-critic methods, where the critic is in fact used to calculate the update target, but not to sample actions. 6.2.2 Proximal Policy Optimization In Schulman et al. (2017a) it was introduced an important Policy Gradient algorithm with “guaranteed monotonic improvement”, called Trust Region Policy optimization (TRPO). The main idea behind this methods was performing a gradient step as large as possible, conditioned by a specific metric expressed through the KL-divergence between the new and old policy. The TRPO results suggested that it is possible to change the policy gradient paradigm of small and smooth policy updates. In Schulman et al. (2017b), it was introduced another algorithm that builds upon TRPO theory, but being much simple and sample efficient. This algorithm is Proximal Policy Optimization (PPO), and it was created by the OpenAI team , and it is one of the most reliable and widely used Deep RL algorithms, with applications from robotics, to fine-tuning large language model Zheng et al. (2023). Formally, the goal behind TRPO is to maximize the expectation: 72
θe maximize Eπθe(at|st) πθe−1(at|st)·ˆ At(6.19) constrained by EDKLπθe−1(·|st), πθe(·|st)≤δ. (6.20) In this objective, DKL measures the Kullback–Leibler divergence between the two policies, and δis a small positive number that limits the KL-divergence. The term ˆ Atis an estimation of the advantage function. Here θeare the parameters vector at a given optimization epoch e. Definition 6.2.2 (Advantage function).The advantage function A(s, a)πis defined as Aπ(s, a) = qπ(s, a)−vπ(s)for all s∈ S, a ∈ A. This function measures the deviation between the expected return when taking the action aat state s, and the average of all actions in the same state. If we look again at the cost function with baseline 6.18, we see that this advantage function is indeed equivalent by simply replacing the baseline by the value function, as suggested before. The idea of estimating the Advantage is really important in Policy Gradient literature, for example the work from Schulman et al. (2018) proposed a Generalized Advantage Estimation (GAE) method, which is widely used in many RL baseline implementations, including in the baseline we will use in the next subsection. There are two main PPO variants. The first one uses the idea of a Penalty, which overcomes the hard constrain from the TRPO objective 6.20, by computing an approximation of the TRPO, that is penalized directly in the cost function. The second variation, which is the one we use in our experiments from the next section, is an alternative update called PPO-Cip, that is much simpler to implement, and does not involve computing the KL-Divergence, nor any hard constraint, but introduces a clipping mechanism in the objective function. Definition 6.2.3 (PPO-Clip update). θe+1 =arg max θ Es,a∼πθkmin r(θe, θe−1, s, a)·Aπθe | {z } original TRPO objective ,clipr(θe, θe−1, s, a),1−e, 1 + e | {z } new-old policy ratio clipped to [1−ϵ,1+ϵ] ·Aπθe, where r(θ2, θ1, s, a)is the ratio between policies as in TRPO: r(θ2, θ1, s, a) = πθ2(a|s) πθ1(a|s) . 73
The PPO clip update may seem complex, and the TRPO theoretical derivation is also not trivial Schulman et al. (2017a,b), but essentially what we are doing is calculating the TRPO surrogate loss, but without letting it move further from the clip region [1 −ϵ, 1 + ϵ]. We get 1as the center of the region because it is the identity r(θold, θold, s, a)( i.e. , if the policy does not change). In practice, there are some possible simplifications used in PPO implementations (see Achiam (2018)). Algorithm 11 Proximal Policy Optimization (PPO) - Clip Require: Initialize random policy with parameters θ∈Rd. 1: θold ←θ. 2: while True do 3: for each parallel worker W >= 1 do 4: Collect Ttransitions following πθold . 5: Compute advantage estimator ˆ Aw( e.g. using GAE Schulman et al. (2018)). 6: end for 7: Perform K < W ·Tmini-batch SGD steps following PPO-clip update 6.2.3. 8: θold ←θ. 9: end while The PPO algorithm 11, differently from the DQN, as defined in the original paper Schulman et al. (2017b), even suggests that several parallel workers can be used to collect transitions and compute the Advantages. 6.2.3 Solving the DiscreteCarvEnv with PPO In order to benchmark the PPO in the DiscreteCarEnv we trained three different models with 8,16 and 32 parallel workers in three different environments with 20, 40 and 80 simple maps, for 3,4, and 6 million time steps, respectively (each model was trained with 5 different seeds). In this case we used the best performing architecture from the previous section: the CNN had two hidden layers, and 5 output features, and the batch size was 256. The model and PPO SB3-implementation required almost no fine-tuning. The parameters used can be found in table 5, and the missing ones are the baseline parameters. The first thing to notice is that PPO actually scales much better i.e., DQN with parallel workers, as expected. The DQN models consistently diverged with 8 parallel workers (figure 27), but PPO with 8 workers was able to converge with a similar sample efficiency of the DQN without parallel workers, although with the training time advantage of the experience collection parallelized. Baseline DQN is typically faster than 74
Figure 30: Scaling parallel workers and maps. PPO, but with multiple workers we can reach similar performance in less time. In fact, DQN still has a better sample efficiency, but since PPO scales well with several workers, it reflects in real compute time. For example in the right-most plot in figure 30, it is possible to see that the model with 32 parallel workers was able to converge asymptotically with the models with 8 and 16 workers, when the training time-steps were also scaled. This allows us to apply this method to tasks with much more maps, which is quite useful in the DiscreteCarEnv. Analogously to the DQN implementation, SB3 provides a really vast set of metrics to analyze PPO’s training performance, namely the general loss, the evolution of the clipped values, the value loss, the the entropy loss , the policy gradient loss and an approximation for the DKL (which is regularization term used for stability in this specific implementation). In the appendix plot 39 it is possible to see the evolution of the first four metrics, respectively, for this first experiment. One of the most relevant facts we can observe when analyzing all this PPO metrics, both performance 30 and train 39, with respect to scaling the number of parallel workers is that essentially the plot curves are similar but shifted with respect to the training-time, which essentially means that scaling the workers in fact affects sample efficiency, but not the performance as in DQN. We will not review every single training metric in detail, since some of them are similar to ones used in DQN and already explained, but for further examination the https://stablebaselines3.readthedocs.io/en/master/modules/ppo.html page can be visited. Lastly, we can then test how well does PPO solves problems with even more maps. To do so, since PPO seems to scale much better than DQN with more parallel workers, we solved three environments with 10 times more maps each, but only doubling the amount of training steps between problems: 3, 6 and 12 million training time-steps. Finally, it seems clear that PPO performance for our problem has a trade-off 75
ments with 29,211 and 213 maps are associated with three different sub-contexts Ctrain1, Ctrain2, Ctrain3⊂ C. The training contexts are two-by-two disjoint, since every set of training maps is totally different, there are no repeated maps. There is another sub-context Ctest ∈ C which represents the test environment, which consists of a set of 1000 maps. To have a optimality reference metric, we have solved 50 of those 1000 maps with Dynamic Programming in order to know the desired number of steps in which an agent should Finnish those maps. Figure 37: Task 1 Zero-Shot Generalization — test set. Given a model trained on the three different training contexts, we have evaluated them with three different test time policies. As referred in the last chapter, deterministic policies are not suitable for generalization, and in the DiscreteCarEnv this is particularly relevant because the agent can get stuck if it systematically chooses an action that leads to a wall crash. To avoid that, the test-time policies are non-markovian and/or stochastic (6.4.1,6.4.2,38). Definition 6.4.1 (Stochastic PPO policy).Given a model trained with PPO and with parameters θ,πθ(s) gives a probability distribution over actions, which is the optimal policy approximation found during training. Instead of following the action with maximum probability for a given state, Stochastic PPO policy simply samples actions from that distribution a∼πθ(·|s). Definition 6.4.2 (Adaptive random).The Adaptive random strategy is a non-markovian policy that takes 82
into account the last two states and actions. If the current and previous states represent different map cells, then the policy simply chooses the action with highest log probability, but if the current and previous states represent the same grid position, then the policy chooses a different action, sampled uniformly from the action space. Definition 6.4.3 (Adaptive Deterministic).The adaptive backup plan is a deterministic non-markovian policy, that keeps the history of the last |A| − 1state-action pairs, and similarly to the Adaptive Random policy it changes the action if it gets stuck, but in order of action probabilities ( i.e. , first choosing the highest probability action, then the second, then third, etc.). To evaluate on the test CMDP, we solved 1 episodes for each one of the 1000 maps, with the three policies described. In the first three plots in figure 37, it is possible two compare the policies with the optimal number of time-steps needed (less is better) given by the black line (π∗legend). The Adaptive Backup policy achieves really close to optimal in those 50 maps, and even optimally in a few episodes for the three trained models. Even for the Adaptive Random policy, it is possible to see that when scaling the number of training maps the performance confidence interval band starts getting bellow the threshold of 102. Such scaling phenomena becomes more clear when looking to the whole test CMDP results (bottom plots in figure 37), but applied to every policy. The spikes in those plots essentially represent episodes which took longer for the agent to finish, and by adding more maps during training it seems that those spikes decrease and the overall performance increases. Another interesting result is relative to the Stochastic PPO policy, which despite having a worse average episode performance i.e., the Adaptive Backup policy, it is able to finish every episode without really poor performances, which can be verified by the virtually non-existent (blue) plot spikes in the training with 211 and 213 maps, which suggests that such policy seems to have a better worst-case performance i.e., the other two, even not being the best one overall. Regarding the second training CMDP (right plot in figure 36), it scales the problem of the first task distribution to include rotations of the maps, random track widths and random grass squares analogously to the task from the curriculum learning problem (figure 34b). This time the training contexts have 211,213 and 214 maps. In figure it is possible to see the Zero-Shot transfer results for the second test task evaluated on 1000 episodes as before. For the final generalization test 38, we are only evaluating the two best performing policies, leaving the Adaptive Random policy out. Due to the variance in the data, it was included the mean of the number of steps per test episode in order to have another relevant metric that helps visualization. Once again, similar performance patterns appeared, where scaling the number of maps seems to be enough to improve 83
Figure 38: Task 2 Zero-Shot Generalization — 1000 test maps. average and worst-case performance. In the smaller CMDP with 211 maps, simply following the distribution of the trained PPO model (a∼πθ(·|s)) seems to yield better episode returns on average i.e., the Adaptive Backup policy, a trend that is reversing as the number of maps increases, because the Adaptive Backup policy monotonically increases the average episode reward faster i.e., the Stochastic PPO policy. In fact, the Stochastic PPO policy has a small average performance boost between models trained with 213 to 214 maps, even though it was able to reach the terminal state in almost every episode (barely no orange spikes in the right plot 38). This average-performance vs worst-case-performance trade-off is an interesting topic for future research that seems to be connected to a kind of bias-variance trade-off in Supervised Learning. The three policies applied in this problem of Zero-Shot Generalization relied on fitting different contextual training environments to a function approximator, but without scaling neither the training capacity nor the training time, only scaling the task diversity. The Adaptive Backup policy was introduced in the context of generalization for RL in Ghosh et al. (2021) (simply called adaptive), where they show that optimality in the test context, cannot be ensured by following a deterministic policy produced from a training in a different context, as we were used to in classical RL. 84
Chapter 7 Conclusions and future work 7.1 Conclusions At the beginning of this text, we highlighted the remarkable ability of humans to learn from a few examples. With the advent of Deep Reinforcement Learning, significant milestones have been achieved. Initially, DeepMind demonstrated human and superhuman performance in Atari games using DQN Mnih et al. (2015,2013). Subsequently, they achieved Grandmaster performance in the complex game of Go . This was first accomplished by integrating expert domain knowledge with Deep RL and Monte Carlo Tree Search in the AlphaGo model. A year later, they surpassed this by achieving the same feat without prior expert knowledge using AlphaGo Zero, and eventually mastered Chess, Go, and Shogi with AlphaZero Silver et al. (2017). Finally, in 2020, MuZero was introduced, and mastered the four mentioned environments without any prior human knowledge, by learning the game dynamics independently Schrittwieser et al. (2020). Despite these remarkable successes, a common factor remains: humans are still far more efficient learners than Deep RL models. For instance, in our simple DiscreteCarEnv, it took 3 million steps for DQN to solve 20 maps, processing 15 times more frames per second than humans can. In fact, in Pouncy et al. (2017), examples are given where humans achieve the performance of a Deep RL model trained for 25 million steps in just a few minutes, without prior experience of the game. In addition, it is important to acknowledge that humans are continuously interacting with a much larger state space and a noisy, unrestricted, and non-task-oriented action space. This critical analysis of the current state- of-the-art in RL, which can also be extended to AI in general, including novel Large Language Models and architectures, suggests that we are probably not “just” a few billion dollars way from the singularity that some refer to as Artificial General Intelligence (AGI) or “solving intelligence”, as Richard Sutton alludes to in his famous “The Bitter Lesson” blog Post Sutton (2019). Apart from the bitter lesson, Reinforcement Learning is very much alive. The fact that even the smallest advances in RL are widely underpinned by important insights, driven by foundational theoretical work, gives 85
us confidence that this field has the right tools to properly reason about decision-making and even about learning itself. We must pursue this path of reaching, and even better, understanding, human-level learning efficiency. Maintaining the spirit of the search for this goal, in the next and final section, we will go through some open problems, ideas to improve developed studies, and proposals for future work. 7.2 Prospects for Future Work Reinforcement Learning (RL) has ample scope for new studies and the improvement of existing methods. While developing this thesis, we encountered several challenges, but it is important to note that there are many more RL areas that deserve attention, such as Reinforcement Learning From Human Feedback (RLHF), Multi-Agent Reinforcement Learning, Offline Reinforcement Learning, Bayesian Reinforcement Learning, and Distributed Reinforcement Learning, to name a few. These growing fields have specific topics of research but are not independent, as advancements in some areas typically accelerate progress in others. Regarding theory, one of the main issues every RL researcher is aware of is the deadly triad . Off-policy methods that bootstrap value estimates, like Q-learning, combined with function approximation, are known not to be guaranteed to converge. However, the existence of several methods that successfully combine these three components to solve complex problems suggests that this issue is not yet fully understood. In this thesis, PPO was chosen over DQN to study generalization across thousands of maps, not because it proved to be more sample efficient, but because the overall throughput with multiple environments was higher. In fact, training DQN with a single environment is faster than PPO because it requires less frequent and less computationally intensive updates. It would be interesting to further investigate how novel techniques, used to enhance DQN, can scale with more workers, such as applying prioritized sampling instead of uniformly choosing mini-batch samples, as seen in Andrychowicz et al. (2018) and Schaul et al. (2016). With respect to Curriculum and Transfer Learning, another possible study is to test other transfer techniques, namely feature extraction, which is particularly suitable in our network architecture, since the trained CNN can be frozen for novel tasks. While conducting state and action space engineering for the DiscreteCarEnv, we encountered several dilemmas and game implementation equivalences. These issues can be viewed through the lens of MDP Homomorphisms and Isomorphisms , which may have some applications and theoretical implications from an algebraic perspective in RL theory, like convergence and complexity analysis between isomorphic MDPs. 86
The last topic We would like to mention concerns with the problem of most RL training methods being CPU-bound. Even though recent advances in both GPU architectures and Deep Learning have enabled fast training through massively parallelized computations, in Deep RL, the data collection process is still CPU-bound, creating a significant bottleneck. This mismatch between CPU-bound data collection and GPU-accelerated computation has led some RL researchers to migrate environments to the GPU to achieve end-to-end GPU Deep-RL. We would like to follow these steps by implementing an open-source, full-GPU version of the DiscreteCarEnv environment in the future. 87
Bibliography Joshua Achiam. Simplified ppo-clip objective, 2018. URL https://drive.google.com/file/d/ 1PDzn9RPvaXjJFZkGeapMHbHGiWWW20Ey/view. Sanae Amani, Christos Thrampoulidis, and Lin Yang. Safe reinforcement learning with linear function approximation. In Marina Meila and Tong Zhang, editors, Proceedings of the 38th International Conference on Machine Learning , volume 139 of Proceedings of Machine Learning Research , pages 243–253. PMLR, 18–24 Jul 2021. URL https://proceedings.mlr.press/v139/amani21a.html. Marcin Andrychowicz, Filip Wolski, Alex Ray, Jonas Schneider, Rachel Fong, Peter Welinder, Bob McGrew, Josh Tobin, Pieter Abbeel, and Wojciech Zaremba. Hindsight experience replay, 2018. E. Barnard. Temporal-difference methods and markov models. IEEE Transactions on Systems, Man, and Cybernetics , 23(2):357–365, 1993. doi: 10.1109/21.229449. Marc G. Bellemare, Will Dabney, and Rémi Munos. A distributional perspective on reinforcement learning, 2017. URL https://arxiv.org/abs/1707.06887. Richard Bellman. Dynamic Programming . Dover Publications, 1957. ISBN 9780486428093. Y. Bengio, Jérôme Louradour, Ronan Collobert, and Jason Weston. Curriculum learning. In Proceedings of the 26th Annual International Conference on Machine Learning , volume 60, page 6, 06 2009. doi: 10.1145/1553374.1553380. Karl Cobbe, Chris Hesse, Jacob Hilton, and John Schulman. Leveraging procedural generation to benchmark reinforcement learning. In Hal Daumé III and Aarti Singh, editors, Proceedings of the 37th International Conference on Machine Learning , volume 119 of Proceedings of Machine Learning Research , pages 2048–2056. PMLR, 13–18 Jul 2020. URL https://proceedings.mlr.press/v119/ cobbe20a.html. Finale Doshi-Velez and George Konidaris. Hidden parameter markov decision processes: A semiparametric 88
regression approach for discovering latent task parametrizations, 2013. URL https://arxiv.org/ abs/1308.3513. Dibya Ghosh, Jad Rahme, Aviral Kumar, Amy Zhang, Ryan P. Adams, and Sergey Levine. Why generalization in rl is difficult: Epistemic pomdps and implicit partial observability, 2021. Ian Goodfellow, Yoshua Bengio, and Aaron Courville. Deep Learning . MIT Press, 2016. http://www. deeplearningbook.org. Assaf Hallak, Dotan Di Castro, and Shie Mannor. Contextual markov decision processes, 2015. Matteo Hessel, Joseph Modayil, Hado van Hasselt, Tom Schaul, Georg Ostrovski, Will Dabney, Dan Horgan, Bilal Piot, Mohammad Azar, and David Silver. Rainbow: Combining improvements in deep reinforcement learning, 2017. Kurt Hornik, Maxwell Stinchcombe, and Halbert White. Multilayer feedforward networks are universal approximators. Neural Networks , 2(5):359–366, 1989. ISSN 0893-6080. doi: https://doi.org/10.1016/ 0893-6080(89)90020-8. URL https://www.sciencedirect.com/science/article/pii/ 0893608089900208. Chi Jin, Zhuoran Yang, Zhaoran Wang, and Michael I Jordan. Provably efficient reinforcement learning with linear function approximation. In Jacob Abernethy and Shivani Agarwal, editors, Proceedings of Thirty Third Conference on Learning Theory , volume 125 of Proceedings of Machine Learning Research , pages 2137–2143. PMLR, 09–12 Jul 2020. URL https://proceedings.mlr.press/v125/jin20a. html. Robert Kirk, Amy Zhang, Edward Grefenstette, and Tim Rocktäschel. A survey of zero-shot generalisation in deep reinforcement learning. Journal of Artificial Intelligence Research , 76:201–264, January 2023. ISSN 1076-9757. doi: 10.1613/jair.1.14174. URL http://dx.doi.org/10.1613/jair.1. 14174. Volodymyr Mnih, Koray Kavukcuoglu, David Silver, Alex Graves, Ioannis Antonoglou, Daan Wierstra, and Martin Riedmiller. Playing atari with deep reinforcement learning, 2013. Volodymyr Mnih, Koray Kavukcuoglu, David Silver, Andrei A. Rusu, Joel Veness, Marc G. Bellemare, Alex Graves, Martin Riedmiller, Andreas K. Fidjeland, Georg Ostrovski, Stig Petersen, Charles Beattie, Amir Sadik, Ioannis Antonoglou, Helen King, Dharshan Kumaran, Daan Wierstra, Shane Legg, and Demis 89
Hassabis. Human-level control through deep reinforcement learning. Nature , 518(7540):529–533, February 2015. ISSN 00280836. URL http://dx.doi.org/10.1038/nature14236. Matthias Muller-Brockhausen, Mike Preuss, and Aske Plaat. Procedural content generation: Better benchmarks for transfer reinforcement learning. In 2021 IEEE Conference on Games (CoG) . IEEE, August 2021. doi: 10.1109/cog52621.2021.9619000. URL http://dx.doi.org/10.1109/ CoG52621.2021.9619000. Sanmit Narvekar, Bei Peng, Matteo Leonetti, Jivko Sinapov, Matthew E. Taylor, and Peter Stone. Curriculum learning for reinforcement learning domains: A framework and survey, 2020. Thomas Pouncy, Samuel Gershman, Pedro Tsividis, Jacqueline Xu, and Joshua Tenenbaum. Human learning in atari. 01 2017. Martin L Puterman. Markov decision processes: discrete stochastic dynamic programming . John Wiley & Sons, 2014. Tom Schaul, John Quan, Ioannis Antonoglou, and David Silver. Prioritized experience replay, 2016. Julian Schrittwieser, Ioannis Antonoglou, Thomas Hubert, Karen Simonyan, Laurent Sifre, Simon Schmitt, Arthur Guez, Edward Lockhart, Demis Hassabis, Thore Graepel, Timothy Lillicrap, and David Silver. Mastering atari, go, chess and shogi by planning with a learned model. Nature , 588(7839):604–609, December 2020. ISSN 1476-4687. doi: 10.1038/s41586-020-03051-4. URL http://dx.doi. org/10.1038/s41586-020-03051-4. John Schulman, Sergey Levine, Philipp Moritz, Michael I. Jordan, and Pieter Abbeel. Trust region policy optimization, 2017a. URL https://arxiv.org/abs/1502.05477. John Schulman, Filip Wolski, Prafulla Dhariwal, Alec Radford, and Oleg Klimov. Proximal policy optimization algorithms. CoRR , abs/1707.06347, 2017b. URL http://dblp.uni-trier.de/db/journals/ corr/corr1707.html#SchulmanWDRK17. John Schulman, Philipp Moritz, Sergey Levine, Michael Jordan, and Pieter Abbeel. High-dimensional continuous control using generalized advantage estimation, 2018. URL https://arxiv.org/abs/ 1506.02438. David Silver, Thomas Hubert, Julian Schrittwieser, Ioannis Antonoglou, Matthew Lai, Arthur Guez, Marc Lanctot, Laurent Sifre, Dharshan Kumaran, Thore Graepel, Timothy Lillicrap, Karen Simonyan, and 90
Demis Hassabis. Mastering chess and shogi by self-play with a general reinforcement learning algorithm, 2017. URL https://arxiv.org/abs/1712.01815. Richard S Sutton. The bitter lesson, 03 2019. URL http://www.incompleteideas.net/ IncIdeas/BitterLesson.html. Richard S. Sutton and Andrew G. Barto. Reinforcement Learning: An Introduction . The MIT Press, second edition, 2018. URL http://incompleteideas.net/book/the-book-2nd.html. Richard S Sutton, David McAllester, Satinder Singh, and Yishay Mansour. Policy gradient methods for reinforcement learning with function approximation. In S. Solla, T. Leen, and K. Müller, editors, Advances in Neural Information Processing Systems , volume 12. MIT Press, 1999. URL https://proceedings.neurips.cc/paper_files/paper/1999/file/ 464d828b85b0bed98e80ade0a5c43b0f-Paper.pdf. Hado van Hasselt, Arthur Guez, and David Silver. Deep reinforcement learning with double q-learning, 2015. URL https://arxiv.org/abs/1509.06461. Hado van Hasselt, Yotam Doron, Florian Strub, Matteo Hessel, Nicolas Sonnerat, and Joseph Modayil. Deep reinforcement learning and the deadly triad, 2018. Mel Vecerik, Todd Hester, Jonathan Scholz, Fumin Wang, Olivier Pietquin, Bilal Piot, Nicolas Heess, Thomas Rothörl, Thomas Lampe, and Martin Riedmiller. Leveraging demonstrations for deep reinforcement learning on robotics problems with sparse rewards, 2018. URL https://arxiv.org/abs/1707. 08817. Yining Wang, Ruosong Wang, Simon S. Du, and Akshay Krishnamurthy. Optimism in reinforcement learning with generalized linear function approximation, 2019. C. J. C. H. Watkins. Learning from Delayed Rewards . PhD thesis, King’s College, Oxford, 1989. Bo Xin, Haixu Yu, You Qin, Qing Tang, and Zhangqing Zhu. Exploration entropy for reinforcement learning. Mathematical Problems in Engineering , 2020:1–12, 01 2020. doi: 10.1155/2020/2672537. Rui Zheng, Shihan Dou, Songyang Gao, Yuan Hua, Wei Shen, Binghai Wang, Yan Liu, Senjie Jin, Qin Liu, Yuhao Zhou, Limao Xiong, Lu Chen, Zhiheng Xi, Nuo Xu, Wenbin Lai, Minghao Zhu, Cheng Chang, Zhangyue Yin, Rongxiang Weng, Wensen Cheng, Haoran Huang, Tianxiang Sun, Hang Yan, Tao Gui, 91