usfa
Implementation of USFAs: https://arxiv.org/pdf/1812.07626.pdf
view repo
The ability of a reinforcement learning (RL) agent to learn about many reward functions at the same time has many potential benefits, such as the decomposition of complex tasks into simpler ones, the exchange of information between tasks, and the reuse of skills. We focus on one aspect in particular, namely the ability to generalise to unseen tasks. Parametric generalisation relies on the interpolation power of a function approximator that is given the task description as input; one of its most common form are universal value function approximators (UVFAs). Another way to generalise to new tasks is to exploit structure in the RL problem itself. Generalised policy improvement (GPI) combines solutions of previous tasks into a policy for the unseen task; this relies on instantaneous policy evaluation of old policies under the new reward function, which is made possible through successor features (SFs). Our proposed universal successor features approximators (USFAs) combine the advantages of all of these, namely the scalability of UVFAs, the instant inference of SFs, and the strong generalisation of GPI. We discuss the challenges involved in training a USFA, its generalisation properties and demonstrate its practical benefits and transfer abilities on a large-scale domain in which the agent has to navigate in a first-person perspective three-dimensional environment.
READ FULL TEXT VIEW PDFImplementation of USFAs: https://arxiv.org/pdf/1812.07626.pdf
Reinforcement learning (RL) provides a general framework to model sequential decision-making problems with sparse evaluative feedback in the form of rewards. The recent successes in deep RL have prompted interest in increasingly more complex tasks and a shift in focus towards scenarios in which a single agent must solve multiple related problems, either simultaneously or sequentially. This paradigm is formally known as multitask RL (Taylor and Stone, 2009; Teh et al., 2017). One of the benefits of learning about multiple tasks at the same time is the possibility of transferring knowledge across tasks; in essence, this means that by jointly learning about a set of tasks one should be able to exploit their common structure to speed up learning and induce better generalisation (Taylor and Stone, 2009; Lazaric, 2012).
A particularly interesting instance of transfer is the generalisation to new, unseen tasks. This potentially allows an agent to perform a task with little or no learning by leveraging knowledge from previously learned tasks. In this paper we will be exploring this scenario.
Consider an RL agent in a persistent environment trying to master a number of tasks. In order to generalise to unseen tasks, the agent needs to be able to identify and exploit some common structure underlying the tasks. Two possible sources of structure in this scenario are: i) some similarity between the solutions of the tasks, either in the policy or in the associated value-function space, and ii) the shared dynamics of the environment (e.g., physics). In this paper we will attempt to build an agent that can make use of both types of structure. For this, we will build on two frameworks that exploit these structures in isolation.
The first one are Schaul et al.’s (2015) universal value function approximators (UVFAs). UVFAs extend the notion of value functions to also include the description of a task, thus directly exploiting the common structure in the associated optimal value functions. The second framework we build upon exploits the common structure in the environment and capitalises on the power of dynamic programming. Barreto et al.’s (2017) framework is based on two core concepts: successor features (SFs), a representation scheme that allows a policy to be evaluated on any task of a given format, and generalised policy improvement (GPI), a generalisation of dynamic programming’s classic operator that uses a set of policies instead of a single one.
UVFAs and SF & GPI generalise to new tasks in quite different, and potentially complementary, ways. UVFAs aim to generalise across the space of tasks by exploiting structure in the underlying space of value functions. In contrast, SF & GPI strategy is to exploit the structure of the RL problem itself. In this paper we propose a model that exhibits both types of generalisation. The basic insight is to note that SFs are multi-dimensional value functions, so we can extend them in the same way a universal value function extends their unidimensional counterparts. We call the resulting model universal successor features approximators, or USFAs for short. USFA is a strict generalisation of its precursors. Specifically, we show that by combining USFAs and GPI we can recover both UVFAs and SF & GPI as particular cases. This opens up a new spectrum of possible approaches in between these two extreme cases. We discuss the challenges involved in training a USFA and demonstrate the practical benefits of doing so on a large-scale domain in which the agent has to navigate in a three-dimensional environment using only images as observations.
In this section we present some background material, formalise the scenario we are interested in, and briefly describe the methods we build upon.
We consider the usual RL framework: an agent interacts with an environment and selects actions in order to maximise the expected amount of reward received in the long run (Sutton and Barto, 1998). As usual, we assume that such an interaction can be modeled as a Markov decision process (MDP, Puterman, 1994). An MDP is defined as a tuple where and are the state and action spaces, gives the next-state distribution upon taking action in state ,
is a random variable representing the reward received at transition
, and is a discount factor that gives smaller weights to future rewards.As mentioned in the introduction, in this paper we are interested in the multitask RL scenario, where the agent has to solve multiple tasks. Each task is defined by a reward function ; thus, instead of a single MDP , our environment is a set of MDPs that share the same structure except for the reward function. Following Barreto et al. (2017), we assume that the expected one-step reward associated with transition is given by
(1) |
where are features of and are weights. The features can be thought of as salient events that may be desirable or undesirable to the agent, such as for example picking up an object, going through a door, or knocking into something. In this paper we assume that the agent is able to recognise such events—that is, is observable—, but the solution we propose can be easily extended to the case where must be learned (Barreto et al., 2017). Our solution also applies to the case where (1) is only approximately satisfied, as discussed by Barreto et al. (2018).
Given representing a task, the goal of the agent is to find a policy that maximises the expected discounted sum of rewards, also called the return where is the reward received at the time step. A principled way to address this problem is to use methods derived from dynamic programming (DP), which heavily rely on the concept of a value function (Puterman, 1994). The action-value function of a policy on task is defined as where denotes expected value when following policy . Based on we can compute a greedy policy ; one of the fundamental results in DP guarantees that for all . The computation of and are called policy evaluation and policy improvement; under certain conditions their successive application leads to the optimal value function , from which one can derive an optimal policy for task as (Sutton and Barto, 1998).
As a convention, in this paper we will add a tilde to a symbol to indicate that the associated quantity is an approximation; we will then refer to the respective tunable parameters as . For example, the agent computes an approximation by tuning .
Here we focus on one aspect of multitask RL: how to transfer knowledge to unseen tasks (Taylor and Stone, 2009; Lazaric, 2012). Specifically, we ask the following question: how can an agent leverage knowledge accumulated on a set of tasks to speed up the solution of a new task ?
In order to investigate the question above we recast it using the formalism commonly adopted in learning. Specifically, we define a distribution over and assume the goal is for the agent to perform as well as possible under this distribution. As usual, we assume a fixed budget of sample transitions and define a training set that is used by the agent to learn about the tasks of interest. We also define a test set and use it to assess the agent’s generalisation—that is, how well it performs on the distribution of MDPs induced by .
A natural way to address the learning problem above is to use Schaul et al.’s (2015) universal value-function approximators (UVFAs). The basic insight behind UVFAs is to note that the concept of optimal value function can be extended to include as one of its arguments a description of the task; an obvious way to do so in the current context is to define the function as the optimal value function associated with task . The function is called a universal value function (UVF); a UVFA is then the corresponding approximation, . When we define transfer as above it becomes clear that in principle a sufficiently expressive UVFA can identify and exploit structure across the joint space . In other words, a properly trained UVFA should be able to generalise across the space of tasks.
A different way of generalising across tasks is to use Barreto et al.’s (2017) framework, which builds on assumption (1) and two core concepts: successor features (SFs) and generalised policy improvement (GPI). The SFs of a state-action pair under policy are given by
(2) |
SFs allow one to immediately compute the value of a policy on any task : it is easy to show that, when (1) holds, . It is also easy to see that SFs satisfy a Bellman equation in which play the role of rewards, so can be learned using any RL method (Szepesvári, 2010).
GPI is a generalisation of the policy improvement step described in Section 2.1. The difference is that in GPI the improved policy is computed based on a set of value functions rather than on a single one. Suppose that the agent has learned the SFs of policies . When exposed to a new task defined by , the agent can immediately compute . Let the GPI policy be defined as , where . The GPI theorem states that for all . The result also extends to the scenario where we replace with approximations (Barreto et al., 2017).
UVFAs and SF & GPI address the transfer problem described in Section 2.2 in quite different ways. With UVFAs, one trains an approximator by solving the training tasks using any RL algorithm of choice. One can then generalise to a new task by plugging its description into and then acting according to the policy . With SF & GPI one solves each task and computes an approximation of the SFs of the resulting policies , . The way to generalise to a new task is to use the GPI policy defined as .
The algorithmic differences between UVFAs and SF & GPI reflect the fact that these approaches exploit distinct properties of the transfer problem. UVFAs aim at generalising across the space of tasks by exploiting structure in the function . In practice, such strategy materialises in the choice of function approximator, which carries assumptions about the shape of
. For example, by using a neural network to represent
one is implicitly assuming that is smooth in the space of tasks; roughly speaking, this means that small perturbations to will result in small changes in .In contrast, SF & GPI’s strategy to generalise across tasks is to exploit structure in the RL problem itself. GPI builds on the general fact that a greedy policy with respect to a value function will in general perform better than the policy that originated the value function. SFs, in turn, exploit the structure (1) to make it possible to quickly evaluate policies across tasks—and thus to apply GPI in an efficient way. The difference between the types of generalisation promoted by UVFAs and SF & GPI is perhaps even clearer when we note that the latter is completely agnostic to the way the approximations are represented, and in fact it can applied even with a tabular representation.
Obviously, both UVFAs and GPI have advantages and limitations. In order to illustrate this point, consider two tasks and that are “similar”, in the sense that is small ( is a norm in ). Suppose that we have trained a UVFA on task and as a result we obtained a good approximation . If the structural assumptions underlying hold—for example, is smooth with respect to —, it is likely that will be a good approximation of . On the other hand, if such assumptions do not hold, we should not expect UVFA to perform well. A sufficient condition for SF & GPI to generalise well from task to task is that the policy does well on task , where is a solution for task . On the downside, SF & GPI will not exploit functional regularities at all, even if they do exist. Let policy be a solution for tasks . In principle we cannot say anything about , the SFs of , even if we have a good approximation .
As one can see, the types of generalisation provided by UVFAs and SF & GPI are in some sense complementary. It is then natural to ask if we can simultaneously have the two types of generalisation. In this paper we propose a model that provides exactly that. The main insight is actually simple: since SFs are multi-dimensional value functions, we can extend them in the same way as universal value functions extend regular value functions. In the next section we elaborate on how exactly to do so.
As discussed in Section 2.2, UVFs are an extension of standard value functions defined as . If is one of the optimal policies of task , we can rewrite the definition as . This makes it clear that the argument plays two roles in the definition of a UVF: it determines both the task and the policy (which will be optimal with respect to ). This does not have to be the case, though. Similarly to Sutton et al.’s (2011) general value functions (GVFs), we could in principle define a function that “disentangles” the task from the policy. This would provide a model that is even more general than UVFs. In this section we show one way to construct such a model when assumption (1) (approximately) holds.
Note that, when (1) is true, we can revisit the definition of SFs and write If we want to be able to compute for any , we need SFs to span the space of policies . Thus, we define universal successor features as . Based on such definition, we call a universal successor features approximator (USFA).
In practice, when defining a USFA we need to define a representation for the policies . A natural choice is to embed onto . Let be a policy-encoding mapping, that is, a function that turns policies
into vectors in
. We can then see USFs as a function of : . The definition of the policy-encoding mapping can have a strong impact on the structure of the resulting USF. We now point out a general equivalence between policies and reward functions that will provide a practical way of defining . It is well known that any reward function induces a set of optimal policies (Puterman, 1994). A point that is perhaps less immediate is that the converse is also true. Given a deterministic policy , one can easily define a set of reward functions that induce this policy: for example, we can have and , with , for any . Therefore, we can use rewards to refer to deterministic policies and vice-versa (as long as potential ambiguities are removed when relevant).Since here we are interested in reward functions of the form (1), if we restrict our attention to policies induced by tasks we end up with a conveniently simple encoding function . From this encoding function it follows that . It should be clear that UVFs are a particular case of this definition when . Going back to the definition of USFs, we can finally write Thus, if we learn a USF , we have a value function that generalises over both tasks and policies, as promised.
We now revisit the question as to why USFAs should provide the benefits associated with both UVFAs and SF & GPI. We will discuss how exactly to train a USFA in the next section, but for now suppose that we have trained one such model using the training tasks in . It is then not difficult to see that we can recover the solutions provided by both UVFAs and SF & GPI. Given an unseen task , let be the GPI policy defined as
(3) |
where . Clearly, if we make , we get exactly the sort of generalisation associated with UVFAs. On the other hand, setting essentially recovers SF & GPI.
The fact that we can recover both UVFAs and SF & GPI opens up a spectrum of possibilities in between the two. For example, we could apply GPI over the training set augmented with the current task, . In fact, USFAs allow us to apply GPI over any set of tasks . The benefits of this flexibility are clear when we look at the theory supporting SF & GPI, as we do next.
Barreto et al. (2017) provide theoretical guarantees on the performance of SF & GPI applied to any task based on a fixed set of SFs. Below we state a slightly more general version of this result that highlights the two types of generalisation promoted by USFAs (proof in Barreto et al.’s (2017) Theorem 2).
Let and let be the action-value function of executing policy on task . Given approximations , let be the GPI policy defined in 3. Then,
(4) |
where is the optimal value of task , are the SFs corresponding to the optimal policy for task , and .
When we write the result in this form, it becomes clear that, for each policy , the right-hand side of (4) involves two terms: i) , the distance between the task of interest and the task that induced , and ii) , the quality of the approximation of the SFs associated with .
In order to get the tightest possible bound (4) we want to include in the policy that minimises . This is exactly where the flexibility of choosing provided by USFAs can come in handy. Note that, if we choose , we recover Barreto et al.’s (2017) bound, which may have an irreducible even with a perfect approximation of the SFs in . On the other extreme, we could query our USFA at the test point . This would result in , but can potentially incur a high cost due to the associated approximation error .
Now that we have an approximation a natural question is how to train this model. In this section we show that the decoupled nature of is reflected in the training process, which assigns clearly distinct roles for tasks and policies .
In our scenario, a transition at time will be . Note that allows us to compute the reward for any task , and since our policies are encoded by , transitions of this form allow us to learn the value function of any policy on any task . To see why this is so, let us define the temporal-difference (TD) error (Sutton and Barto, 1998) used in learning these value functions. Given transitions in the form above, the -step TD error associated with policy on task will be
(5) |
where . As is well known, the TD error allows us to learn the value of policy on task ; since here is a function of and only, we can learn about any policy on any task by just plugging in the appropriate vectors.
Equation (3.3) highlights some interesting (and subtle) aspects involved in training a USFA. Since the value function can be decoupled into two components, and , the process of evaluating a policy on a task reduces to learning using the vector-based TD error showing up in (3.3).
Since is a function of only, the updates to will not depend on . How do the tasks influence the training of a USFA, then? If sample transitions are collected by a behaviour policy, as is usually the case in online RL, a natural choice is to have this policy be induced by a task . When this is the case the training tasks will define the distribution used to collect sample transitions. Whenever we want to update for a different than the one used in generating the data, we find ourselves under the off-policy regime (Sutton and Barto, 1998).
Assuming that the behaviour policy is induced by the tasks , training a USFA involves two main decisions: how to sample tasks from and how to sample policies to be trained through (3.3) or some variant. As alluded to before, these decisions may have a big impact on the performance of the resulting USFA, and in particular on the trade-offs involved in the choice of the set of policies used by the GPI policy (3). As a form of illustration, Algorithm 1 shows a possible regime to train a USFA based on particularly simple strategies to select tasks and to sample policies . One aspect of Algorithm 1 worth calling attention to is the fact that the distribution used to select policies can depend on the current task
. This allows one to focus on specific regions of the policy space; for example, one can sample policies using a Gaussian distribution centred around
.In this section we describe the experiments conducted to test the proposed architecture in a multitask setting and assess its ability to generalise to unseen tasks.
We start with a simple illustrative example to provide intuition on the kinds of generalisation provided by UVFAs and SF & GPI. We also show how in this example USFAs can effectively leverage both types of generalisation and outperform its precursors. For this we will consider the simple two-state MDP depicted in Figure 2. To motivate the example, suppose that state of our MDP represents the arrival of a traveler to a new city. The traveler likes coffee and food and wants to try what the new city has to offer. In order to model that, we will use features , with representing the quality of the coffee and representing the quality of the food, both ranging from to . The traveler has done some research and identified the places that serve the best coffee and the best food; in our MDP these places are modelled by terminal states associated with actions ‘’ and ‘’ whose respective associated rewards are and . As one can infer from these feature vectors, the best coffee place does not serve food and the best restaurant does not serve coffee (at least not a very good one). Nevertheless, there are other places in town that serve both; as before, we will model these places by actions associated with features . We assume that and consider alternative places evenly spaced on the preference spectrum. We model how much the traveler wants coffee and food on a given day by . If the traveler happens to want only one of these (i.e. ), she can simply choose actions ‘’ or ‘’ and get a reward . If instead she wants both coffee and food (i.e. if is not an “one-hot” vector), it may actually be best to venture out to one of the other places. Unfortunately, this requires the traveler to spend some time researching the area, which we model by an action ‘’ associated with feature . After choosing ‘’ the traveler lands on state and can now reach any place in town: , , , …, . Note that, depending on the vector of preferences , it may be worth paying the cost of to subsequently get a reward of (here ).
In order to assess the transfer ability of UVFAs, SF & GPI and USFAs, we define a training set and test tasks corresponding to directions in the two-dimensional -space: . We start by analysing what SF & GPI would do in this scenario. We focus on training task , but an analogous reasoning applies to task . Let be the optimal policy associated with task . It is easy to see that . Thus, under it should be clear that for all test tasks . Since the exact same reasoning applies to task if we replace action with action , the GPI policy (3) computed over will be suboptimal for most test tasks in . Training a UVFA on the same set , will not be perfect either due to the very limited number of training tasks. Nonetheless the smoothness in the approximation allows for a slightly better generalisation in .
Alternatively, we can use Algorithm 1 to train a USFA on the training set . In order to do so we sampled policies using a uniformly random distribution (see line 6 in Algorithm 1). When acting on the test tasks we considered two choices for the candidates set: and . Empirical results are provided in Figure 2. As a reference we report the performance of SF & GPI using the true – no approximation. We also show the learning curve of a UVFA. As shown in the figure, USFA clearly outperforms its precursors and quickly achieves near optimal performance. This is due to two factors. First, contrary to vanilla SF & GPI, USFA can discover and exploit the rich structure in the policy-space, enjoying the same generalisation properties as UVFAs but now enhanced by the combination of the off-policy and off-task training regime. Second, the ability to sample a candidate set that induces some diversity in the policies considered by GPI overcomes the suboptimality associated with the training SFs and . We explore this effect in a bit more detail in the suppl. material.
Environment and tasks. We used the DeepMind Lab platform to design a 3D environment consisting of one large room containing four types of objects: TVs, balls, hats, and balloons (Beattie et al., 2016; Barreto et al., 2018). A depiction of the environment through the eyes of the agent can be seen in Fig. 3. Features are indicator functions associated with object types, i.e., if and only if the agent collects an object of type (say, a TV) on the transition . A task is defined by four real numbers indicating the rewards attached to each object. Note that these numbers can be negative, in which case the agent has to avoid the corresponding object type. For instance, in task [1-100] the agent is interested in objects of the first type and should avoid objects of the second type.
Agent architecture. A depiction of the architecture used for the USFA agent is illustrated in Fig. 1. The architecture has three main modules: i) A fairly standard input processing unit composed of three convolution layers and an LSTM followed by a non-linearity (Schmidhuber, 1996); ii) A policy conditioning module that combines the state embedding coming from the first module, , and the policy embedding, , and produces outputs corresponding to the SFs of policy , ; and iii) The evaluation module, which, given a task and the SFs , will construct the evaluation of policy on , .
Training and baselines. We trained the above architecture end-to-end using a variation of Alg. 1 that uses Watkins’s (1989) to apply -learning with eligibility traces. As for the distribution used in line 6 of Alg. 1 we adopted a Gaussian centred at : , where
is the identity matrix. We used the canonical vectors of
as the training set, . Once an agent was trained on we evaluated it on a separate set of unseen tasks, , using the GPI policy (3) over different sets of policies . Specifically, we used: , which corresponds to a UVFA with an architecture specialised to (1); , which corresponds to doing GPI on the SFs of the training policies (similar to (Barreto et al., 2017)), and , which is a combination of the previous two. We also included as baselines two standard UVFAs that do not take advantage of the structure (1); one of them was trained on-policy and the other one was trained off-policy (see supplement). The evaluation on the test tasks was done by “freezing” the agent at different stages of the learning process and using the GPI policy (3) to select actions. To collect and process the data we used an asynchronous scheme similar to IMPALA (Espeholt et al., 2018).. Shaded areas represent one standard deviation over
runs.Fig. 4 shows the results of the agents after being trained on . One thing that immediately stands out in the figure is the fact that all architectures generalise quite well to the test tasks. This is a surprisingly good result when we consider the difficulty of the scenario considered: recall that the agents are solving the test tasks without any learning taking place. This performance is even more impressive when we note that some test tasks contain negative rewards, something never experienced by the agents during training. When we look at the relative performance of the agents, it is clear that USFAs perform considerably better than the unstructured UVFAs. This is true even for the case where , in which USFAs essentially reduce to a structured UVFA that was trained by decoupling tasks and policies. The fact that USFAs outperform UVFAs in the scenario considered here is not particularly surprising, since the former exploit the structure (1) while the latter cannot. In any case, it is reassuring to see that our model can indeed exploit such a structure effectively. This result also illustrates a particular way of turning prior knowledge about a problem into a favourable inductive bias in the UVFA architecture.
It is also interesting to see how the different instantiations of USFAs compare against each other. As shown in Fig. 4, there is a clear advantage in including to the set of policies used in GPI (3). This suggests that, in the specific instantiation of this problem, the type of generalisation provided by SF & GPI is more effective than that associated with UVFAs. One result that may seem counter-intuitive at first is the fact that USFAs with sometimes perform worse than their counterparts using , especially on tasks with negative rewards. Here we note two points. First, although including more tasks to results in stronger guarantees for the GPI policy, strictly speaking there are no guarantees that the resulting policy will perform better (see Barreto et al.’s Theorem 1, 2017). Another explanation very likely in the current scenario is that errors in the approximations may have a negative impact on the resulting GPI policy (3). As argued previously, adding a point to can sometimes increase the upper bound in (4), if the approximation at this point is not reliable. On the other hand, comparing USFA’s results using and , we see that by combining the generalisation of UVFAs and GPI we can boost the performance of a model that only relies on one of them. This highlights the fine balance between the two error terms in (4) and emphasizes how critical selecting low-error candidates in can be.
In the above scenario, SF & GPI on the training set seems to provide a more effective way of generalising, as compared to UVFAs, even when the latter has a structure specialised to (1). Nevertheless, with less conservative choices of that provide a greater coverage of the space we expect the structured UVFA () to generalise better. Note that this can be done without changing and is not possible with conventional UVFAs. One of the strengths of USFAs is exactly that: by disentangling tasks and policies, one can learn about the latter without ever having to actually try them out in the environment. We exploit this possibility to repeat our experiments now using . Results are shown in Fig.5. As expected, the generalisation of the structured UVFA improves considerably, almost matching that of GPI. This shows that USFAs can operate in two regimes: i) with limited coverage of the policy space, GPI over will provide a reliable generalisation; ii) with a broader coverage of the space structured UVFAs will do increasingly better.^{1}^{1}1Videos of USFAs in action on the links https://youtu.be/Pn76cfXbf2Y and https://youtu.be/0afwHJofbB0.
Multitask RL is an important topic that has generated a large body of literature. Solutions to this problem can result in better performance on the training set (Espeholt et al., 2018), can improve data efficiency (Teh et al., 2017) and enable generalisation to new tasks. For a comprehensive presentation of the subject please see Taylor and Stone (2009) and Lazaric (2012) and references therein.
There exist various techniques that incorporate tasks directly into the definition of the value function for multitask learning (Kaelbling, 1993; Ashar, 1994; Sutton et al., 2011). UVFAs have been used for zero-shot generalisation to combinations of tasks (Mankowitz et al., 2018; Hermann et al., 2017), or to learn a set of fictitious goals previously encountered by the agent (Andrychowicz et al., 2017).
Many recent multitask methods have been developed for learning subtasks or skills for a hierarchical controller (Vezhnevets et al., 2017; Andreas et al., 2016; Oh et al., 2017). In this context, Devin et al. (2017) and Heess et al. (2016) proposed reusing and composing sub-networks that are shared across tasks and agents in order to achieve generalisation to unseen configurations. Finn et al. (2017) uses meta-learning to acquire skills that can be fine-tuned effectively. Sequential learning and how to retain previously learned skills has been the focus of a number of investigations (Kirkpatrick et al., 2016; Rusu et al., 2016). All of these works aim to train an agent (or a sub-module) to generalise across many subtasks. All of these can be great use-cases for USFAs.
USFAs use a UVFA to estimate SFs over multiple policies. The main reason to do so is to apply GPI, which provides a superior zero-shot policy in an unseen task. There have been previous attempts to combine SFs and neural networks, but none of them used GPI
(Kulkarni et al., 2016; Zhang et al., 2016). Recently, Ma et al. (2018) have also considered combining SFs and UVFAs. They propose building a goal-conditioned policy that aims to generalise over a collection of goals. In their work, the SFs are trained to track this policy and only used to build the critic employed in training the goal-conditioned policy. Thus, they are considering the extrapolation in and using the SFs as an aid in training. Moreover, as both the training and SFs and are done on-policy, the proposed system has only seen instances where the SFs, critic and policy are all conditioned on the same goal. In contrast, in this work we argue and show the benefits of decoupling the task and policy to enable generalisation via GPI when appropriate, while preserving the ability to exploit the structure in the policy space. We use the SFs as a way to factorize and exploit effectively the structure in value function space. And we will use these evaluations directly to inform our action selectionIn this paper we presented USFAs, a generalisation of UVFAs through SFs. The combination of USFAs and GPI results in a powerful model capable of exploiting the same types of regularity exploited by its precursors: structure in the value function, like UVFAs, and structure in the problem itself, like SF & GPI. This means that USFAs can not only recover their precursors but also provide a whole new spectrum of possible models in between them. We described the choices involved in training and evaluating a USFA and discussed the trade-offs associated with these alternatives. To make the discussion concrete, we presented two examples aimed to illustrate different regimes of operation. The first example embodies a MDP where the generalisation in the optimal policy space is fairly easy but the number of optimal policies we would want to represent can be large. This is a scenario where UVFAs would strive, while vanilla SF & GPI will struggle due to the large number of policies needed to build a good GPI policy. In this case, we show that USFAs can leverage the sort of parametric generalisation provided by UVFAs and even improve on it, due to its decoupled training regime and the use of GPI in areas where the approximation is not quite perfect. Our second example is in some sense a reciprocal one, where we know from previous work that the generalisation provided via GPI can be very effective even on a small set of policies, while generalising in the space of optimal policies, like UVFAs do, seems to require a lot more data. Here we show that USFAs can recover the type of generalisation provided by SFs when appropriate. This example also highlights some of the complexities involved in training at scale and shows how USFAs are readily applicable to this scenario. Overall, we believe USFAs are a powerful model that can exploit the available structure effectively: i) the structure induced by the shared dynamics (via SFs), ii) the structure in the policy space (like UVFAs) and finally iii) the structure in the RL problem itself (via GPI), and could potentially be useful across a wide range of RL applications that exhibit these properties.
Proceedings of the International Conference on Machine Learning (ICML)
, pages 501–510, 2018.Synthesis Lectures on Artificial Intelligence and Machine Learning. Morgan & Claypool Publishers, 2010.
In this paper we argue that one of the main benefits provided by USFAs is the ability to combine the types of generalisation associated with UVFAs and GPI. In this section, we will take a close look at a very simple example to illustrate the two of generalisation we are considering and how they are different. This is a very small example where the number of optimal policies are very limited and the induced tasks are not that interesting, but we chose this solely to illustrate the decision process induced by GPI and how it differs from parametric generalisation in via a functional approximator (FA).
Let us consider a an MDP with a single state and two actions. Upon executing action the agent gets a reward of and remains in state ; the execution of action leads to a potentially non-zero reward followed by termination. We define unidimensional features as and . A task is thus induced by a scalar which essentially re-scales and defines the reward the agent receives before termination. In this environment, the space of tasks considered are induced by a scalar . In this space of tasks, one can easily see that there are only two optimal policies: taking action and receiving the reward if , or taking action and remaining in indefinitely. Thus the space of optimal value functions is very simple. For convenience, we include a depiction of this space in Figure 6.
Suppose now we are in the scenario studied in the paper, where after training on a set of tasks the agent should generalise to a test task . Specifically, let us consider three points in this space – three tasks we are going to consider for learning and approximating their optimal policies . Given these three points we are going to fit a parametric function that aims to generalise in the space of . A depiction of this is included in Figure 7(a). Now, given a new point we can obtain a zero-shot estimate for – see Figure 7(b). Due to approximation error under a very limited number of training points, this estimate will typically not recover perfectly . In the case of UVFA (and other FAs trying to generalise in task space), we are going to get a guess based on optimal value function we have built, and we are going to take decision based on this estimate .
Given the same base tasks we can now look at what the other method of generalisation would be doing. We are going to denote by the (inferred) optimal policy of task . Since we have learnt the SFs corresponding to all of these policies , we can now evaluate how well each of these policies would do on the current test task : for all . A depiction of this step is included in Figure 8(a). Given these evaluations of previous behaviours, GPI takes the maximum of these values – ”trusting”, in a sense, the most promising value. In our case this corresponds to the behaviour associated with task , which in this case happens to have the same optimal policy as our test task . Thus in this particular example, the evaluation of a previously learned behaviour gives us a much better basis for inducing a behaviour in our test task . Moreover if the SFs are perfect we would automatically get the optimal value function for .
It is worth noting that, in this case, by learning a USFA we can recover both scenarios described above based on our choice of the candidate set for GPI . In particular, if we recover the mechanism in Figure 7, while for we recover the generalisation in Figure 8. Furthermore, for any choice of trained points that include one positive and one negative choice of , by relying on GPI we can generalise perfectly to the whole space of tasks, while an approach based exclusively on the sort of generalisation provided by UVFAs may struggle to fit the full function. Analogously, in scenarios where the structure of the optimal space favours (UV)FAs, we expect USFAs to leverage this type of generalisation. An example of such a scenario is given in the first part of the experimental section – Section 4.1, and further details in Section B.
In this section we provide some additional analysis and results omitted from the main text. As a reminder, this is a two state MDP, where the first state is a root state, the transition from comes at a cost and all other actions lead to a final positive reward corresponding to how much the resulting state/restaurant alligns with our preferences (our task) right now. For convenience, we provide below the depiction of the Trip MDP introduced in Section 4.1.
In the experiments run we considered a fixed set of training tasks for all methods. The set of outcomes from the exploratory state is defined as for . Note that this includes the binary states for and respectively . We ran this MDP with , and . Thus outside the binary outcomes, the agent can select other mixed outcomes and, as argued in the main text, under these conditions there will be a selection of the -space in which each of these outcomes will be optimal. Thus the space of optimal policies, we hope to recover, is generally . Nevertheless, there is a lot of structure in this space, that the functional approximators can uncover and employ in their generalization.
In the main paper, we reported the zero-shot aggregated performance over all direction . This should cover most of the space of tasks/trade-offs we would be interest in. In this section we include the generalization for other sets . First in Fig. 9 we depict the performance of the algorithms considered across the whole space . Fig. 10 is just a different visualization of the previous plot, where we focus on how far these algorithms are from recovering the optimal performance. This also shows the subtle effect mentioned in the discussion in the main text, induced by the choice of in the USFA evaluation.
A particularly adversarial choice of test tasks for the vanilla SF & GPIwould be the diagonal in the quadrant depicted in the plot above: . This is, in a sense, maximally away from the training tasks and both of the precursor models are bound to struggle in this portion of the space. This intuition was indeed empirically validated. Results are provided in Fig. 11. As mentioned above, this is an adversarial evaluation, mainly to point out that, in general, there might be regions of the space were the generalization of the previous models can be very bad, but where the combination of them can still recover close to optimal performance.
This section contains a detailed description of the USFA agent used in our experimental section. As a reminder, we include the agent’s architecture below (Figure 1 in the main text).
As highlighted in Section 4.2, our agent comprises of three main modules:
Input processing module: computes a state representation from observation . This module is made up of three convolutional layers (structure identical to the one used in [Mnih et al., 2015]), the output of which then serves as input to a LSTM (256). This LSTM takes as input the previously executed action . The output of the LSTM is passed through a non-linearity
(chosen here to be a ReLu) to produce a vector of
units, .Policy conditioning module: compute the SFs , given a (sampled) policy embedding and the state representation . This module first produces number of samples ( in our experiments). Each of these is then transformed via a 2-layer MLP(32,32) to produce a vector of size , for each sample . This vector gets concatenated with the state representation
and the resulting vector is further processed by a 2-layer MLP that produces a tensor of dimensions
for each , where . These correspond to SFs for policy . Note that this computation can be done quite efficiently by reusing the state embedding , doing the downstream computation in parallel for each policy embedding .Task evaluation module: computes the value function for a given task description . This module does not have any parameters as the value functions are simply composable from and the task description via assumption (1). This module with output value functions that will be used to produce a behavior via GPI.
An important decision in this design was how and where to introduce the conditioning on the policy. In all experiments shown here the conditioning was done simply by concatenating the two embeddings and , although stronger conditioning via an inner product was tried yielding similar performance. The ’where’ on the other hand is much more important. As the conditioning on the policy happens quite late in the network, most of the processing (up to ) can be done only once, and we can sample multiple and compute the corresponding at a fairly low computational cost. As mentioned above, these will be combined with the task vector to produce the candidate action value functions for GPI. Note that this helps both in training and in acting, as otherwise the unroll of the LSTM would be policy conditioned, making the computation of the SFs and the off-policy -step learning quite expensive. Furthermore, if we look at the learning step we see that this step can also benefit from this structure, as the gradient computation of can be reused. We will only have a linear dependence on on the update of the parameters and computations in the red blocks in Figure 12.
UVFA baseline agents have a similar architecture, but now the task description is fed in as an input to the network. The conditioning on the task of UVFAs is done in a similar fashion as we did the conditioning on the policies in USFAs, to make the computational power and capacity comparable. The input processing module is the same and now downstream, instead of conditioning on the policy embedding , we condition on task description . This conditioning if followed by a 2-layer MLP that computes the value functions , which induces the greedy policy .
The agents’ training was carried out using the IMPALA architecture [Espeholt et al., 2018]. On the learner side, we adopted a simplified version of IMPALA that uses as the RL algorithm. In our experiments, for all agents we used . Depending on the sampling distribution , in learning we will be often off-policy. That is, most of the time, we are going to learn about a policy and update its corresponding SFs approximations , using data generated by acting in the environment according to some other policy . In order to account for this off-policiness, whenever computing the n-step return required in eq. 3.3, we are going to cut traces whenever the policies start to disagree and bootstrap from this step on [Sutton and Barto, 1998]. Here we can see how the data distribution induce by the choice of training tasks can influence the training process. If the data distribution is very close to the set , as in our first experiment, most of the policies we are going to sample will be close to the policies that generated the data. This means that we might be able to make use of longer trajectories in this data, as the policies will rarely disagree. On the other hand, by staying close to the training tasks, we might hurt our ability to generalise in the policy space, as our first experiment suggest (see Figure 4). By having a broader distribution , we can learn about more diverse policies in this space, but we will also increase our off-policiness. We can see from Figure 5, that our algorithm can successfully learn and operate in both of these regimes.
For the distributed collection of data we used actors per task. Each actor gathered trajectories of length that were then added to the common queue. The collection of data followed an -greedy policy with a fixed . The training curves shown in the paper correspond to the performance of the the -greedy policy (that is, they include exploratory actions of the agents).
All agents were evaluated in the same fashion. During the training process, periodically (every 20M frames) we will evaluate the agents performance on a test of held out test tasks. We take these intermediate snapshots of our agents and ’freeze’ their parameters to assess zero-shot generalisation. Once a test task is provided, the agent interacts with the environment for 20 episodes, one minute each and the average (undiscounted) reward is recorded. These produce the evaluation curves in Figure 4. Evaluations are done with a small , following a GPI policy with different instantiations of . For the pure UVFA agents, the evaluation is similar: -greedy on the produced value functions , with the same evaluation .
In our experiments we defined a set of easy test tasks (close to ) and a set of harder tasks, in order to cover reasonably well a few distinct scenarios:
Testing generalisation to tasks very similar to the training set, e.g. ;
Testing generalisation to harder tasks with different reward profiles: only positive rewards, only negative rewards, and mixed rewards.
In the main text, we included only a selection of these for illustrative purposes. Here we present the full results.
This section contains the complete results of the first experiment conducted. As a reminder, in this experiment we were training a USFA agent on , with and compare its performance with two conventional UVFA agents (one trained on-policy and the other one using all the data generated to learn off-policy) on a range of unseen test tasks. Complete set of result is included below, as follows: Figure 13 includes results on easy tasks, close to the tasks contained in the training set (generalisation to those should be fairly straightforward); Figure 14 and Figure 15 present results on more challenging tasks, quite far away from the training set, testing out agents ability to generate to the whole 4D hypercube.
In this section, we include the omitted results from our second experiment. As a reminder, in this experiment we were training two USFA agents on the same set of canonical tasks, but employing different distributions
, one will low variance
, focusing in learning policies around the training set , and another one with larger variance , that will try to learn about a lot more policies away from the training set, thus potentially facilitating the generalisation provided by the UVFA component. Results are displayed in Figures 16-17 on all tasks in the hard evaluation set.We also trained our USFA agent on a larger set of training tasks that include the previous canonical tasks, as well as four other tasks that contain both positive and negative reward 1000, 0100, 0010, 0001, 1-100, 01-10, 001-1, -1000. Thus we expect this agent to generalises better as a result of its training. A selection of these results and sample performance in training are included in Fig. 18.