Datasets:
Tasks:
Question Answering
Modalities:
Image
Formats:
imagefolder
Languages:
English
Size:
100K - 1M
ArXiv:
License:
Add files using upload-large-folder tool
Browse filesFiles changed (50)
- md/train/0IOX0YcCdTn/0IOX0YcCdTn.mdAdded+513
- md/train/0cmMMy8J5q/0cmMMy8J5q.mdAdded+357
- md/train/1XwPDFrJObw/1XwPDFrJObw.mdAdded+361
- md/train/8twKpG5s8Qh/8twKpG5s8Qh.mdAdded+330
- md/train/A5VV3UyIQz/A5VV3UyIQz.mdAdded+391
- md/train/B1ZZTfZAW/B1ZZTfZAW.mdAdded+344
- md/train/BJxwPJHFwS/BJxwPJHFwS.mdAdded
- md/train/BkxUvnEYDH/BkxUvnEYDH.mdAdded+522
- md/train/BkxnKkrtvS/BkxnKkrtvS.mdAdded+499
- md/train/ByJDAIe0b/ByJDAIe0b.mdAdded+487
- md/train/CZ8Y3NzuVzO/CZ8Y3NzuVzO.mdAdded+251
- md/train/DNl5s5BXeBn/DNl5s5BXeBn.mdAdded+446
- md/train/ETBc_MIMgoX/ETBc_MIMgoX.mdAdded+357
- md/train/H1fl8S9ee/H1fl8S9ee.mdAdded+379
- md/train/H1lefTEKDS/H1lefTEKDS.mdAdded+514
- md/train/HyGTuv9eg/HyGTuv9eg.mdAdded+224
- md/train/Ja-hVQrfeGZ/Ja-hVQrfeGZ.mdAdded
- md/train/MRQJmsNPp8E/MRQJmsNPp8E.mdAdded
- md/train/OdklztJBBYH/OdklztJBBYH.mdAdded
- md/train/Rd138pWXMvG/Rd138pWXMvG.mdAdded
- md/train/S191YzbRZ/S191YzbRZ.mdAdded
- md/train/SJxzFySKwH/SJxzFySKwH.mdAdded
- md/train/Syg-YfWCW/Syg-YfWCW.mdAdded
- md/train/SygXPaEYvH/SygXPaEYvH.mdAdded
- md/train/SyhRVm-Rb/SyhRVm-Rb.mdAdded
- md/train/Syx5eT4KDS/Syx5eT4KDS.mdAdded
- md/train/WZnVnlFBKFj/WZnVnlFBKFj.mdAdded
- md/train/bM4Iqfg8M2k/bM4Iqfg8M2k.mdAdded
- md/train/dmCL033_YwO/dmCL033_YwO.mdAdded
- md/train/gwnoVHIES05/gwnoVHIES05.mdAdded
- md/train/kcI3T5qe1jr/kcI3T5qe1jr.mdAdded
- md/train/mQPBmvyAuk/mQPBmvyAuk.mdAdded
- md/train/nMefdZyJ7ie/nMefdZyJ7ie.mdAdded
- md/train/oSrM_jG_Ng/oSrM_jG_Ng.mdAdded
- md/train/r1Ue8Hcxg/r1Ue8Hcxg.mdAdded
- md/train/r1Usiwcex/r1Usiwcex.mdAdded
- md/train/r1lUl6NFDH/r1lUl6NFDH.mdAdded
- md/train/r1xapAEKwS/r1xapAEKwS.mdAdded
- md/train/r1xjgxBFPB/r1xjgxBFPB.mdAdded
- md/train/rJzLciCqKm/rJzLciCqKm.mdAdded
- md/train/rkeYUsRqKQ/rkeYUsRqKQ.mdAdded
- md/train/rkgvXlrKwH/rkgvXlrKwH.mdAdded
- md/train/rkxmPgrKwB/rkxmPgrKwB.mdAdded
- md/train/ryewE3R5YX/ryewE3R5YX.mdAdded
- md/train/rylb3eBtwr/rylb3eBtwr.mdAdded
- md/train/ryxWIgBFPS/ryxWIgBFPS.mdAdded
- md/train/s-NI4H4e3Rf/s-NI4H4e3Rf.mdAdded
- md/train/ssohLcmn4-r/ssohLcmn4-r.mdAdded
- md/train/tc5qisoB-C/tc5qisoB-C.mdAdded
- md/train/wg_kD_nyAF/wg_kD_nyAF.mdAdded
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513# ALFWORLD: ALIGNING TEXT AND EMBODIED ENVIRONMENTS FOR INTERACTIVE LEARNING
Mohit Shridhar† Xingdi Yuan♡ Marc-Alexandre Côté♡ Yonatan Bisk‡ Adam Trischler♡ Matthew Hausknecht †University of Washington ♡Microsoft Research, Montréal ‡Carnegie Mellon University ♣Microsoft Research
ALFWorld.github.io
# ABSTRACT
Given a simple request like Put a washed apple in the kitchen fridge, humans can reason in purely abstract terms by imagining action sequences and scoring their likelihood of success, prototypicality, and efficiency, all without moving a muscle. Once we see the kitchen in question, we can update our abstract plans to fit the scene. Embodied agents require the same abilities, but existing work does not yet provide the infrastructure necessary for both reasoning abstractly and executing concretely. We address this limitation by introducing ALFWorld, a simulator that enables agents to learn abstract, text-based policies in TextWorld (Côté et al., 2018) and then execute goals from the ALFRED benchmark (Shridhar et al., 2020) in a rich visual environment. ALFWorld enables the creation of a new BUTLER agent whose abstract knowledge, learned in TextWorld, corresponds directly to concrete, visually grounded actions. In turn, as we demonstrate empirically, this fosters better agent generalization than training only in the visually grounded environment. BUTLER’s simple, modular design factors the problem to allow researchers to focus on models for improving every piece of the pipeline (language understanding, planning, navigation, and visual scene understanding).
# 1 INTRODUCTION
Consider helping a friend prepare dinner in an unfamiliar house: when your friend asks you to clean and slice an apple for an appetizer, how would you approach the task? Intuitively, one could reason abstractly: (1) find an apple (2) wash the apple in the sink (3) put the clean apple on the cutting board (4) find a knife (5) use the knife to slice the apple (6) put the slices in a bowl. Even in an unfamiliar setting, abstract reasoning can help accomplish the goal by leveraging semantic priors. Priors like locations of objects – apples are commonly found in the kitchen along with implements for cleaning and slicing, object affordances – a sink is useful for washing an apple unlike a refrigerator, pre-conditions – better to wash an apple before slicing it, rather than the converse. We hypothesize that, learning to solve tasks using abstract language, unconstrained by the particulars of the physical world, enables agents to complete embodied tasks in novel environments by leveraging the kinds of semantic priors that are exposed by abstraction and interaction.
 Figure 1: ALFWorld: Interactive aligned text and embodied worlds. An example with high-level text actions (left) and low-level physical actions (right).
To test this hypothesis, we have created the novel ALFWorld framework, the first interactive, parallel environment that aligns text descriptions and commands with physically embodied robotic simulation. We build ALFWorld by extending two prior works: TextWorld (Côté et al., 2018) - an engine for interactive text-based games, and ALFRED (Shridhar et al., 2020) - a large scale dataset for visionlanguage instruction following in embodied environments. ALFWorld provides two views of the same underlying world and two modes by which to interact with it: TextWorld, an abstract, text-based environment, generates textual observations of the world and responds to high-level text actions; ALFRED, the embodied simulator, renders the world in high-dimensional images and responds to low-level physical actions as from a robot (Figure 1).1 Unlike prior work on instruction following (MacMahon et al., 2006; Anderson et al., 2018a), which typically uses a static corpus of cross-modal expert demonstrations, we argue that aligned parallel environments like ALFWorld offer a distinct advantage: they allow agents to explore, interact, and learn in the abstract environment of language before encountering the complexities of the embodied environment.
While fields such as robotic control use simulators like MuJoCo (Todorov et al., 2012) to provide infinite data through interaction, there has been no analogous mechanism – short of hiring a human around the clock – for providing linguistic feedback and annotations to an embodied agent. TextWorld addresses this discrepancy by providing programmatic and aligned linguistic signals during agent exploration. This facilitates the first work, to our knowledge, in which an embodied agent learns the meaning of complex multi-step policies, expressed in language, directly through interaction.
Empowered by the ALFWorld framework, we introduce BUTLER (Building Understanding in Textworld via Language for Embodied Reasoning), an agent that first learns to perform abstract tasks in TextWorld using Imitation Learning (IL) and then transfers the learned policies to embodied tasks in ALFRED. When operating in the embodied world, BUTLER leverages the abstract understanding gained from TextWorld to generate text-based actions; these serve as high-level subgoals that facilitate physical action generation by a low-level controller. Broadly, we find that BUTLER is capable of generalizing in a zero-shot manner from TextWorld to unseen embodied tasks and settings. Our results show that training first in the abstract text-based environment is not only $7 \times$ faster, but also yields better performance than training from scratch in the embodied world. These results lend credibility to the hypothesis that solving abstract language-based tasks can help build priors that enable agents to generalize to unfamiliar embodied environments.
Our contributions are as follows:
$\ S 2$ ALFWorld environment: The first parallel interactive text-based and embodied environment.
$\ S \ O 3$ BUTLER architecture: An agent that learns high-level policies in language that transfer to low-level embodied executions, and whose modular components can be independently upgraded.
$\ S 4$ Generalization: We demonstrate empirically that BUTLER, trained in the abstract text domain, generalizes better to unseen embodied settings than agents trained from corpora of demonstrations or from scratch in the embodied world.
# 2 ALIGNING ALFRED AND TEXTWORLD
The ALFRED dataset (Shridhar et al., 2020), set in the THOR simulator (Kolve et al., 2017), is a benchmark for learning to complete embodied household tasks using natural language instructions and egocentric visual observations. As shown in Figure 1 (right), ALFRED tasks pose challenging interaction and navigation problems to an agent in a high-fidelity simulated environment. Tasks are annotated with a goal description that describes the objective (e.g., “put a pan on the dining table”). We consider both template-based and human-annotated goals; further details on goal specification can be found in Appendix H. Agents observe
<table><tr><td rowspan=1 colspan=1>Task type</td><td rowspan=1 colspan=2># train # seen# unseen</td></tr><tr><td rowspan=7 colspan=1>Pick&PlaceExamine in LightClean&PlaceHeat &PlaceCool &PlacePick Two &PlaceAll</td><td rowspan=1 colspan=1>790</td><td rowspan=1 colspan=1>35 24</td></tr><tr><td rowspan=1 colspan=1>308</td><td rowspan=1 colspan=1>18</td></tr><tr><td rowspan=1 colspan=1>650</td><td rowspan=1 colspan=1>31</td></tr><tr><td rowspan=1 colspan=1>459</td><td rowspan=1 colspan=1>16 23</td></tr><tr><td rowspan=1 colspan=1>533</td><td rowspan=1 colspan=1>25 21</td></tr><tr><td rowspan=1 colspan=1>813</td><td rowspan=1 colspan=1>17</td></tr><tr><td rowspan=1 colspan=1>3,553</td><td rowspan=1 colspan=1>134</td></tr></table>
Table 1: Six ALFRED task types with heldout seen and unseen evaluation sets.
the world through high-dimensional pixel images and interact using low-level action primitives: MOVEAHEAD, ROTATELEFT/RIGHT, LOOKUP/DOWN, PICKUP, PUT, OPEN, CLOSE, and TOGGLEON/OFF.
The ALFRED dataset also includes crowdsourced language instructions like “turn around and walk over to the microwave” that explain how to complete a goal in a step-by-step manner. We depart from the ALFRED challenge by omitting these step-by-step instructions and focusing on the more diffcult problem of using only on goal descriptions specifying what needs to be achieved.
Our aligned ALFWorld framework adopts six ALFRED task-types (Table 1) of various difficulty levels.2 Tasks involve first finding a particular object, which often requires the agent to open and search receptacles like drawers or cabinets. Subsequently, all tasks other than Pick & Place require some interaction with the object such as heating (place object in microwave and start it) or cleaning (wash object in a sink). To complete the task, the object must be placed in the designated location.
Within each task category there is significant variation: the embodied environment includes 120 rooms (30 kitchens, 30 bedrooms, 30 bathrooms, 30 living rooms), each dynamically populated with a set of portable objects (e.g., apple, mug), and static receptacles (e.g., microwave, fridge). For each task type we construct a larger train set, as well as seen and unseen validation evaluation sets: (1): seen consists of known task instances {task-type, object, receptacle, room} in rooms seen during training, but with different instantiations of object locations, quantities, and visual appearances (e.g. two blue pencils on a shelf instead of three red pencils in a drawer seen in training). (2): unseen consists of new task instances with possibly known object-receptacle pairs, but always in unseen rooms with different receptacles and scene layouts than in training tasks.
The seen set is designed to measure in-distribution generalization, whereas the unseen set measures out-of-distribution generalization. The scenes in ALFRED are visually diverse, so even the same task instance can lead to very distinct tasks, e.g., involving differently colored apples, shaped statues, or textured cabinets. For this reason, purely vision-based agents such as the unimodal baselines in Section 5.2 often struggle to generalize to unseen environments and objects.
The TextWorld framework (Côté et al., 2018) procedurally generates text-based environments for training and evaluating language-based agents. In order to extend TextWorld to create text-based analogs of each ALFRED scene, we adopt a common latent structure representing the state of the simulated world. ALFWorld uses PDDL - Planning Domain Definition Language (McDermott et al., 1998) to describe each scene from ALFRED and to construct an equivalent text game using the TextWorld engine. The dynamics of each game are defined by the PDDL domain (see Appendix C for additional details). Textual observations shown in Figure 1 are generated with templates sampled from a context-sensitive grammar designed for the ALFRED environments. For interaction, TextWorld environments use the following high-level actions:
goto {recep} open {recep} clean {obj} with {recep}
take {obj} from {recep} put {obj} in/on {recep} close {recep} toggle {obj}{recep} heat {obj} with {recep} cool {obj} with {recep} where {obj} and {recep} correspond to objects and receptacles. Note that heat, cool, clean, and goto are high-level actions that correspond to several low-level embodied actions.
ALFWorld, in summary, is an cross-modal framework featuring a diversity of embodied tasks with analogous text-based counterparts. Since both components are fully interactive, agents may be trained in either the language or embodied world and evaluated on heldout test tasks in either modality. We believe the equivalence between objects and interactions across modalities make ALFWorld an ideal framework for studying language grounding and cross-modal learning.
# 3 INTRODUCING BUTLER: AN EMBODIED MULTI-TASK AGENT
We investigate learning in the abstract language modality before generalizing to the embodied setting. The BUTLER agent uses three components to span the language and embodied modalities: BUTLER::BRAIN – the abstract text agent, BUTLER::VISION – the language state estimator, and BUTLER::BODY – the low-level controller. An overview of BUTLER is shown in Figure 2 and each component is described below.
 Figure 2: BUTLER Agent consists of three modular components. 1) BUTLER::BRAIN: a text agent pre-trained with the TextWorld engine (indicated by the dashed yellow box) which simulates an abstract textual equivalent of the embodied world. When subsequently applied to embodied tasks, it generates high-level actions that guide the controller. 2) BUTLER::VISION: a state estimator that translates, at each time step, the visual frame $v _ { t }$ from the embodied world into a textual observation $o _ { t }$ using a pre-trained Mask R-CNN detector. The generated observation $o _ { t }$ , the initial observation $o _ { 0 }$ , and the task goal $g$ are used by the text agent the to predict the next high-level action $a _ { t }$ . 3) BUTLER::BODY: a controller that translates the high-level text action $a _ { t }$ into a sequence of one or more low-level embodied actions.
# 3.1 BUTLER::BRAIN (TEXT AGENT) $\mathbf { \partial } : o _ { 0 } , o _ { t } , g \to a _ { t }$
BUTLER::BRAIN is a novel text-based game agent that generates high-level text actions in a token-by-token fashion akin to Natural Language Generation (NLG) approaches for dialogue (Sharma et al., 2017) and summarization (Gehrmann et al., 2018). An overview of the agent’s architecture is shown in Figure 3. At game step $t$ , the encoder takes the initial text observation $o _ { 0 }$ , current observation $o _ { t }$ , and the goal description $g$ as input and generates a context
 Figure 3: BUTLER::BRAIN: The text agent takes the initial/current observations $o _ { 0 } / o _ { t }$ , and goal $g$ to generate a textual action $a _ { t }$ token-by-token.
aware representation of the current observable game state. The observation $o _ { 0 }$ explicitly lists all the navigable receptacles in the scene, and goal $g$ is sampled from a set of language templates (see Appendix $\mathrm { H }$ ). Since the games are partially observable, the agent only has access to the observation describing the effects of its previous action and its present location. Therefore, we incorporate two memory mechanisms to imbue the agent with history: (1) a recurrent aggregator, adapted from Yuan et al. (2018), combines the encoded state with recurrent state $h _ { t - 1 }$ from the previous game step; (2) an observation queue feeds in the $k$ most recent, unique textual observations. The decoder generates an action sentence $a _ { t }$ token-by-token to interact with the game. The encoder and decoder are based on a Transformer Seq2Seq model with pointer softmax mechanism (Gulcehre et al., 2016). We leverage pre-trained BERT embeddings (Sanh et al., 2019), and tie output embeddings with input embeddings (Press and Wolf, 2016). The agent is trained in an imitation learning setting with DAgger (Ross et al., 2011) using expert demonstrations. See Appendix A for complete details.
When solving a task, an agent might get stuck at certain states due to various failures (e.g., action is grammatically incorrect, wrong object name). The observation for a failed action does not contain any useful feedback, so a fully deterministic actor tends to repeatedly produce the same incorrect action. To address this problem, during evaluation in both TextWorld and ALFRED, BUTLER::BRAIN uses Beam Search (Reddy et al., 1977) to generate alternative action sentences in the event of a failed action. But otherwise greedily picks a sequence of best words for efficiency. Note that Beam Search is not used to optimize over embodied interactions like prior work (Wang et al., 2019). but rather to simply improve the generated action sentence during failures.
# 3.2 BUTLER::VISION (STATE ESTIMATOR) ∶ vt → ot
At test time, agents in the embodied world must operate purely from visual input. To this end, BUTLER::VISION’s language state estimator functions as a captioning module that translates visual observations $v _ { t }$ into textual descriptions $o _ { t }$ . Specifically, we use a pre-trained Mask R-CNN detector (He et al., 2017) to identify objects in the visual frame. The detector is trained separately in a supervised setting with random frames from ALFRED training scenes (see Appendix D). For each frame $v _ { t }$ , the detector generates $N$ detections $\{ ( c _ { 1 } , m _ { 1 } ) , ( c _ { 2 } , \bar { m _ { 2 } } ) , \ldots , ( c _ { N } , \bar { m _ { N } } ) \}$ , where $c _ { n }$ is the predicted object class, and $m _ { n }$ is a pixel-wise object mask. These detections are formatted into a sentence using a template e.g., On table 1, you see a mug 1, a tomato 1, and a tomato 2. To handle multiple instances of objects, each object is associated with a class $c _ { n }$ and a number ID e.g., tomato 1. Commands goto, open, and examine generate a list of detections, whereas all other commands generate affirmative responses if the action succeeds e.g., $a _ { t }$ : put mug 1 on desk $2 o _ { t + 1 }$ : You put mug 1 on desk 2, otherwise produce Nothing happens to indicate failures or no state-change. See Appendix G for a full list of templates. While this work presents preliminary results with template-based descriptions, future work could generate more descriptive observations using pre-trained image-captioning models (Johnson et al., 2016), video-action captioning frameworks (Sun et al., 2019), or scene-graph parsers (Tang et al., 2020).
$$\mathrm { U T L E R } { \mathrel { : } } \mathrm { B o D Y } \left( \mathrm { C O N T R O L L E R } \right) : v _ { t } , a _ { t } \to \left\{ \hat { a } _ { 1 } , \hat { a } _ { 2 } , \dots , \hat { a } _ { L } \right\}$$
The controller translates a high-level text action $a _ { t }$ into a sequence of $L$ low-level physical actions $\{ \hat { a } _ { 1 } , \hat { a } _ { 2 } , \dots , \hat { a } _ { L } \}$ that are executable in the embodied environment. The controller handles two types of commands: manipulation and navigation. For manipulation actions, we use the ALFRED API to interact with the simulator by providing an API action and a pixel-wise mask based on Mask R-CNN detections $m _ { n }$ that was produced during state-estimation. For navigation commands, each episode is initialized with a pre-built grid-map of the scene, where each receptacle instance is associated with a receptacle class and an interaction viewpoint $( x , y , \theta , \phi )$ with $x$ and $y$ representing the 2D position, $\theta$ and $\phi$ representing the agent’s yaw rotation and camera tilt. The goto command invokes an $\mathbf { A } ^ { * }$ planner to find the shortest path between two viewpoints. The planner outputs a sequence of $L$ displacements in terms of motion primitives: MOVEAHEAD, ROTATERIGHT, ROTATELEFT, LOOKUP, and LOOKDOWN, which are executed in an open-loop fashion via the ALFRED API. We note that a given pre-built grid-map of receptacle locations is a strong prior assumption, but future work could incorporate existing models from the vision-language navigation literature (Anderson et al., 2018a; Wang et al., 2019) for map-free navigation.
# 4 EXPERIMENTS
We design experiments to answer the following questions: (1) How important is an interactive language environment versus a static corpus? (2) Do policies learnt in TextWorld transfer to embodied environments? (3) Can policies generalize to human-annotated goals? (4) Does pre-training in an abstract textual environment enable better generalization in the embodied world?
# 4.1 IMPORTANCE OF INTERACTIVE LANGUAGE
The first question addresses our core hypothesis that training agents in interactive TextWorld environments leads to better generalization than training agents with a static linguistic corpus. To test this hypothesis, we use DAgger (Ross et al., 2011) to train the BUTLER::BRAIN agent in TextWorld and compare it against Seq2Seq, an identical agent trained with Behavior Cloning from an equivalentlysized corpus of expert demonstrations. The demonstrations come from the same expert policies and we control the number of episodes to ensure a fair comparison. Table 2 presents results for agents trained in TextWorld and subsequently evaluated in embodied environments in a zero-shot manner. The agents are trained independently on individual tasks and also jointly on all six task types. For each task category, we select the agent with best evaluation performance in TextWorld (from 8 random seeds); this is done separately for each split: seen and unseen. These best-performing agents are then evaluated on the heldout seen and unseen embodied ALFRED tasks. For embodied evaluations, we also report goal-condition success rates, a metric proposed in ALFRED (Shridhar et al., 2020) to measure partial goal completion.
<table><tr><td rowspan="2">task-type</td><td colspan="2">TextWorld</td><td colspan="2">Seq2Seq</td><td colspan="2">BUTLER</td><td colspan="2">BUTLER-ORACLE</td><td colspan="2">Human Goals</td></tr><tr><td>seen</td><td>unseen</td><td>seen</td><td>unseen</td><td>seen</td><td>unseen</td><td>seen</td><td>unseen</td><td>seen</td><td>unseen</td></tr><tr><td>Pick&Place</td><td>69</td><td>50</td><td>28(28)</td><td>17 (17)</td><td>30 (30)</td><td>24 (24)</td><td>53 (53)</td><td>31 (31)</td><td>20 (20)</td><td>10 (10)</td></tr><tr><td>Examine in Light</td><td>69</td><td>39</td><td>5(13)</td><td>0 (6)</td><td>10 (26)</td><td>0 (15)</td><td>22 (41)</td><td>12 (37)</td><td>2 (9)</td><td>0 (8)</td></tr><tr><td>Clean & Place</td><td>67</td><td>74</td><td>32 (41)</td><td>12 (31)</td><td>32 (46)</td><td>22 (39)</td><td>44 (57)</td><td>41 (56)</td><td>18 (31)</td><td>22 (39)</td></tr><tr><td>Heat&Place</td><td>88</td><td>83</td><td>10 (29)</td><td>12 (33)</td><td>17 (38)</td><td>16 (39)</td><td>60 (66)</td><td>60 (72)</td><td>8 (29)</td><td>5 (30)</td></tr><tr><td>Cool & Place</td><td>76</td><td>91</td><td>2(19)</td><td>21 (34)</td><td>5 (21)</td><td>19 (33)</td><td>41 (49)</td><td>27 (44)</td><td>7(26)</td><td>17 (34)</td></tr><tr><td>Pick Two & Place</td><td>54</td><td>65</td><td>12 (23)</td><td>0 (26)</td><td>15 (33)</td><td>8 (30)</td><td>32 (42)</td><td>29 (44)</td><td>6(16)</td><td>0 (6)</td></tr><tr><td>All Tasks</td><td>40</td><td>35</td><td>6(15)</td><td>5(14)</td><td>19 (31)</td><td>10 (20)</td><td>37 (46)</td><td>26 (37)</td><td>8(17)</td><td>3 (12)</td></tr></table>
Table 2: Zero-shot Domain Transfer. Left: Success percentages of the best BUTLER::BRAIN agents evaluated purely in TextWorld. Mid-Left: Success percentages after zero-shot transfer to embodied environments. Mid-Right: Success percentages of BUTLER with an oracle state-estimator and controller, an upper-bound. Right: Success percentages of BUTLER with human-annotated goal descriptions, an additional source of generalization difficulty. All successes are averaged across three evaluation runs. Goal-condition success rates (Shridhar et al., 2020) are given in parentheses. The Seq2Seq baseline is trained in TextWorld from pre-recorded expert demonstrations using standard supervised learning. BUTLER is our main model using the Mask R-CNN detector and $\mathbf { A } ^ { * }$ navigator. BUTLER-ORACLE uses an oracle state-estimator with ground-truth object detections and an oracle controller that directly teleports between locations.
Comparing BUTLER to Seq2Seq, we see improved performance on all types of seen tasks and five of the seven types of unseen tasks, supporting the hypothesis that interactive TextWorld training is a key component in generalizing to unseen embodied tasks. Interactive language not only allows agents to explore and build an understanding of successful action patterns, but also to recover from mistakes. Through trial-and-error the BUTLER agent learns task-guided heuristics, e.g., searching all the drawers in kitchen to look for a knife. As Table 2 shows, these heuristics are subsequently more capable of generalizing to the embodied world. More details on TextWorld training and generalization performance can be found in Section 5.1.
# 4.2 TRANSFERRING TO EMBODIED TASKS
Since TextWorld is an abstraction of the embodied world, transferring between modalities involves overcoming domain gaps that are present in the real world but not in TextWorld. For example, the physical size of objects and receptacles must be respected – while TextWorld will allow certain objects to be placed inside any receptacle, in the embodied world it might be impossible to put a larger object into a small receptacle (e.g. a large pot into a microwave).
Subsequently, a TextWorld-trained agent’s ability to solve embodied tasks is hindered by these domain gaps. So to study the transferability of the text agent in isolation, we introduce BUTLER-ORACLE in Table 2, an oracle variant of BUTLER which uses perfect state-estimation, object-detection, and navigation. Despite these advantages, we nevertheless observe a notable drop in performance from TextWorld to BUTLER-ORACLE. This performance gap results from the domain gaps described above as well as misdetections from Mask R-CNN and navigation failures caused by collisions. Future work might address this issue by reducing the domain gap between the two environments, or performing additional fine-tuning in the embodied setting.
The supplementary video contains qualitative examples of the BUTLER agent solving tasks in unseen environments. It showcases 3 successes and 1 failure of a TextWorld-only agent trained on All Tasks. In “put a watch in the safe”, the agent has never seen the ‘watch’-‘safe’ combination as a goal.
# 4.3 GENERALIZING TO HUMAN-ANNOTATED GOALS
BUTLER is trained with templated language, but in realistic scenarios, goals are often posed with open-ended natural language. In Table 2, we present Human Goals results of BUTLER evaluated on human-annotated ALFRED goals, which contain 66 unseen verbs (e.g., ‘wash’, ‘grab’, ‘chill’) and 189 unseen nouns (e.g., ‘rag’, ‘lotion’, ‘disc’; see Appendix H for full list). Surprisingly, we find non-trivial goal-completion rate indicating that certain categories of task, such as pick and place, are quite generalizable to human language. While these preliminary results with natural language are encouraging, we expect future work could augment the templated language with synthetic-to-real transfer methods (Marzoev et al., 2020) for better generalization.
4.4 TO PRETRAIN OR NOT TO PRETRAIN IN TEXTWORLD?
Given the domain gap between TextWorld and the embodied world, Why not eliminate this gap by training from scratch in the embodied world? To answer this question, we investigate three training strategies: (i) EMBODIED-ONLY: pure embodied training, (ii) TW-ONLY: pure TextWorld training followed by zero-shot embodied transfer and
<table><tr><td rowspan=2 colspan=1>Training Strategy</td><td rowspan=2 colspan=1> train(succ %)</td><td rowspan=1 colspan=1>seen</td><td rowspan=2 colspan=1>unseen train speed(succ %) (eps/s)</td></tr><tr><td rowspan=1 colspan=1>(succ %)</td></tr><tr><td rowspan=3 colspan=1>EMBODIED-ONLYTW-ONLYHYBRID</td><td rowspan=1 colspan=1>21.6</td><td rowspan=1 colspan=1>33.6</td><td rowspan=2 colspan=1>23.1 0.934.3 6.1</td></tr><tr><td rowspan=2 colspan=1>23.111.9</td><td rowspan=1 colspan=1>27.1</td></tr><tr><td rowspan=1 colspan=1>21.4</td><td rowspan=1 colspan=1>23.1 0.7</td></tr></table>
Table 3: Training Strategy Success. Trained on All Tasks for 50K episodes and evaluated in embodied scenes using an oracle state-estimator and controller.
(iii) HYBRID training that switches between the two environments with $7 5 \%$ probability for TextWorld and $2 5 \%$ for embodied world. Table 3 presents success rates for these agents trained and evaluated on All Tasks. All evaluations were conducted with an oracle state-estimator and controller. For a fair comparison, each agent is trained for 50K episodes and the training speed is recorded for each strategy. We report peak performance for each split.
Results indicate that TW-ONLY generalizes better to unseen environments while EMBODIED-ONLY quickly overfits to seen environments (even with a perfect object detector and teleport navigator). We hypothesize that the abstract TextWorld environment allows the agent to focus on quickly learning tasks without having to deal execution-failures and expert-failures caused by physical constraints inherent to embodied environments. TextWorld training is also $7 \times$ faster4 since it does not require running a rendering or physics engine like in the embodied setting. See Section F for more quantitative evaluations on the benefits of training in TextWorld.
# 5 ABLATIONS
We conduct ablation studies to further investigate: (1) The generalization performance of BUTLER::BRAIN within TextWorld environments, (2) The ability of unimodal agents to learn directly through visual observations or action history, (3) The importance of various hyper-parameters and modeling choices for the performance of BUTLER::BRAIN.
# 5.1 GENERALIZATION WITHIN TEXTWORLD
We train and evaluate BUTLER::BRAIN in abstract TextWorld environments spanning the six tasks in Table 1, as well as All Tasks. Similar to the zero-shot results presented in Section 4.1, the All Tasks setting shows the extent to which a single policy can learn and generalize on the large set of 3,553 different tasks, but here without having to deal with failures from embodied execution.
We first experimented with training BUTLER::BRAIN through reinforcement learning (RL) where the agent is rewarded after completing a goal. Due to the infesibility of using candidate commands or command templates as discussed in Section I, the RL agent had to generate actions token-by-token. Since the probability of randomly stumbling upon a grammatically correct and contextually valid action is very low (7.02e-44 for sequence length 10), the RL agent struggled to make any meaningful progress towards the tasks.
After concluding that current reinforcement learning approaches were not successful on our set of training tasks, we turned to DAgger (Ross et al., 2011) assisted by a rule-based expert (detailed in Appendix E). BUTLER::BRAIN is trained for 100K episodes using data collected by interacting with the set of training games.
Results in Table 4 show (i) Training success rate varies from $1 6 \mathrm { - } 6 0 \%$ depending on the category of tasks, illustrating the challenge of solving hundreds to thousands of training tasks within each category. (ii) Transferring from training to heldout test games typically reduces performance, with the unseen rooms leading to the largest performance drops. Notable exceptions include heat and cool tasks where unseen performance exceeds training performance. (iii) Beam search is a key contributor to test performance; its ablation causes a performance drop of $21 \%$ on the seen split of All Tasks. (iv) Further ablating the DAgger strategy and directly training a Sequence-to-Sequence (Seq2Seq) model
<table><tr><td></td><td colspan="3">Pick &Place</td><td colspan="3">Examine in Light</td><td colspan="3">Clean& Place</td><td colspan="3">Heat & Place</td><td colspan="3">Cool& Place</td><td colspan="3">Pick Two& Place</td><td colspan="3">All Tasks</td></tr><tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td>tn</td><td>sn</td><td>un</td><td>tn</td><td>sn</td><td>un</td><td>tn</td><td>sn</td><td>un</td><td>tn</td><td>sn</td><td>un</td><td>tn</td><td>sn</td><td>un</td><td>tn</td><td>sn</td><td>un</td><td>tn</td><td>sn</td><td>un</td></tr><tr><td>BUTLER</td><td>54 54</td><td>61</td><td>46</td><td>59</td><td>39</td><td>22</td><td>37</td><td>44</td><td>39</td><td>60</td><td>81</td><td>74</td><td>46</td><td>60</td><td>100</td><td>27</td><td>29</td><td>24</td><td>16</td><td>40</td><td>37</td></tr><tr><td>BUTLERg Seq2Seq</td><td>31</td><td>43 26</td><td>33 8</td><td>59</td><td>31 31</td><td>17</td><td>37</td><td>30</td><td>26 42</td><td>60 36</td><td>69 50</td><td>70 30</td><td>46 27</td><td>50 32</td><td>76 33</td><td>27 17</td><td>38 8</td><td>12 6</td><td>16 9</td><td>19 10</td><td>22</td></tr><tr><td></td><td></td><td></td><td></td><td>44</td><td></td><td>11</td><td>34</td><td>30</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>9</td></tr></table>
Table 4: Generalization within TextWorld environments: We independently train BUTLER::BRAIN on each type of TextWorld task and evaluate on heldout scenes of the same type. Respectively, tn/sn/un indicate success rate on train/seen/unseen tasks. All sn and un scores are computed using the random seeds (from 8 in total) producing the best final training score on each task type. BUTLER is trained with DAgger and performs beam search during evaluation. Without beam search, ${ \bf B U T L E R } _ { g }$ decodes actions greedily and gets stuck repeating failed actions. Further removing DAgger and training the model in a Seq2Seq fashion leads to worse generalization. Note that tn scores for BUTLER are lower than sn and un as they were computed without beam search.
with pre-recorded expert demonstrations causes a bigger performance drop of $30 \%$ on seen split of All Tasks. These results suggest that online interaction with the environment, as facilitated by DAgger learning and beam search, is essential for recovering from mistakes and sub-optimal behavior.
# 5.2 UNIMODAL BASELINES
Table 5 presents results for unimodal baseline comparisons to BUTLER. For all baselines, the action space and controller are fixed, but the state space is substituted with different modalities. To study the agents’ capability of learning a single policy that generalizes across various tasks, we train and evaluate on All Tasks. In VISION (RESNET18), the textual observation from the state-estimator is replaced with ResNet-18 fc7 features (He et al., 2016) from the visual frame. Similarly, VISION (MCNN-FPN) uses the pre-trained Mask R-CNN from the state-estimator to extract FPN layer features for the whole image. ACTION-ONLY acts without any visual or textual feedback. We report peak performance for each split.
Table 5: Unimodal Baselines. Trained on All Tasks with 50K episodes and evaluated in the embodied environment.
<table><tr><td>Agent</td><td>seen (succ %)</td><td>unseen (succ %)</td></tr><tr><td>BUTLER</td><td>18.8</td><td>10.1</td></tr><tr><td>VISION (RESNET18)</td><td>10.0</td><td>6.0</td></tr><tr><td>VISION (MCNN-FPN)</td><td>11.4</td><td>4.5</td></tr><tr><td>ACTION-ONLY</td><td>0.0</td><td>0.0</td></tr></table>
The visual models tend to overfit to seen environments and generalize poorly to unfamiliar environments. Operating in text-space allows better transfer of policies without needing to learn state representations that are robust to visually diverse environments. The zero-performing ACTION-ONLY baseline indicates that memorizing action sequences is an infeasible strategy for agents.
# 5.3 MODEL ABLATIONS
Figure 4 illustrates more factors that affect the performance of BUTLER::BRAIN. The three rows of plots show training curves, evaluation curves in seen and unseen settings, respectively. All experiments were trained and evaluated on All Tasks with 8 random seeds.
In the first column, we show the effect of using different observation queue lengths $k$ as described in Section 3.1, in which size 0 refers to not providing any observation information to the agent. In the second column, we examine the effect of explicitly keeping the initial observation $o _ { 0 }$ , which lists all the receptacles in the
 Figure 4: Model ablations on All Tasks. $\mathbf { X }$ -axis: 0 to $5 0 \mathrm { k }$ episodes; y-axis: normalized success from 0 to $7 5 \%$ .
scene. Keeping the initial observation $o _ { 0 }$ facilitates the decoder to generate receptacle words more accurately for unseen tasks, but may be unnecessary in seen environments. The third column suggests that the recurrent component in our aggregator is helpful in making history-based decisions particularly in seen environments where keeping track of object locations is useful. Finally, in the fourth column, we see that using more training games can lead to better generalizability in both seen and unseen settings. Fewer training games achieve high training scores by quickly overfitting, which lead to zero evaluation scores.
# 6 RELATED WORK
The longstanding goal of grounding language learning in embodied settings (Bisk et al., 2020) has lead to substantial work on interactive environments. ALFWorld extends that work with fully-interactive aligned environments that parallel textual interactions with photo-realistic renderings and physical interactions.
Interactive Text-Only Environments: We build on the work of text-based environments like TextWorld (Côté et al., 2018) and Jericho (Hausknecht et al., 2020). While these environment allow for textual interactions, they are not grounded in visual or physical modalities.
Vision and language: While substantial work exists on vision-language representation learning e.g., MAttNet (Yu et al., 2018b), CMN (Hu et al., 2017), VQA (Antol et al., 2015), CLEVR (Johnson et al., 2017), ViLBERT (Lu et al., 2019), they lack embodied or sequential decision making.
Embodied Language Learning: To address language learning in embodied domains, a number of interactive environments have been proposed: BabyAI (Chevalier-Boisvert et al., 2019), Room2Room (Anderson et al., 2018b), ALFRED (Shridhar et al., 2020), InteractiveQA (Gordon et al., 2018), EmbodiedQA (Das et al., 2018), and NetHack (Küttler et al., 2020). These environments use language to communicate instructions, goals, or queries to the agent, but not as a fully-interactive textual modality.
Language for State and Action Representation: Others have used language for more than just goal-specification. Schwartz et al. (2019) use language as an intermediate state to learn policies in VizDoom. Similarly, Narasimhan et al. (2018) and Zhong et al. (2020) use language as an intermediate representation to transfer policies across different environments. Hu et al. (2019) use a natural language instructor to command a low-level executor, and Jiang et al. (2019) use language as an abstraction for hierarchical RL. However these works do not feature an interactive text environment for pre-training the agent in an abstract textual space. Zhu et al. (2017) use high-level commands similar to ALFWorld to solve tasks in THOR with IL and RL-finetuning methods, but the policy only generalizes to a small set of tasks due to the vision-based state representation. Using symbolic representations for state and action is also an inherent characteristic of works in task-and-motionplanning (Kaelbling and Lozano-Pérez, 2011; Konidaris et al., 2018) and symbolic planning (Asai and Fukunaga, 2017).
World Models: The concept of using TextWorld as a “game engine” to represent the world is broadly related to inverse graphics (Kulkarni et al., 2015) and inverse dynamics (Wu et al., 2017) where abstract visual or physical models are used for reasoning and future predictions. Similarly, some results in cognitive science suggest that humans use language as a cheaper alternative to sensorimotor simulation (Banks et al., 2020; Dove, 2014).
# 7 CONCLUSION
We introduced ALFWorld, the first interactive text environment with aligned embodied worlds. ALFWorld allows agents to explore, interact, and learn abstract polices in a textual environment. Pre-training our novel BUTLER agent in TextWorld, we show zero-shot generalization to embodied tasks in the ALFRED dataset. The results indicate that reasoning in textual space allows for better generalization to unseen tasks and also faster training, compared to other modalities like vision.
BUTLER is designed with modular components which can be upgraded in future work. Examples include the template-based state-estimator and the $\mathbf { A } ^ { * }$ navigator which could be replaced with learned modules, enabling end-to-end training of the full pipeline. Another avenue of future work is to learn “textual dynamics models” through environment interactions, akin to vision-based world models (Ha and Schmidhuber, 2018). Such models would facilitate construction of text-engines for new domains, without requiring access to symbolic state descriptions like PDDL. Overall, we are excited by the challenges posed by aligned text and embodied environments for better cross-modal learning.
# REFERENCES
Adhikari, A., Yuan, X., Côté, M.-A., Zelinka, M., Rondeau, M.-A., Laroche, R., Poupart, P., Tang, J., Trischler, A., and Hamilton, W. L. (2020). Learning dynamic belief graphs to generalize on text-based games. In Neural Information Processing Systems (NeurIPS).
Ammanabrolu, P. and Hausknecht, M. (2020). Graph constrained reinforcement learning for natural language action spaces. In International Conference on Learning Representations.
Anderson, P., Wu, Q., Teney, D., Bruce, J., Johnson, M., Sünderhauf, N., Reid, I., Gould, S., and van den Hengel, A. (2018a). Vision-and-language navigation: Interpreting visually-grounded navigation instructions in real environments. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition.
Anderson, P., Wu, Q., Teney, D., Bruce, J., Johnson, M., Sünderhauf, N., Reid, I., Gould, S., and van den Hengel, A. (2018b). Vision-and-Language Navigation: Interpreting visually-grounded navigation instructions in real environments. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition (CVPR).
Antol, S., Agrawal, A., Lu, J., Mitchell, M., Batra, D., Zitnick, C. L., and Parikh, D. (2015). VQA: Visual Question Answering. In International Conference on Computer Vision (ICCV).
Asai, M. and Fukunaga, A. (2017). Classical planning in deep latent space: Bridging the subsymbolicsymbolic boundary. arXiv preprint arXiv:1705.00154.
Ba, L. J., Kiros, J. R., and Hinton, G. E. (2016). Layer normalization. CoRR, abs/1607.06450.
Banks, B., Wingfield, C., and Connell, L. (2020). Linguistic distributional knowledge and sensorimo tor grounding both contribute to semantic category production.
Bisk, Y., Holtzman, A., Thomason, J., Andreas, J., Bengio, Y., Chai, J., Lapata, M., Lazaridou, A., May, J., Nisnevich, A., Pinto, N., and Turian, J. (2020). Experience Grounds Language. In Empirical Methods in Natural Language Processing.
Chevalier-Boisvert, M., Bahdanau, D., Lahlou, S., Willems, L., Saharia, C., Nguyen, T. H., and Bengio, Y. (2019). BabyAI: First steps towards grounded language learning with a human in the loop. In International Conference on Learning Representations.
Cho, K., van Merriënboer, B., Gulcehre, C., Bahdanau, D., Bougares, F., Schwenk, H., and Bengio, Y. (2014). Learning phrase representations using RNN encoder–decoder for statistical machine translation. In Proceedings of the 2014 Conference on Empirical Methods in Natural Language Processing (EMNLP).
Côté, M.-A., Kádár, A., Yuan, X., Kybartas, B., Barnes, T., Fine, E., Moore, J., Tao, R. Y., Hausknecht, M., Asri, L. E., Adada, M., Tay, W., and Trischler, A. (2018). Textworld: A learning environment for text-based games. CoRR, abs/1806.11532.
Das, A., Datta, S., Gkioxari, G., Lee, S., Parikh, D., and Batra, D. (2018). Embodied Question Answering. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition (CVPR).
Dove, G. (2014). Thinking in words: language as an embodied medium of thought. Topics in cognitive science, 6(3):371–389.
Gehrmann, S., Deng, Y., and Rush, A. (2018). Bottom-up abstractive summarization. In Proceedings of the 2018 Conference on Empirical Methods in Natural Language Processing.
Gordon, D., Kembhavi, A., Rastegari, M., Redmon, J., Fox, D., and Farhadi, A. (2018). Iqa: Visual question answering in interactive environments. In Computer Vision and Pattern Recognition (CVPR), 2018 IEEE Conference on.
Gulcehre, C., Ahn, S., Nallapati, R., Zhou, B., and Bengio, Y. (2016). Pointing the unknown words. In Proceedings of the 54th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers).
Ha, D. and Schmidhuber, J. (2018). Recurrent world models facilitate policy evolution. In Advances in Neural Information Processing Systems 31.
Hausknecht, M. and Stone, P. (2015). Deep recurrent q-learning for partially observable mdps. arXiv preprint arXiv:1507.06527.
Hausknecht, M. J., Ammanabrolu, P., Côté, M.-A., and Yuan, X. (2020). Interactive fiction games: A colossal adventure. In AAAI.
He, K., Gkioxari, G., Dollár, P., and Girshick, R. (2017). Mask r-cnn. In Proceedings of the IEEE international conference on computer vision.
He, K., Zhang, X., Ren, S., and Sun, J. (2016). Deep residual learning for image recognition. In Proceedings of the IEEE conference on computer vision and pattern recognition.
Helmert, M. (2006). The Fast Downward planning system. Journal of Artificial Intelligence Research.
Hu, H., Yarats, D., Gong, Q., Tian, Y., and Lewis, M. (2019). Hierarchical decision making by generating and following natural language instructions. In Advances in Neural Information Processing Systems.
Hu, R., Rohrbach, M., Andreas, J., Darrell, T., and Saenko, K. (2017). Modeling relationships in referential expressions with compositional modular networks. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition.
Jiang, Y., Gu, S. S., Murphy, K. P., and Finn, C. (2019). Language as an abstraction for hierarchical deep reinforcement learning. In Advances in Neural Information Processing Systems.
Johnson, J., Hariharan, B., van der Maaten, L., Fei-Fei, L., Zitnick, C. L., and Girshick, R. (2017). Clevr: A diagnostic dataset for compositional language and elementary visual reasoning. In CVPR.
Johnson, J., Karpathy, A., and Fei-Fei, L. (2016). Densecap: Fully convolutional localization networks for dense captioning. In Proceedings of the IEEE conference on computer vision and pattern recognition.
Kaelbling, L. P. and Lozano-Pérez, T. (2011). Hierarchical task and motion planning in the now. In 2011 IEEE International Conference on Robotics and Automation, pages 1470–1477. IEEE.
Kingma, D. P. and Ba, J. (2014). Adam: A method for stochastic optimization. arXiv preprint arXiv:1412.6980.
Kolve, E., Mottaghi, R., Han, W., VanderBilt, E., Weihs, L., Herrasti, A., Gordon, D., Zhu, Y., Gupta, A., and Farhadi, A. (2017). Ai2-thor: An interactive 3d environment for visual ai. arXiv preprint arXiv:1712.05474.
Konidaris, G., Kaelbling, L. P., and Lozano-Perez, T. (2018). From skills to symbols: Learning symbolic representations for abstract high-level planning. Journal of Artificial Intelligence Research, 61:215–289.
Kulkarni, T. D., Whitney, W. F., Kohli, P., and Tenenbaum, J. (2015). Deep convolutional inverse graphics network. In Advances in neural information processing systems.
Küttler, H., Nardelli, N., Miller, A. H., Raileanu, R., Selvatici, M., Grefenstette, E., and Rocktäschel, T. (2020). The nethack learning environment.
Lin, T.-Y., Maire, M., Belongie, S., Hays, J., Perona, P., Ramanan, D., Dollár, P., and Zitnick, C. L. (2014). Microsoft coco: Common objects in context. In European conference on computer vision.
Lu, J., Batra, D., Parikh, D., and Lee, S. (2019). Vilbert: Pretraining task-agnostic visiolinguistic representations for vision-and-language tasks. In Advances in Neural Information Processing Systems.
MacMahon, M., Stankiewicz, B., and Kuipers, B. (2006). Walk the talk: Connecting language, knowledge, and action in route instructions. In Proceedings of the 21st National Conference on Artificial Intelligence (AAAI-2006).
Marzoev, A., Madden, S., Kaashoek, M. F., Cafarella, M., and Andreas, J. (2020). Unnatural language processing: Bridging the gap between synthetic and natural language data. arXiv preprint arXiv:2004.13645. McDermott, D., Ghallab, M., Howe, A., Knoblock, C., Ram, A., Veloso, M., Weld, D., and Wilkins, D. (1998). Pddl-the planning domain definition language. Narasimhan, K., Barzilay, R., and Jaakkola, T. (2018). Grounding language for transfer in deep reinforcement learning. JAIR, 63(1):849–874. Press, O. and Wolf, L. (2016). Using the output embedding to improve language models. arXiv preprint arXiv:1608.05859. Reddy, D. R. et al. (1977). Speech understanding systems: A summary of results of the five-year research effort. Department of Computer Science. Camegie-Mell University, Pittsburgh, PA, 17. Ross, S., Gordon, G., and Bagnell, D. (2011). A reduction of imitation learning and structured prediction to no-regret online learning. In Proceedings of the fourteenth international conference on artificial intelligence and statistics. Sanh, V., Debut, L., Chaumond, J., and Wolf, T. (2019). Distilbert, a distilled version of bert: smaller, faster, cheaper and lighter. arXiv preprint arXiv:1910.01108. Schwartz, E., Tennenholtz, G., Tessler, C., and Mannor, S. (2019). Language is power: Representing states using natural language in reinforcement learning. Sharma, S., Asri, L. E., Schulz, H., and Zumer, J. (2017). Relevance of unsupervised metrics in taskoriented dialogue for evaluating natural language generation. arXiv preprint arXiv:1706.09799. Shridhar, M., Thomason, J., Gordon, D., Bisk, Y., Han, W., Mottaghi, R., Zettlemoyer, L., and Fox, D. (2020). Alfred: A benchmark for interpreting grounded instructions for everyday tasks. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 10740–10749. Sun, C., Myers, A., Vondrick, C., Murphy, K., and Schmid, C. (2019). Videobert: A joint model for video and language representation learning. In Proceedings of the IEEE International Conference on Computer Vision. Tang, K., Niu, Y., Huang, J., Shi, J., and Zhang, H. (2020). Unbiased scene graph generation from biased training. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition. Todorov, E., Erez, T., and Tassa, Y. (2012). Mujoco: A physics engine for model-based control. In 2012 IEEE/RSJ International Conference on Intelligent Robots and Systems. Vaswani, A., Shazeer, N., Parmar, N., Uszkoreit, J., Jones, L., Gomez, A. N., Kaiser, L. u., and Polosukhin, I. (2017). Attention is all you need. In Advances in Neural Information Processing Systems 30. Wang, X., Huang, Q., Celikyilmaz, A., Gao, J., Shen, D., Wang, Y.-F., Wang, W. Y., and Zhang, L. (2019). Reinforced cross-modal matching and self-supervised imitation learning for visionlanguage navigation. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition. Wu, J., Lu, E., Kohli, P., Freeman, B., and Tenenbaum, J. (2017). Learning to see physics via visual de-animation. In Advances in Neural Information Processing Systems. Yu, A. W., Dohan, D., Le, Q., Luong, T., Zhao, R., and Chen, K. (2018a). Fast and accurate reading comprehension by combining self-attention and convolution. In International Conference on Learning Representations. Yu, L., Lin, Z., Shen, X., Yang, J., Lu, X., Bansal, M., and Berg, T. L. (2018b). Mattnet: Modular attention network for referring expression comprehension. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition.
Yuan, X., Côté, M.-A., Sordoni, A., Laroche, R., Combes, R. T. d., Hausknecht, M., and Trischler, A. (2018). Counting to explore and generalize in text-based games. arXiv preprint arXiv:1806.11525.
Zhong, V., Rocktäschel, T., and Grefenstette, E. (2020). RTFM: Generalising to novel environment dynamics via reading. In ICLR.
Zhu, Y., Gordon, D., Kolve, E., Fox, D., Fei-Fei, L., Gupta, A., Mottaghi, R., and Farhadi, A. (2017). Visual semantic planning using deep successor representations. In IEEE International Conference on Computer Vision, ICCV 2017, Venice, Italy, October 22-29, 2017.
# A DETAILS OF BUTLER::BRAIN
In this section, we use $o _ { t }$ to denote text observation at game step $t , g$ to denote the goal description provided by a game.
We use $L$ to refer to a linear transformation and $L ^ { f }$ means it is followed by a non-linear activation function $f$ . Brackets $[ \cdot ; \cdot ]$ denote vector concatenation, $\odot$ denotes element-wise multiplication.
# A.1 OBSERVATION QUEUE
As mentioned in Section 3.1, we utilize an observation queue to cache the text observations that have been seen recently. Since the initial observation $o _ { 0 }$ describes the high level layout of a room, including receptacles present in the current game, we it visible to BUTLER::BRAIN at all game steps, regardless of the length of the observation queue. Specifically, the observation queue has an extra space storing $o _ { 0 }$ , at any game step, we first concatenate all cached observations in the queue, then prepend the $o _ { 0 }$ to form the input to the encoder. We find this helpful because it facilitates the pointer softmax mechanism in the decoder (described below) by guiding it to point to receptacle words in the observation. An ablation study on this is provided in Section 5.
# A.2 ENCODER
We use a transformer-based encoder, which consists of an embedding layer and a transformer block (Vaswani et al., 2017). Specifically, embeddings are initialized by pre-trained 768-dimensional BERT embeddings (Sanh et al., 2019). The embeddings are fixed during training in all settings.
The transformer block consists of a stack of 5 convolutional layers, a self-attention layer, and a 2-layer MLP with a ReLU non-linear activation function in between. In the block, each convolutional layer has 64 filters, each kernel’s size is 5. In the self-attention layer, we use a block hidden size $H$ of 64, as well as a single head attention mechanism. Layernorm (Ba et al., 2016) is applied after each component inside the block. Following standard transformer training, we add positional encodings into each block’s input.
At every game step $t$ , we use the same encoder to process text observation $o _ { t }$ and goal description g. The resulting representations are hot ∈ RLot ×H and $h _ { g } \in \mathbb { R } ^ { L _ { g } \times H }$ , where $L _ { o _ { t } }$ is the number of tokens in $o _ { t }$ , $L _ { g }$ denotes the number of tokens in $g$ $\phantom { } _ { l } , H = 6 \dot { 4 }$ is the hidden size.
# A.3 AGGREGATOR
We adopt the context-query attention mechanism from the question answering literature (Yu et al., 2018a) to aggregate the two representations $h _ { o _ { t } }$ and $h _ { g }$ .
Specifically, a tri-linear similarity function is used to compute the similarity between each token in $h _ { o _ { t } }$ with each token in $h _ { g }$ . The similarity between $i$ -th token in $h _ { o }$ and $j$ -th token in $h _ { g }$ is thus computed by (omitting game step $t$ for simplicity):
$$\mathrm { S i m } ( i , j ) = W ( h _ { o _ { i } } , h _ { g _ { j } } , h _ { o _ { i } } \odot h _ { g _ { j } } ) ,$$
where $W$ is a trainable parameter in the tri-linear function. By applying the above computation for each ho and hg pair, we get a similarity matrix S ∈ RLo×Lg .
By computing the softmax of the similarity matrix $S$ along both dimensions (number of tokens in goal description $L _ { g }$ and number of tokens in observation $L _ { o . }$ ), we get $S _ { g }$ and $S _ { o }$ , respectively. The two representations are then aggregated by:
$$\begin{array} { r l r } & { } & { h _ { o g } = [ h _ { o } ; P ; h _ { o } \odot P ; h _ { o } \odot Q ] , } \\ & { } & { P = S _ { g } h _ { g } ^ { \top } , \qquad } \\ & { } & { Q = S _ { g } S _ { o } ^ { \top } h _ { o } ^ { \top } , \qquad } \end{array}$$
where $h _ { o g } \in \mathbb { R } ^ { L _ { o } \times 4 H }$ is the aggregated observation representation.
Next, a linear transformation projects the aggregated representations to a space with size $H = 6 4$ :
$$h _ { o g } = L ^ { \mathrm { t a n h } } ( h _ { o g } ) .$$
To incorporate history, we use a recurrent neural network. Specifically, we use a GRU (Cho et al., 2014):
$$\begin{array} { r } { h _ { \mathrm { R N N } } = \mathrm { M e a n } ( h _ { o g } ) , \qquad } \\ { h _ { t } = \mathrm { G R U } ( h _ { \mathrm { R N N } } , h _ { t - 1 } ) , \qquad } \end{array}$$
in which, the mean pooling is performed along the dimension of number of tokens, i.e., $h _ { \mathrm { R N N } } \in \mathbb { R } ^ { H }$ . $h _ { t - 1 }$ is the output of the GRU cell at game step $t - 1$ .
# A.4 DECODER
Our decoder consists of an embedding layer, a transformer block and a pointer softmax mechanism (Gulcehre et al., 2016). We first obtain the source representation by concatenating $h _ { o g }$ and $h _ { t }$ , resulting hsrc ∈ RLo×2H .
Similar to the encoder, the embedding layer is frozen after initializing it with pre-trained BERT embeddings. The transformer block consists of two attention layers and a 3-layer MLP with ReLU non-linear activation functions inbetween. The first attention layer computes the self attention of the input embeddings $h _ { \mathrm { s e l f } }$ as a contextual encoding for the target tokens. The second attention layer then computes the attention $\boldsymbol { \alpha } _ { \mathrm { s r c } } ^ { i } \in \mathbb { R } ^ { L _ { o } }$ between the source representation $h _ { \mathrm { { s r c } } }$ and the $i$ -th token in $h _ { \mathrm { s e l f } }$ . The $i \cdot$ -th target token is consequently represented by the weighted sum of $h _ { \mathrm { { s r c } } }$ , with the weights $\alpha _ { \mathrm { s r c } } ^ { i }$ . This generates a source information-aware target representation $h _ { \mathrm { t g t } } ^ { \prime } \in \mathbb { R } ^ { L _ { \mathrm { t g t } } \times H }$ , where $L _ { \mathrm { t g t } }$ denotes the number of tokens in the target sequence. Next, $h _ { \mathrm { t g t } } ^ { \prime }$ is fed into the 3-layer MLP with ReLU activation functions inbetween, resulting $h _ { \mathrm { t g t } } \in \mathbb { R } ^ { L _ { \mathrm { t g t } } \times H }$ . The block hidden size of this transformer is $H = 6 4$ .
Taking $h _ { \mathrm { t g t } }$ as input, a linear layer with tanh activation projects the target representation into the same space as the embeddings (with dimensionality of 768), then the pre-trained embedding matrix $E$ generates output logits (Press and Wolf, 2016), where the output size is same as the vocabulary size. The resulting logits are then normalized by a softmax to generate a probability distribution over all tokens in vocabulary:
$$p _ { a } ( y ^ { i } ) = E ^ { \mathrm { S o f t m a x } } ( L ^ { \mathrm { t a n h } } ( h _ { \mathrm { t g t } } ) ) ,$$
in which, $p _ { a } ( y ^ { i } )$ is the generation (abstractive) probability distribution.
We employ the pointer softmax (Gulcehre et al., 2016) mechanism to switch between generating a token $y ^ { i }$ (from a vocabulary) and pointing (to a token in the source text). Specifically, the pointer softmax module computes a scalar switch $s ^ { i }$ at each generation time-step $i$ and uses it to interpolate the abstractive distribution $p _ { a } ( y ^ { i } )$ over the vocabulary (Equation 5) and the extractive distribution $p _ { x } ( y ^ { i } ) = \alpha _ { \mathrm { s r c } } ^ { i }$ over the source text tokens:
$$p ( y ^ { i } ) = s ^ { i } \cdot p _ { a } ( y ^ { i } ) + ( 1 - s ^ { i } ) \cdot p _ { x } ( y ^ { i } ) ,$$
where $s ^ { i }$ is conditioned on both the attention-weighted source representation $\sum _ { j } \alpha _ { \mathrm { s r c } } ^ { i , j } \cdot h _ { \mathrm { s r c } } ^ { j }$ and the decoder state $h _ { \mathrm { t g t } } ^ { i }$ :
$$s ^ { i } = L _ { 1 } ^ { \mathrm { s i g m o i d } } ( \operatorname { t a n h } ( L _ { 2 } ( \sum _ { j } \alpha _ { \mathrm { s r c } } ^ { i , j } \cdot h _ { \mathrm { s r c } } ^ { j } ) + L _ { 3 } ( h _ { \mathrm { t g t } } ^ { i } ) ) ) .$$
In which, $\boldsymbol { L } _ { 1 } \in \mathbb { R } ^ { H \times 1 }$ , $L _ { 2 } \in \mathbb { R } ^ { 2 H \times H }$ and L3 ∈ RH×H are linear layers, $H = 6 4$ .
# B TRAINING AND IMPLEMENTATION DETAILS
In this section, we provide hyperparameters and other implementation details.
For all experiments, we use Adam (Kingma and Ba, 2014) as the optimizer. The learning rate is set to 0.001 with a clip gradient norm of 5.
During training with DAgger, we use a batch size of 10 to collect transitions (tuples of $\{ o _ { 0 } , o _ { t } , g , \hat { a } _ { t } \} )$ at each game step $t$ , where $\hat { a } _ { t }$ is the ground-truth action provided by the rule-based expert (see Section E). We gather a sequence of transitions from each game episode, and push each sequence into a replay buffer, which has a capacity of 500K episodes. We set the max number of steps per episode to be 50. If the agent uses up this budget, the game episode is forced to terminate. We linearly anneal the fraction of the expert’s assistance from $100 \%$ to $1 \%$ across a window of 50K episodes.
The agent is updated after every 5 steps of data collection. We sample a batch of 64 data points from the replay buffer. In the setting with the recurrent aggregator, every sampled data point is a sequence of 4 consecutive transitions. Following the training strategy used in the recurrent DQN literature (Hausknecht and Stone, 2015; Yuan et al., 2018), we use the first 2 transitions to estimate the recurrent states, and the last 2 transitions for updating the model parameters.
BUTLER::BRAIN learns to generate actions token-by-token, where we set the max token length to be 20. The decoder stops generation either when it generates a special end-of-sentence token [EOS], or hits the token length limit.
When using the beam search heuristic to recover from failed actions (see Figure 5), we use a beam width of 10, and take the top-5 ranked outputs as candidates. We iterate through the candidates in the rank order until one of them succeeds. This heuristic is not always guaranteed to succeed, however, we find it helpful in most cases. Note that we do not employ beam search when we evaluate during the training process for efficiency, e.g., in the seen and unseen curves shown in Figure 4. We take the best performing checkpoints and then apply this heuristic during evaluation and report the resulting scores in tables (e.g., Table 2).
 Figure 5: Beam search for recovery actions.
By default unless mentioned otherwise (ablations), we use all available training games in each of the task types. We use an observation queue length of 5 and use a recurrent aggregator. The model is trained with DAgger, and during evaluation, we apply the beam search heuristic to produce the reported scores. All experiment settings in TextWorld are run with 8 random seeds. All text agents are trained for 50,000 episodes.
# C TEXTWORLD ENGINE
Internally, the TextWorld Engine is divided into two main components: a planner and text generator.
Planner TextWorld Engine uses Fast Downward (Helmert, 2006), a domain-independent classical planning system to maintain and update the current state of the game. A state is represented by a set of predicates which define the relations between the entities (objects, player, room, etc.) present in the game. A state can be modified by applying production rules corresponding to the actions listed in Table 6. All variables, predicates, and rules are defined using the PDDL language.
For instance, here is a simple state representing a player standing next to a microwave which is closed and contains a mug:
$$\begin{array} { r } { \begin{array} { r l } { s _ { t } = } & { \mathsf { a t } \big ( p \mathcal { I } a y e r , m i c r o w a v e \big ) \otimes \mathrm { i n } \big ( m u g , m i c r o w a v e \big ) } \\ & { \otimes \mathrm { c l o s e d } \big ( m i c r o w a v e \big ) \otimes \mathrm { o p e n a b l e } \big ( m i c r o w a v e \big ) , } \end{array} } \end{array}$$
where the symbol $\otimes$ is the linear logic multiplicative conjunction operator. Given that state, a valid action could be open microwave, which would essentially transform the state by replacing $\mathsf { c l o s e d } ( m i c r o w a v e )$ with open(microwave).
Text generator The other component of the TextWorld Engine, the text generator, uses a contextsensitive grammar designed for the ALFRED environments. The grammar consists of text templates similar to those listed in Table 6. When needed, the engine will sample a template given some context,
i.e., the current state and the last action. Then, the template gets realized using the predicates found in the current state.
# D MASK R-CNN DETECTOR
We use a Mask R-CNN detector (He et al., 2017) pre-trained on MSCOCO (Lin et al., 2014) and fine-tune it with additional labels from ALFRED training scenes. To generate additional labels, we replay the expert demonstrations from ALFRED and record ground-truth image and instance segmentation pairs from the simulator (THOR) after completing each high-level action e.g., goto, pickup etc. We generate a dataset of 50K images, and fine-tune the detector for 4 epochs with a batch size of 8 and a learning rate of 5e-4. The detector recognizes 73 object classes where each class could vary up to 1-10 instances. Since demonstrations in the kitchen are often longer as they involve complex sequences like heating, cleaning etc., the labels are slightly skewed towards kitchen objects. To counter this, we balance the number of images sampled from each room (kitchen, bedroom, livingroom, bathroom) so the distribution of object categories is uniform across the dataset.
# E RULE-BASED EXPERT
To train text agents in an imitation learning (IL) setting, we use a rule-based expert for supervision. A given task is decomposed into sequence of subgoals (e.g., for heat & place: find the object, pick the object, find the microwave, heat the object with the microwave, find the receptacle, place the object in the receptacle), and a closed-loop controller tries to sequentially execute these goals. We note that while designing rule-based experts for ALFWorld is relatively straightforward, experts operating directly in embodied settings like the PDDL planner used in ALFRED are prone to failures due to physical infeasibilities and non-deterministic behavior in physics-based environments.
# F BENEFITS OF TRAINING IN TEXTWORLD OVER EMBODIED WORLD
Pre-training in TextWorld offers several benefits over directly training in embodied environments. Figure 6 presents the performance of an expert (that agents are trained to imitate) across various environments. The abstract textual space leads to higher goal success rates resulting from successful navigation and manipulation subroutines. TextWorld agents also do not suffer from object misdetections and slow execution speed.
 Figure 6: Domain Analysis: The performance of an expert across various environments.
# G OBSERVATION TEMPLATES
The following templates are used by the state-estimator to generate textual observations $o _ { t }$ . The object IDs {obj id} correspond to Mask R-CNN objects detection or ground-truth instance IDs. The receptacle IDs {recep id} are based on the receptacles listed in the initial observation $o _ { 0 }$ . Failed actions and actions without any state-changes result in Nothing happens.
Table 6: High-level text actions supported in ALFWorld along with their observation templates.
<table><tr><td>Actions</td><td>Templates</td></tr><tr><td>goto</td><td>(a)You arrive at {loc id}. On the {recep id}, you see a {obj1 id}, ... and a {objN id}. (b)You arrive at {loc id}. The {recep id} is closed. (c) You arrive at {loc id}. The {recep id} is open. On it,you see a {obji id},... and a {objN id}.</td></tr><tr><td>take</td><td>You pick up the {obj id} from the {recep id}.</td></tr><tr><td>put</td><td>You put the {obj id} on the {recep id}.</td></tr><tr><td>open</td><td>(a) You open the {recep id}. In it, you see a {obj1 id},... and a {objN id}. (b)You open the {recep id}. The {recep id} is empty.</td></tr><tr><td>close</td><td>You close the {recep id}.</td></tr><tr><td>toggle</td><td>You turn the {obj id} on.</td></tr><tr><td>heat</td><td>You heat the {obj id} with the {recep id}.</td></tr><tr><td>cool</td><td>You cool the {obj id} with the {recep id}.</td></tr><tr><td>clean</td><td>You clean the {obj id} with the {recep id}.</td></tr><tr><td>inventory</td><td>(a) You are carrying: {obj id}. (b)You are not carrying anything.</td></tr><tr><td>examine</td><td>(a) On the {recep id},you see a {obj1 id},.. and a {objN id}. (b)This is a hot/cold/clean {obj).</td></tr></table>
# H GOAL DESCRIPTIONS
# H.1 TEMPLATED GOALS
The goal instructions for training games are generated with following templates. Here obj, recep, lamp refer to object, receptacle, and lamp classes, respectively, that pertain to a particular task. For each task, the two corresponding templates are sampled with equal probability.
Table 7: Task-types and the corresponding goal description templates.
<table><tr><td>task-type</td><td>Templates</td></tr><tr><td>Pick&Place</td><td>(a)put a {obj} in {recep}. (b) put some {obj} on{recep}.</td></tr><tr><td>Examine in Light</td><td>(a)look at {obj} under the {lamp}. (b)examine ethe {obj} with the {lamp}.</td></tr><tr><td>Clean&Place</td><td>(a)put a clean {obj} in {recep}. (b) clean some {obj} and put it in {recep}.</td></tr><tr><td>Heat&Place</td><td>(a)puta hot {obj} in {recep}. (b)heat some {obj} and put it in {recep}.</td></tr><tr><td>Cool&Place</td><td>(a)put a cool {obj} in {recep}. (b)cool some {obj} and put it in {recep}.</td></tr><tr><td>Pick Two&Place</td><td>(a)put two {obj} in {recep}. (b) find two {obj} and put them {recep}.</td></tr></table>
# H.2 HUMAN ANNOTATED GOALS
The human goal descriptions used during evaluation contain 66 unseen verbs and 189 unseen nouns with respect to the templated goal instructions used during training.
Unseen Verbs: acquire, arrange, can, carry, chill, choose, cleaning, clear, cook, cooked, cooled, dispose, done, drop, end, fill, filled, frying, garbage, gather, go, grab, handled, heated, heating, hold, holding, inspect, knock, left, lit, lock, microwave, microwaved, move, moving, pick, picking, place, placed, placing, putting, read, relocate, remove, retrieve, return, rinse, serve, set, soak, stand, standing, store, take, taken, throw, transfer, turn, turning, use, using, walk, warm, wash, washed.
Unseen Nouns: alarm, area, back, baisin, bar, bars, base, basin, bathroom, beat, bed, bedroom, bedside, bench, bin, books, bottle, bottles, bottom, box, boxes, bureau, burner, butter, can, canteen, card, cardboard, cards, cars, cds, cell, chair, chcair, chest, chill, cistern, cleaning, clock, clocks, coffee, container, containers, control, controllers, controls, cooker, corner, couch, count, counter, cover, cream, credit, cupboard, dining, disc, discs, dishwasher, disks, dispenser, door, drawers, dresser, edge, end, floor, food, foot, freezer, game, garbage, gas, glass, glasses, gold, grey, hand, head, holder, ice, inside, island, item, items, jars, keys, kitchen, knifes, knives, laddle, lamp, lap, left, lid, light, loaf, location, lotion, machine, magazine, maker, math, metal, microwaves, move, nail, newsletters, newspapers, night, nightstand, object, ottoman, oven, pans, paper, papers, pepper, phone, piece, pieces, pillows, place, polish, pot, pullout, pump, rack, rag, recycling, refrigerator, remote, remotes, right, rinse, roll, rolls, room, safe, salt, scoop, seat, sets, shaker, shakers, shelves, side, sink, sinks, skillet, soap, soaps, sofa, space, spatulas, sponge, spoon, spot, spout, spray, stand, stool, stove, supplies, table, tale, tank, television, textbooks, time, tissue, tissues, toaster, top, towel, trash, tray, tv, vanity, vases, vault, vegetable, wall, wash, washcloth, watches, water, window, wine.
# I ACTION CANDIDATES VS ACTION GENERATION
BUTLER::BRAIN generates actions in a token-by-token fashion. Prior text-based agents typically use a list of candidate commands from the game engine (Adhikari et al., 2020) or populate a list of command templates (Ammanabrolu and Hausknecht, 2020). We initially trained our agents with candidate commands from the TextWorld Engine, but they quickly ovefit without learning affordances, commonsense, or pre-conditions, and had zero performance on embodied transfer. In the embodied setting, without access to a TextWorld Engine, it is difficult to generate candidate actions unless a set of heuristics is handcrafted with strong priors and commonsense knowledge. We also experimented with populating a list of command templates, but found this to be infeasible as some scenarios involved 1000s of populated actions per game step.
# J ALFRED TASK DESCRIPTIONS
The following descriptions describe the processes involved in each of six task-types:
• Pick & Place (e.g., “put a plate on the coffee table”) - the agent must find an object of the desired type, pick it up, find the correct location to place it, and put it down there. • Examine in Light (e.g., “examine a book under the lamp”) - the agent must find an object of the desired type, locate and turn on a light source with the desired object in-hand. • Clean & Place (e.g., “clean the knife and put in the drawer”) - the agent must find an object of the desired type, pick it up, go to a sink or a basin, wash the object by turning on the faucet, then find the correct location to place it, and put it down there. • Heat & Place (e.g., “heat a mug and put on the coffee table”) - the agent must find an object of the desired type, pick it up, go to a microwave, heat the object turning on the microwave, then find the correct location to place it, and put it down there. • Cool & Place (e.g., “put a cool bottle on the countertop”) - the agent must find an object of the desired type, pick it up, go to a fridge, put the object inside the fridge and cool it, then find the correct location to place it, and put it down there. • Pick Two & Place (e.g., “put two pencils in the drawer”) - the agent must find an object of the desired type, pick it up, find the correct location to place it, put it down there, then look for another object of the desired type, pick it up, return to previous location, and put it down there with the other object.
# K ALFWORLD TEXT GAME EXAMPLES
Three examples of ALFWorld text game walkthroughs:
You are in the middle of a room. Looking quickly around you, you see a towelholder 1, a toilet 1, a bathtubbasin 1, a drawer 4, a handtowelholder 2, a drawer 6, a drawer 1, a countertop 1, a sinkbasin 1, a drawer 2, a drawer 3, a toiletpaperhanger 1, a drawer 5, a handtowelholder 1, a towelholder 2, a sinkbasin 2, and a garbagecan 1.
Your task is to: put a clean cloth in bathtubbasin.
$>$ go to drawer 5 You arrive at loc 9. The drawer 5 is closed. > open drawer 5 You open the drawer 5. The drawer 5 is open. In it, you see a candle 1. > close drawer 5 You close the drawer 5. $>$ go to countertop 1 You arrive at loc 25. On the countertop 1, you see a cloth 2, a soapbottle 1, a cloth 1, and a candle 3. > take cloth 1 from countertop 1 You pick up the cloth 1 from the countertop 1. $>$ go to sinkbasin 1 You arrive at loc 20. On the sinkbasin 1, you see nothing. > clean cloth 1 with sinkbasin 1 You clean the cloth 1 using the sinkbasin 1. > go to bathtubbasin 1 You arrive at loc 14. On the bathtubbasin 1, you see a soapbar 1. > put cloth 1 in/on bathtubbasin 1 You won!
You are in the middle of a room. Looking quickly around you, you see a drawer 15, a drawer 19, a drawer 7, a armchair 1, a drawer 3, a drawer 16, a drawer 2, a drawer 17, a sidetable 3, a sidetable 5, a drawer 4, a drawer 20, a sofa 1, a drawer 13, a drawer 12, a drawer 9, a drawer 21, a sidetable 4, a sidetable 2, a drawer 5, a drawer 11, a drawer 1, a garbagecan 1, a dresser 1, a cabinet 1, a drawer 8, a drawer 18, a sidetable 1, a drawer 14, a drawer 6, and a drawer 10.
Your task is to: find two remotecontrol and put them in armchair.
$>$ go to sidetable 2 You arrive at loc 34. On the sidetable 2, you see a remotecontrol 1. $>$ take remotecontrol 1 from sidetable 2 You pick up the remotecontrol 1 from the sidetable 2. $>$ go to armchair 1 You arrive at loc 1. On the armchair 1, you see nothing. $>$ put remotecontrol 1 in/on armchair 1 You put the remotecontrol 1 in/on the armchair 1. $>$ go to dresser 1 You arrive at loc 18. On the dresser 1, you see a creditcard 1, a television 1, a laptop 1, a book 1, a statue 2, and a cellphone 2. > go to sidetable 5 You arrive at loc 17. On the sidetable 5, you see a box 1, and a creditcard 2. $>$ go to sofa 1 You arrive at loc 2. On the sofa 1, you see a newspaper 1, a pillow 1, and a remotecontrol 2. $>$ take remotecontrol 2 from sofa 1 You pick up the remotecontrol 2 from the sofa 1. > go to armchair 1 You arrive at loc 1. On the armchair 1, you see a remotecontrol 1. > put remotecontrol 2 in/on armchair 1 You won!
You are in the middle of a room. Looking quickly around you, you see a safe 1, a shelf 4, a drawer 2, a bed 1, a drawer 1, a shelf 5, a shelf 2, a sidetable 2, a shelf 3, a drawer 3, a shelf 1, a sidetable 1, a desk 1, and a garbagecan 1.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357# ZERO-COST PROXIES FOR LIGHTWEIGHT NAS
Mohamed S. Abdelfattah1, Abhinav Mehrotra1, Łukasz Dudziak1, Nicholas D. Lane1,2 1 Samsung AI Center, Cambridge · 2 University of Cambridge mohamed1.a@samsung.com
# ABSTRACT
Neural Architecture Search (NAS) is quickly becoming the standard methodology to design neural network models. However, NAS is typically compute-intensive because multiple models need to be evaluated before choosing the best one. To reduce the computational power and time needed, a proxy task is often used for evaluating each model instead of full training. In this paper, we evaluate conventional reduced-training proxies and quantify how well they preserve ranking between neural network models during search when compared with the rankings produced by final trained accuracy. We propose a series of zero-cost proxies, based on recent pruning literature, that use just a single minibatch of training data to compute a model’s score. Our zero-cost proxies use 3 orders of magnitude less computation but can match and even outperform conventional proxies. For example, Spearman’s rank correlation coefficient between final validation accuracy and our best zero-cost proxy on NAS-Bench-201 is 0.82, compared to 0.61 for EcoNAS (a recently proposed reduced-training proxy). Finally, we use these zerocost proxies to enhance existing NAS search algorithms such as random search, reinforcement learning, evolutionary search and predictor-based search. For all search methodologies and across three different NAS datasets, we are able to significantly improve sample efficiency, and thereby decrease computation, by using our zero-cost proxies. For example on NAS-Bench-101, we achieved the same accuracy $4 \times$ quicker than the best previous result. Our code is made public at: https://github.com/mohsaied/zero-cost-nas.
# 1 INTRODUCTION
Instead of manually designing neural networks, neural architecture search (NAS) algorithms are used to automatically discover the best ones (Tan & Le, $2 0 1 9 \mathrm { a }$ ; Liu et al., 2019; Bender et al., 2018). Early work by Zoph & Le (2017) proposed using a reinforcement learning (RL) controller that constructs candidate architectures, these are evaluated and then feedback is provided to the controller based on the performance of the candidate. One major problem with this basic NAS methodology is that each evaluation is very costly – typically on the order of hours or days to train a single neural network fully. We focus on this evaluation phase – we propose using proxies that require a single minibatch of data and a single forward/backward propagation pass to score a neural network. This is inspired by recent pruning-at-initialization work by Lee et al. (2019), Wang et al. (2020) and Tanaka et al. (2020) wherein a per-parameter saliency metric is computed before training to inform parameter pruning. Can we use such saliency metrics to score an entire neural network? Furthermore, can we use these “single minibatch” metrics to rank and compare multiple neural networks for use within NAS? If so, how do we best integrate these metrics within existing NAS algorithms such as RL or evolutionary search? These are the questions that we hope to (empirically) tackle in this work with the goal of making NAS less compute-hungry. Our contributions are:
• Zero-cost proxies We adapt pruning-at-initialization metrics for use with NAS. This requires these metrics to operate at the granularity of an entire network rather than individual parameters – we devise and validate approaches that aggregate parameter-level metrics in a manner suitable for ranking candidates during NAS search.
• Comparison to conventional proxies We perform a detailed comparison between zerocost and conventional NAS proxies that use a form of reduced-computation training. First, we quantify the rank consistency of conventional proxies on large-scale datasets: $1 5 \mathrm { k }$ models vs. 50 models used in (Zhou et al., 2020). Second, we show that zero-cost proxies can match or exceed the rank consistency of conventional proxies.
• Ablations on NAS benchmarks We perform ablations of our zero-cost proxies on five different NAS benchmarks (NAS-Bench-101/201/NLP/ASR and PyTorchCV) to both test the zero-cost metrics under different settings, and expose properties of successful metrics.
• Integration with NAS Finally, we propose two ways to use zero-cost metrics effectively within NAS algorithms: random search, reinforcement learning, aging evolution and predictor-based search. For all algorithms and three NAS datasets we show significant speedups, up to $4 \times$ for NAS-Bench-101 compared to current state-of-the-art.
# 2 RELATED WORK
NAS Efficiency To decrease NAS search time, various techniques were used in the literature. Pham et al. (2018) and Cai et al. (2018) use weight sharing between candidate models to decrease the training time during evaluation. Liu et al. (2019) and others use smaller datasets (CIFAR-10) as a proxy to the full task (ImageNet1k). In EcoNAS, Zhou et al. (2020) extensively investigated reduced-training proxies wherein input size, model size, number of training samples and number of epochs were reduced in the NAS evaluation phase. We compare to EcoNAS in this work to elucidate how well our zero-cost proxies perform compared to familiar and widely-used conventional proxies.
Pruning The goal is to reduce the number of parameters in a neural network, one way to do this is by identifying a saliency (importance) metric for each parameter, and the less-important parameters are removed. For example, Han et al. (2015), Frankle & Carbin (2019) and others use parameter magnitudes as the criterion while LeCun et al. (1990), Hassibi & Stork (1993) and Molchanov et al. (2017) use gradients. However, the aforementioned works require training before computing the saliency criterion. A new class of pruning-at-initialization algorithms, that require no training, were introduced by Lee et al. (2019) and extended by Wang et al. (2020) and Tanaka et al. (2020). A single forward/backward propagation pass is used to compute a saliency criterion which is successfully used to heavily prune neural networks before training. We extend these pruning-at-initialization criteria towards scoring entire neural networks and we investigate their use with NAS algorithms.
Intersection between pruning and NAS Concepts from pruning have been used within NAS multiple times. For example, Mei et al. (2020) use channel pruning in their AtomNAS work to arrive at customized multi-kernel-size convolutions (mixconvs as introduced by Tan & Le (2019b)). In their Blockswap work, Turner et al. (2020) use Fisher information at initialization to score different lightweight primitives that are substituted into a neural network to decrease computation. This is the earliest work we could find that attempts to perform a type of NAS by scoring neural networks without training using a pruning criterion, More recently, Mellor et al. (2020) introduced a new metric for scoring neural networks at initialization based on the correlation of Jacobians with different inputs. They perform “NAS without training” by performing random search with their zero-cost metric (jacob cov) to rank neural networks instead of using accuracy. We include jacob cov in our analysis and we introduce five more zero-cost metrics in this work.
# 3 PROXIES FOR NEURAL NETWORK ACCURACY
# 3.1 CONVENTIONAL NAS PROXIES (ECONAS)
In conventional sample-based NAS, a proxy training regime is often used to predict a model’s accuracy instead of full training. Zhou et al. (2020) investigate conventional proxies in depth by computing the Spearman rank correlation coefficient (Spearman $\rho$ ) of a proxy task to final test accuracy. The proxy used is a reduced-computation training, wherein one of the following four variables is reduced: (1) number of epochs, (2) number of training samples, (3) input resolution (4) model size (controlled through the number of channels after the first convolution). Even though such proxies were used in many prior works, EcoNAS is the first systematic study of conventional proxy tasks that we found. One main finding by Zhou et al. (2020) is that using approximately $\textstyle { \frac { 1 } { 4 } }$ of the model size and input resolution, all training samples, and $\textstyle { \frac { 1 } { 1 0 } }$ the number of epochs was a reasonable proxy which yielded the best results for their experiment (Zhou et al., 2020).
# 3.2 ZERO-COST NAS PROXIES
We present alternative proxies for network accuracy that can be used to speed up NAS. A simple proxy that we use is grad norm in which we sum the Euclidean norm of the gradients after a single minibatch of training data. Other metrics listed below were previously introduced in the context of parameter pruning at the granularity of a single parameter – a saliency is computed to rank parameters and remove the least important ones. We adapt these metrics to score and rank entire neural network models for NAS.
# 3.2.1 SNIP, GRASP AND SYNAPTIC FLOW
In their snip work, Lee et al. (2019) proposed performing parameter pruning based on a saliency metric computed at initialization using a single minibatch of data. This saliency criteria approximates the change in loss when a specific parameter is removed. Wang et al. (2020) attempted to improve on the snip metric by approximating the change in gradient norm (instead of loss) when a parameter is pruned in their grasp objective. Finally, Tanaka et al. (2020) generalized these so-called synaptic saliency scores and proposed a modified version (synflow) which avoids layer collapse when performing parameter pruning. Instead of using a minibatch of training data and cross-entropy loss (as in snip or grasp), with synflow we compute a loss which is simply the product of all parameters in the network; therefore, no data is needed to compute this loss or the synflow metric itself. These are the three metrics:
$$\mathrm { s n i p } : S _ { P } ( \theta ) = \left| \frac { \partial \mathcal { L } } { \partial \theta } \odot \theta \right| , \quad \mathrm { g r a s s p } : S _ { P } ( \theta ) = - ( H \frac { \partial \mathcal { L } } { \partial \theta } ) \odot \theta , \quad \mathrm { ~ s y n f 1 o w : ~ } S _ { P } ( \theta ) = \frac { \partial \mathcal { L } } { \partial \theta } \odot \theta .$$
where $\mathcal { L }$ is the loss function of a neural network with parameters $\theta , H$ is the Hessian1, $S _ { p }$ is the per-parameter saliency and $\odot$ is the Hadamard product. We extend these saliency metrics to score an entire neural network by summing over all parameters $N$ in the model: $\begin{array} { r } { S _ { n } = \dot { \sum } _ { i } ^ { N } S _ { p } ( \theta ) _ { i } } \end{array}$ .
# 3.2.2 FISHER
Theis et al. (2018) perform channel pruning by removing activation channels (and their corresponding parameters) that are estimated to have the least effect on the loss. They build on the work of Molchanov et al. (2017) and Figurnov et al. (2016). More recently, Turner et al. (2020) aggregated this fisher metric for all channels in a convolution primitive to quantify the importance of that primitive when it is replaced by a more efficient alternative. We further aggregate the fisher metric for all layers in a neural network to score an entire network as shown in the following equations:
$${ \mathrm { \bf { f i s h e r : } } } \ S _ { z } ( z ) = \left( { \frac { \partial { \mathcal { L } } } { \partial z } } z \right) ^ { 2 } , \quad \ S _ { n } = \sum _ { i = 1 } ^ { M } S _ { z } ( z _ { i } )$$
where $S _ { z }$ is the saliency per activation $z$ , and $M$ is the length of the vectorized feature map.
# 3.2.3 JACOBIAN COVARIANCE
This metric was purpose-designed to score neural networks in the context of NAS – we refer the reader to the original paper for detailed reasoning and derivation of the metric which we call jacob cov (Mellor et al., 2020). In brief, this metric captures the correlation of activations within a network when subject to different inputs within a minibatch of data – the lower the correlation, the better the network is expected to perform as it can differentiate between different inputs well.
# 4 EMPIRICAL EVALUATION OF PROXY TASKS
Generally, most of the proxies presented in the previous section try to capture how trainable a neural network is by inspecting the gradients at the beginning of training. In this work, we refrain from attempting to explain precisely why each metric works (or does not work) and instead focus on the empirical evaluation of those metrics in different scenarios. We use the Spearman rank correlation coefficient (Spearman $\rho$ ) to quantify how well a proxy ranks models compared to the ground-truth ranking produced by final test accuracy (Daniel, 1990).
 Figure 1: Evaluation of different econas proxies on NAS-Bench-201 CIFAR-10. FLOPS and runtime are normalized to the FLOPS/runtime of a single baseline (full training) epoch.
# 4.1 NAS-BENCH-201
NAS-Bench-201 is a purpose-built benchmark for prototyping NAS algorithms (Dong & Yang, 2020). It contains 15,625 CNN models from a cell-based search space and corresponding training statistics. We first use NAS-Bench-201 to evaluate conventional proxies from EcoNAS, then we evaluate our zero-cost proxies and compare the two approaches.
# 4.1.1 ECONAS PROXY ON NAS-BENCH-201
Even though Zhou et al. (2020) thoroughly investigated reduced-training proxies, they only evaluated a small model zoo consisting of 50 models. To study EcoNAS more extensively we evaluate it on all 15,625 models in NAS-Bench-201 search space (training details in A.1). The full configuration training of NAS-Bench-201 on CIFAR-10 uses input resolution $\scriptstyle 1 = 3 2$ , number of channels in the stem convolution $\scriptstyle { \mathrm { c = } } 1 6$ and number of epochs $\scriptstyle { \mathrm { e } = 2 0 0 }$ – we summarize this as: $r _ { 3 2 } c _ { 1 6 } e _ { 2 0 0 }$ .
According to the EcoNAS study, the most effective configuration divides both the input resolution and stem channels by ${ \sim } 4$ and the number of epochs by 10, that is, $r _ { 8 } c _ { 4 } e _ { 2 0 }$ for NAS-Bench-201 models. Keeping that in mind we investigate $r _ { 8 } c _ { 4 }$ in Fig. 1 (labeled econas); however, this proxy training seems to suffer from overfitting as correlation to final accuracy started to drop after 20 epochs. Additionally, the Spearman $\rho$ was a modest 0.61 when evaluated on all 15,625 models in NAS-Bench-201 – a far cry from the 0.87 achieved on the 50 models in the EcoNAS paper (Zhou et al., 2020). We additionally explore $r _ { 8 } c _ { 8 }$ , $r _ { 1 6 } c _ { 4 }$ and $r _ { 1 6 } c _ { 8 }$ and find a very good proxy with $r _ { 1 6 } c _ { 8 } e _ { 1 5 }$ , labeled in Fig. 1 as econas+. From the plots in Fig. 1, we would like to highlight that:
1. A reduced-training proxy that works well on one search space may not work well on another as highlighted by the difference in Spearman $\rho$ between econas and econas+. This occurs even though both tasks in this case were CIFAR-10 image classification. 2. Even though EcoNAS-style proxies reduce computation load by a large factor (as seen in the middle plot in Fig. 1, this does not translate fully into actual runtime improvement when run on a nominal desktop $\mathrm { G P U } ^ { 2 }$ . We therefore plot actual GPU speedup in the third subplot in Fig. 1. For example, notice that the point labeled econas $( r _ { 8 } c _ { 4 } e _ { 2 0 } )$ has the same FLOPS as $\sim \frac { 1 } { 1 0 }$ of a full training epoch, but when measured on a GPU, takes time equivalent to 5 full training epochs – a $5 0 \times$ gap between theoretical and actual speedup.
# 4.1.2 ZERO-COST PROXIES ON NAS-BENCH-201
We now shift our focus towards our zero-cost NAS proxies which rely on gradient computations using a single minibatch of data at initialization. A clear advantage of zero-cost proxies is that they take very little time to compute – the forward/backward pass using a single minibatch of data. We ran the zero-cost proxies on all 15,625 models in NAS-Bench-201 for three image classification datasets and we summarize the results in Table 1.
The synflow metric performed the best on all three datasets with a Spearman $\rho$ consistently above 0.73, jacob cov was second best but was also very well-correlated to final accuracy. Next came grad norm and snip with a Spearman $\rho$ close to 0.6. We add another metric that we simply label with vote that takes a majority vote between the three metrics synflow, jacob cov and snip when ranking two models. This performed better than any single metric with a Spearman $\rho$ consistently above 0.8. At the cost of just 3 minibatches instead of $\sim 1 0 0 0$ , this is already performing slightly better than econas+, and much better than econas as shown in Fig. 2a. In Fig. 2 we also plot the rank correlation of validation accuracy (without any reduced training) over the first 10 epochs of training for the three datasets available in NAS-Bench-201.
 Figure 2: Correlation of validation accuracy to final test accuracy during the first 12 epochs of training for three datasets on the NAS-Bench-201 search space. Zero-cost and EcoNAS proxies are also labeled for comparison.
Table 1: Spearman $\rho$ of zero-cost proxies on NAS-Bench-201.
<table><tr><td>Dataset</td><td>grad_norm</td><td>snip</td><td>grasp</td><td>fisher</td><td>synflow</td><td> jacob_cov</td><td>vote</td></tr><tr><td>CIFAR-10</td><td>0.58</td><td>0.58</td><td>0.48</td><td>0.36</td><td>0.74</td><td>0.73</td><td>0.82</td></tr><tr><td>CIFAR-100</td><td>0.64</td><td>0.63</td><td>0.54</td><td>0.39</td><td>0.76</td><td>0.71</td><td>0.83</td></tr><tr><td>ImageNet16-120</td><td>0.58</td><td>0.58</td><td>0.56</td><td>0.33</td><td>0.75</td><td>0.71</td><td>0.82</td></tr></table>
Having set a comparison point with EcoNAS and reduced-training proxies, we have shown that zero-cost proxies can match and outperform these conventional methods in a large-scale empirical analysis. However, different NAS search spaces may behave differently, so in the remainder of this section, we test the zero-cost proxies on different search spaces.
# 4.2 MODELS IN THE WILD (PYTORCHCV)
To study zero-cost proxies in a different setting, we scored the models in the PyTorchCV database (Semery, 2020). PytorchCV contains common state-of-the-art neural networks such as ResNets (He ´ et al., 2016), DenseNets (Huang et al., 2017), MobileNets (Howard et al., 2017) and EfficientNets (Tan & Le, 2019a) – a representative assortment of top-performing models. We evaluated $\mathord { \sim } 5 0$ models for CIFAR-10, CIFAR-100 (Krizhevsky, 2009) and SVHN (Netzer et al., 2011), and $\sim 2 0 0$ models for ImageNet1k (Deng et al., 2009). Fig. 3 shows the resulting correlation for the zero-cost metrics. synflow, snip, fisher and grad norm all perform similarly well on all datasets, with the exception of SVHN where synflow outperforms other metrics by a large margin. However, grasp failed in this setting completely as shown by the low mean Spearman $\rho$ and high variance as shown in Fig. 3. Curiously, jacob cov also failed in this setting even though it performed well on NASBench-201. This suggests that this metric is better at scoring models from within a search space (similar topology and size), but becomes worse when scoring unrelated models.
# 4.3 OTHER SEARCH SPACES
We investigate our zero-cost metrics with other NAS benchmarks. Our goal is to empirically find a good metric to speed up NAS algorithms reliably on different tasks and datasets.
• NAS-Bench-101: This is the first and largest NAS benchmark available with over $4 2 3 \mathrm { k }$ CNN models and training statistics on CIFAR-10 (Ying et al., 2019). • NAS-Bench-NLP: Klyuchnikov et al. (2020) investigate the architectures of 14k different recurrent cells in natural language processing (NLP) tasks such as next word prediction.
 Figure 3: Performance of zero-cost metrics on PyTorchCV models (averaged over 5 seeds).
• NAS-Bench-ASR: This is our in-house dataset for convolution-based automatic speech recognition models evaluated on the TIMIT dataset (Garofolo et al., 1993). The search space includes linear, convolution, zeroize and skip-connections, forming 8242 models (Mehrotra et al., 2021).
Compared to NAS-Bench-201, these datasets are either much larger (NAS-Bench-101) or based on a different task (NAS-Bench-NLP/ASR). From Table 2 we would like to highlight that the synflow metric (highlighted in bold) is the only consistent one across all analyzed benchmarks. Additionally, even for the synflow metric, rank correlation is quite a bit lower than that for NAS-Bench-201 ( ${ \sim } 0 . 3$ vs. ${ \sim } 0 . 8 )$ . Other than global rank correlation, we posit that ranking of top models from a search space is also critically important for NAS algorithms – this is because we ultimately care about finding those top models. In Section A.4 we perform an analysis of how top models are ranked by zero-cost proxies. Additionally, local rank correlation of top models could be important for NAS algorithms when two good models are compared using their proxy metric value. Tables 9 and 10 show that the only metric that maintains correct ranking among top models consistently across all NAS benchmarks is synflow. In Section 5 we deliberately evaluate 3 benchmarks that exhibit different levels of rank correlation: NAS-Bench-201/101/ASR to see if we can integrate synflow within NAS and achieve consistent gains for all three search spaces.
Table 2: Spearman $\rho$ of zero-cost proxies on other NAS search spaces.
<table><tr><td></td><td> grad_norm</td><td>snip</td><td>grasp</td><td>fisher</td><td>synflow</td><td> jacob_cov</td></tr><tr><td>NAS-Bench-101</td><td>0.20</td><td>0.16</td><td>0.45</td><td>0.26</td><td>0.37</td><td>0.38</td></tr><tr><td>NAS-Bench-NLP</td><td>-0.21</td><td>-0.19</td><td>0.16</td><td>1</td><td>0.34</td><td>0.56</td></tr><tr><td>NAS-Bench-ASR</td><td>0.07</td><td>0.01</td><td>1</td><td>0.02</td><td>0.40</td><td>-0.37</td></tr></table>
# 5 ZERO-COST NAS
Mellor et al. (2020) proposed using jacob cov to score a set of randomly-sampled models and to greedily choose the model with the highest score. This “NAS without training” methodology is very attractive thanks to its simplicity and low computational cost. In this section, we evaluate our metrics in this setting that we simply call “random search” (RAND). We extend this methodology slightly: instead of just training the top model, we keep training models (from best to worst as ranked by the zero-cost metric) until the desired accuracy is achieved. However, this approach can only produce results that are as good as the metric being used – and we have no guarantees (just empirical evidence) that these metrics will perform well on all datasets. Therefore, we also investigate how to integrate zero-cost metrics within existing NAS algorithms such as reinforcement learning (RL) (Zoph & Le, 2017), aging evolution (AE) search (Real et al., 2019) and predictor-based search (Dudziak et al., 2020). More specifically, we investigate enhancing these search algorithms through either (a) zero-cost warmup phase or (b) zero-cost move proposal.
 Figure 4: Search speedup with the synflow zero-cost proxy on NAS-Bench-201 CIFAR-100.
# 5.1 ZERO-COST WARMUP
Generally speaking, by warmup we mean using the zero-cost proxies at the beginning of the search process to initialize the search algorithm without training any models or using accuracy. The main parameter in zero-cost warmup is the number of models for which we compute and use the zero-cost metric $( N )$ , and the potential gain comes from the fact that this number can be usually much larger than the number of models we can afford to train $( T \ll N )$ ).
Aging Evolution We score $N$ random models with our proxy metric and choose the ones ranked highest as the initial population (pool) in the aging evolution (AE) algorithm (Real et al., 2019).
Reinforcement Learning In the REINFORCE algorithm (Zoph & Le (2017)), we sample $N$ random models and use their zero-cost scores to reward the controller, thus biasing it towards selecting architectures which are likely to have higher values of the chosen metrics. During warmup, reward for the controller is calculated by linearly normalizing values returned by the proxy functions to the range $[ - 1 , 1 ]$ (with online adjustment of min and max).
Binary Predictor We warm up a binary graph convolutional network (GCN) predictor from Dudziak et al. (2020) by training it to predict relative performance of two models by considering their zero-cost scores instead of accuracy. For $N$ warmup points, we use the relative rankings (according to the zero-cost metric) of all pairs of models $( 0 . 5 N ( N - 1 )$ pairs) when performing warmup training for the predictor. As in (Dudziak et al., 2020), models ranked by the predictor after each training round (including the warmup phase) and the top models are evaluated.
# 5.2 ZERO-COST MOVE PROPOSAL
Whereas warmup tries to leverage global correlation of the proxy metrics to the accuracy of models, move proposal focuses on a local neighborhood at each step. A common parameter for move proposal algorithms is denoted as $R$ and means sample ratio, i.e., how many models can be checked using zero-cost metrics each time we select a model to train.
Aging Evolution The algorithm is enhanced by performing “guided” mutations. More specifically, each time a model is being mutated (in the baseline algorithm this is done randomly) we consider all possible mutations with edit distance 1 from the current model, score them using the zero-cost proxies and select the best one to add to the pool.
 Figure 5: Search speedup with the synflow zero-cost proxy on NAS-Bench-ASR TIMIT.
Reinforcement Learning In the case of REINFORCE, move proposal is similar to warmup – instead of rewarding a controller $N$ time before the search begins, we interleave $R$ zero-cost rewards for each accuracy reward $( R \ll N$ ).
# 5.3 RESULTS
For all NAS experiments, we repeat experiments 32 times and we plot the median and shade between the lower/upper quartiles. Our baselines are already heavily tuned and achieve the same or better results than those reported in the original NAS-Bench-101/201 papers. When adding zero-cost warmup or move proposal with synflow, we leave all search hyper-parameters unchanged.
NAS-Bench-201 The global/top- $10 \%$ rank correlations of synflow for this dataset are (0.76/0.42) so we expect this proxy to perform quite well. Indeed, as Figure 4 and Table 7 show, we improve search speed on all four types of searches using zero-cost warmup and move proposal. RAND and RL are both significantly improved, both in terms of sample efficiency and final achieved accuracy. But even more powerful algorithms like AE and BP exhibit $5 . 6 \times$ and $2 . 3 \times$ speedups respectively to arrive at $7 3 . 5 \%$ accuracy. Generally, the more zero-cost warmup, the better the results. This holds true for all algorithms except RL which degrades at $1 5 \mathrm { k }$ warmup points, suggesting that the controller is overfitting to the synflow metric instead of learning to optimize for accuracy.
NAS-Bench-101 This dataset is an order of magnitude larger than NAS-Bench-201 and has lower global/top- $10 \%$ rank correlations of (0.37/0.14). In many ways, this provides a true test as to whether these lower correlations are still useful with zero-cost warmup and move proposal. Table 3 shows a summary of the results and Figure 7 (in Section A.6) shows the full plots. As the table shows, even with modest correlations, there is a major boost to all searching algorithms thus outperforming the best previously published result by a large margin and setting a new state-of-the-art result on this dataset. However, it is worth noting that the binary predictor exhibits no improvement (but also no degradation). Perhaps this is because it was already very sample-efficient and synflow warmup couldn’t help further due to its relatively poor correlation on this dataset.
Table 3: Comparison to prior work on NAS-Bench-101 dataset.
<table><tr><td rowspan="2"></td><td rowspan="2">Wen et al. (2019)</td><td rowspan="2">Wei et al. (2020)</td><td rowspan="2">Dudziak et al. (2020)</td><td colspan="3">Ours</td></tr><tr><td>RL+M(100)</td><td>AE+W (15k)</td><td>RAND+W (3k)</td></tr><tr><td># Trained Models</td><td>256</td><td>150</td><td>140</td><td>51</td><td>50</td><td>34</td></tr><tr><td>Test Accuracy [%]</td><td>94.17</td><td>94.14</td><td>94.22</td><td>94.22</td><td>94.22</td><td>94.22</td></tr></table>
NAS-Bench-ASR We repeat our evaluation on NAS-Bench-ASR with global/top- $10 \%$ correlations (0.40/0.40). Even though this is a different task (speech recognition), synflow warmup and move proposal both yield large improvements in search speeds compared to all baselines in Figure 5 and Table 8. For example, to achieve a phoneme error rate (PER) of $2 1 . 3 \%$ , baseline RAND and RL required $> 1 0 0 0$ trained models, and AE required 138 trained models; however, this is reduced to 68, 173 and 87 trained models with 2000 models of zero-cost warmup.
# 6 DISCUSSION
In this section we investigate why zero-cost NAS is effective in improving the sample efficiency of NAS algorithms by looking more closely at how top models are selected by the synflow proxy.
Warmup Table 4 shows the number of top- $5 \%$ most-accurate models ranked within the top 64 models by the synflow metric. If we compare random warmup versus zero-cost warmup with synflow, random warmup will only return $5 \%$ or $\sim 3$ models out of 64 that are within the top $5 \%$ of models whereas synflow warmup returns a higher number of top- $5 \%$ models as listed in Table 4. This is key to the improvements observed when adding zero-cost warmup to algorithms like random search or AE. For example, with AE, the numbers in Table 4 are indicative of the models that may end up in the initial AE pool. By initializing the AE pool with many good models, it becomes more likely that a random mutation will lead to an even better model, thus allowing the search to find a top model more quickly. Note that synflow is able to rank many good models in its top 64 models even when global/local correlation is low (as it is the case for NAS-Bench-ASR).
Table 4: Number of top- $5 \%$ most-accurate models within the top 64 models returned by synflow.
<table><tr><td colspan="3">NAS-Bench-201</td><td rowspan="2">NAS-Bench-101</td><td rowspan="2">NAS-Bench-ASR</td></tr><tr><td>CIFAR-10</td><td>CIFAR-100</td><td>ImageNet16-120</td></tr><tr><td>44</td><td>54</td><td>56</td><td>12</td><td>16</td></tr></table>
Move Proposal For a search algorithm like AE, search moves consist of random mutations (with edit distance 1 for our experiments) for a model from the AE pool. Zero-cost move proposal enhances this by trying out all possible mutations and selecting the best one according to synflow. To investigate how this improves search efficiency, we took 1000 random points and explored their local neighbourhood cluster of possible mutations. Table 5 shows the probability that the synflow proxy correctly identifies the top model. Indeed, synflow improves the chance of selecting the best mutation from $\sim 4 \%$ to $> 3 0 \%$ for NAS-Bench-201 and $12 \%$ for NAS-Bench-101. Even for NAS-Bench-ASR a random mutation has a $7 . 7 \%$ chance $( = 1 / 1 3 )$ to select the best mutation, but this increases to $10 \%$ with the synflow proxy thus speeding up convergence to top models.
Table 5: For 1000 clusters of models with edit distance 1, we empirically measure the probability that the synflow proxy will select the most accurate model from each cluster.
<table><tr><td rowspan="2"></td><td colspan="3">NAS-Bench-201</td><td rowspan="2">NAS-Bench-101</td><td rowspan="2">NAS-Bench-ASR</td></tr><tr><td>CIFAR-10</td><td>CIFAR-100</td><td>ImageNet16-120</td></tr><tr><td>Top Model Match</td><td>32%</td><td>35%</td><td>33%</td><td>12%</td><td>10%</td></tr><tr><td>Average Cluster Size</td><td>25</td><td>25</td><td>25</td><td>26</td><td>13</td></tr></table>
# 7 CONCLUSION
In this paper, we introduced six zero-cost proxies, mainly based on recent pruning-at-initialization work, that are used to rank neural network models in NAS. First, we compared to conventional proxies (EcoNAS) that perform reduced-computation training and we found that zero-cost proxies such as synflow can outperform EcoNAS in maintaining rank consistency. Next, we verified our zerocost metrics on four additional datasets of varying sizes and tasks and found that indeed out of the six initially-considered zero-cost metrics, only synflow was robust across all datasets for both global and top- $10 \%$ rank correlation. Finally, we proposed two ways to integrate synflow within NAS algorithms: zero-cost warmup and zero-cost move proposal. Both methods demonstrated significant speedups across four search algorithms and three NAS benchmarks, setting new state-of-the-art results for both NAS-Bench-101 and NAS-Bench-201 datasets. Our strong and consistent empirical results suggest that the synflow metric, when combined with warmup and move proposal can be an effective and reliable methodology for speeding up different NAS algorithms. We hope that our work lays a foundation for further zero-cost techniques that expose favourable model properties with little computation thus making NAS more readily accessible without exorbitant computing resources. The most immediate open question for future investigation is why the synflow proxy works well – analytical insights will enable further research in zero-cost NAS proxies.
# REFERENCES
Gabriel Bender, Pieter-Jan Kindermans, Barret Zoph, Vijay Vasudevan, and Quoc V. Le. Understanding and simplifying one-shot architecture search. In International Conference on Machine Learning (ICML), 2018.
Han Cai, Tianyao Chen, Weinan Zhang, Yong Yu, and Jun Wang. Efficient architecture search by network transformation. In AAAI Conference on Artificial Intelligence (AAAI), 2018.
Wayne W. Daniel. Applied Nonparametric Statistics. Boston: PWS-Kent, 1990.
Jia Deng, Wei Dong, Richard Socher, Li-Jia Li, Kai Li, and Li Fei-Fei. ImageNet: A Large-Scale Hierarchical Image Database. In CVPR, 2009.
Xuanyi Dong and Yi Yang. NAS-Bench-201: Extending the Scope of Reproducible Neural Architecture Search. In International Conference on Learning Representations (ICLR), 2020.
Łukasz Dudziak, Thomas Chau, Mohamed S. Abdelfattah, Royson Lee, Hyeji Kim, and Nicholas D. Lane. BRP-NAS: Prediction-based NAS using GCNs. In Neural Information Processing Systems (NeurIPS), 2020.
Mikhail Figurnov, Aizhan Ibraimova, Dmitry P Vetrov, and Pushmeet Kohli. Perforatedcnns: Acceleration through elimination of redundant convolutions. In Neural Information Processing Systems (NeurIPS), 2016.
Jonathan Frankle and Michael Carbin. The lottery ticket hypothesis: Finding sparse, trainable neural networks. In International Conference on Learning Representations (ICLR), 2019.
John S. Garofolo, Lori F. Lamel, William M. Fisher, Jonathan G. Fiscus, David S. Pallett, Nancy L. Dahlgren, and Victor Zue. Timit acoustic phonetic continuous speech corpus. Linguistic Data Consortium, 1993. URL https://catalog.ldc.upenn.edu/LDC93S1.
Song Han, Jeff Pool, John Tran, and William Dally. Learning both weights and connections for efficient neural network. In Neural Information Processing Systems (NeurIPS), 2015.
Babak Hassibi and David G. Stork. Second order derivatives for network pruning: Optimal brain surgeon. In Advances in Neural Information Processing Systems 5, 1993.
Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Deep residual learning for image recognition. In Computer Vision and Pattern Recognition (CVPR), June 2016.
Andrew G. Howard, Menglong Zhu, Bo Chen, Dmitry Kalenichenko, Weijun Wang, Tobias Weyand, Marco Andreetto, and Hartwig Adam. MobileNets: Efficient Convolutional Neural Networks for Mobile Vision Applications. arXiv preprint arXiv:1704.04861, 2017.
Gao Huang, Zhuang Liu, Laurens van der Maaten, and Kilian Q. Weinberger. Densely connected convolutional networks. In Computer Vision and Pattern Recognition (CVPR), July 2017.
Nikita Klyuchnikov, Ilya Trofimov, Ekaterina Artemova, Mikhail Salnikov, Maxim Fedorov, and Evgeny Burnaev. Nas-bench-nlp: Neural architecture search benchmark for natural language processing. arXiv preprint arXiv:2006.07116, 2020.
Alex Krizhevsky. Learning Multiple Layers of Features from Tiny Images, 2009. URL https: //www.cs.toronto.edu/˜kriz/cifar.html.
Yann LeCun, John S. Denker, and Sara A. Solla. Optimal brain damage. In Neural Information Processing Systems (NeurIPS), 1990.
Namhoon Lee, Thalaiyasingam Ajanthan, and Philip HS Torr. Snip: Single-shot network pruning based on connection sensitivity. In International Conference on Learning Representations (ICLR), 2019.
Hanxiao Liu, Karen Simonyan, and Yiming Yang. DARTS: Differentiable architecture search. In International Conference on Learning Representations (ICLR), 2019.
Abhinav Mehrotra, Alberto Gil Ramos, Sourav Bhattacharya, Łukasz Dudziak, Ravichander Vipperla, Thomas Chau, Mohamed S. Abdelfattah, Samin Ishtiaq, and Nicholas D. Lane. NASBench-ASR: Reproducible Neural Architecture Search for Speech Recognition. In International Conference on Learning Representations (ICLR), 2021.
Jieru Mei, Yingwei Li, Xiaochen Lian, Xiaojie Jin, Linjie Yang, Alan Yuille, and Jianchao Yang. AtomNAS: Fine-grained end-to-end neural architecture search. In International Conference on Learning Representations (ICLR), 2020.
Joseph Mellor, Jack Turner, Amos Storkey, and Elliot J. Crowley. Neural architecture search without training. arXiv preprint arXiv:2006.04647, 2020.
Pavlo Molchanov, Stephen Tyree, Tero Karras, Timo Aila, and Jan Kautz. Pruning convolutional neural networks for resource efficient inference. In International Conference on Learning Representations (ICLR), 2017.
Yuval Netzer, Tao Wang, Adam Coates, Alessandro Bissacco, Bo Wu, and Andrew Y. Ng. Reading Digits in Natural Images with Unsupervised Feature Learning. In NeurIPS Workshop on Deep Learning and Unsupervised Feature Learning, 2011.
Barak A. Pearlmutter. Fast Exact Multiplication by the Hessian. Neural Computation, 1993.
Hieu Pham, Melody Y. Guan, Barret Zoph, Quoc V. Le, and Jeff Dean. Efficient neural architecture search via parameter sharing, 2018.
Esteban Real, Alok Aggarwal, Yanping Huang, and Quoc V. Le. Regularized Evolution for Image Classifier Architecture Search. In AAAI Conference on Artificial Intelligence (AAAI), 2019.
Oleg Semery. PyTorchCV Convolutional neural networks for computer vision, August 2020. URL ´ https://github.com/osmr/imgclsmob.
Mingxing Tan and Quoc Le. EfficientNet: Rethinking model scaling for convolutional neural networks. In International Conference on Machine Learning (ICML), 2019a.
Mingxing Tan and Quoc V. Le. Mixconv: Mixed depthwise convolutional kernels, 2019b.
Hidenori Tanaka, Daniel Kunin, Daniel L. K. Yamins, and Surya Ganguli. Pruning neural networks without any data by iteratively conserving synaptic flow. arXiv preprint arXiv:2006.05467, 2020.
Lucas Theis, Iryna Korshunova, Alykhan Tejani, and Ferenc Huszar. Faster gaze prediction with ´ dense networks and fisher pruning. arXiv:1801.05787, 2018.
Jack Turner, Elliot J. Crowley, Michael O’Boyle, Amos Storkey, and Gavin Gray. Blockswap: Fisher-guided block substitution for network compression on a budget. In International Conference on Learning Representations (ICLR), 2020.
Chaoqi Wang, Guodong Zhang, and Roger Grosse. Picking winning tickets before training by preserving gradient flow. In International Conference on Learning Representations (ICLR), 2020.
Chen Wei, Chuang Niu, Yiping Tang, and Jimin Liang. NPENAS: Neural predictor guided evolution for neural architecture search. arXiv 2003.12857, 03 2020.
Wei Wen, Hanxiao Liu, Hai Li, Yiran Chen, Gabriel Bender, and Pieter-Jan Kindermans. Neural predictor for neural architecture search. arXiv:1912.00848, 2019.
Chris Ying, Aaron Klein, Eric Christiansen, Esteban Real, Kevin Murphy, and Frank Hutter. NASbench-101: Towards reproducible neural architecture search. In International Conference on Machine Learning (ICML), 2019.
Dongzhan Zhou, Xinchi Zhou, Wenwei Zhang, Chen Change Loy, Shuai Yi, Xuesen Zhang, and Wanli Ouyang. Econas: Finding proxies for economical neural architecture search. In Conference on Computer Vision and Pattern Recognition (CVPR), June 2020.
Barret Zoph and Quoc V. Le. Neural architecture search with reinforcement learning. In International Conference on Learning Representations (ICLR), 2017.
# A APPENDIX
Because this paper is empirically-driven, there are many more results than what we presented in the main text of the paper. In the appendix we list many important results that support our main arguments and hypotheses in the main text of this paper.
# A.1 EXPERIMENTAL DETAILS
In Table 6 we list the hyper-parameters used in training the EcoNAS proxies to produce Figure 1. The only difference to the standard NAS-Bench-201 training pipeline (Dong & Yang, 2020) is our use of fewer epochs for the learning rate annealing schedule – we anneal the learning rate to zero over 40 epochs instead of 200. This is a common technique used in speeding up convergence for training proxies Zhou et al. (2020). We acknowledge that slightly better correlations could have been achieved for econas and econas $^ +$ proxies in Figure 1 if the learning rate was annealed to zero over fewer epochs (20 and 15 epochs respectively). However, we do not anticipate the results to change significantly.
Table 6: EcoNAS training hyper-parameters for NAS-Bench-201.
<table><tr><td>optimizer Nesterov momentum weight decay</td><td>SGD √ 0.9 0.0005 (p=0.5)</td><td>initial LR final LR LR schedule epochs batch size</td><td>0.1 0 cosine 40 256</td></tr></table>
One additional comment regarding Figure 1 in the main paper. While we run the training ourselves for all EcoNAS variants in the plot, we take the data for the line labeled baseline directly from the NAS-Bench-201 dataset. We are not sure why the line is not smooth like the lines for the EcoNAS variants that we trained but assume that this is an artifact of averaging over multiple seeds in the NAS-Bench-201 dataset. In any case, we do not anticipate that this would change any conclusions or observations that we draw from this plot.
Finally, we would like to note some details about our NAS experiments in Section 5. NAS datasets provide multiple seeds of results for each model, so whenever we “train” a model, we query a random seed from the database to mimic a real NAS pipeline without caching. We refer the reader to (Dudziak et al., 2020), specifically Section S3.2 for more details on this.
# A.2 GPU RUNTIME FOR ECONAS
Figure 6 shows the speedup of different EcoNAS proxies compared to baseline training. Even though $r _ { 8 } c _ { 4 }$ has $6 4 \times$ less computation compared to $r _ { 3 2 } c _ { 1 6 }$ , it achieves a maximum of $4 \times$ real speedup even when the batch size is increased.
 Figure 6: Higher batch sizes when training econas proxies have diminishing returns in terms of measured speedup. This measurement is done for 10 randomly-sampled NAS-Bench-201 models on the CIFAR-10 dataset.
# A.3 TABULATED RESULTS
This subsection contains tabulated results from Figures 4 and 5 to facilitate comparisons with future work. Tables 7 and 8 highlight important data points about the NAS searches we conducted with NAS-Bench-201 and NAS-Bench-ASR respectively. We highlight results in two ways: First, we show the accuracy of the best model found after 50 trained models. Second, we indicate the number of trained models needed for each search method to reach a specific accuracy $7 3 . 5 \%$ CIFAR-10 classification accuracy for NAS-Bench-201 and $2 1 . 3 \%$ TIMIT PER.) We colour the best results (red) and the second best (blue) results in each table.
Table 7: Zero-cost NAS comparison with baseline algorithms on NAS-Bench-201 CIFAR-100. We show accuracy after 50 trained models and the number of models to reach $7 3 . 5 \%$ accuracy.
<table><tr><td rowspan="2"></td><td rowspan="2">Baseline</td><td colspan="3">Warmup</td><td colspan="2">Move</td></tr><tr><td>1000 (BP=256)</td><td>3000 (BP=512)</td><td>15k</td><td>10</td><td>100</td></tr><tr><td>RAND</td><td>71.31/1000+</td><td>72.98 /1000+</td><td>73.18 /1000+</td><td>73.75 /8</td><td></td><td>1</td></tr><tr><td>RL</td><td>71.08 /1000+</td><td>72.76 /145</td><td>73.14/84</td><td>73.21/107</td><td>71.16/289</td><td>73.34 / 70</td></tr><tr><td>AE</td><td>71.53 /139</td><td>72.91 / 115</td><td>73.40 /71</td><td>73.63 / 25</td><td>71.3 /77</td><td></td></tr><tr><td>BP</td><td>72.74 /93</td><td>73.32 / 66</td><td>73.85 / 40</td><td>1</td><td></td><td>1</td></tr></table>
Table 8: Zero-cost NAS comparison with baseline algorithms on NAS-Bench-ASR. We show PER after 50 trained models and the number of models to reach PER $= 2 1 . 3 \%$ .
<table><tr><td rowspan="2"></td><td rowspan="2">Baseline</td><td colspan="2">Warmup</td><td colspan="2">Move</td></tr><tr><td>500</td><td>2000</td><td>10</td><td>100</td></tr><tr><td>RAND</td><td>21.65 /1000+</td><td>21.38 /1000+</td><td>21.35 / 68</td><td></td><td></td></tr><tr><td>RL</td><td>21.66 /1000+</td><td>21.48 /1000+</td><td>21.45 / 173</td><td>21.62 / 169</td><td>21.43 / 161</td></tr><tr><td>AE</td><td>21.62 / 138</td><td>21.40 / 115</td><td>21.36 / 87</td><td></td><td>21.74 / 112</td></tr></table>
# A.4 ANALYSIS OF THE TOP $10 \%$ OF MODELS
In the main text we pointed to the fact that only synflow achieves consistent rank correlation for the top- $10 \%$ of models across different datasets. Here, in Table 9 we provide the full results. Additionally, we hypothesized that a successful metric will rank many of the most-accurate models in its top models. In Table 10 we enumerate the percentage of top- $10 \%$ most accurate models ranked as top- $10 \%$ by each proxy metric. Again, synflow is the only consistent metric for all datasets, and performs best on average.
Table 9: Spearman $\rho$ of zero-cost proxies for the top $10 \%$ of points on all NAS search spaces.
<table><tr><td></td><td>grad_norm</td><td>snip</td><td>grasp</td><td>fisher</td><td>synflow</td><td> jacob_cov</td></tr><tr><td>NB2-CIFAR-10</td><td>-0.38</td><td>-0.38</td><td>-0.37</td><td>-0.38</td><td>0.18</td><td>0.17</td></tr><tr><td>NB2-CIFAR-100</td><td>-0.09</td><td>-0.09</td><td>-0.11</td><td>-0.16</td><td>0.42</td><td>0.08</td></tr><tr><td>NB2-ImageNet16-120</td><td>0.13</td><td>0.13</td><td>0.10</td><td>0.02</td><td>0.55</td><td>0.05</td></tr><tr><td>NAS-Bench-101</td><td>0.05</td><td>-0.01</td><td>-0.01</td><td>0.07</td><td>0.14</td><td>0.08</td></tr><tr><td>NAS-Bench-NLP</td><td>-0.03</td><td>-0.02</td><td>0.04</td><td>1</td><td>0.10</td><td>0.04</td></tr><tr><td>NAS-Bench-ASR</td><td>0.25</td><td>0.13</td><td>1</td><td>-0.07</td><td>0.40</td><td>-0.03</td></tr></table>
# A.5 ANALYSIS OF WARMUP AND MOVE PROPOSAL
This section provides more results relevant to our discussion in Section 6. Table 11 shows the number of top- $5 \%$ models ranked in the top 64 models by each metric. This is an extension to Table 4 in the main text that only shows the results for synflow. As shown in the table, synflow is the most powerful metric that we tried.
Table 12 shows the rank correlation coefficient of models within 1000 randomly-sampled local clusters of models. This result highlights that both grad norm and jacob cov work well in distinguishing between very similar models. However, synflow still consistently the best metric in this analysis. Furthermore, we measure the percentage of times that a metric correctly predicts the top model within a local cluster of models in Table 13 This is an extension to Table 5 in the main text. The results are averaged over 1000 randomly-sampled local clusters. Again, synflow has the highest probability of selecting the top model compared to other zero-cost metrics.
Table 10: Percentage of top- $10 \%$ most-accurate models within the top- $10 \%$ of models ranked by each zero-cost metric.
<table><tr><td></td><td>grad_norm</td><td>snip</td><td>grasp</td><td>fisher</td><td>synflow</td><td> jacob_cov</td></tr><tr><td>NB2-CIFAR-10</td><td>30%</td><td>31%</td><td>30%</td><td>5%</td><td>46%</td><td>25%</td></tr><tr><td>NB2-CIFAR-100</td><td>35%</td><td>36%</td><td>34%</td><td>4%</td><td>50%</td><td>24%</td></tr><tr><td>NB2-ImageNet16-120</td><td>31%</td><td>31%</td><td>32%</td><td>5%</td><td>44%</td><td>30%</td></tr><tr><td>NAS-Bench-101</td><td>2%</td><td>3%</td><td>26%</td><td>3%</td><td>23%</td><td>2%</td></tr><tr><td>NAS-Bench-NLP</td><td>10%</td><td>10%</td><td>4%</td><td>1</td><td>22%</td><td>38%</td></tr><tr><td>NAS-Bench-ASR</td><td>0%</td><td>0%</td><td>1</td><td>0%</td><td>15%</td><td>46%</td></tr></table>
Table 11: Number of top- $5 \%$ most-accurate models within the top-64 models returned by each metric.
<table><tr><td></td><td>grad_norm</td><td>snip</td><td>grasp</td><td>fisher</td><td>synflow</td><td>jacob_cov</td></tr><tr><td>NB2-CIFAR-10</td><td>0</td><td>0</td><td>0</td><td>0</td><td>44</td><td>15</td></tr><tr><td>NB2-CIFAR-100</td><td>4</td><td>4</td><td>4</td><td>0</td><td>54</td><td>16</td></tr><tr><td>NB2-ImageNet16-120</td><td>13</td><td>13</td><td>14</td><td>0</td><td>56</td><td>15</td></tr><tr><td>NAS-Bench-101</td><td>0</td><td>0</td><td>6</td><td>0</td><td>12</td><td>0</td></tr><tr><td>NAS-Bench-ASR</td><td>1</td><td>0</td><td>1</td><td>1</td><td>16</td><td>13</td></tr></table>
Table 12: Rank correlation coefficient for the local neighbourhoods (edit distance $= 1$ ) of 1000 clusters in each search space.
<table><tr><td></td><td>grad_norm</td><td>snip</td><td>grasp</td><td>fisher</td><td>synflow</td><td> jacob_cov</td></tr><tr><td>NB2-CIFAR-10</td><td>0.51</td><td>0.51</td><td>0.37</td><td>0.37</td><td>0.66</td><td>0.62</td></tr><tr><td>NB2-CIFAR-100</td><td>0.58</td><td>0.58</td><td>0.44</td><td>0.41</td><td>0.69</td><td>0.61</td></tr><tr><td>NB2-ImageNet16-120</td><td>0.56</td><td>0.57</td><td>0.5</td><td>0.4</td><td>0.67</td><td>0.61</td></tr><tr><td>NAS-Bench-101</td><td>0.23</td><td>0.21</td><td>0.44</td><td>0.27</td><td>0.36</td><td>0.37</td></tr><tr><td>NAS-Bench-ASR</td><td>0.59</td><td>0.4</td><td>1</td><td>0.56</td><td>0.38</td><td>0.28</td></tr></table>
Table 13: For 1000 clusters of points with edit distance $= 1$ . We count the number of times wherein the top model returned by a zero-cost metric matches the top model according to validation accuracy. This represents the probability that zero-cost move proposal will perform the best possible mutation.
<table><tr><td></td><td> grad_norm</td><td>snip</td><td>grasp</td><td>fisher</td><td>synflow</td><td> jacob_cov</td></tr><tr><td>NB2-CIFAR-10</td><td>14.8%</td><td>14.8%</td><td>12.7%</td><td>5.7%</td><td>32.2%</td><td>14.5%</td></tr><tr><td>NB2-CIFAR-100</td><td>19.1%</td><td>18.5%</td><td>14.2%</td><td>6.0%</td><td>35.4%</td><td>13.8%</td></tr><tr><td>NB2-ImageNet16-120</td><td>17.5%</td><td>18.5%</td><td>15.7%</td><td>5.5%</td><td>33.4%</td><td>16.7%</td></tr><tr><td>NAS-Bench-101</td><td>0.4%</td><td>0.9%</td><td>7.4%</td><td>0.5%</td><td>12.3%</td><td>0.5%</td></tr><tr><td>NAS-Bench-ASR</td><td>11.0%</td><td>9.8%</td><td>1</td><td>10.3%</td><td>10.3%</td><td>10.5%</td></tr></table>
# A.6 NAS-BENCH-101 SEARCH PLOTS
Figure 7 shows the NAS search curves for all considered algorithms on NAS-Bench-101 dataset. Important points from this plot are summarized in Table 3 in the main text.
 Figure 7: Search speedup with the synflow zero-cost proxy on NAS-Bench-101 CIFAR-10.
# A.7 SENSITIVITY ANALYSIS
We performed some sensitivity analysis to investigate how the zero-cost metrics perform on all points within NAS-Bench-201 with different initialization seed, initialization method and minibatch size. We comment on each table in its caption; however, to summarize, all metrics seem to be relatively unaffected when initialization and minibatch size are varied. The one exception can be seen in Table 15 where fisher benefits when biases are initialized with zeroes.
Table 14: All metrics remain fairly constant when varying the initialization seed – the variations are only observed at the third significant digit. Dataload is random with 128 samples and initialization is done with default PyTorch initialization scheme.
<table><tr><td>seed</td><td>grad_norm</td><td>snip</td><td>grasp</td><td>fisher</td><td>synflow</td><td> jacob_cov</td></tr><tr><td>1</td><td>0.578</td><td>0.581</td><td>0.487</td><td>0.361</td><td>0.737</td><td>0.735</td></tr><tr><td>2</td><td>0.580</td><td>0.583</td><td>0.488</td><td>0.354</td><td>0.740</td><td>0.728</td></tr><tr><td>3</td><td>0.582</td><td>0.584</td><td>0.486</td><td>0.358</td><td>0.738</td><td>0.726</td></tr><tr><td>4</td><td>0.581</td><td>0.584</td><td>0.491</td><td>0.356</td><td>0.738</td><td>0.73</td></tr><tr><td>5</td><td>0.581</td><td>0.583</td><td>0.486</td><td>0.356</td><td>0.738</td><td>0.727</td></tr><tr><td>Average</td><td>0.580</td><td>0.583</td><td>0.488</td><td>0.357</td><td>0.738</td><td>0.729</td></tr></table>
Table 15: fisher becomes noticeably better when biases are initialized to zero; otherwise, metrics seem to perform independently of initialization method. Results averaged over 3 seeds.
<table><tr><td>Weights init</td><td>Bias init</td><td> grad_norm</td><td>snip</td><td>grasp</td><td>fisher</td><td>synflow</td><td> jacob_cov</td></tr><tr><td>default</td><td>default</td><td>0.580</td><td>0.583</td><td>0.488</td><td>0.357</td><td>0.738</td><td>0.729</td></tr><tr><td>kaiming</td><td>default</td><td>0.548</td><td>0.558</td><td>0.364</td><td>0.332</td><td>0.731</td><td>0.723</td></tr><tr><td>xavier</td><td>default</td><td>0.543</td><td>0.568</td><td>0.424</td><td>0.345</td><td>0.736</td><td>0.729</td></tr><tr><td>default</td><td>zero</td><td>0.581</td><td>0.583</td><td>0.488</td><td>0.509</td><td>0.738</td><td>0.729</td></tr><tr><td>kaiming</td><td>zero</td><td>0.542</td><td>0.551</td><td>0.370</td><td>0.479</td><td>0.730</td><td>0.723</td></tr><tr><td>xavier</td><td>zero</td><td>0.540</td><td>0.566</td><td>0.412</td><td>0.495</td><td>0.735</td><td>0.730</td></tr></table>
Table 16: Surprisingly, grasp becomes worse with more (random) data, while grad norm and snip degrade very slightly. Other metrics seem to perform independently of the number of samples in the minibatch. Initialization is done with default PyTorch initialization scheme.
<table><tr><td>Number of Samples</td><td>grad_norm</td><td>snip</td><td>grasp</td><td>fisher</td><td>synflow</td><td> jacob_cov</td></tr><tr><td>32</td><td>0.595</td><td>0.596</td><td>0.511</td><td>0.362</td><td>0.737</td><td>0.732</td></tr><tr><td>64</td><td>0.589</td><td>0.59</td><td>0.509</td><td>0.361</td><td>0.737</td><td>0.735</td></tr><tr><td>128</td><td>0.578</td><td>0.581</td><td>0.487</td><td>0.361</td><td>0.737</td><td>0.735</td></tr><tr><td>256</td><td>0.564</td><td>0.569</td><td>0.447</td><td>0.361</td><td>0.737</td><td>0.731</td></tr><tr><td>512</td><td>0.547</td><td>0.552</td><td>0.381</td><td>0.361</td><td>0.737</td><td>0.724</td></tr></table>
# A.8 RESULTS FOR ALL ZERO-COST METRICS
Here we provide some NAS search results using all considered metrics for both RAND and AE searches on NAS-Bench-101/201 datasets. Our experiments point to synflow as the only effective zero-cost metric across different datasets; however, we provide the plots below for the reader to inspect how poorer metrics perform in NAS.
 (d) NAS-Bench-101 CIFAR-10 Figure 8: Evaluation of all zero-cost proxies on different datasets and search algorithms: random search (RAND) and aging evolution (AE). RAND benefits greatly from a strong metric (such as synflow) but may deteriorate with a weaker metric as shown in the plot. However, AE benefits when a strong metric is used and is resilient to weaker metrics as well – it is able to recover and achieve the top accuracy in most cases.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361# Towards Instance-Optimal Offline Reinforcement Learning with Pessimism
Ming Yin 1,2 and Yu-Xiang Wang1
1Department of Computer Science, UC Santa Barbara 2Department of Statistics and Applied Probability, UC Santa Barbara ming_yin@ucsb.edu yuxiangw@cs.ucsb.edu
# Abstract
We study the offline reinforcement learning (offline RL) problem, where the goal is to learn a reward-maximizing policy in an unknown Markov Decision Process (MDP) using the data coming from a policy $\mu$ . In particular, we consider the sample complexity problems of offline RL for finite-horizon MDPs. Prior works study this problem based on different data-coverage assumptions, and their learning guarantees are expressed by the covering coefficients which lack the explicit characterization of system quantities. In this work, we analyze the Adaptive Pessimistic Value Iteration (APVI) algorithm and derive the suboptimality upper bound that nearly matches
$$O \left( \sum _ { h = 1 } ^ { H } \sum _ { s _ { h } , a _ { h } } { d _ { h } ^ { \pi ^ { \star } } ( s _ { h } , a _ { h } ) \sqrt { \frac { \mathrm { V a r } _ { P _ { s _ { h } , a _ { h } } } ( V _ { h + 1 } ^ { \star } + r _ { h } ) } { d _ { h } ^ { \mu } ( s _ { h } , a _ { h } ) } } \sqrt { \frac { 1 } { n } } } \right) .$$
In complementary, we also prove a per-instance information-theoretical lower bound under the weak assumption that $d _ { h } ^ { \mu } ( s _ { h } , a _ { h } ) > 0$ if $d _ { h } ^ { \pi ^ { \star } } ( s _ { h } , a _ { h } ) > 0$ . Different from the previous minimax lower bounds, the per-instance lower bound (via local minimaxity) is a much stronger criterion as it applies to individual instances separately. Here $\pi ^ { \star }$ is a optimal policy, $\mu$ is the behavior policy and $d _ { h } ^ { \mu }$ is the marginal state-action probability. We call (1) the intrinsic offline reinforcement learning bound since it directly implies all the existing optimal results: minimax rate under uniform data-coverage assumption, horizon-free setting, single policy concentrability, and the tight problem-dependent results. Later, we extend the result to the assumption-free regime (where we make no assumption on $\mu$ ) and obtain the assumption-free intrinsic bound. Due to its generic form, we believe the intrinsic bound could help illuminate what makes a specific problem hard and reveal the fundamental challenges in offline RL.
# 1 Introduction
In offline reinforcement learning (offline RL Levine et al. [2020], Lange et al. [2012]), the goal is to learn a reward-maximizing policy in an unknown environment (Markov Decision Process or MDP) using the historical data coming from a (fixed) behavior policy $\mu$ . Unlike online RL, where the agent can keep interacting with the environment and gain new feedback by exploring unvisited state-action space, offline RL usually populates when such online interplays are expensive or even unethical. Due to its nature of without the access to interact with the MDP model (which causes the distributional mismatches), most of the literature that study the sample complexity / provable efficiency of offline RL (e.g. Le et al. [2019], Chen and Jiang [2019], Xie and Jiang [2020, 2021],
Yin et al. [2021a,b], Ren et al. [2021], Rashidinejad et al. [2021], Xie et al. [2021b]) rely on making different data-coverage assumptions for making the problem learnable and provide the near-optimal worst-case performance bounds that depend on their data-coverage coefficients. Those results are valuable in general as they do not depend on the structure of the particular problem, therefore, remain valid even for pathological MDPs. But is this good enough?
In practice, the empirical performances of offline reinforcement learning (e.g. Gulcehre et al. [2020], Fu et al. [2020, 2021], Janner et al. [2021]) are often far better than what those non-adaptive / problem-independent bounds would indicate. Although empirical evidence can help explain why we may observe better or worse performances on different MDPs, a systematic understanding of what types of decision processes and what kinds of behavior policies are inherently easier or more challenging for offline RL is lacking. Besides, despite the fact that a non-adaptive bound can learn even the pathological examples within the assumption family, there is no guarantee for the instances outside the family. However, practical offline reinforcement learning problems are usually beyond the scope of certain data-coverage assumptions, which limits the applicability of those results. Can we make as few assumptions as possible? Or even more, what can we guarantee when no assumption is made about offline learning?
Those motivate us to derive the provably efficient bounds that are adaptive to the individual instances but only require minimal assumptions so they can be widely applied in most cases. Ideally, such bounds should characterize the system structures of the specific problems, hold even for peculiar instances that do not satisfy the standard data-coverage assumptions, and recover the worst-case guarantees when the assumptions are satisfied. As mentioned in Zanette and Brunskill [2019], a fully adaptive characterization in RL is important as it might bring considerable saving in the time spent designing domain-specific RL solutions and in training a human expert to judge and recognize the complexity of different problems.
# 1.1 Our contribution
In this work, we provide the analysis for the adaptive pessimistic value iteration (APVI) (Algorithm 1) with finite horizon time-inhomogeneous (non-stationary) MDPs and derive a strong adaptive bound that is near-optimal under the weak assumption $d _ { h } ^ { \mu } ( s _ { h } , a _ { h } ) > 0$ if $d _ { h } ^ { \pi ^ { \star } } ( s _ { h } , a _ { h } ) > \bar { 0 }$ (Theorem 4.1). Specifically, our bound (quantity (1)) explicitly depends on the marginal importance ratios (between the optimal policy $\pi ^ { \star }$ and the behavior policy $\mu _ { . }$ ) and the per-step conditional variances. In addition, we provide an instance-dependent (local minimax) lower bound (Theorem 4.3) to certify (1) is nearly optimal at the instance level for offline learning and call it the intrinsic offline learning bound. The intrinsic bound has the following consequences.
• In the non-adaptive / worst-case regime (4.1-4.3), the intrinsic bound implies $\widetilde { O } ( H ^ { 3 } / d _ { m } \epsilon ^ { 2 } )$ complexity under the uniform data-coverage 2.1, $\tilde { O } ( H ^ { 3 } S C ^ { \star } / \epsilon ^ { 2 } )$ complexity under the single policy concentrability assumption 2.3 and $\widetilde { O } ( H / d _ { m } \epsilon ^ { 2 } )$ complexity when the sum of rewards is bounded by 1. All of those are optimal in their respectively regimes [Yin et al., 2021a, Rashidinejad et al., 2021, Xie et al., 2021b, Ren et al., 2021];
• In the adaptive domain (4.4), the intrinsic bound implies the tight problem-dependent counterpart of Zanette and Brunskill [2019], yields ${ \tilde { O } } ( H ^ { 3 } / n d _ { m } )$ fast convergence in the deterministic systems, has improved complexity in the partially deterministic systems and a family of highly mixing problems, and remains optimal when reducing to the tabular contextual bandits.
Beyond the above, due to the generic form of the intrinsic bound, we could come up with as many problem instances (that are of our interests) as possible and study their properties. In this sense, the intrinsic bound helps illuminate the fundamental nature of offline RL.
Furthermore, as a step towards assumption-free offline reinforcement learning, we build a modified AVPI and obtain an adaptive bound that could characterize the suboptimality gap in the state-action space that is agnostic to the behavior policy (Theorem 5.1). To the best of our knowledge, all of these results are the first of its kinds.
# 1.2 Related work
Finite sample analysis for offline reinforcement learning can be traced back to Szepesvári and Munos [2005], Antos et al. [2008a,b] for the infinite horizon discounted setting via Fitted Q-Iteration (FQI) type function approximation algorithms. [Chen and Jiang, 2019, Le et al., 2019, Xie and Jiang, 2021, 2020] follow this line of research and derive the information-theoretical bounds. Recently, Xie and Jiang [2021] considers the offline RL with only the realizability assumption, Liu et al. [2020], Chang et al. [2021] considers the offline RL without sufficient coverage and Kidambi et al. [2020], Uehara and Sun [2021] uses the model-based approach for addressing offline RL. Under those weak coverage assumption, their finite sample analysis are suboptimal (e.g. in terms of the effective horizon $( 1 - \gamma ) ^ { \bar { - } 1 } .$ ). Recently, Yin et al. [2021a,b], Ren et al. [2021] study the finite horizon case. In the linear MDP case, Jin et al. [2020] studies the pessimistic algorithm for offline policy learning under only the compliance assumption, and, concurrently, Xie et al. [2021a] proposes the general pessimistic function approximation framework with instantiation in linear MDP and Zanette et al. [2021] shows actor-critic style algorithm is near-optimal for linear Bellman complete model. In addition, Wang et al. [2021], Zanette [2021] prove some exponential lower bounds under their linear function approximation assumptions.
Among them, there are a few works that achieve the sample optimality under their respective assumptions. Under the uniform data coverage (minimal state-action probability $d _ { m } > 0$ ), Yin et al. [2021a] first proves the optimal ${ \cal \tilde { O } } ( H ^ { 3 } / d _ { m } \epsilon ^ { 2 } )$ complexity in the time-inhomogeneous MDP. Recently, Yin et al. [2021b] designs the offline variance reduction algorithm to achieve the optimal $\tilde { O } ( H ^ { 2 } / d _ { m } \epsilon ^ { 2 } )$ rate for the time-homogeneous case. Under the setting where the total cumulative reward is bounded by 1, Ren et al. [2021] obtains the horizon-free result with $\tilde { O } ( 1 / d _ { m } )$ . More recently, Rashidinejad et al. [2021] considers the single concentrability coefficient $\begin{array} { r } { C ^ { \star } : = \operatorname* { m a x } _ { s , a } d ^ { \pi ^ { \star } } ( s , a ) / d ^ { \mu } ( s , a ) } \end{array}$ and derives the upper bound $\tilde { O } [ ( 1 - \gamma ) ^ { - 5 } S C ^ { \star } / \epsilon ^ { 2 } ]$ in the infinite horizon setting which is recently improved by the concurrent work Xie et al. [2021b]. While those worst-case guarantees are desirable, none of them can explain the hardness of the individual problems.1
# 2 Preliminaries
Episodic non-stationary (time-varying) reinforcement learning. A finite-horizon Markov Decision Process (MDP) is denoted by a tuple $M = ( S , A , P , r , H , d _ { 1 } )$ [Sutton and Barto, 2018], where $s$ is the finite state space and $\mathcal { A }$ is the finite action space with $S : = | S | < \infty , A : = | A | < \infty$ . A nonstationary transition kernel $P _ { h } : S \times \mathcal { A } \times \mathcal { S } \mapsto [ 0 , 1 ]$ maps each state action $\left( s _ { h } , a _ { h } \right)$ to a probability distribution $P _ { h } ( \cdot | s _ { h } , a _ { h } )$ and $P _ { h }$ can be different across the time. Besides, $r : S \times A \mapsto \mathbb { R }$ is the expected instantaneous reward function satisfying $0 \leq r \leq 1$ . $d _ { 1 }$ is the initial state distribution. $H$ is the horizon. A policy $\pi = ( \pi _ { 1 } , \ldots , \pi _ { H } )$ assigns each state $s _ { h } \in S$ a probability distribution over actions according to the map $s _ { h } \mapsto \pi _ { h } ( \cdot | s _ { h } ) \forall h \in [ H ]$ . An MDP together with a policy $\pi$ induce a random trajectory $s _ { 1 } , a _ { 1 } , r _ { 1 } , \ldots , s _ { H } , a _ { H } , r _ { H } , s _ { H + 1 }$ with $s _ { 1 } \sim d _ { 1 } , a _ { h } \sim \pi ( \cdot | s _ { h } ) , s _ { h + 1 } \sim P _ { h } ( \cdot | s _ { h } , a ) , \forall h \in [ H ]$ and $r _ { h }$ is a random realization given the observed $s _ { h } , a _ { h }$ .
$Q$ -values, Bellman (optimality) equations. The value function $V _ { h } ^ { \pi } ( \cdot ) \in \mathbb { R } ^ { S }$ and $\mathbf { Q }$ -value function $Q _ { h } ^ { \pi } ( \cdot , \cdot ) \in \mathbb { R } ^ { S \times A }$ for any policy $\pi$ is defined as: $V _ { h } ^ { \pi } ( s ) ~ = ~ \mathbb { E } _ { \pi } [ \sum _ { t = h } ^ { H } r _ { t } | s _ { h } = s ]$ , $Q _ { h } ^ { \pi } ( s , a ) =$ $\begin{array} { r } { \mathbb { E } _ { \pi } [ \sum _ { t = h } ^ { H } r _ { t } | s _ { h } , a _ { h } \ = \ s , a ] } \end{array}$ , $\forall s , a \in \mathcal { S } , \mathcal { A } , h \in [ H ]$ . The performance is defined as $v ^ { \pi } : =$ $\begin{array} { r } { \mathbb { E } _ { d _ { 1 } } \left[ V _ { 1 } ^ { \pi } \right] = \mathbb { E } _ { \pi , d _ { 1 } } \left[ \sum _ { t = 1 } ^ { H } r _ { t } \right] } \end{array}$ , where we denote $V _ { h } ^ { \pi } , Q _ { h } ^ { \pi }$ as column vectors and $P _ { h } ~ \in ~ \mathbb { R } ^ { S A \times S }$ the transition matrix, then the vector form Bellman (optimality) equations follow $\forall h \in [ H ]$ : $\begin{array} { r } { Q _ { h } ^ { \pi } = r _ { h } + P _ { h } V _ { h + 1 } ^ { \pi } } \end{array}$ , $V _ { h } ^ { \pi } = \mathbb { E } _ { a \sim \pi _ { h } } [ Q _ { h } ^ { \pi } ]$ , $Q _ { h } ^ { \star } = r _ { h } + P _ { h } V _ { h + 1 } ^ { \star }$ , $V _ { h } ^ { \star } = \operatorname* { m a x } _ { a } Q _ { h } ^ { \star } ( \cdot , a )$ .In addition, we denote the per-step marginal state-action occupancy $d _ { h } ^ { \pi } ( s , a )$ as: $d _ { h } ^ { \pi } ( s , a ) : = \mathbb { P } [ s _ { h } =$ $s | s _ { 1 } \sim d _ { 1 } , \pi ] \cdot \pi _ { h } ( a | s )$ , which is the marginal state-action probability at time $h$ .
Offline setting and the goal. The offline RL requires the agent to find a policy $\pi$ such that the performance $v ^ { \pi }$ is maximized, given only the episodic data $\mathcal { D } = \{ ( s _ { h } ^ { \tau } , a _ { h } ^ { \tau } , r _ { h } ^ { \tau } , s _ { h + 1 } ^ { \tau } ) \} _ { \tau \in [ n ] } ^ { h \in [ H ] }$ rolled out from some behavior policy $\mu$ . The offline nature requires we cannot change $\mu$ and in particular we do not assume the functional knowledge of $\mu$ . That is to say, given the batch data $\mathcal { D }$ and a targeted accuracy $\epsilon > 0$ , the offline RL seeks to find a policy $\pi _ { \mathrm { a l g } }$ such that $v ^ { \star } - v ^ { \pi _ { \mathrm { a l g } } } \leq \epsilon$ .
# 2.1 Assumptions in offline RL
We revise several types of assumptions proposed by existing studies that can yield provably efficient results. Recall $d _ { h } ^ { \mu } ( s _ { h } , a _ { h } )$ is the marginal state-action probability and $\mu$ is the behavior policy.
Assumption 2.1 (Uniform data coverage [Yin et al., 2021a]). The behavior policy obeys that $d _ { m } : =$ $\begin{array} { r } { \operatorname* { m i n } _ { h , s _ { h } , a _ { h } } d _ { h } ^ { \mu } ( s _ { h } , a _ { h } ) > 0 . } \end{array}$ . Here the infimum is over all the states satisfying there exists certain policy so that this state can be reached by the current MDP with this policy.
This is the strongest assumption in offline RL as it requires $\mu$ to explore each state-action pairs with positive probability. Under 2.1, it mostly holds $1 / d _ { m } \ge S A$ . This reveals offline learning is generically harder than the generative model setting [Agarwal et al., 2020] in the statistical sense. On the other hand, this is required for the uniform $O P E$ task in Yin et al. [2021a] as it seeks to simultaneously evaluate all the policies within the policy class and it is in general a harder task than offline learning itself.
Assumption 2.2 (Uniform concentrability Szepesvári and Munos [2005], Chen and Jiang [2019]). For all the policies, $\begin{array} { r } { C _ { \mu } : = \operatorname* { s u p } _ { \pi , h } | | d _ { h } ^ { \pi } ( \cdot , \cdot ) / d _ { h } ^ { \mu } ( \cdot , \cdot ) | | _ { \infty } < \infty . } \end{array}$ .
This is a classical offline RL condition that is commonly assumed in the function approximation scheme (e.g. Fitted Q-Iteration). Qualitatively, this is a uniform data-coverage assumption that is similar to Assumption 2.1, but quantitatively, the coefficient $C _ { \mu }$ can be smaller than $1 / \bar { d _ { m } } \bar { }$ due the $d _ { h } ^ { \pi }$ term in the numerator.
Assumption 2.3 (Liu et al. [2019]). There exists one optimal policy $\pi ^ { \star }$ , s.t. $\forall s _ { h } , a _ { h } \ \in \ S , A ,$ , $d _ { h } ^ { \mu } ( s _ { h } , a _ { h } ) \ > \ 0$ if $d _ { h } ^ { \pi ^ { \star } } ( s _ { h } , a _ { h } ) > 0$ . We further denote the trackable set as $\mathcal C _ { h } : = \{ ( s _ { h } , a _ { h } )$ : $d _ { h } ^ { \tilde { \mu } } ( s _ { h } , a _ { h } ) > 0 \}$ .
Assumption 2.3 is (arguably) the weakest assumption needed for accurately learning the optimal value $v ^ { \star }$ and we will use 2.3 for most parts of this paper. It only requires $\mu$ to trace the state-action space of one optimal policy and can be agnostic at other locations. Rashidinejad et al. [2021], Xie et al. [2021b] considers this assumption and provide analysis is based on the single concentrability coefficient $\begin{array} { r } { C ^ { \star } : = \operatorname* { m a x } _ { s , a } { d ^ { \pi ^ { \star } } ( s , a ) } / { d ^ { \mu } ( s , a ) } } \end{array}$ . The dependence on $C ^ { \star }$ makes their result less adaptive since there can be lots of locations that have the ratio ${ d ^ { \pi } } ^ { \star } ( s , a ) / { d ^ { \mu } } ( s , a )$ much smaller than $C ^ { \star }$ . Furthermore, what could we end up with when 2.3 is not met? We will provide our answers in the subsequent sections.
# 3 A warm-up case study: Vanilla Pessimistic Value Iteration
As a step towards the optimal and strong adaptive offline RL bound, we analyze the vanilla pessimistic value iteration (VPVI), a tabular counterpart of pessimistic value iteration (PEVI initiated in Jin et al. [2020]), to understand what is missing for achieving the fully adaptivity. In particular, VPVI relies on the model-based construction.
Model-based Components. Given data n $\begin{array} { r } { { \mathcal { D } } \ = \ \left\{ \left( s _ { h } ^ { \tau } , a _ { h } ^ { \tau } , r _ { h } ^ { \tau } , s _ { h + 1 } ^ { \tau } \right) \right\} _ { \tau \in [ n ] } ^ { h \in [ H ] } } \end{array}$ , we denote $n _ { s _ { h } , a _ { h } } : =$ $\begin{array} { r } { \sum _ { \tau = 1 } ^ { n } \mathbf { 1 } [ s _ { h } ^ { \tau } , { a } _ { h } ^ { \tau } \ = \ s _ { h } , { a } _ { h } ] } \end{array}$ be the total counts that vis construct the estimators for $\left( s _ { h } , a _ { h } \right)$ pair at time as: , then we use the $P _ { h }$ $r _ { h }$
$$\widehat { P } _ { h } ( s ^ { \prime } | s _ { h } , a _ { h } ) = \frac { \sum _ { \tau = 1 } ^ { n } \mathbf { 1 } [ ( s _ { h + 1 } ^ { \tau } , a _ { h } ^ { \tau } , s _ { h } ^ { \tau } ) = ( s ^ { \prime } , s _ { h } , a _ { h } ) ] } { n _ { s _ { h } , a _ { h } } } , \widehat { r } _ { h } ( s _ { h } , a _ { h } ) = \frac { \sum _ { \tau = 1 } ^ { n } \mathbf { 1 } [ ( a _ { h } ^ { \tau } , s _ { h } ^ { \tau } ) = ( s _ { h } , a _ { h } ) ] \cdot r _ { h } ^ { \tau } } { n _ { s _ { h } , a _ { h } } } ,$$
if $n _ { s _ { h } , a _ { h } } > 0$ and $\widehat { P } _ { h } ( s ^ { \prime } | s _ { h } , a _ { h } ) = 1 / S , \widehat { r } _ { h } ( s _ { h } , a _ { h } ) = 0$ if $n _ { s _ { h } , a _ { h } } = 0$ . In particular, we use the word b“vanilla” as it directly mirrors Jin et al. [2020] with a pessimistic penalty of order $O ( H / \sqrt { n _ { s _ { h } , a _ { h } } } )$ . 2 With $\widehat { P } _ { h } , \widehat { r } _ { h }$ in Algorithm 2 (which we defer to Appendix), VPVI guarantees the following:
Theorem 3.1. Under the Assumption 2.3, denote $\begin{array} { r } { \bar { d } _ { m } : = \operatorname* { m i n } _ { h \in [ H ] } \{ d _ { h } ^ { \mu } ( s _ { h } , a _ { h } ) : d _ { h } ^ { \mu } ( s _ { h } , a _ { h } ) > 0 \} } \end{array}$ . For any $0 < \delta < 1$ , there exists absolute constants $c _ { 0 } , C ^ { \prime } > 0$ , such that when $n > c _ { 0 } \cdot 1 / \bar { d } _ { m } \cdot \iota$ $( \iota = \log ( H S A / \delta ) )$ , with probability $1 - \delta$ , the output policy $\widehat { \pi }$ of VPVI satisfies
$$0 \leq v ^ { \star } - v ^ { \widehat { \pi } } \leq C ^ { \prime } H \sum _ { h = 1 } ^ { H } \sum _ { ( s _ { h } , a _ { h } ) \in \mathcal { C } _ { h } } d _ { h } ^ { \pi ^ { \star } } ( s _ { h } , a _ { h } ) \cdot \sqrt { \frac { \iota } { n \cdot d _ { h } ^ { \mu } ( s _ { h } , a _ { h } ) } } .$$
The full proof can be found in Appendix C. Theorem 3.1 makes some improvements over the existing works. First, it is more adaptive than the results with uniform data-coverage Assumption 2.1 (Yin et al. [2021a], Ren et al. [2021]). In addition, by straightforward calculation (3) can be bounded by $\tilde { O } ( \sqrt { H ^ { 4 } S C ^ { \star } / n } )$ which improves VI-LCB [Rashidinejad et al., 2021] by a factor of $H$ .3 Besides, the analysis of VPVI also improves the direct reduction of PEVI [Jin et al., 2020] in the tabular case by a factor $_ { S A }$ since their $\beta = S A H$ when $d = S A$ .
However, VPVI is not optimal as the dependence on horizon is $H ^ { 4 }$ which does not match the optimal worst case guarantee $H ^ { 3 }$ [Yin et al., 2021a] in the nonstationary setting. Also, the explicit dependence on $H$ in (3) possibly hides some key features of the specific offline RL instances. For example, no improvement can be made if the system has the deterministic transition.
# Algorithm 1 Adaptive (assumption-free) Pessimistic Value Iteration or LCBVI-Bernstein
1: Input: Offline dataset $\boldsymbol { \mathcal { D } } = \{ ( \boldsymbol { s } _ { h } ^ { \tau } , \boldsymbol { a } _ { h } ^ { \tau } , \boldsymbol { r } _ { h } ^ { \tau } , \boldsymbol { s } _ { h + 1 } ^ { \tau } ) \} _ { \tau , h = 1 } ^ { n , H }$ . Set $C _ { 1 } = 2 , C _ { 2 } = 1 4$ , failure probability $\delta$ . 2: Initialization: Set $\widehat { V } _ { H + 1 } ( \cdot ) 0$ . Set $\iota = \log ( H S A / \delta )$ . (if assumption-free, set $M ^ { \dagger } , \widehat { M } ^ { \dagger }$ as in Section 5.) 3: for time $h = H , H - 1 , \ldots , 1 \bullet$ do 4: Set $\widehat { Q } _ { h } ( \cdot , \cdot ) \gets \widehat { r } _ { h } ( \cdot , \cdot ) + ( \widehat { P } _ { h } \cdot \widehat { V } _ { h + 1 } ) ( \cdot , \cdot ) \mathrm { ~ } ( \mathrm { u s e } \widehat { r } _ { h } ^ { \dag } + ( \widehat { P } _ { h } ^ { \dag } \cdot \widehat { V } _ { h + 1 } )$ if assumption-free) 5: $\forall s _ { h } , a _ { h }$ , set $\begin{array} { r } { \Gamma _ { h } ( s _ { h } , a _ { h } ) = C _ { 1 } \sqrt { \frac { \operatorname { V a r } _ { \widehat { P } _ { s _ { h } , a _ { h } } } ( \widehat { r } _ { h } + \widehat { V } _ { h + 1 } ) \cdot \iota } { { n _ { s _ { h } , a _ { h } } } } } + \frac { C _ { 2 } H \cdot \iota } { n _ { s _ { h } , a _ { h } } } } \end{array}$ if $n _ { s _ { h } , a _ { h } } \ge 1$ , o.w. set to $\frac { C H \iota } { 1 }$ . 6: (If assumption-free, use C1qVarPb†sh,ah ( $\begin{array} { r } { C _ { 1 } \sqrt { \mathrm { V a r } _ { \widehat { P } _ { s _ { h } , a _ { h } } ^ { \dagger } } ( \widehat { r } _ { h } ^ { \dagger } + \widehat { V } _ { h + 1 } ) \cdot \iota / n _ { s _ { h } , a _ { h } } } + \frac { C _ { 2 } H \cdot \iota } { n _ { s _ { h } , a _ { h } } } } \end{array}$ C2H·ιn if nsh,ah ≥ 1, o.w. use 0.) 7: Set $\widehat { Q } _ { h } ^ { p } ( \cdot , \cdot ) \gets \widehat { Q } _ { h } ( \cdot , \cdot ) - \dot { \Gamma _ { h } } ( \cdot , \cdot )$ . Set $\overline { { { Q } } } _ { h } ( \cdot , \cdot ) \operatorname* { m i n } \{ \widehat { Q } _ { h } ^ { p } ( \cdot , \cdot ) , H - h + 1 \} ^ { + }$ . // Pessmistic update 8: $\forall s _ { h }$ , Select $\begin{array} { r } { \widehat \pi _ { h } ( \cdot | s _ { h } ) \gets \operatorname * { a r g m a x } _ { \pi _ { h } } \langle \overline { Q } _ { h } ( s _ { h } , \cdot ) , \pi _ { h } ( \cdot | s _ { h } ) \rangle } \end{array}$ . Set $\widehat { V } _ { h } ( s _ { h } ) \gets \langle \overline { { Q } } _ { h } ( s _ { h } , \cdot ) , \widehat { \pi } _ { h } ( \cdot | s _ { h } ) \rangle$ . 9: end for 10: Output: $\left\{ \widehat { \pi } _ { h } \right\}$ .
# 4 Intrinsic Offline Reinforcement Learning bound
Now we go deeper to understand what is the more intrinsic characterization for offline reinforcement learning. From the study of VPVI, penalizing the Q-function by $\widetilde { O } ( H / \sqrt { n _ { s _ { h } , a _ { h } } } )$ is crude as it estimates the confidence width of ${ \widehat { Q } } _ { h }$ in Algorithm 2 too conservatively therefore loses the accuracy (the bound is suboptimal). This motivates us to use empirical standard deviation instead to create a more adaptive (and also less conservative) Bernstein-type confidence width as the pessimistic penalty:
$$\Gamma _ { h } ( s _ { h } , a _ { h } ) = \widetilde { \mathcal { O } } \bigg [ \sqrt { \frac { \mathrm { V a r } _ { \widetilde { P } _ { s _ { h } , a _ { h } } } ( \widehat { r } _ { h } + \widehat { V } _ { h + 1 } ) } { { n } _ { s _ { h } , a _ { h } } } } + \frac { H } { { n } _ { s _ { h } , a _ { h } } } \bigg ] \ ( \mathrm { i f } \ n _ { s _ { h } , a _ { h } } > 0 ) ; \ = \widetilde { \mathcal { O } } ( H ) \ ( \mathrm { i f } \ n _ { s _ { h } , a _ { h } } = 0 ) .$$
and update $\widehat { Q } _ { h } \gets \widehat { Q } _ { h } - \Gamma _ { h }$ . On one hand, $\sqrt { \mathrm { V a r } _ { \widehat { P } _ { s _ { h } , a _ { h } } } ( \widehat { r } _ { h } + \widehat { V } _ { h + 1 } ) / n _ { s _ { h } , a _ { h } } }$ is a “less pessimistic” penalty than VPVI due to $\sqrt { \mathrm { V a r } _ { \widehat { P } } ( \widehat { r } _ { h } + \widehat { V } _ { h + 1 } ) } \le H$ and critically this design is more data-adaptive since it holds negative view towards the locations with high uncertainties and recommends the locations that we are confident about, as opposed to the online RL (which encourages exploration in the uncertain locations). Such principles are not reflected by the isotropic design in VPVI. On the other hand, it carries the extremely negative view towards fully agnostic locations ${ \widetilde { O } } ( H )$ which in turn causes the agent unlikely to choose them. We summarized the this adaptive pessimistic value
iteration (APVI) into the Algorithm 1, with $\widehat { P } _ { h } , \widehat { r } _ { h }$ defined in (2). APVI has the following guarantee. bA sketch of the analysis is presented in Section B and Appendix F includes the full proof.
Theorem 4.1 (Intrinsic offline RL bound). Under the Assumption 2.3, denote $\bar { d } _ { m } : =$ $\mathrm { m i n } _ { h \in [ H ] } \{ d _ { h } ^ { \mu } ( s _ { h } , a _ { h } ) \ : \ d _ { h } ^ { \mu } ( s _ { h } , a _ { h } ) \ > \ 0 \}$ . For any $0 ~ < ~ \delta ~ < ~ 1$ , there exists absolute constants $c _ { 0 } , C ^ { \prime } > 0$ , such that when $n > c _ { 0 } \cdot 1 / \bar { d } _ { m } \cdot \iota ( \iota = \log ( H S A / \delta ) )$ , with probability $1 - \delta$ , the output policy $\widehat { \pi }$ of APVI (Algorithm $I$ ) satisfies $\widetilde O$ hides log factor and higher order terms)
$$0 \leq v ^ { \star } - v ^ { \widehat { \pi } } \leq C ^ { \prime } \sum _ { h = 1 } ^ { H } \sum _ { ( s _ { h } , a _ { h } ) \in \mathcal { C } _ { h } } d _ { h } ^ { \pi ^ { \star } } \left( s _ { h } , a _ { h } \right) \cdot \sqrt { \frac { \mathrm { V a r } _ { P _ { s _ { h } , a _ { h } } } \left( r _ { h } + V _ { h + 1 } ^ { \star } \right) \cdot \iota } { n \cdot d _ { h } ^ { \mu } \left( s _ { h } , a _ { h } \right) } } + \widetilde O \left( \frac { H ^ { 3 } } { n \cdot \bar { d } _ { m } } \right)$$
Remark 4.2. APVI (Algorithm $I$ ) can also be called LCBVI-Bernstein as it creates the offline counterpart of UCBVI in Azar et al. [2017]. However, to highlight that the resulting bound fully adapts to the specific system structure, we use the word “adaptive” instead.
APVI makes significant improvements in a lot of aspects. First and foremost, the dominate term is fully expressed by the system quantities that admits no explicit dependence on $H , S , A$ . To the best of our knowledge, this is the first offline RL bound that concretely depicts the interrelations within the problem when the problem instance is a tuple $( M , \pi ^ { \star } , \mu )$ : an MDP $M$ (coupled with the optimal policy $\pi ^ { \star }$ ) with the data rolling from an offline logging policy $\mu$ . As we will discuss later, this result indicates (nearly) all the optimal worst-case non-adaptive bounds (and clearly also the VPVI) under their respective regimes / assumptions. Thus, (5) is generic. More interestingly, Theorem 4.1 caters to the specific MDP structures and adaptively yields improved sample complexities (e.g. faster convergence in deterministic systems) that existing works cannot imply. Such features are crucial as it helps us to understand what type of problems are harder / easier than others, and even more, in a quantitative way. Last but not least, to illustrate this bound exhibits the intrinsic nature of offline RL, we prove a per-instance dependent information-theoretical lower bound that shares a similar formulation. The proof of Theorem 4.3 can be found in Appendix G.
Theorem 4.3 (Instance-dependent information theoretical offline lower bound). Denote $\begin{array} { c c c c c c } { { \mathcal G } } & { { : = } } & { { \{ ( \mu , M ) } } & { { : } } & { { \exists \pi ^ { \star } } } & { { s } } \end{array}$ .t. $d _ { h } ^ { \mu } ( s , a ) \quad > \quad 0 \quad i f \quad d _ { h } ^ { \pi ^ { \star } } ( s , a ) \quad > \quad 0 \}$ . Fix an instance $\begin{array} { r l r l r } { { \mathcal { P } } } & { { } = } & { ( \mu , M ) } & { { } \in { } } & { { \mathcal { G } } } \end{array}$ . Let $\mathcal { D }$ consists of $n$ episodes and define $\begin{array} { r l } { \xi } & { { } = } \end{array}$ $\begin{array} { r } { \operatorname* { s u p } _ { h , s _ { h } , a _ { h } , s _ { h + 1 } , d _ { h } ^ { \mu } ( s _ { h } , a _ { h } ) \cdot \operatorname { V a r } _ { P _ { s _ { h } , a _ { h } } } ( V _ { h + 1 } ^ { \star } ) > 0 } \frac { P _ { h } ( s _ { h + 1 } | s _ { h } , a _ { h } ) \big ( V _ { h + 1 } ^ { \star } ( s _ { h + 1 } ) - \mathbb { E } _ { P _ { s _ { h } , a _ { h } } } ( V _ { h + 1 } ^ { \star } | ) \big ) } { \sqrt { 2 \cdot d _ { h } ^ { \mu } ( s _ { h } , a _ { h } ) \cdot \operatorname { V a r } _ { P _ { s _ { h } , a _ { h } } } ( V _ { h + 1 } ^ { \star } ) } } } \end{array}$ Ph(sh+1|sh,ah)(V ?h+1(sh+1)−EPsh,ah [V ?h+1]) . Let π to be the output of any algorithm. Define the local non-asymptotic minimax risk as
$$\mathfrak { R } _ { n } ( \mathcal { P } ) : = \operatorname* { s u p } _ { \mathcal { P } ^ { \prime } \in \mathcal { G } } \operatorname* { i n f } _ { \widehat { \pi } } \operatorname* { m a x } _ { \mathcal { Q } \in \{ \mathcal { P } , \mathcal { P } ^ { \prime } \} } \sqrt { n } \cdot \mathbb { E } _ { \mathcal { Q } } \left[ v ^ { \star } ( \mathcal { Q } ) - v ^ { \widehat { \pi } } \right]$$
where $v ^ { \star } ( \mathcal { Q } )$ denotes the optimal value under the instance $\mathcal { Q }$ . Then there exists universal constants $c _ { 0 } , p , C > 0$ , such that if $\begin{array} { r } { { \bf \ddot { \sigma } } n \geq c _ { 0 } H ^ { 6 } \xi ^ { 4 } / ( \sum _ { h = 1 } ^ { H } \sum _ { s _ { h } , a _ { h } } { d _ { h } ^ { \pi } } ^ { \star } ( s _ { h } , a _ { h } ) \sqrt { \frac { \mathrm { V a r } { P _ { s _ { h } , a _ { h } } } ( V _ { h + 1 } ^ { \star } ) } { \zeta \cdot d _ { h } ^ { \mu } ( s _ { h } , a _ { h } ) } } ) ^ { 2 } } \end{array}$ , with constant probability $p > 0$ , Then we have (here $\zeta = H / \bar { d } _ { m , }$ ):
$$\mathfrak { R } _ { n } ( \mathcal { P } ) \geq C \cdot \sum _ { h = 1 } ^ { H } \sum _ { ( s _ { h } , a _ { h } ) \in \mathcal { C } _ { h } } d _ { h } ^ { \pi ^ { \star } } ( s _ { h } , a _ { h } ) \cdot \sqrt { \frac { \mathrm { V a r } _ { P _ { s _ { h } , a _ { h } } } ( r _ { h } + V _ { h + 1 } ^ { \star } ) } { \zeta \cdot d _ { h } ^ { \mu } ( s _ { h } , a _ { h } ) } } ,$$
where $\mathcal { P } = ( \mu , M )$ and $M = \left( S , A , P , r , H , d _ { 1 } \right)$ .
The interpretation of Theorem 4.3 is: for any instance $\mathcal { P }$ , learning requires (7) (divided by $1 / \sqrt { n } )$ for any algorithm. Note this notion is significantly stronger than the previous minimax offline lower bounds [Yin et al., 2021a, Rashidinejad et al., 2021, Xie et al., 2021b, Jin et al., 2020] (where they only select a particular family of hard problems), therefore, their lower bounds in general do not hold for individual instances.
The quantity (1) nearly-matches the per-instance lower bound (7) (they deviate by a factor of $\zeta = \hat { H } / \hat { d } _ { m }$ due to the technical reason) and, in addition, we provide a matching minimax lower bound in Appendix H. These results certify Theorem 4.1 is not only adaptive but also near-optimal.
Hence, we call the quantity $\begin{array} { r l } & { \sum _ { h = 1 } ^ { H } \sum _ { ( s _ { h } , a _ { h } ) \in \mathcal { C } _ { h } } { d _ { h } ^ { \pi ^ { \star } } ( s _ { h } , a _ { h } ) \cdot \sqrt { \frac { \operatorname { V a r } _ { P _ { s _ { h } , a _ { h } } } ( r _ { h } + V _ { h + 1 } ^ { \star } ) } { n \cdot d _ { h } ^ { \mu } ( s _ { h } , a _ { h } ) } } } } \end{array}$ intrinsic offline reinforcement learning bound. In the sequel, we provide thorough discussions to explain the intrinsic bound embraces the fundamental challenges in offline RL and the strong adaptivity. The detailed technical derivations that are missing in Section 4.1-4.4 are deferred to Appendix I.
 Figure 1: A visualization on how intrinsic learning bound subsumes existing best-known results: uniform visitation, single concentrability (partial coverage) and adaptive domain.
# 4.1 Optimality under Uniform data-coverage assumption
Under the uniform exploration Assumption 2.1 with parameter $d _ { m } : = \operatorname* { m i n } _ { h , s _ { h , } a _ { h } } d _ { h } ^ { \mu } ( s _ { h } , a _ { h } ) > 0$ Yin et al. [2021a] analyzes the model-based plug-in approach and obtains the optimal sample complexity $\widetilde { O } ( H ^ { 3 } / d _ { m } \epsilon ^ { 2 } )$ and shows $\Omega ( H ^ { 3 } / d _ { m } \epsilon ^ { 2 } )$ is also the lower bound. Indeed, this rate can ebe directly implied by the intrinsic RL bound via Cauchy inequality and the Sum of Total Variance (Lemma J.6):4
$$\begin{array} { r l } & { \displaystyle \sum _ { h = 1 } ^ { H } \langle d _ { h } ^ { \pi ^ { \star } } ( \cdot ) , \sqrt { \frac { \mathrm { V a r } _ { P ( \cdot ) } ( r _ { h } + V _ { h + 1 } ^ { \star } ) } { n \cdot d _ { h } ^ { \mu } ( \cdot ) } } \rangle = \displaystyle \sum _ { h = 1 } ^ { H } \langle \sqrt { d _ { h } ^ { \pi ^ { \star } } ( \cdot ) } , \sqrt { \frac { d _ { h } ^ { \pi ^ { \star } } ( \cdot ) \odot \mathrm { V a r } _ { P ( \cdot ) } ( r _ { h } + V _ { h + 1 } ^ { \star } ) } { n \cdot d _ { m } } } \rangle } \\ & { \displaystyle \leq \displaystyle \sum _ { h = 1 } ^ { H } \left\| \sqrt { d _ { h } ^ { \pi ^ { \star } } ( \cdot ) } \right\| _ { 2 } \left\| \sqrt { \frac { d _ { h } ^ { \pi ^ { \star } } ( \cdot ) \odot \mathrm { V a r } _ { P ( \cdot ) } ( r _ { h } + V _ { h + 1 } ^ { \star } ) } { n \cdot d _ { m } } } \right\| _ { 2 } \leq \sqrt { \frac { H \cdot \mathrm { V a r } _ { \pi ^ { \star } } ( \cdot \sum _ { h = 1 } ^ { H } r _ { h } ) } { n \cdot d _ { m } } } \leq \sqrt { \frac { H ^ { 3 } } { n \cdot d _ { m } } } } \end{array}$$
which translates to $\widetilde { O } ( H ^ { 3 } / d _ { m } \epsilon ^ { 2 } )$ complexity. Our result maintains the optimal worst-case guarantee when $\mu$ has the uniform data-coverage:
Proposition 4.4. Under Assumption 2.1 and apply Theorem 4.1, APVI achieves the sample complexity of minimax-rate $\widetilde { O } ( H ^ { 3 } / d _ { m } \epsilon ^ { 2 } )$ (Theorem 4.1 and Theorem G.2 in Yin et al. [2021a]).
Remark 4.5. We believe if the MDP is time-invariant, then by a modified construction of $\widehat { P }$ , $\widehat { r }$ in (2) our result will imply the minimax-rate of $\widetilde { O } ( H ^ { 2 } / d _ { m } \epsilon ^ { 2 } )$ as achieved in Yin et al. [2021b]. We include this discussion in Appendix I.
# 4.2 Bounded sum of total rewards and the Horizon-Free case
$\begin{array} { r } { r _ { h } \geq 0 , \sum _ { h = 1 } ^ { H } r _ { h } \in [ 0 , 1 ] } \end{array}$ f studies that follow the bounded sum of total rewards assumption: i.e. [Krishnamurthy et al., 2016, Jiang et al., 2017, Zhang et al., 2021]. Such a Jiang and Agarwal [2018]. In offline RL, Ren et al. [2021] derives the nearly horizon-free worst case bound $\widetilde { O } ( \sqrt { 1 / n d _ { m } } )$ for the time-invariant MDPs, under the Assumption 2.1. As a comparison, our Theorem 4.1 achieves the following guarantee for the time-varying (non-stationary) MDPs.
Proposition 4.6. Assume $r _ { h } \ge 0 ,$ , $\textstyle \sum _ { h = 1 } ^ { H } r _ { h } \leq 1$ . Then in the time-varying case AVPI (Theorem 4.1) outputs a policy $\widehat { \pi }$ such that the suboptimality gap $\boldsymbol { v } ^ { \star } - \boldsymbol { v } ^ { \widehat { \pi } }$ is bounded by $\widetilde { O } ( \sqrt { H / n d _ { m } } )$ with high bprobability under the Assumption 2.1.
The derivation is straightforward by using $\begin{array} { r } { \operatorname { V a r } _ { \pi ^ { \star } } ( \sum _ { h = 1 } ^ { H } r _ { h } ) \le 1 } \end{array}$ in (8). This proposition is interesting since it indicates when the MDP is non-stationary, $\widetilde { O } ( H / d _ { m } \epsilon ^ { 2 } )$ is required in the worst case even under $\textstyle \sum _ { h = 1 } ^ { H } r _ { h } \leq 1$ .5 The extra $H$ factor resembles the challenge that we have $H$ transitions $( P _ { 1 } , \dots , P _ { H } )$ to learn, as opposed to the bandit-type $1 / d _ { m } \epsilon ^ { 2 }$ result due to there is only one $P$ throughout (time-invariant). This reveals that one hardness in solving the MDP is in proportion to the number of different transition kernels within the MDP. Such a finding could help researchers understand the special settings like low switching cost in transitions [Bai et al., 2019] or nonstationarity [Cheung et al., 2020].
# 4.3 Optimality with Single Concentrability
In the finite horizon discounted setting, Rashidinejad et al. [2021] proposes the single policy concentrability assumption which is defined as C? := maxh,s,a dh (s,a)dµ(s,a) in the current episodic nonstationary MDP setting. As discussed in Appendix D, their lower bound translates to $\Omega ( { \sqrt { \frac { H ^ { 3 } S C ^ { \star } } { n } } } )$ and their VI-LCB algorithm yields q H5SC?n ) suboptimality gap in H-horizon case. Since single policy concentrability is strictly weaker than its uniform version (Assumption 2.2), we only discuss this set up. In particular, we have the following implication from our Theorem 4.1 (whose derivation can be found in Appendix I):
Proposition 4.7. Let π? be a deterministic policy such that C? := maxh,s,a dπ h (s,a)dµ(s,a) . Then by Theorem 4.1, with high probability the output policy of APVI satisfies the suboptimality gap $\widetilde { O } ( \sqrt { \frac { H ^ { 3 } S C ^ { \star } } { n } } )$ in the time-varying (non-stationary) MDPs.
This can computed similar to (8) except we use $\begin{array} { r } { \frac { \boldsymbol { d } _ { h } ^ { \pi ^ { \star } } ( s , a ) } { \boldsymbol { d } _ { h } ^ { \mu } ( s , a ) } \leq C ^ { \star } } \end{array}$ . Our implication improves the VI-LCB by the factor $H ^ { 2 }$ (in terms of sample complexity) and is optimal (recover the concurrent Xie et al. [2021b]). Qualitatively, single concentrability is the same as Assumption 2.3, but the use of $C ^ { \star }$ makes the bound highly problem independent and limits the adaptivity. Problem dependent bound is a more interesting domain as it tailors to each MDP separately. We discuss it now.
# 4.4 Problem dependent domain
We define the pre-step environmental norm (the finite horizon counterpart of Maillard et al. [2014]) as: $\begin{array} { r } { \mathbb { Q } _ { h } ^ { \star } = \operatorname* { m a x } _ { s _ { h } , a _ { h } } { \operatorname { V a r } _ { P _ { s _ { h } , a _ { h } } } { \left( r _ { h } + V _ { h + 1 } ^ { \star } \right) } } } \end{array}$ for all $h \in [ H ]$ , and relax the total sum of rewards to be bounded by any arbitrary value $\boldsymbol { B }$ (i.e. $\textstyle \sum _ { h = 1 } ^ { H } r _ { h } \leq B )$ , then Theorem 4.1 implies:
Proposition 4.8. Under Assumption 2.1, with high probability, subopmality of AVPI is bounded by
$$\operatorname* { m i n } \bigg \{ \widetilde O \big ( \sum _ { h = 1 } ^ { H } \sqrt { \frac { \mathbb { Q } _ { h } ^ { \star } } { n \bar { d } _ { m } } } \big ) , \widetilde O \big ( \sqrt { \frac { H \cdot \mathcal { B } ^ { 2 } } { n \bar { d } _ { m } } } \big ) \bigg \} + \widetilde O ( \frac { H ^ { 3 } } { n \bar { d } _ { m } } ) .$$
Such a result mirrors the online version of the tight problem-dependent bound Zanette and Brunskill [2019] but with a more general pre-step environmental norm for the non-stationary MDPs.6 For the problem instances with either small $\boldsymbol { B }$ or small $\mathbb { Q } _ { h } ^ { \star }$ , our result yields much better performances, as discussed in the following.
Deterministic systems. For many practical applications of interest, the systems are equipped with low stochasticity, e.g. robotics, or even deterministic dynamics, e.g. the game of GO. In those scenarios, the agent needs less experience for each state-action therefore the learning procedure could be much faster. In particular, when the system is fully deterministic (in both transitions and rewards) then $\mathbb { Q } _ { h } ^ { \star } = 0$ for all $h$ . This enables a faster convergence rate of order $\frac { H ^ { 3 } } { n \bar { d } _ { m } }$ and significantly improves over the existing non-adaptive results that have order $\scriptstyle { \frac { 1 } { \sqrt { n } } }$ . The convergence rate $\textstyle { \frac { 1 } { n } }$ matches Wen and ) regret into the PAC bound.
Partially deterministic systems. Practical worlds are complicated and we could sometimes have a mixture model which contains both deterministic and stochastic steps. In those scenarios, the main complexity is decided by the number of stochastic stages: suppose there are $t$ stochastic $P _ { h } , r _ { h }$ ’s and $H - t$ deterministic $P _ { h ^ { \prime } } , r _ { h ^ { \prime } }$ ’s, then completing the offline learning guarantees $t \cdot \sqrt { \operatorname* { m a x } Q _ { h } ^ { \star } / n \bar { d } _ { m } }$ suboptimality gap, which could be much smaller than $H \cdot \sqrt { \operatorname* { m a x } Q _ { h } ^ { \star } / n \bar { d } _ { m } }$ when $t \ll H$ .
Fast mixing domains. Consider a class of highly mixing non-stationary MDPs (a variant of Zanette and Brunskill [2018]) that satisfies the transition $P _ { h } ( \cdot | s _ { h } , a _ { h } ) : = \nu _ { h } ( \cdot ) \overline { { } }$ depends on neither the state $s _ { h }$ nor the action $a _ { h }$ . Define $\bar { s } _ { t } : = \arg \operatorname* { m a x } V _ { t } ^ { \star } ( s )$ and $\underline { { s } } _ { t } : = \arg \operatorname* { m a x } V _ { t } ^ { \star } ( s$ . Also, denote $\mathrm { r n g } V _ { h } ^ { \star }$ to be the range of $V _ { h } ^ { \star }$ . In such cases, Bellman optimality equations have the form
$$V _ { h } ^ { \star } \left( \bar { s } _ { h } \right) = \operatorname* { m a x } _ { a } \left( r _ { h } \left( \bar { s } _ { h } , a \right) + \nu _ { h } ^ { \top } V _ { h + 1 } ^ { \star } \right) , \ V _ { h } ^ { \star } \left( { { s } _ { h } } \right) = \operatorname* { m a x } _ { a } \left( r _ { h } \left( { { s } _ { h } } , a \right) + \nu _ { h } ^ { \top } V _ { h + 1 } ^ { \star } \right)$$
which yield $\begin{array} { r } { \mathfrak { s } \mathrm { \ r n g } { V } _ { h } ^ { \star } = V _ { h } ^ { \star } \left( \bar { s } _ { h } \right) - V _ { h } ^ { \star } \left( \underline { { s } } _ { h } \right) = \operatorname* { m a x } _ { a } r _ { h } \left( \bar { s } _ { h } , a \right) - \operatorname* { m i n } _ { a } r _ { h } \left( \underline { { s } } _ { h } , a \right) \le 1 , } \end{array}$ , and this in turn gives $\mathbb { Q } _ { h } ^ { \star } \le 1 + ( \mathrm { r n g } V _ { h } ^ { \star } ) ^ { 2 } = 2$ . As a result, the suboptimality is bounded by $\widetilde { O } ( \sqrt { H ^ { 2 } / n d _ { m } } )$ in the worst case. This result reveals, although this is a family of stochastic non-stationary MDPs, but it is only as hard as the family of stationary MDPs in the minimax sense $\left( \Omega ( H ^ { 2 } / d _ { m } \epsilon ^ { 2 } ) \right)$ ).
Tabular contextual bandits. Our result also implies $\begin{array} { r l } & { \widetilde { \cal O } ( \sum _ { x _ { 1 } , a _ { 1 } } { d _ { 1 } ^ { \pi ^ { \star } } ( x _ { 1 } , a _ { 1 } ) \sqrt { \frac { \mathrm { V a r } ( r _ { 1 } ) } { n \cdot d _ { 1 } ^ { \mu } ( x _ { 1 } , a _ { 1 } ) } } } ) } \end{array}$ q Var(r1)n·dµ1 (x1,a1) ) gap for the offline tabular contextual bandit problem and improves to $\widetilde { \cal O } ( 1 / n d _ { m } )$ when the reward is deterministic. In either cases, the result is optimal and this is due to: when $r _ { 1 }$ is deterministic, the agent only needs one sample at every location (see Bubeck and Cesa-Bianchi [2012] for a survey).
# 5 Towards Assumption-Free Offline RL
While assumption 2.3 is (arguably) the weakest assumption for correctly learning the optimal value, for the real-world applications even this might not be guaranteed. Can we still learn something meaningful? In this section, we consider this most general setting where the behavior policy $\mu$ can be arbitrary. In this case, $\mu$ might not cover any optimal policy $\pi ^ { \star }$ (i.e. there might be high reward location $( s , a )$ that $\mu$ can never visit, e.g. in the extreme case where a clumsy doctor only uses one treatment all the time), and, irrelevant to the number of episode $n$ , a constant suboptimality gap needs to be suffered. To tackle this problem, we create a fictitious augmented MDP $M ^ { \dagger }$ that can help characterize the discrepancy of the values between the original MDP $M$ and the estimated MDP $\widehat { M } ^ { \dag }$ . In particular, $M ^ { \dagger }$ is negative towards agnostic state-actions $s _ { h } , a _ { h }$ by setting $r _ { h } ^ { \dagger } = 0$ cand transitions to an absorbing state s†h+1.
Pessimistic augmented MDP. $M ^ { \dagger }$ is defined with one extra state $s _ { h } ^ { \dagger }$ for all $h \in \{ 2 , \dots , H + 1 \}$ with the augmented state space $S ^ { \dagger } = S \cup \{ s _ { h } ^ { \dagger } \}$ . The transition and the reward are defined as follows:
$$P _ { h } ^ { \dagger } ( \cdot \mid s _ { h } , a _ { h } ) = \left\{ \begin{array} { l l } { P _ { h } ( \cdot \mid s _ { h } , a _ { h } ) , n _ { s _ { h } , a _ { h } } > 0 , } \\ { \delta _ { s _ { h + 1 } ^ { \dagger } } , s _ { h } = s _ { h } ^ { \dagger } \mathrm { o r } n _ { s _ { h } , a _ { h } } = 0 . } \end{array} \right. \quad r ^ { \dagger } ( s _ { h } , a _ { h } ) = \left\{ \begin{array} { l l } { r ( s _ { h } , a _ { h } ) , n _ { s _ { h } , a _ { h } } > 0 , } \\ { 0 , s _ { h } = s _ { h } ^ { \dagger } \mathrm { o r } n _ { s _ { h } , a _ { h } } = 0 . } \end{array} \right.$$
here $\delta _ { s }$ is the Dirac measure and we denote $V _ { h } ^ { \dag \pi }$ and $v ^ { \dag \pi }$ to be the values under $M ^ { \dagger }$ . $\widehat { M } ^ { \dagger }$ is the empirical counterpart of $M ^ { \dagger }$ with $\widehat { P }$ , $\widehat { r }$ (the same as (2)) replacing $P , r .$ By Algorithm 1, we have bTheorem 5.1 (Assumption-free offline reinforcement learning). Let us make no assumption for $\mu$ and still denote $\bar { d } _ { m } : = \operatorname * { m i n } _ { h \in [ H ] } \{ d _ { h } ^ { \mu } ( s _ { h } , a _ { h } ) : d _ { h } ^ { \mu } ( s _ { h } , a _ { h } ) > 0 \}$ . For any $0 < \delta < 1$ , there exists absolute constants $c _ { 0 } , C ^ { \prime } > 0$ , such that when $n > c _ { 0 } \cdot 1 / \bar { d } _ { m } \cdot \iota ( \iota = \log ( H S A / \delta ) )$ , with probability $1 - \delta$ , the output policy $\widehat { \pi }$ of APVI satisfies (recall $\mathcal { C } _ { h } : = \{ ( s _ { h } , a _ { h } ) : d _ { h } ^ { \mu } ( s _ { h } , a _ { h } ) > 0 \}$ )
$$v ^ { \star } - v ^ { \widehat { \pi } } \leq \sum _ { h = 2 } ^ { H + 1 } d _ { h } ^ { \dagger \pi ^ { \star } } \left( s _ { h } ^ { \dagger } \right) + C ^ { \prime } \sum _ { h = 1 } ^ { H } \sum _ { ( s _ { h } , a _ { h } ) \in { \mathcal { C } } _ { h } } d _ { h } ^ { \dagger \pi ^ { \star } } \left( s _ { h } , a _ { h } \right) \cdot \sqrt { \frac { \operatorname { V a r } _ { P _ { \hat { s } _ { h } , a _ { h } } ^ { \dagger } } \left( r _ { h } ^ { \dagger } + V _ { h + 1 } ^ { \dagger \pi ^ { \star } } \right) \cdot \iota } { n \cdot d _ { h } ^ { \mu } \left( s _ { h } , a _ { h } \right) } } + \widetilde { O } \left( \frac { H ^ { 3 } } { n \bar { d } _ { m } } \right) ,$$
where $d _ { h } ^ { \dagger \pi ^ { \star } } ( s _ { h } , a _ { h } ) \leq d _ { h } ^ { \pi ^ { \star } } ( s _ { h } , a _ { h } ) , V _ { h } ^ { \dagger \pi ^ { \star } } ( s _ { h } ) \leq V _ { h } ^ { \star } ( s _ { h } ) .$ for all $s _ { h } , a _ { h } \in S \times \mathcal { A } ,$ , and for all $h \in [ H ]$ , $\begin{array} { r } { d _ { h } ^ { \dagger \pi ^ { \star } } ( s _ { h } ^ { \dagger } ) = \sum _ { t = 1 } ^ { h - 1 } \sum _ { ( s _ { t } , a _ { t } ) \in \mathcal { S } \times \mathcal { A } \backslash \mathcal { C } _ { t } } d _ { t } ^ { \dagger \pi ^ { \star } } \big ( s _ { t } , a _ { t } \big ) } \end{array}$ . The proof is in Appendix $E$ .
Take-aways of Theorem 5.1. In $M ^ { \dagger }$ , there is no agnostic location any more since the original unknown spaces now all have known deterministic transitions to $s ^ { \dagger }$ in $M ^ { \dagger }$ . At a price, the algorithm has to suffer the constant suboptimality PH+1h=2 $\textstyle \sum _ { h = 2 } ^ { H + 1 } d _ { h } ^ { \dagger \pi ^ { \star } } ( s _ { h } ^ { \dagger } )$ due to no data in the region. The quantity $\textstyle \sum _ { h = 2 } ^ { H + 1 } d _ { h } ^ { \dag \pi ^ { \star } } ( s _ { h } ^ { \dag } )$ helps characterize the hardness when nothing is assumed about $\mu$ : it is always less than $H$ (cannot suffer more than suboptimality); under Assumption 2.1, it is 0 since with high probability (by Chernoff bound) and this causes $\boldsymbol { \mathcal { S } } \times \boldsymbol { \mathcal { A } } \backslash \boldsymbol { \bar { \mathcal { C } } } _ { h } = \boldsymbol { \emptyset }$ ; under Assumption 2.3, it is also 0 and 5.1 reduces to Theorem 4.1 (see Appendix F).
# 5.1 Assumption Free vs Without Great Coverage (Partial Coverage)
Recently there is a surge of studies that aim at weakening the assumptions of provable offline $/$ batch RL. Those learning bounds are derived (mostly) under the insufficient data coverage assumptions. One type of works consider the assumption without great coverage (or partial coverage): Chang et al. [2021], Uehara and Sun [2021] assume $\begin{array} { r } { \operatorname* { m a x } _ { s , a } d ^ { \pi _ { e } } ( s , a ) / \mu ( s , a ) < \infty } \end{array}$ where $\pi _ { e }$ is either an expert policy or a policy of great quality and they further compete against with this policy $\pi _ { e }$ . Those assumptions are similar to 2.3 and therefore are stronger than the assumption-free RL we considered in 5.1.
In addition, there are other studies that apply to the case where $\mu$ can be arbitrary: Liu et al. [2020] considers the behavior policy with insufficient coverage probability $\epsilon _ { \zeta }$ (see their Definition 1), and they end up with the constant suboptimality gap Vmaxζ1−γ (their Theorem 1), when the insufficient coverage probability $\epsilon _ { \zeta } > 0$ , this gap has order $( 1 - \gamma ) ^ { - 2 }$ , which is larger in order than the biggest possible suboptimality gap $( 1 - \gamma ) ^ { - 1 }$ therefore unable to characterize the essential statistical gap over the region that can never be visited by the behavior policy (and this happens similarly in Kidambi et al. [2020], see their Theorem 1); Jin et al. [2020] derive the nice assumption-free result via regularization and their bound can incur $O ( H ^ { 2 } )$ constant gap when there is at least one $\left( s _ { h } , a _ { h } \right)$ cannot be obtained by $\mu$ for all $h \in [ H ]$ (i.e. replacing $n d _ { h } ^ { \bar { \mu } } ( { \bar { s } } _ { h } , a _ { h } )$ by 1 in (3)). The concurrent work Xie et al. [2021a] provides a better characterization (and they call it off-support error) with roughly $\begin{array} { r } { \frac { 1 } { 1 - \gamma } \sum _ { \left( s , a \right) \in S \times A } \left( d _ { \pi } \backslash \nu \right) \left( s , a \right) \left[ \Delta f _ { \pi } ( s , a ) - ( \mathcal { T } ^ { \pi } \Delta f _ { \pi } ) \left( s , \bar { a } \right) \right] } \end{array}$ , however, in the worst case $\Delta f _ { \pi } ( s , a ) - ( T ^ { \pi } \Delta f _ { \pi } ) ( s , a )$ might be large (which depends on the quality (assumption) of the function approximation class).
In contrast, our 1) describes the $\textstyle \sum _ { h = 2 } ^ { H + 1 } d _ { h } ^ { \dag \pi ^ { \star } } ( s _ { h } ^ { \dag } )$ quantity (with p in a more pr $\begin{array} { r } { d _ { h } ^ { \dagger \pi ^ { \star } } ( s _ { h } ^ { \dagger } ) = \sum _ { t = 1 } ^ { h - 1 } \sum _ { ( s _ { t } , a _ { t } ) \in \mathcal { S } \times \mathcal { A } \backslash \mathcal { C } _ { t } } d _ { t } ^ { \dagger \pi ^ { \star } } ( s _ { t } , a _ { t } ) \leq } \end{array}$ into $s ^ { \dagger }$ and it is always bounded between 0 and $H$ . It reduces to 0 when $\pi ^ { \star }$ is covered. The gap is always of order $H$ (as opposed to $O ( H ^ { 2 } ) _ { * }$ ).
# 6 Discussion and Conclusion
This work studies the offline reinforcement learning problem and contributes the intrinsic offline learning bound which is a near-optimal and strong adaptive bound that subsumes existing worst-case bounds under various assumptions. The adaptive characterization of the intrinsic bound abandons the explicit dependence on $H , S , A , C ^ { \star } , d _ { m }$ and helps reveal the fundamental hardness of each individual instances. In this sense, it draws a clearer picture of what offline reinforcement learning looks like and serves as a step towards instance optimality in offline RL.
Nevertheless, it is still unclear whether (5) is optimal over all the instances. For example, for fully deterministic systems, our bound provides a faster convergence $H ^ { 3 } / n \bar { d } _ { m }$ , however, $\bar { H } ^ { 3 }$ might be very suboptimal comparing to algorithms that are designed specifically for deterministic MDPs, since the agent only need to experience each location $( s , a )$ once to fully acquire the dynamic $P ( \cdot | s , a )$ and $r ( s , a )$ . Recently, Xiao et al. [2021] goes beyond the minimax (worst case) optimality and studies the instance optimality behavior for the simplified batch bandit setting. One of their findings is: for “easy enough” tasks, different type of algorithms can be equally good, provably. This seems to suggest instance optimality only matters for problems that are hard to learn. How to formally define the instance optimality metric for different problems remains an open problem and how to design a single algorithm that can achieve optimality for all instances could be challenging (or even infeasible). We leave those as the future works.
# Acknowledgment
The research is partially supported by NSF Awards #2007117 and #2003257. MY would like to thank Chenjun Xiao for bringing up a related literature [Xiao et al., 2021] and Masatoshi Uehara, Yu Bai for helpful suggestions.
# References
Alekh Agarwal, Sham Kakade, and Lin F Yang. Model-based reinforcement learning with a generative model is minimax optimal. In Conference on Learning Theory, pages 67–83, 2020.
Andras Antos, Remi Munos, and Csaba Szepesvari. Fitted q-iteration in continuous action-space mdps. In Advances in Neural Information Processing Systems, pages 9–16, 2008a.
András Antos, Csaba Szepesvári, and Rémi Munos. Learning near-optimal policies with bellmanresidual minimization based fitted policy iteration and a single sample path. Machine Learning, 71 (1):89–129, 2008b.
Mohammad Gheshlaghi Azar, Ian Osband, and Rémi Munos. Minimax regret bounds for reinforcement learning. In Proceedings of the 34th International Conference on Machine Learning-Volume 70, pages 263–272. JMLR. org, 2017.
Yu Bai, Tengyang Xie, Nan Jiang, and Yu-Xiang Wang. Provably efficient q-learning with low switching cost. In Advances in Neural Information Processing Systems, volume 32, 2019.
Ronen I Brafman and Moshe Tennenholtz. R-max-a general polynomial time algorithm for nearoptimal reinforcement learning. Journal of Machine Learning Research, 3(Oct):213–231, 2002.
Sébastien Bubeck and Nicolo Cesa-Bianchi. Regret analysis of stochastic and nonstochastic multiarmed bandit problems. Foundations and Trends in Machine Learning, 2012.
Jacob Buckman, Carles Gelada, and Marc G Bellemare. The importance of pessimism in fixed-dataset policy optimization. International Conference on Learning Representations, 2021.
Qi Cai, Zhuoran Yang, Chi Jin, and Zhaoran Wang. Provably efficient exploration in policy optimization. In International Conference on Machine Learning, pages 1283–1294. PMLR, 2020.
T Tony Cai and Mark G Low. An adaptation theory for nonparametric confidence intervals. The Annals of statistics, 32(5):1805–1840, 2004.
Jonathan D Chang, Masatoshi Uehara, Dhruv Sreenivas, Rahul Kidambi, and Wen Sun. Mitigating covariate shift in imitation learning via offline data without great coverage. Advances in Neural Information Processing Systems, 2021.
Jinglin Chen and Nan Jiang. Information-theoretic considerations in batch reinforcement learning. In International Conference on Machine Learning, pages 1042–1051, 2019.
Herman Chernoff et al. A measure of asymptotic efficiency for tests of a hypothesis based on the sum of observations. The Annals of Mathematical Statistics, 23(4):493–507, 1952.
Wang Chi Cheung, David Simchi-Levi, and Ruihao Zhu. Reinforcement learning for non-stationary markov decision processes: The blessing of (more) optimism. In International Conference on Machine Learning, pages 1843–1854. PMLR, 2020.
Yaqi Duan, Zeyu Jia, and Mengdi Wang. Minimax-optimal off-policy evaluation with linear function approximation. In International Conference on Machine Learning, pages 8334–8342, 2020.
Justin Fu, Aviral Kumar, Ofir Nachum, George Tucker, and Sergey Levine. D4rl: Datasets for deep data-driven reinforcement learning. arXiv preprint arXiv:2004.07219, 2020.
Justin Fu, Mohammad Norouzi, Ofir Nachum, George Tucker, Ziyu Wang, Alexander Novikov, Mengjiao Yang, Michael R Zhang, Yutian Chen, Aviral Kumar, et al. Benchmarks for deep off-policy evaluation. International Conference on Learning Representations, 2021.
Caglar Gulcehre, Ziyu Wang, Alexander Novikov, Tom Le Paine, Sergio Gómez Colmenarejo, Konrad Zolna, Rishabh Agarwal, Josh Merel, Daniel Mankowitz, Cosmin Paduraru, et al. Rl unplugged: Benchmarks for offline reinforcement learning. Advances in neural information processing systems, 2020.
Michael Janner, Qiyang Li, and Sergey Levine. Reinforcement learning as one big sequence modeling problem. Advances in neural information processing systems, 2021.
Nan Jiang and Alekh Agarwal. Open problem: The dependence of sample complexity lower bounds on planning horizon. In Conference On Learning Theory, pages 3395–3398, 2018.
Nan Jiang and Lihong Li. Doubly robust off-policy value evaluation for reinforcement learning. In Proceedings of the 33rd International Conference on International Conference on Machine Learning-Volume 48, pages 652–661. JMLR. org, 2016.
Nan Jiang, Akshay Krishnamurthy, Alekh Agarwal, John Langford, and Robert E Schapire. Contextual decision processes with low bellman rank are pac-learnable. In International Conference on Machine Learning-Volume 70, pages 1704–1713, 2017.
Ying Jin, Zhuoran Yang, and Zhaoran Wang. Is pessimism provably efficient for offline rl? International Conference on Machine Learning, 2020.
Tobias Jung and Peter Stone. Gaussian processes for sample efficient reinforcement learning with rmax-like exploration. In Joint European Conference on Machine Learning and Knowledge Discovery in Databases, pages 601–616. Springer, 2010.
Koulik Khamaru, Ashwin Pananjady, Feng Ruan, Martin J Wainwright, and Michael I Jordan. Is temporal difference learning optimal? an instance-dependent analysis. SIAM Journal on Mathematics of Data Science, 2021a.
Koulik Khamaru, Eric Xia, Martin J Wainwright, and Michael I Jordan. Instance-optimality in optimal value estimation: Adaptivity via variance-reduced q-learning. arXiv preprint arXiv:2106.14352, 2021b.
Rahul Kidambi, Aravind Rajeswaran, Praneeth Netrapalli, and Thorsten Joachims. Morel: Modelbased offline reinforcement learning. Advances in neural information processing systems, 2020.
Akshay Krishnamurthy, Alekh Agarwal, and John Langford. PAC reinforcement learning with rich observations. In Advances in Neural Information Processing Systems, pages 1840–1848, 2016.
Sascha Lange, Thomas Gabel, and Martin Riedmiller. Batch reinforcement learning. In Reinforcement learning, pages 45–73. Springer, 2012.
Hoang Le, Cameron Voloshin, and Yisong Yue. Batch policy learning under constraints. In International Conference on Machine Learning, pages 3703–3712, 2019.
Sergey Levine, Aviral Kumar, George Tucker, and Justin Fu. Offline reinforcement learning: Tutorial, review, and perspectives on open problems. arXiv preprint arXiv:2005.01643, 2020.
Yao Liu, Adith Swaminathan, Alekh Agarwal, and Emma Brunskill. Off-policy policy gradient with state distribution correction. In Uncertainty in Artificial Intelligence, 2019.
Yao Liu, Adith Swaminathan, Alekh Agarwal, and Emma Brunskill. Provably good batch reinforcement learning without great exploration. Advances in neural information processing systems, 2020.
Odalric-Ambrym Maillard, Timothy A Mann, and Shie Mannor. How hard is my mdp?" the distribution-norm to the rescue". Advances in Neural Information Processing Systems, 27:1835– 1843, 2014.
Andreas Maurer and Massimiliano Pontil. Empirical bernstein bounds and sample variance penaliza tion. Conference on Learning Theory, 2009.
Paria Rashidinejad, Banghua Zhu, Cong Ma, Jiantao Jiao, and Stuart Russell. Bridging offline reinforcement learning and imitation learning: A tale of pessimism. arXiv preprint arXiv:2103.12021, 2021.
Tongzheng Ren, Jialian Li, Bo Dai, Simon S Du, and Sujay Sanghavi. Nearly horizon-free offline reinforcement learning. Advances in neural information processing systems, 2021.
Karthik Sridharan. A gentle introduction to concentration inequalities. Dept. Comput. Sci., Cornell Univ., Tech. Rep, 2002.
Richard S Sutton and Andrew G Barto. Reinforcement learning: An introduction. MIT press, 2018.
Csaba Szepesvári and Rémi Munos. Finite time bounds for sampling based fitted value iteration. In Proceedings of the 22nd international conference on Machine learning, pages 880–887, 2005.
Joel Tropp et al. Freedman’s inequality for matrix martingales. Electronic Communications in Probability, 16:262–270, 2011.
Masatoshi Uehara and Wen Sun. Pessimistic model-based offline rl: Pac bounds and posterior sampling under partial coverage. arXiv preprint arXiv:2107.06226, 2021.
Ruosong Wang, Dean P Foster, and Sham M Kakade. What are the statistical limits of offline rl with linear function approximation? International Conference on Machine Learning, 2021.
Zheng Wen and Benjamin Van Roy. Efficient exploration and value function generalization in deterministic systems. Advances in Neural Information Processing Systems, 26, 2013.
Chenjun Xiao, Yifan Wu, Jincheng Mei, Bo Dai, Tor Lattimore, Lihong Li, Csaba Szepesvari, and Dale Schuurmans. On the optimality of batch policy optimization algorithms. In International Conference on Machine Learning, pages 11362–11371. PMLR, 2021.
Tengyang Xie and Nan Jiang. $\mathbf { Q } ^ { * }$ approximation schemes for batch reinforcement learning: A theoretical comparison. In Uncertainty in Artificial Intelligence, pages 550–559, 2020.
Tengyang Xie and Nan Jiang. Batch value-function approximation with only realizability. International Conference on Machine Learning, 2021.
Tengyang Xie, Ching-An Cheng, Nan Jiang, Paul Mineiro, and Alekh Agarwal. Bellman-consistent pessimism for offline reinforcement learning. Advances in neural information processing systems, 2021a.
Tengyang Xie, Nan Jiang, Huan Wang, Caiming Xiong, and Yu Bai. Policy finetuning: Bridging sample-efficient offline and online reinforcement learning. Advances in neural information processing systems, 2021b.
Ming Yin and Yu-Xiang Wang. Asymptotically efficient off-policy evaluation for tabular reinforcement learning. In International Conference on Artificial Intelligence and Statistics, pages 3948–3958. PMLR, 2020.
Ming Yin and Yu-Xiang Wang. Optimal uniform ope and model-based offline reinforcement learning in time-homogeneous, reward-free and task-agnostic settings. Advances in neural information processing systems, 2021.
Ming Yin, Yu Bai, and Yu-Xiang Wang. Near-optimal provable uniform convergence in offline policy evaluation for reinforcement learning. In International Conference on Artificial Intelligence and Statistics, pages 1567–1575. PMLR, 2021a.
Ming Yin, Yu Bai, and Yu-Xiang Wang. Near-optimal offline reinforcement learning via double variance reduction. Advances in neural information processing systems, 2021b.
Andrea Zanette. Exponential lower bounds for batch reinforcement learning: Batch rl can be exponentially harder than online rl. International Conference on Machine Learning, 2021.
Andrea Zanette and Emma Brunskill. Problem dependent reinforcement learning bounds which can identify bandit structure in mdps. In International Conference on Machine Learning, pages 5747–5755. PMLR, 2018.
Andrea Zanette and Emma Brunskill. Tighter problem-dependent regret bounds in reinforcement learning without domain knowledge using value function bounds. In International Conference on Machine Learning, pages 7304–7312. PMLR, 2019.
Andrea Zanette, Martin J Wainwright, and Emma Brunskill. Provable benefits of actor-critic methods for offline reinforcement learning. Advances in neural information processing systems, 2021.
Zihan Zhang, Xiangyang Ji, and Simon S Du. Is reinforcement learning more difficult than bandits? a near-optimal algorithm escaping the curse of horizon. Conference of Learning Theory, 2021.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330# Why Do Better Loss Functions Lead to Less Transferable Features?
Simon Kornblith1∗, Ting Chen1 , Honglak Lee2†, Mohammad Norouzi1 1Google Research, Toronto 2University of Michigan
# Abstract
Previous work has proposed many new loss functions and regularizers that improve test accuracy on image classification tasks. However, it is not clear whether these loss functions learn better representations for downstream tasks. This paper studies how the choice of training objective affects the transferability of the hidden representations of convolutional neural networks trained on ImageNet. We show that many objectives lead to statistically significant improvements in ImageNet accuracy over vanilla softmax cross-entropy, but the resulting fixed feature extractors transfer substantially worse to downstream tasks, and the choice of loss has little effect when networks are fully fine-tuned on the new tasks. Using centered kernel alignment to measure similarity between hidden representations of networks, we find that differences among loss functions are apparent only in the last few layers of the network. We delve deeper into representations of the penultimate layer, finding that different objectives and hyperparameter combinations lead to dramatically different levels of class separation. Representations with higher class separation obtain higher accuracy on the original task, but their features are less useful for downstream tasks. Our results suggest there exists a trade-off between learning invariant features for the original task and features relevant for transfer tasks.
# 1 Introduction
Features learned by deep neural networks on ImageNet transfer effectively to a wide range of computer vision tasks [23, 60, 34]. These networks are often pretrained using vanilla softmax cross-entropy [10, 11], but recent work reports that other loss functions such as label smoothing [66] and sigmoid cross-entropy [8] outperform softmax cross-entropy on ImageNet. Although a previous investigation suggested that label smoothing and dropout can hurt transfer learning [34], the vast majority of work studying alternatives to softmax cross-entropy has restricted its empirical investigation to the accuracy of the trained networks on the original dataset. While it is valuable to study the impact of objective functions on classification accuracy, improving transfer accuracy of learned representations can have a more significant practical impact for many applications.
This paper takes a comparative approach to understand the effects of different training objectives for image classification through the lens of neural network representations and their transferability. We carefully tune hyperparameters of each loss function and confirm that several loss functions outperform softmax cross-entropy by a statistically significant margin on ImageNet. However, we find that these improvements do not transfer to other tasks (see Table 1 and Figure 1). We delve deeper and explain these empirical findings in terms of effects of different objectives on neural network representations. Our key findings are as follows:
• We analyze the performance of 9 different objectives on ImageNet and in transfer settings. Although many loss functions and regularizers lead to statistically significant improvements over vanilla softmax cross-entropy on ImageNet, these gains do not transfer. These alternative loss functions produce fixed feature extractors that transfer substantially worse to other tasks, in terms of both linear and $\mathbf { k }$ -nearest neighbors classification accuracy, and provide no benefit when representations are fully fine-tuned.
• The choice of objective primarily affects representations in network layers close to the output. Centered kernel alignment (CKA) reveals large differences in representations of the last few layers of the network, whereas earlier layers are similar regardless of which training objective is used. This helps explain why the choice of objective has little impact on fine-tuning transfer accuracy.
• All objectives that improve accuracy over softmax cross-entropy also lead to greater separation between representations of different classes in the penultimate layer features. These alternative objectives appear to collapse within-class variability in representations, which accounts for both the improvement in accuracy on the original task and the reduction in the quality of the features on downstream tasks.
# 2 Loss Functions and Output Layer Regularizers
We investigate 9 loss functions and output layer regularizers. Let $z \in \mathbb { R } ^ { K }$ denote the network’s output (“logit”) vector, and let ${ \pmb t } \in \{ 0 , 1 \} ^ { K }$ denote a one-hot vector of targets. Let $\pmb { x } \in \mathbb { R } ^ { M }$ denote the vector of penultimate layer activations, which gives rise to the output vector as ${ z = W x + b }$ where $\pmb { W } \in \bar { \mathbb { R } } ^ { K \times M }$ is the matrix of final layer weights, and $^ { b }$ is a vector of biases.
All investigated loss functions include a term that encourages $_ { z }$ to have a high dot product with $\pmb { t }$ . To avoid solutions that make this dot product large simply by increasing the scale of $_ z$ , these loss functions must also include one or more contractive terms and/or normalize $_ z$ . Many “regularizers” correspond to additional contractive terms added to the loss, so we do not draw a firm distinction between loss functions and regularizers. We describe each objective in detail below, and provide hyperparameters in Appendix A.1.
Softmax cross-entropy [10, 11] is the de facto loss function for multi-class classification in deep learning:
$$\mathcal { L } _ { \mathrm { s o f m a x } } ( z , t ) = - \sum _ { k = 1 } ^ { K } t _ { k } \log \left( \frac { e ^ { z _ { k } } } { \sum _ { j = 1 } ^ { K } e ^ { z _ { j } } } \right) = - \sum _ { k = 1 } ^ { K } t _ { k } z _ { k } + \log \sum _ { k = 1 } ^ { K } e ^ { z _ { k } } .$$
The loss consists of a term that maximizes the dot product between the logits and targets, as well as a contractive term that minimizes the LogSumExp of the logits.
Label smoothing [66] “smooths” the targets for softmax cross-entropy. The new targets are given by mixing the original targets with a uniform distribution over all labels, $t ^ { \prime } = t \times ( 1 - \alpha ) + \alpha / K$ , where $\alpha$ determines the weighting of the original and uniform targets. In order to maintain the same scale for the gradient with respect to the positive logit, in our experiments, we scale the label smoothing loss by $\bar { 1 } / ( 1 - \alpha )$ . The resulting loss is:
$$\mathcal { L } _ { \mathrm { s m o o t h } } ( z , t ; \alpha ) = - \frac { 1 } { 1 - \alpha } \sum _ { k = 1 } ^ { K } \left( ( 1 - \alpha ) t _ { k } + \frac { \alpha } { K } \right) \log \left( \frac { e ^ { z _ { k } } } { \sum _ { j = 1 } ^ { K } e ^ { z _ { j } } } \right)$$
Müller et al. [43] previously showed that label smoothing improves calibration and encourages class centroids to lie at the vertices of a regular simplex.
Dropout on penultimate layer: Dropout [64] is among the most prominent regularizers in the deep learning literature. We consider dropout applied to the penultimate layer of the neural network, i.e., when inputs to the final layer are randomly kept with some probability $\rho$ . When employing dropout, we replace the penultimate layer activations $_ { \textbf { \em x } }$ with $\tilde { \pmb { x } } = \pmb { x } \odot \pmb { \xi } / \rho$ where $\xi _ { i } \sim \mathrm { B e r n o u l l i } ( \rho )$ . Writing the dropped out logits as $\tilde { z } = W \tilde { \mathbf { \em x } } + b$ , the dropout loss is:
$$\mathcal { L } _ { \mathrm { d r o p o u t } } ( W , b , x , t ; p ) = \mathbb { E } _ { \boldsymbol { \xi } } \left[ \mathcal { L } _ { \mathrm { s o f t m a x } } ( \boldsymbol { \tilde { z } } , t ) \right] = - \sum _ { k = 1 } ^ { K } t _ { k } z _ { k } + \mathbb { E } _ { \boldsymbol { \xi } } \left[ \log \sum _ { k = 1 } ^ { K } e ^ { \tilde { z } _ { k } } \right] .$$
Dropout produces both implicit regularization, by introducing noise into the optimization process [75], and explicit regularization, by changing the parameters that minimize the loss [69].
Extra final layer $L ^ { 2 }$ regularization: It is common to place the same $L ^ { 2 }$ regularization on the final layer as elsewhere in the network. However, we find that applying greater $L ^ { 2 }$ regularization to the final layer can improve performance. The corresponding loss is:
$$\mathcal { L } _ { \mathrm { e x t r a } _ { - } 1 2 } ( W , z , t ; \lambda _ { \mathrm { f i n a l } } ) = \mathcal { L } _ { \mathrm { s o f t m a x } } ( z , t ) + \lambda _ { \mathrm { f i n a l } } \| W \| _ { \mathsf { F } } ^ { 2 } .$$
In architectures with batch normalization, adding additional $L ^ { 2 }$ regularization has no explicit regularizing effect if the learnable scale $( \gamma )$ parameters are unregularized, but it still exerts an implicit regularizing effect by altering optimization.
Logit penalty: Whereas label smoothing encourages logits not to be too negative, and dropout imposes a penalty on the logits that depends on the covariance of the weights, an alternative possibility is simply to explicitly constrain logits to be small in $L ^ { 2 }$ norm:
$$\mathcal { L } _ { \mathrm { l o g i t \_ p e n a l t y } } ( z , t ; \beta ) = \mathcal { L } _ { \mathrm { s o f t m a x } } ( z , t ) + \beta \| z \| ^ { 2 } .$$
Dauphin and Cubuk [19] showed that this regularizer yields accuracy improvements comparable to dropout.
Logit normalization: We consider the use of $L ^ { 2 }$ normalization, rather than regularization, of the logits. Because the entropy of the output of the softmax function depends on the scale of the logits, which is lost after normalization, we introduce an additional temperature parameter $\tau$ that controls the magnitude of the logit vector, and thus, indirectly, the minimum entropy of the output distribution:
$$\mathcal { L } _ { \mathrm { l o g i t . n o r m } } ( z , t ; \tau ) = \mathcal { L } _ { \mathrm { s o f m a x } } ( z / ( \tau \| z \| ) , t ) = - \frac { 1 } { \tau \| z \| } \sum _ { k = 1 } ^ { K } t _ { k } z _ { k } + \log \sum _ { k = 1 } ^ { K } e ^ { z _ { k } / ( \tau \| z \| ) } .$$
Cosine softmax: We additionally consider $L ^ { 2 }$ normalization of both the penultimate layer features and the final layer weights corresponding to each class. This loss is equivalent to softmax crossentropy loss if the logits are given by cosine similarity $\sin ( \mathbf x , \pmb y ) = \pmb x ^ { \hat { \mathsf { T } } } \pmb y / ( \| \pmb x \| \| \pmb y \| )$ between the weight vector and the penultimate layer plus a per-class bias:
$$\mathcal { L } _ { \mathrm { c o s } } ( W , b , x , t ; \tau ) = - \sum _ { k = 1 } ^ { K } t _ { k } \left( \mathrm { s i m } ( W _ { k , : } , x ) / \tau + b _ { k } \right) + \log \sum _ { k = 1 } ^ { K } e ^ { \mathrm { s i m } ( W _ { k , : } , x ) / \tau + b _ { k } } ,$$
where $\tau$ is a temperature parameter as above. Similar losses have appeared in previous literature [54, 71, 76, 72, 73, 21, 38, 15], and variants have introduced explicit additive or multiplicative margins to this loss that we do not consider here [38, 72, 73, 21]. We observe that, even without an explicit margin, manipulating the temperature has a large impact on observed class separation.
Sigmoid cross-entropy, also known as binary cross-entropy, is the natural analog to softmax crossentropy for multi-label classification problems. Although we investigate only single-label multi-class classification tasks, we train networks with sigmoid cross-entropy and evaluate accuracy by ranking the logits of the sigmoids. This approach is related to the one-versus-rest strategy for converting binary classifiers to multi-class classifiers. The sigmoid cross-entropy loss is:
$$\begin{array} { r l } & { { \mathcal { L } } _ { \mathrm { s c e } } ( z , t ) = - \sum _ { k = 1 } ^ { K } \left( t _ { k } \log \left( \frac { e ^ { z _ { k } } } { e ^ { z _ { k } } + 1 } \right) + \left( 1 - t _ { k } \right) \log \left( 1 - \frac { e ^ { z _ { k } } } { e ^ { z _ { k } } + 1 } \right) \right) } \\ & { \qquad = - \sum _ { k = 1 } ^ { K } t _ { k } z _ { k } + \sum _ { k = 1 } ^ { K } \log ( e ^ { z _ { k } } + 1 ) . } \end{array}$$
The LogSumExp term of softmax loss is replaced with the sum of the softplus-transformed logits. We initialize the biases of the logits $^ { b }$ to $- \log ( K )$ so that the initial output probabilities are approximately $1 / K$ . Beyer et al. [8] have previously shown that sigmoid cross-entropy loss leads to improved accuracy on ImageNet relative to softmax cross-entropy.
Squared error: Finally, we investigate squared error loss, as formulated by Hui and Belkin [30]:
$$\mathcal { L } _ { \mathrm { m s e } } ( z , t ; \kappa , M ) = \frac { 1 } { K } \sum _ { k = 1 } ^ { K } \left( \kappa t _ { k } ( z _ { k } - M ) ^ { 2 } + ( 1 - t _ { k } ) z _ { k } ^ { 2 } \right) ,$$
where $\kappa$ and $M$ are hyperparameters. $\kappa$ sets the strength of the loss for the correct class relative to incorrect classes, whereas $M$ controls the magnitude of the correct class target. When $\kappa = M = 1$ , the loss is simply the mean squared error between $_ z$ and $\textbf { \em t }$ . Like Hui and Belkin [30], we find that placing greater weight on the correct class slightly improves ImageNet accuracy.
# 3 Results
For each loss, we trained 8 ResNet-50 [29, 27] models on the ImageNet ILSVRC 2012 dataset [20, 57]. To tune loss hyperparameters and the epoch for early stopping, we performed 3 training runs per hyperparameter configuration where we held out a validation set of 50,046 ImageNet training examples. We provide further details regarding the experimental setup in Appendix A. We also confirm that our main findings hold for Inception v3 [66] models in Appendix B.
# 3.1 Better objectives improve accuracy, but do not transfer better
Table 1: Objectives that produce higher ImageNet accuracy lead to less transferable fixed features. “ImageNet” columns reflect accuracy of ResNet-50 models on the ImageNet validation set. “Transfer” columns reflect accuracy of $L ^ { 2 }$ -regularized multinomial logistic regression or $k$ -nearest neighbors classifiers trained to classify different transfer datasets using the fixed penultimate layer features of the ImageNet-trained networks. Numbers are averaged over 8 different pretraining runs; values not significantly different than the best are bold-faced $\mathit { p } < 0 . 0 5$ , $t$ -test). The strength of $L ^ { 2 }$ regularization is selected on a holdout set, and $k$ is selected using leave-one-out cross-validation on the training set. See Appendix Table B.1 for a similar table for Inception v3 models, Appendix D.2 for linear transfer accuracy evaluated at different epochs of ImageNet pretraining, and Appendix D.3 for similar findings on the Chexpert chest $\mathrm { X }$ -ray dataset [31].
<table><tr><td rowspan="2">Pretraining loss</td><td colspan="2">ImageNet</td><td colspan="8">Transfer</td></tr><tr><td>Top-1</td><td>Top-5</td><td>Food</td><td>CIFAR10</td><td>CIFAR100</td><td>Birdsnap</td><td>SUN397</td><td>Cars</td><td>Pets</td><td>Flowers</td></tr><tr><td>Linear transfer:</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>Softmax</td><td>77.0</td><td>93.40</td><td>74.6</td><td>92.4</td><td>76.9</td><td>55.4</td><td>62.0</td><td>60.3</td><td>92.0</td><td>94.0</td></tr><tr><td>Label smoothing</td><td>77.6</td><td>93.78</td><td>72.7</td><td>91.6</td><td>75.2</td><td>53.6</td><td>61.6</td><td>54.8</td><td>92.9</td><td>91.9</td></tr><tr><td>Sigmoid</td><td>77.9</td><td>93.50</td><td>73.4</td><td>91.7</td><td>75.7</td><td>52.3</td><td>62.0</td><td>56.1</td><td>92.5</td><td>92.9</td></tr><tr><td>More final layer L2</td><td>77.7</td><td>93.79</td><td>70.6</td><td>91.0</td><td>73.7</td><td>51.5</td><td>60.1</td><td>50.3</td><td>92.4</td><td>89.8</td></tr><tr><td>Dropout</td><td>77.5</td><td>93.62</td><td>72.6</td><td>91.4</td><td>75.0</td><td>53.6</td><td>61.2</td><td>54.7</td><td>92.6</td><td>92.1</td></tr><tr><td>Logit penalty</td><td>77.7</td><td>93.83</td><td>68.1</td><td>90.2</td><td>72.3</td><td>48.1</td><td>59.0</td><td>48.3</td><td>92.3</td><td>86.6</td></tr><tr><td>Logit normalization</td><td>77.8</td><td>93.71</td><td>66.3</td><td>90.5</td><td>72.9</td><td>50.7</td><td>58.1</td><td>45.4</td><td>92.0</td><td>82.9</td></tr><tr><td>Cosine softmax</td><td>77.9</td><td>93.86</td><td>62.0</td><td>89.9</td><td>71.3</td><td>45.4</td><td>55.0</td><td>36.7</td><td>91.1</td><td>75.3</td></tr><tr><td>Squared error</td><td>77.2</td><td>92.79</td><td>39.8</td><td>82.2</td><td>56.3</td><td>21.8</td><td>39.9</td><td>15.3</td><td>84.7</td><td>46.7</td></tr><tr><td>K-nearest neighbors:</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>Softmax</td><td>77.0</td><td>93.40</td><td>60.9</td><td>88.8</td><td>67.4</td><td>38.4</td><td>53.0</td><td>28.9</td><td>88.8</td><td>83.6</td></tr><tr><td>Label smoothing</td><td>77.6</td><td>93.78</td><td>59.2</td><td>88.3</td><td>66.3</td><td>39.2</td><td>53.5</td><td>27.3</td><td>91.5</td><td>80.3</td></tr><tr><td>Sigmoid</td><td>77.9</td><td>93.50</td><td>58.5</td><td>88.2</td><td>66.6</td><td>34.4</td><td>52.8</td><td>26.7</td><td>90.8</td><td>81.5</td></tr><tr><td>More final layer L2</td><td>77.7</td><td>93.79</td><td>55.0</td><td>87.7</td><td>65.0</td><td>36.2</td><td>51.1</td><td>24.4</td><td>90.9</td><td>75.6</td></tr><tr><td>Dropout</td><td>77.5</td><td>93.62</td><td>58.4</td><td>88.2</td><td>66.4</td><td>38.1</td><td>52.4</td><td>27.8</td><td>91.1</td><td>80.1</td></tr><tr><td>Logit penalty</td><td>77.7</td><td>93.83</td><td>52.5</td><td>86.5</td><td>62.9</td><td>31.0</td><td>49.3</td><td>22.4</td><td>90.8</td><td>68.1</td></tr><tr><td>Logit normalization</td><td>77.8</td><td>93.71</td><td>50.9</td><td>86.6</td><td>63.1</td><td>35.1</td><td>45.8</td><td>24.1</td><td>88.2</td><td>63.1</td></tr><tr><td>Cosine softmax</td><td>77.9</td><td>93.86</td><td>45.5</td><td>86.0</td><td>61.5</td><td>28.8</td><td>41.8</td><td>19.0</td><td>87.0</td><td>52.7</td></tr><tr><td>Squared error</td><td>77.2</td><td>92.79</td><td>27.7</td><td>74.5</td><td>44.3</td><td>13.8</td><td>28.6</td><td>9.1</td><td>82.6</td><td>28.2</td></tr></table>
We found that, when properly tuned, all investigated objectives except squared error provide a statistically significant improvement over softmax cross-entropy, as shown in the left two columns of Table 1. The gains are small but meaningful, with sigmoid crossentropy and cosine softmax both leading to an improvement of $0 . 9 \%$ in top-1 accuracy over the baseline. For further discussion of differences in the training curves, robustness, calibration, and predictions of these models, see Appendix C.
Although networks trained with softmax cross-entropy attain lower ImageNet top-1 accuracy than any other loss function, they nonetheless provide the most transferable features. We evaluated the transferability of the fixed features of our ImageNet-pretrained models by training linear or $\mathbf { k }$ -nearest neighbors (kNN) classifiers to classify 8 different natural image datasets: Food-101 [9], CIFAR-10 and CIFAR-100 [36], Birdsnap [6], SUN397 [77], Stanford Cars [35], Oxford-IIIT Pets [51], and Oxford Flowers [48]. The results of these experiments are shown in Table 1 and Figure 1. In both linear and kNN settings, representations learned with vanilla softmax cross-entropy perform best for most tasks.
 Figure 1: Higher ImageNet accuracy is not associated with higher linear transfer accuracy. Points represent individual training runs. See Appendix Figure D.1 for similar plots for individual datasets.
Table 2: The training objective has little impact on the performance of fine-tuned networks. Accuracy of fine-tuning pretrained networks on transfer datasets, averaged over 3 different pretraining initializations. We tune hyperparameters separately for each objective and dataset. Numbers not significantly different than the best are bold-faced $( p < 0 . 0 5$ , $t$ -test for individual datasets, two-way ANOVA for average). See Appendix A.3 for training details.
<table><tr><td>Pretraining loss</td><td>Food</td><td>CIFAR10</td><td>CIFAR100</td><td>Birdsnap</td><td>SUN397</td><td>Cars</td><td>Pets</td><td>Flowers</td><td>Avg.</td></tr><tr><td>Softmax</td><td>88.2</td><td>96.9</td><td>84.1</td><td>76.2</td><td>63.4</td><td>91.3</td><td>93.1</td><td>96.7</td><td>86.2</td></tr><tr><td>Label smoothing</td><td>88.3</td><td>96.7</td><td>84.0</td><td>76.3</td><td>63.6</td><td>91.2</td><td>93.7</td><td>96.3</td><td>86.3</td></tr><tr><td>Sigmoid</td><td>88.3</td><td>96.9</td><td>83.6</td><td>76.2</td><td>63.5</td><td>91.8</td><td>93.7</td><td>96.3</td><td>86.3</td></tr><tr><td>More final layer L²</td><td>88.1</td><td>96.9</td><td>84.4</td><td>75.9</td><td>64.5</td><td>91.5</td><td>93.8</td><td>96.2</td><td>86.4</td></tr><tr><td>Dropout</td><td>88.3</td><td>96.7</td><td>84.2</td><td>76.5</td><td>63.9</td><td>91.2</td><td>93.9</td><td>96.3</td><td>86.4</td></tr><tr><td>Logit penalty</td><td>88.4</td><td>96.9</td><td>83.9</td><td>76.4</td><td>63.3</td><td>91.2</td><td>93.4</td><td>96.0</td><td>86.2</td></tr><tr><td>Logit normalization</td><td>87.9</td><td>96.9</td><td>82.9</td><td>76.0</td><td>58.3</td><td>91.2</td><td>92.7</td><td>95.9</td><td>85.2</td></tr><tr><td>Cosine softmax</td><td>88.3</td><td>96.9</td><td>83.2</td><td>75.6</td><td>56.9</td><td>91.3</td><td>92.5</td><td>95.9</td><td>85.1</td></tr><tr><td>Squared error</td><td>87.8</td><td>96.9</td><td>84.0</td><td>75.7</td><td>61.0</td><td>91.4</td><td>93.0</td><td>95.2</td><td>85.6</td></tr></table>
As shown in Table 2, when networks are fully fine-tuned on downstream tasks, the pretraining objective has little effect on the resulting accuracy. When averaging across all tasks, the best loss provides only a $0 . 2 \%$ improvement over softmax cross-entropy, which does not reach statistical significance and is much smaller than the $0 . 9 \%$ difference in ImageNet top-1 accuracy. Thus, using a different loss function for pretraining can improve accuracy on the pretraining task, but this improvement does not appear to transfer to downstream tasks.
# 3.2 The choice of objective primarily affects hidden representations close to the output
Our observation that “improved” objectives improve only on ImageNet and not on transfer tasks raises questions about which representations, exactly, they affect. We use two tools to investigate differences in the hidden representations of networks trained with different loss functions. First, we use centered kernel alignment [33, 17, 18] to directly measure the similarity of hidden representations across networks trained with different loss functions. Second, we measure the sparsity of the ReLU activations in each layer. Both analyses suggest that all loss functions learn similar representations throughout the majority of the network, and differences are present only in the last few ResNet blocks.
Linear centered kernel alignment (CKA) provides a way to measure similarity of neural network representations that is invariant to rotation and isotropic scaling in representation space [33, 17, 18]. Unlike other ways of measuring representational similarity between neural networks, linear CKA can identify architectural correspondences between layers of networks trained from different initializations [33], a prerequisite for comparing networks trained with different objectives. Given two matrices $\ b { X } \in \mathbb { R } ^ { n \times p _ { 1 } }$ and $\ b { Y } \in \mathbb { R } ^ { n \times p _ { 2 } }$ containing activations to the same $n$ examples, linear CKA computes the cosine similarity between the reshaped $n \times n$ covariance matrices between examples:
$$\operatorname { C K A } _ { \operatorname { l i n e a r } } ( X , Y ) = { \frac { \operatorname { v e c } ( \operatorname { c o v } ( X ) ) \cdot \operatorname { v e c } ( \operatorname { c o v } ( Y ) ) } { \| \operatorname { c o v } ( X ) \| _ { \mathrm { F } } \| \operatorname { c o v } ( Y ) \| _ { \mathrm { F } } } } .$$
We measured CKA between all possible pairings of ResNet blocks from 18 networks (2 different initializations for each objective). To reduce memory requirements, we used minibatch CKA [47] with minibatches of size 1500 and processed the ImageNet validation set for 10 epochs.
As shown in Figure 2, representations of the majority of network layers are highly similar regardless of loss function, but late layers differ substantially. Figure 2a shows similarity between all pairs of blocks from pairs of networks, where one network is trained with vanilla softmax cross-entropy and the other is trained with either softmax or a different loss function. The diagonals of these plots indicate the similarity between architecturally corresponding layers. For all network pairs, the diagonals are stronger than the off-diagonals, indicating that architecturally corresponding layers are more similar than non-corresponding layers. However, in the last few layers of the network, the diagonals are substantially brighter when both networks are trained with softmax than when the second network is trained with a different loss, indicating representational differences in these layers. Figure 2b shows similarity of representations among all loss functions for a subset of blocks. Consistent differences among loss functions are present only in the last third of the network, starting around block 13.
 Figure 2: The choice of loss function affects representations only in later network layers. All plots show linear centered kernel alignment (CKA) between representations computed on the ImageNet validation set. a: CKA between network layers, for pairs of ResNet-50 models trained from different initializations with different losses. As controls, the top-right plot shows CKA between two networks trained with softmax, and the bottom-right plot shows CKA between a model trained with softmax loss and a model at initialization where batch norm moments have been computed on the training set. b: CKA between representations extracted from corresponding layers of networks trained with different loss functions. Diagonal reflects similarity of networks with the same loss function trained from different initalizations. See Appendix Figure B.1 for a similar figure for Inception v3 models.
 Figure 3: Loss functions affect sparsity of later layer representations. Plot shows the average $\%$ non-zero activations for each ResNet-50 block, after the residual connection and subsequent nonlinearity, on the ImageNet validation set. Dashed lines indicate boundaries between stages.
The sparsity of activations reveals a similar pattern of layer-wise differences between networks trained with different loss functions. Figure 3 shows the proportion of non-zero activations in different layers. In all networks, the percentage of non-zero ReLU activations decreases with depth, attaining its minimum at the last convolutional layer. In the first three ResNet stages, activation sparsity is broadly similar regardless of the loss. However, in the final stage and penultimate average pooling layer, the degree of sparsity depends greatly on the loss. Penultimate layer representations of vanilla softmax networks are the least sparse, with $9 2 . 8 \%$ non-zero activations. Logit normalization, cosine softmax, and squared error all result in much sparser ( $4 2 5 \%$ non-zero) activations.
Table 3: Regularization and alternative losses improve class separation in the penultimate layer. Results are averaged over 8 ResNet-50 models per loss on the ImageNet training set.
<table><tr><td>Loss/regularizer ImageNet top-1</td><td>Class sep. (R²)</td></tr><tr><td>Softmax</td><td>77.0 ± 0.06 0.349 ± 0.0002</td></tr><tr><td>Label smooth.</td><td>77.6 ± 0.03 0.420 ± 0.0003</td></tr><tr><td>Sigmoid</td><td>77.9 ± 0.05 0.427 ± 0.0003</td></tr><tr><td>Extra L²</td><td>77.7 ± 0.03 0.572 ± 0.0006</td></tr><tr><td>Dropout</td><td>77.5 ± 0.04 0.461 ± 0.0003</td></tr><tr><td>Logit penalty</td><td>77.7 ± 0.04 0.601 ± 0.0004</td></tr><tr><td>Logit norm</td><td>77.8 ± 0.02 0.517 ± 0.0002</td></tr><tr><td>Cosine softmax</td><td>77.9 ± 0.02 0.641 ± 0.0003</td></tr><tr><td>Squared error</td><td>77.2 ± 0.04 0.845 ± 0.0002</td></tr></table>
 Figure 4: Class separation in different layers of ResNet50, averaged over 8 models per loss on the ImageNet training set. For convolutional layers, we compute cosine distances by flattening the representations of examples across spatial dimensions.
These results immediately suggest an explanation for the limited effect of the training objective on networks’ fine-tuning performance. We observe differences among objectives only in later network layers, but previous work has found that these layers change substantially during finetuning [79, 53, 46], an observation we replicate in Appendix D.4. Thus, the choice of training objective appears to affect parts of the network that are specific to the pretraining task, and do not transfer when the network is fine-tuned on other tasks.
# 3.3 Regularization and alternative losses increase class separation
The previous section suggests that different loss functions learn very different penultimate layer representations, even when their overall accuracy is similar. However, as shown in Appendix C.4, combining different losses and penultimate layer regularizers provides no accuracy improvements over training with only one, suggesting that they share similar mechanisms. In this section, we demonstrate that a simple property of networks’ penultimate layer representations can explain their beneficial effect on accuracy relative to vanilla softmax cross-entropy, as well as their harmful effect on fixed features. Specifically, compared to vanilla softmax cross-entropy, all investigated losses cause the network to reduce the relative within-class variance in the penultimate layer representation space. This reduction in within-class variance corresponds to increased separation between classes, and is harmful to linear transfer.
The ratio of the average within-class cosine distance to the overall average cosine distance measures the dispersion of representations of examples belonging to the same class relative to the overall dispersion of embeddings. We take one minus this quantity to get a closed-form index of class separation that is between 0 and 1:
$$R ^ { 2 } = 1 - \bar { d } _ { \mathrm { w i t h i n } } / \bar { d } _ { \mathrm { t o t a l } }$$
$$\bar { d } _ { \mathrm { w i t h i n } } = \sum _ { k = 1 } ^ { K } \sum _ { m = 1 } ^ { N _ { k } } \sum _ { n = 1 } ^ { N _ { k } } \frac { 1 - \sin ( x _ { k , m } , x _ { k , n } ) } { K N _ { k } ^ { 2 } } , \quad \bar { d } _ { \mathrm { t o t a l } } = \sum _ { j = 1 } ^ { K } \sum _ { k = 1 } ^ { K } \sum _ { m = 1 } ^ { N _ { j } } \sum _ { n = 1 } ^ { N _ { k } } \frac { 1 - \sin ( x _ { j , m } , x _ { k , n } ) } { K ^ { 2 } N _ { j } N _ { k } }$$
where ${ \pmb x } _ { k , m }$ is the embedding of example $m$ in class $k \in \{ 1 , \ldots , K \}$ , $N _ { k }$ is the number of examples in class $k$ , and $\sin ( \mathbf x , \pmb y ) = \pmb x ^ { \top } \pmb y / ( \| \pmb x \| \| \pmb y \| )$ is cosine similarity between vectors. As we show in Appendix E.1, if the embeddings are first $L ^ { 2 }$ normalized, then $1 - R ^ { 2 }$ is the ratio of the average within-class variance to the weighted total variance, where the weights are inversely proportional to the number of examples in each class. For a balanced dataset, $R ^ { 2 }$ is equivalent to centered kernel alignment [17, 18] between the embeddings and the one-hot label matrix, with a cosine kernel. See Appendix E.2 for results with other distance metrics.
As shown in Table 3 and Figure 4, all regularizers and alternative loss functions we investigate produce greater class separation in penultimate layer representations as compared to vanilla softmax loss. Importantly, this increase in class separation is specific to forms of regularization that affect networks’ final layers. In Appendix E.3, we show that adding regularization through data augmentation improves accuracy without a substantial change in class separation. We further investigate the training dynamics of class separation in Appendix E.4, finding that, for softmax cross-entropy, class separation peaks early in training and then falls, whereas for other objectives, class separation either saturates or continues to rise as training progresses.
 Figure 5: Class separation negatively correlates with linear transfer accuracy. a: Mean linear transfer accuracy across all tasks vs. class separation on ImageNet, for different loss functions. b: For cosine softmax loss, training at higher temperature produces greater class separation but worse linear transfer accuracy.
Table 4: Temperature of cosine softmax loss controls ImageNet accuracy, class separation $( R ^ { 2 } )$ , and linear transfer accuracy.
<table><tr><td rowspan="2">Temp.</td><td colspan="2">ImageNet</td><td colspan="8">Transfer</td></tr><tr><td>Top-1</td><td>R²</td><td>Food</td><td>CIFAR10</td><td>CIFAR100</td><td>Birdsnap</td><td>SUN397</td><td>Cars</td><td>Pets</td><td>Flowers</td></tr><tr><td>0.01</td><td>74.9</td><td>0.236</td><td>73.4</td><td>91.9</td><td>76.5</td><td>57.2</td><td>60.5</td><td>62.9</td><td>91.7</td><td>93.6</td></tr><tr><td>0.02</td><td>77.0</td><td>0.358</td><td>72.1</td><td>91.8</td><td>76.2</td><td>56.5</td><td>60.4</td><td>58.5</td><td>92.2</td><td>91.2</td></tr><tr><td>0.03</td><td>77.5</td><td>0.475</td><td>69.1</td><td>91.5</td><td>74.9</td><td>53.7</td><td>59.1</td><td>51.8</td><td>92.3</td><td>87.4</td></tr><tr><td>0.04</td><td>77.6</td><td>0.562</td><td>66.0</td><td>90.7</td><td>73.8</td><td>50.3</td><td>57.4</td><td>45.1</td><td>91.7</td><td>82.2</td></tr><tr><td>0.05</td><td>77.6</td><td>0.634</td><td>62.8</td><td>90.4</td><td>72.2</td><td>47.6</td><td>55.4</td><td>38.6</td><td>91.0</td><td>78.3</td></tr><tr><td>0.06</td><td>77.5</td><td>0.693</td><td>60.3</td><td>89.3</td><td>69.8</td><td>43.3</td><td>53.8</td><td>33.3</td><td>91.0</td><td>72.7</td></tr><tr><td>0.07</td><td>77.5</td><td>0.738</td><td>57.1</td><td>88.7</td><td>68.6</td><td>39.6</td><td>51.4</td><td>29.1</td><td>90.2</td><td>67.9</td></tr><tr><td>0.08</td><td>77.6</td><td>0.770</td><td>53.7</td><td>87.7</td><td>66.5</td><td>35.5</td><td>49.4</td><td>25.7</td><td>89.3</td><td>63.2</td></tr></table>
# 3.4 Greater class separation is associated with less transferable features
Although losses that improve class separation lead to higher accuracy on the ImageNet validation set, the feature extractors they learn transfer worse to other tasks. Figure 5a plots mean linear transfer accuracy versus class separation for each of the losses we investigate. We observe a significant negative correlation (Spearman’s $\rho = - 0 . 9 3$ , $p = 0 . 0 0 2 )$ . Notably, vanilla softmax cross-entropy produces the least class separation and the most transferable features, whereas squared error produces much greater class separation than other losses and leads to much lower transfer performance.
To confirm this relationship between class separation, ImageNet accuracy, and transfer, we trained models with cosine softmax with varying values of the temperature parameter $\tau$ .1 As shown in Table 4, lower temperatures yield lower top-1 accuracies and worse class separation. However, even though the lowest temperature of $\tau = 0 . 0 1$ achieved $2 . 7 \%$ lower accuracy on ImageNet than the best temperature, this lowest temperature gave the best features for nearly all transfer datasets. Thus, $\tau$ controls a tradeoff between the generalizability of penultimate-layer features and the accuracy on the target dataset. For $\tau \geq 0 . 0 4$ , ImageNet accuracy saturates, but, as shown in Figure 5b, class separation continues to increase and transfer accuracy continues to decrease.
Is there any situation where features with greater class separation could be beneficial for a downstream task? In Figure 6, we use $L ^ { 2 }$ -regularized logistic regression to relearn the original 1000-way ImageNet classification head from penultimate layer representations of 40,000 examples from the ImageNet validation set.2 We find that features from networks trained with vanilla softmax loss perform worst, whereas features from networks with greater class separation perform substantially better. Thus, it seems that representations with greater class separation are “overfit,” not to the pretraining datapoints, but to the pretraining classes—they perform better for classifying these classes, but worse when the downstream task requires classifying different classes.
 Figure 6: Class separation positively correlates with accuracy when relearning how to classify ImageNet classes from limited data. All accuracy numbers are computed on a 10,000 example subset of the ImageNet validation set (10 examples per class). Blue dots indicate accuracy of the weights of the original ImageNettrained model. Orange dots indicate accuracy of a linear classifier trained on the other 40,000 examples from the ImageNet validation set. Lines connect blue and orange dots corresponding to the same objective. The gap between the accuracies of the original and relearned classifiers narrows as class separation increases. Class separation is measured on the ImageNet training set. All numbers are averaged over 8 models.
Our results above provide some further evidence that greater class separation can be beneficial in real-world scenarios where downstream datasets share classes with the pretraining dataset. In Tables 1 and 4, representations with the lowest class separation perform best on all datasets except for Oxford-IIIT Pets, where representations with slightly greater class separation consistently perform slightly better. We thus explore class overlap between transfer datasets and ImageNet in Appendix F, and find that, of the 37 cat and dog breeds in Oxford-IIIT Pets, 25 correspond directly to ImageNet classes. Furthermore, it is possible to achieve $7 1 . 2 \%$ accuracy on Oxford-IIIT Pets simply by taking the top-1 predictions of an ImageNet classifier and and mapping them directly to its classes, but this strategy achieves much lower accuracy on other datasets.
# 4 Related work
Understanding training objectives. There is a great deal of previous work that investigates why some objectives perform better than others, using both theoretical and empirical approaches. On linearly separable data, theoretical analysis shows that gradient descent on both unregularized logistic or multinomial logistic regression objectives (i.e., linear models with sigmoid or softmax crossentropy loss) eventually converges to the minimum norm solution [63]. These results can be extended to neural networks in certain restricted settings [28, 74]. However, the convergence to this solution is very slow. Theoretical analysis of dropout has bounded the excess risk of single-layer [70] and two-layer [42] networks. Empirical studies have attempted to understand regularization in more realistic settings. Label smoothing has been explained in terms of mitigation of label noise [39, 13], entropy regularization [52, 41], and accelerated convergence [78]. Other work has shown that dropout on intermediate layers has both implicit and explicit effects, and both are important to accuracy [74]. Janocha and Czarnecki [32] previously studied both empirical and mathematical similarities and differences among loss functions for supervised classification in the context of deep learning.
Training objectives for transfer. Our study of the transferability of networks trained with different objectives extends the previous investigation of Kornblith et al. [34], which showed that two of the regularizers considered here (label smoothing and dropout) lead to features that transfer worse. Similar results have been reported for self-supervised learning, where the loss parameters that maximize accuracy on the contrastive task do not provide the best features for linear classification [14]. Our work demonstrates that this phenomenon is pervasive, and connects it to properties of hidden representations. By contrast, work that explores out-of-distribution (OOD) generalization, where the training and evaluation datasets consist of the same classes but with some degree of distribution shift, finds that ImageNet accuracy is highly predictive of OOD accuracy across many pretrained models [55, 67]. In Appendix Table C.2, we show that, across loss functions, ImageNet validation set accuracy is not entirely correlated with OOD accuracy, but different losses produce much smaller differences in OOD accuracy than linear transfer accuracy.
Other related work has attempted to devise loss functions to learn more transferable embeddings for few-shot learning [62, 65, 7, 15, 49], but embeddings of models trained with softmax cross-entropy often perform on par with these more sophisticated techniques [68]. Doersch et al. [22] motivate their few-shot learning method as a way to mitigate “supervision collapse,” which they do not directly quantify, but is closely related to our notion of class separation. While our paper was under review, two studies reported advantages for increased final layer $L ^ { 2 }$ regularization when performing few-shot linear transfer from very large pretraining datasets to some, but not all, downstream tasks [80, 1]. Our findings suggest that these advantages may arise because the pretraining and downstream tasks share classes, but further investigation is needed to confirm this hypothesis.
Class separation. Prior work has investigated class separation in neural networks in a variety of different ways. Theoretical work connects various concepts of the normalized margin between classes to the generalization properties of neural networks [4, 44, 5, 45]. Empirically, Chen et al. [12] measure class separation via “angular visual hardness,” the arccosine-transformed cosine similarity between the weight vectors and examples, and suggested an association between this metric and accuracy. However, as shown in Appendix Figure E.1, this metric is unable to differentiate between networks trained with softmax and sigmoid cross-entropy. Papyan et al. [50] describe a phenomenon they call “neural collapse,” which occurs after training error vanishes and is associated with the collapse of the class means, classifier, and activations to the vertices of an equiangular tight frame, implying maximal class separation. We relate our observations to theirs in Appendix Table E.2. More generally, studies have investigated how class information evolves through the hidden layers of neural networks using linear classifiers [2], binning estimators of mutual information [61, 58, 26], Euclidean distances [59], the soft nearest neighbor loss [24], and manifold geometry [3, 16]. In the context of a study of representational consistency across networks trained from different initializations, Mehrer et al. [40] previously reported increased class separation in CIFAR-10 networks trained with dropout.
Other work has explored relationships between measures of class separation in embedding spaces and accuracy in few-shot and deep metric learning settings. In deep metric learning, Roth et al. [56] show that objectives that lead to greater class separation generally produce higher recall, and find a similar relationship for a measure of the uniformity of the singular value spectrum of the representation space. In few-shot learning, different work has reached different conclusions: Goldblum et al. [25] find that regularization that increases class separation improves few-shot classification performance on mini-ImageNet and CIFAR-FS, whereas Liu et al. [37] find that introducing a negative margin into a cosine softmax loss yields both lower class separation and higher accuracy.
# 5 Limitations
Although we investigate many losses and multiple architectures, our experiments are limited to moderately sized datasets with moderately sized models, and our conclusions are limited to supervised classification settings. ResNet-50 on trained on ImageNet is a realistic transfer scenario where our analysis is computationally tractable, but bigger models trained on bigger datasets with more classes achieve better performance. These bigger datasets with richer label spaces could potentially help to mitigate the trade-off between pretraining accuracy and feature quality, and may also have class-level overlap with many downstream tasks, making greater class separation helpful rather than harmful.
Our results establish that a wide variety of losses that improve over vanilla softmax cross-entropy lead to greater class separation, but this observation does not immediately lead to a recipe for higher pretraining accuracy. The relationship between class separation and pretraining accuracy is nonmonotonic: squared error achieves the highest class separation but does not significantly outperform vanilla softmax cross-entropy.
# 6 Conclusion
In this study, we find that the properties of a loss that yields good performance on the pretraining task are different from the properties of a loss that learns good generic features. Training objectives that lead to better performance on the pretraining task learn more invariant representations with greater class separation. However, these same properties are detrimental when fixed features are transferred to other tasks. Moreover, because different loss functions produce different representations only in later network layers, which change substantially during fine-tuning, gains in pretraining accuracy do not lead to gains when models are fine-tuned on downstream tasks.
Our work suggests opportunities for improving fixed feature representations in deep neural networks. We see no inherent reason that features learned by softmax cross-entropy should be optimal for transfer, but previous work has optimized for pretraining accuracy, rather than transferable features. With the increasing importance of transfer learning in deep learning, we believe that future research into loss functions should explicitly target and evaluate performance under transfer settings.
# Acknowledgements
We thank Pieter-Jan Kindermans for comments on the manuscript, and Geoffrey Hinton and David Fleet for useful discussions.
# References
[1] S. Abnar, M. Dehghani, B. Neyshabur, and H. Sedghi. Exploring the limits of large scale pre-training. arXiv preprint arXiv:2110.02095, 2021. [2] G. Alain and Y. Bengio. Understanding intermediate layers using linear classifier probes. arXiv preprint arXiv:1610.01644, 2016. [3] A. Ansuini, A. Laio, J. H. Macke, and D. Zoccolan. Intrinsic dimension of data representations in deep neural networks. In Advances in Neural Information Processing Systems, 2019. [4] P. L. Bartlett. For valid generalization, the size of the weights is more important than the size of the network. Advances in Neural Information Processing Systems, pages 134–140, 1997. [5] P. L. Bartlett, D. J. Foster, and M. Telgarsky. Spectrally-normalized margin bounds for neural networks. Advances in Neural Information Processing Systems, 2017:6241–6250, 2017. [6] T. Berg, J. Liu, S. W. Lee, M. L. Alexander, D. W. Jacobs, and P. N. Belhumeur. Birdsnap: Large-scale fine-grained visual categorization of birds. In IEEE Conference on Computer Vision and Pattern Recognition, pages 2019–2026. IEEE, 2014. [7] L. Bertinetto, J. F. Henriques, P. Torr, and A. Vedaldi. Meta-learning with differentiable closed-form solvers. In International Conference on Learning Representations, 2019. [8] L. Beyer, O. J. Hénaff, A. Kolesnikov, X. Zhai, and A. v. d. Oord. Are we done with ImageNet? arXiv preprint arXiv:2006.07159, 2020. [9] L. Bossard, M. Guillaumin, and L. Van Gool. Food-101 — mining discriminative components with random forests. In European Conference on Computer Vision, pages 446–461. Springer, 2014. [10] J. S. Bridle. Probabilistic interpretation of feedforward classification network outputs, with relationships to statistical pattern recognition. In Neurocomputing, pages 227–236. Springer, 1990. [11] J. S. Bridle. Training stochastic model recognition algorithms as networks can lead to maximum mutual information estimation of parameters. In Advances in Neural Information Processing Systems, pages 211–217, 1990. [12] B. Chen, W. L. A. Garg, Z. Yu, A. Shrivastava, J. Kautz, and A. Anandkumar. Angular visual hardness. In International Conference on Machine Learning, 2020. [13] B. Chen, L. Ziyin, Z. Wang, and P. P. Liang. An investigation of how label smoothing affects generalization. arXiv preprint arXiv:2010.12648, 2020. [14] T. Chen, S. Kornblith, M. Norouzi, and G. Hinton. A simple framework for contrastive learning of visual representations. In International Conference on Machine Learning, 2020. [15] W.-Y. Chen, Y.-C. Liu, Z. Kira, Y.-C. F. Wang, and J.-B. Huang. A closer look at few-shot classification. In International Conference on Learning Representations, 2019. [16] U. Cohen, S. Chung, D. D. Lee, and H. Sompolinsky. Separability and geometry of object manifolds in deep neural networks. Nature Communications, 11(1):1–13, 2020. [17] C. Cortes, M. Mohri, and A. Rostamizadeh. Algorithms for learning kernels based on centered alignment. The Journal of Machine Learning Research, 13(1):795–828, 2012. [18] N. Cristianini, J. Shawe-Taylor, A. Elisseeff, and J. S. Kandola. On kernel-target alignment. In Advances in Neural Information Processing Systems, pages 367–373, 2002. [19] Y. Dauphin and E. D. Cubuk. Deconstructing the regularization of batchnorm. In International Conference on Learning Representations, 2021. [20] J. Deng, W. Dong, R. Socher, L.-J. Li, K. Li, and L. Fei-Fei. ImageNet: A large-scale hierarchical image database. In IEEE Conference on Computer Vision and Pattern Recognition, pages 248–255. Ieee, 2009. [21] J. Deng, J. Guo, N. Xue, and S. Zafeiriou. Arcface: Additive angular margin loss for deep face recognition. In IEEE Conference on Computer Vision and Pattern Recognition, pages 4690–4699, 2019. [22] C. Doersch, A. Gupta, and A. Zisserman. Crosstransformers: spatially-aware few-shot transfer. arXiv preprint arXiv:2007.11498, 2020. [23] J. Donahue, Y. Jia, O. Vinyals, J. Hoffman, N. Zhang, E. Tzeng, and T. Darrell. Decaf: A deep convolutional activation feature for generic visual recognition. In International Conference on Machine Learning, 2014. [24] N. Frosst, N. Papernot, and G. Hinton. Analyzing and improving representations with the soft nearest neighbor loss. In International Conference on Machine Learning, pages 2012–2020. PMLR, 2019. [25] M. Goldblum, S. Reich, L. Fowl, R. Ni, V. Cherepanova, and T. Goldstein. Unraveling metalearning: Understanding feature representations for few-shot tasks. In International Conference on Machine Learning, pages 3607–3616. PMLR, 2020. [26] Z. Goldfeld, E. v. d. Berg, K. Greenewald, I. Melnyk, N. Nguyen, B. Kingsbury, and Y. Polyanskiy. Estimating information flow in deep neural networks. In International Conference on Machine Learning, 2018. [27] S. Gross and M. Wilber. Training and investigating residual nets. In The Torch Blog. http: //torch.ch/blog/2016/02/04/resnets.html, 2016. [28] S. Gunasekar, J. D. Lee, D. Soudry, and N. Srebro. Implicit bias of gradient descent on linear convolutional networks. In Advances in Neural Information Processing Systems, pages 9461–9471, 2018. [29] K. He, X. Zhang, S. Ren, and J. Sun. Deep residual learning for image recognition. In IEEE Conference on Computer Vision and Pattern Recognition, pages 770–778, 2016. [30] L. Hui and M. Belkin. Evaluation of neural architectures trained with square loss vs crossentropy in classification tasks. In International Conference on Learning Representations, 2021. [31] J. Irvin, P. Rajpurkar, M. Ko, Y. Yu, S. Ciurea-Ilcus, C. Chute, H. Marklund, B. Haghgoo, R. Ball, K. Shpanskaya, et al. Chexpert: A large chest radiograph dataset with uncertainty labels and expert comparison. In Proceedings of the AAAI conference on artificial intelligence, volume 33, pages 590–597, 2019. [32] K. Janocha and W. M. Czarnecki. On loss functions for deep neural networks in classification. Schedae Informaticae, 25, 2016. [33] S. Kornblith, M. Norouzi, H. Lee, and G. Hinton. Similarity of neural network representations revisited. In International Conference on Machine Learning, 2019. [34] S. Kornblith, J. Shlens, and Q. V. Le. Do better ImageNet models transfer better? In IEEE Conference on Computer Vision and Pattern Recognition, pages 2661–2671, 2019. [35] J. Krause, J. Deng, M. Stark, and L. Fei-Fei. Collecting a large-scale dataset of fine-grained cars. In Second Workshop on Fine-Grained Visual Categorization, 2013. [36] A. Krizhevsky and G. Hinton. Learning multiple layers of features from tiny images. Technical report, University of Toronto, 2009. [37] B. Liu, Y. Cao, Y. Lin, Q. Li, Z. Zhang, M. Long, and H. Hu. Negative margin matters: Understanding margin in few-shot classification. In European Conference on Computer Vision, pages 438–455. Springer, 2020. [38] W. Liu, Y. Wen, Z. Yu, M. Li, B. Raj, and L. Song. Sphereface: Deep hypersphere embedding for face recognition. In IEEE Conference on Computer Vision and Pattern Recognition, pages 212–220, 2017. [39] M. Lukasik, S. Bhojanapalli, A. Menon, and S. Kumar. Does label smoothing mitigate label noise? In International Conference on Machine Learning, pages 6448–6458. PMLR, 2020. [40] J. Mehrer, C. J. Spoerer, N. Kriegeskorte, and T. C. Kietzmann. Individual differences among deep neural network models. Nature Communications, 11(1):1–12, 2020. [41] C. Meister, E. Salesky, and R. Cotterell. Generalized entropy regularization or: There’s nothing special about label smoothing. In Proceedings of the 58th Annual Meeting of the Association for Computational Linguistics, pages 6870–6886, 2020. [42] P. Mianjy and R. Arora. On convergence and generalization of dropout training. Advances in Neural Information Processing Systems, 33, 2020. [43] R. Müller, S. Kornblith, and G. E. Hinton. When does label smoothing help? In Advances in Neural Information Processing Systems, pages 4696–4705, 2019. [44] B. Neyshabur, R. Tomioka, and N. Srebro. Norm-based capacity control in neural networks. In Conference on Learning Theory, pages 1376–1401. PMLR, 2015. [45] B. Neyshabur, S. Bhojanapalli, and N. Srebro. A pac-bayesian approach to spectrally-normalized margin bounds for neural networks. In International Conference on Learning Representations, 2018. [46] B. Neyshabur, H. Sedghi, and C. Zhang. What is being transferred in transfer learning? In Advances in Neural Information Processing Systems, 2020. [47] T. Nguyen, M. Raghu, and S. Kornblith. Do wide and deep networks learn the same things? uncovering how neural network representations vary with width and depth. In International Conference on Learning Representations, 2021. [48] M.-E. Nilsback and A. Zisserman. Automated flower classification over a large number of classes. In Computer Vision, Graphics & Image Processing, 2008. ICVGIP’08. Sixth Indian Conference on, pages 722–729. IEEE, 2008. [49] B. N. Oreshkin, P. Rodriguez, and A. Lacoste. Tadam: Task dependent adaptive metric for improved few-shot learning. arXiv preprint arXiv:1805.10123, 2018. [50] V. Papyan, X. Han, and D. L. Donoho. Prevalence of neural collapse during the terminal phase of deep learning training. Proceedings of the National Academy of Sciences, 117(40): 24652–24663, 2020. [51] O. M. Parkhi, A. Vedaldi, A. Zisserman, and C. Jawahar. Cats and dogs. In IEEE Conference on Computer Vision and Pattern Recognition, pages 3498–3505. IEEE, 2012. [52] G. Pereyra, G. Tucker, J. Chorowski, Ł. Kaiser, and G. Hinton. Regularizing neural networks by penalizing confident output distributions. arXiv preprint arXiv:1701.06548, 2017. [53] M. Raghu, C. Zhang, J. Kleinberg, and S. Bengio. Transfusion: Understanding transfer learning for medical imaging. In Advances in Neural Information Processing Systems. Curran Associates, Inc., 2019. [54] R. Ranjan, C. D. Castillo, and R. Chellappa. L2-constrained softmax loss for discriminative face verification. arXiv preprint arXiv:1703.09507, 2017. [55] B. Recht, R. Roelofs, L. Schmidt, and V. Shankar. Do ImageNet classifiers generalize to ImageNet? In International Conference on Machine Learning, 2019. [56] K. Roth, T. Milbich, S. Sinha, P. Gupta, B. Ommer, and J. P. Cohen. Revisiting training strategies and generalization performance in deep metric learning. In International Conference on Machine Learning, pages 8242–8252. PMLR, 2020. [57] O. Russakovsky, J. Deng, H. Su, J. Krause, S. Satheesh, S. Ma, Z. Huang, A. Karpathy, A. Khosla, M. Bernstein, et al. Imagenet large scale visual recognition challenge. International journal of computer vision, 115(3):211–252, 2015. [58] A. M. Saxe, Y. Bansal, J. Dapello, M. Advani, A. Kolchinsky, B. D. Tracey, and D. D. Cox. On the information bottleneck theory of deep learning. Journal of Statistical Mechanics: Theory and Experiment, 2019(12):124020, 2019. [59] A. Schilling, C. Metzner, J. Rietsch, R. Gerum, H. Schulze, and P. Krauss. How deep is deep enough?–quantifying class separability in the hidden layers of deep neural networks. arXiv preprint arXiv:1811.01753, 2018. [60] A. Sharif Razavian, H. Azizpour, J. Sullivan, and S. Carlsson. Cnn features off-the-shelf: an astounding baseline for recognition. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition Workshops, 2014. [61] R. Shwartz-Ziv and N. Tishby. Opening the black box of deep neural networks via information. arXiv preprint arXiv:1703.00810, 2017. [62] J. Snell, K. Swersky, and R. Zemel. Prototypical networks for few-shot learning. In Advances in Neural Information Processing Systems, pages 4077–4087, 2017. [63] D. Soudry, E. Hoffer, M. S. Nacson, S. Gunasekar, and N. Srebro. The implicit bias of gradient descent on separable data. The Journal of Machine Learning Research, 19(1):2822–2878, 2018. [64] N. Srivastava, G. Hinton, A. Krizhevsky, I. Sutskever, and R. Salakhutdinov. Dropout: a simple way to prevent neural networks from overfitting. The Journal of Machine Learning Research, 15(1):1929–1958, 2014. [65] F. Sung, Y. Yang, L. Zhang, T. Xiang, P. H. Torr, and T. M. Hospedales. Learning to compare: Relation network for few-shot learning. In IEEE Conference on Computer Vision and Pattern Recognition, pages 1199–1208, 2018. [66] C. Szegedy, V. Vanhoucke, S. Ioffe, J. Shlens, and Z. Wojna. Rethinking the inception architecture for computer vision. In IEEE Conference on Computer Vision and Pattern Recognition, pages 2818–2826, 2016. [67] R. Taori, A. Dave, V. Shankar, N. Carlini, B. Recht, and L. Schmidt. Measuring robustness to natural distribution shifts in image classification. Advances in Neural Information Processing Systems, 2020. [68] Y. Tian, Y. Wang, D. Krishnan, J. B. Tenenbaum, and P. Isola. Rethinking few-shot image classification: a good embedding is all you need? In European Conference on Computer Vision, 2020. [69] S. Wager, S. Wang, and P. S. Liang. Dropout training as adaptive regularization. In Advances in Neural Information Processing Systems, pages 351–359, 2013. [70] S. Wager, W. Fithian, S. Wang, and P. S. Liang. Altitude training: Strong bounds for single-layer dropout. In Advances in Neural Information Processing Systems, 2014. [71] F. Wang, X. Xiang, J. Cheng, and A. L. Yuille. Normface: L2 hypersphere embedding for face verification. In Proceedings of the 25th ACM international Conference on Multimedia, pages 1041–1049, 2017. [72] F. Wang, J. Cheng, W. Liu, and H. Liu. Additive margin softmax for face verification. IEEE Signal Processing Letters, 25(7):926–930, 2018. [73] H. Wang, Y. Wang, Z. Zhou, X. Ji, D. Gong, J. Zhou, Z. Li, and W. Liu. Cosface: Large margin cosine loss for deep face recognition. In IEEE Conference on Computer Vision and Pattern Recognition, pages 5265–5274, 2018. [74] C. Wei, J. D. Lee, Q. Liu, and T. Ma. Regularization matters: Generalization and optimization of neural nets vs their induced kernel. In Advances in Neural Information Processing Systems, pages 9712–9724, 2019. [75] C. Wei, S. Kakade, and T. Ma. The implicit and explicit regularization effects of dropout. In International Conference on Machine Learning, 2020. [76] N. Wojke and A. Bewley. Deep cosine metric learning for person re-identification. In 2018 IEEE Winter Conference on Applications of Computer Vision (WACV), pages 748–756. IEEE, 2018. [77] J. Xiao, J. Hays, K. A. Ehinger, A. Oliva, and A. Torralba. Sun database: Large-scale scene recognition from abbey to zoo. In IEEE Conference on Computer Vision and Pattern Recognition, pages 3485–3492. IEEE, 2010. [78] Y. Xu, Y. Xu, Q. Qian, H. Li, and R. Jin. Towards understanding label smoothing. arXiv preprint arXiv:2006.11653, 2020. [79] J. Yosinski, J. Clune, Y. Bengio, and H. Lipson. How transferable are features in deep neural networks? In Neural Information Processing Systems, volume 27. Curran Associates, Inc., 2014. [80] X. Zhai, A. Kolesnikov, N. Houlsby, and L. Beyer. Scaling vision transformers. arXiv preprint arXiv:2106.04560, 2021.
# Checklist
1. For all authors...
(a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? [Yes] (b) Did you describe the limitations of your work? [Yes] We discuss limitations in Section 5. (c) Did you discuss any potential negative societal impacts of your work? [N/A] (d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes]
2. If you are including theoretical results...
(a) Did you state the full set of assumptions of all theoretical results? [N/A] (b) Did you include complete proofs of all theoretical results? [N/A]
3. If you ran experiments...
(a) Did you include the code, data, and instructions needed to reproduce the main experimental results (either in the supplemental material or as a URL)? [No] (b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes] We provide training details in Appendix A.1. (c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [No] We do not report the standard deviations across seeds in all tables because it is not possible to do so while keeping the text at a readable size. However, we perform appropriate statistical testing based on the standard deviations across seeds and bold-face numbers in each table that are not statistically significant from the best. (d) Did you include the total amount of compute and the type of resources used (e.g., type of GPUs, internal cluster, or cloud provider)? [Yes]
4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets...
(a) If your work uses existing assets, did you cite the creators? [Yes] (b) Did you mention the license of the assets? [No] (c) Did you include any new assets either in the supplemental material or as a URL? [No] (d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating? [N/A] (e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [N/A]
5. If you used crowdsourcing or conducted research with human subjects...
(a) Did you include the full text of instructions given to participants and screenshots, if applicable? [N/A] (b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [N/A] (c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [N/A]123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391# EXPLAINABLE DEEP ONE-CLASS CLASSIFICATION
Philipp Liznerski1∗ Lukas Ruff2∗ Robert A. Vandermeulen2∗ Billy Joe Franks1 Marius Kloft1 Klaus-Robert Muller ¨ 2 3 4 5 $^ { 1 } \mathrm { M L }$ group, Technical University of Kaiserslautern, Germany $^ { 2 } \mathbf { M } \mathbf { L }$ group, Technical University of Berlin, Germany 3Google Research, Brain Team, Berlin, Germany 4Department of Artificial Intelligence, Korea University, Seoul, Republic of Korea 5Max Planck Institute for Informatics, Saarbrucken, Germany ¨ {liznerski, franks, kloft}@cs.uni-kl.de {lukas.ruff, vandermeulen, klaus-robert.mueller}@tu-berlin.de
# ABSTRACT
Deep one-class classification variants for anomaly detection learn a mapping that concentrates nominal samples in feature space causing anomalies to be mapped away. Because this transformation is highly non-linear, finding interpretations poses a significant challenge. In this paper we present an explainable deep one-class classification method, Fully Convolutional Data Description (FCDD), where the mapped samples are themselves also an explanation heatmap. FCDD yields competitive detection performance and provides reasonable explanations on common anomaly detection benchmarks with CIFAR-10 and ImageNet. On MVTec-AD, a recent manufacturing dataset offering ground-truth anomaly maps, FCDD sets a new state of the art in the unsupervised setting. Our method can incorporate ground-truth anomaly explanations during training and using even a few of these $( \sim 5 )$ improves performance significantly. Finally, using FCDD’s explanations, we demonstrate the vulnerability of deep one-class classification models to spurious image features such as image watermarks.1
# 1 INTRODUCTION
Anomaly detection (AD) is the task of identifying anomalies in a corpus of data (Edgeworth, 1887; Barnett and Lewis, 1994; Chandola et al., 2009; Ruff et al., 2021). Powerful new anomaly detectors based on deep learning have made AD more effective and scalable to large, complex datasets such as high-resolution images (Ruff et al., 2018; Bergmann et al., 2019). While there exists much recent work on deep AD, there is limited work on making such techniques explainable. Explanations are needed in industrial applications to meet safety and security requirements (Berkenkamp et al., 2017; Katz et al., 2017; Samek et al., 2020), avoid unfair social biases (Gupta et al., 2018), and support human experts in decision making (Jarrahi, 2018; Montavon et al., 2018; Samek et al., 2020). One typically makes anomaly detection explainable by annotating pixels with an anomaly score and, in some applications, such as finding tumors in cancer detection (Quellec et al., 2016), these annotations are the primary goal of the detector.
One approach to deep AD, known as Deep Support Vector Data Description (DSVDD) (Ruff et al., 2018), is based on finding a neural network that transforms data such that nominal data is concentrated to a predetermined center and anomalous data lies elsewhere. In this paper we present Fully Convolutional Data Description (FCDD), a modification of DSVDD so that the transformed samples are themselves an image corresponding to a downsampled anomaly heatmap. The pixels in this heatmap that are far from the center correspond to anomalous regions in the input image. FCDD does this by only using convolutional and pooling layers, thereby limiting the receptive field of each output pixel. Our method is based on the one-class classification paradigm (Moya et al., 1993; Tax, 2001; Tax and Duin, 2004; Ruff et al., 2018), which is able to naturally incorporate known anomalies Ruff et al. (2021), but is also effective when simply using synthetic anomalies.
We show that FCDD’s anomaly detection performance is close to the state of the art on the standard AD benchmarks with CIFAR-10 and ImageNet while providing transparent explanations. On MVTecAD, an AD dataset containing ground-truth anomaly maps, we demonstrate the accuracy of FCDD’s explanations (see Figure 1), where FCDD sets a new state of the art. In further experiments we find that deep one-class classification models (e.g. DSVDD) are prone to the “Clever Hans” effect (Lapuschkin et al., 2019) where a detector fixates on spurious features such as image watermarks. In general, we find that the generated anomaly heatmaps are less noisy and provide more structure than the baselines, including gradient-based methods (Simonyan et al., 2013; Sundararajan et al., 2017) and autoencoders (Sakurada and Yairi, 2014; Bergmann et al., 2019).
 Figure 1: FCDD explanation heatmaps for MVTec-AD (Bergmann et al., 2019). Rows from top to bottom show: (1) nominal samples (2) anomalous samples (3) FCDD anomaly heatmaps (4) ground-truth anomaly maps.
# 2 RELATED WORK
Here we outline related works on deep AD focusing on explanation approaches. Classically deep AD used autoencoders (Hawkins et al., 2002; Sakurada and Yairi, 2014; Zhou and Paffenroth, 2017; Zhao et al., 2017). Trained on a nominal dataset autoencoders are assumed to reconstruct anomalous samples poorly. Thus, the reconstruction error can be used as an anomaly score and the pixel-wise difference as an explanation (Bergmann et al., 2019), thereby naturally providing an anomaly heatmap. Recent works have incorporated attention into reconstruction models that can be used as explanations (Venkataramanan et al., 2019; Liu et al., 2020). In the domain of videos, Sabokrou et al. (2018) used a pre-trained fully convolutional architecture in combination with a sparse autoencoder to extract 2D features and provide bounding boxes for anomaly localization. One drawback of reconstruction methods is that they offer no natural way to incorporate known anomalies during training.
More recently, one-class classification methods for deep AD have been proposed. These methods attempt to separate nominal samples from anomalies in an unsupervised manner by concentrating nominal data in feature space while mapping anomalies to distant locations (Ruff et al., 2018; Chalapathy et al., 2018; Goyal et al., 2020). In the domain of NLP, DSVDD has been successfully applied to text, which yields a form of interpretation using attention mechanisms (Ruff et al., 2019). For images, Kauffmann et al. (2020) have used a deep Taylor decomposition (Montavon et al., 2017) to derive relevance scores.
Some of the best performing deep AD methods are based on self-supervision. These methods transform nominal samples, train a network to predict which transformation was used on the input, and provide an anomaly score via the confidence of the prediction (Golan and El-Yaniv, 2018; Hendrycks et al., 2019b). Hendrycks et al. (2019a) have extended this to incorporate known anomalies as well. No explanation approaches have been considered for these methods so far.
Finally, there exists a great variety of explanation methods in general, for example model-agnostic methods (e.g. LIME (Ribeiro et al., 2016)) or gradient-based techniques (Simonyan et al., 2013; Sundararajan et al., 2017). Relating to our work, we note that fully convolutional architectures have been used for supervised segmentation tasks where target segmentation maps are required during training (Long et al., 2015; Noh et al., 2015).
# 3 EXPLAINING DEEP ONE-CLASS CLASSIFICATION
We review one-class classification and fully convolutional architectures before presenting our method.
Deep One-Class Classification Deep one-class classification (Ruff et al., 2018; 2020b) performs anomaly detection by learning a neural network to map nominal samples near a center c in output space, causing anomalies to be mapped away. For our method we use a Hypersphere Classifier (HSC) (Ruff et al., 2020a), a recently proposed modification of Deep SAD (Ruff et al., 2020b), a semi-supervised version of DSVDD (Ruff et al., 2018). Let $X _ { 1 } , \ldots , X _ { n }$ denote a collection of samples and $y _ { 1 } , \ldots , y _ { n }$ be labels where $y _ { i } = 1$ denotes an anomaly and $y _ { i } = 0$ denotes a nominal sample. Then the HSC objective is
$$\operatorname* { m i n } _ { \mathcal { W } , \mathbf { c } } \quad \frac { 1 } { n } \sum _ { i = 1 } ^ { n } ( 1 - y _ { i } ) h ( \phi ( X _ { i } ; \mathcal { W } ) - \mathbf { c } ) - y _ { i } \log \left( 1 - \exp \left( - h ( \phi ( X _ { i } ; \mathcal { W } ) - \mathbf { c } ) \right) \right) ,$$
where $\mathbf { c } \in \mathbb { R } ^ { d }$ is the center, and $\phi : \mathbb { R } ^ { c \times h \times w } \mathbb { R } ^ { d }$ a neural network with weights $\mathcal { W }$ . Here $h$ is the pseudo-Huber loss (Huber et al., 1964), $h ( \mathbf { a } ) = \sqrt { \left\| \mathbf { a } \right\| _ { 2 } ^ { 2 } + 1 } - 1$ , which is a robust loss that interpolates from quadratic to linear penalization. The HSC loss encourages $\phi$ to map nominal samples near c and anomalous samples away from the center c. In our implementation, the center $\mathbf { c }$ corresponds to the bias term in the last layer of our networks, i.e. is included in the network $\phi$ , which is why we omit c in the FCDD objective below.
Fully Convolutional Architecture Our method uses a fully convolutional network (FCN) (Long et al., 2015; Noh et al., 2015) that maps an image to a matrix of features, i.e. $\phi : \overline { { \mathbb { R } ^ { c \times h \times w } } } \mathbb { R } ^ { 1 \times u \times v }$ by using alternating convolutional and pooling layers only, and does not contain any fully connected layers. In this context, pooling can be seen as a special kind of convolution with fixed parameters.
 Figure 2: Visualization of a $3 \times 3$ convolution followed by a $3 \times 3$ transposed convolution with a Gaussian kernel, both using a stride of 2.
A core property of a convolutional layer is that each pixel of its output only depends on a small region of its input, known as the output pixel’s receptive field. Since the output of a convolution is produced by moving a filter over the input image, each output pixel has the same relative position as its associated receptive field in the input. For instance, the lower-left corner of the output representation has a corresponding receptive field in the lower-left corner of the input image, etc. (see Figure 2 left side). The outcome of several stacked convolutions also has receptive fields of limited size and consistent relative position, though their size grows with the amount of layers. Because of this an FCN preserves spatial information.
Fully Convolutional Data Description Here we introduce our novel explainable AD method Fully Convolutional Data Description (FCDD). By taking advantage of FCNs along with the HSC above, we propose a deep one-class method where the output features preserve spatial information and also serve as a downsampled anomaly heatmap. For situations where one would like to have a full-resolution heatmap, we include a methodology for upsampling the low-resolution heatmap based on properties of receptive fields.
 Figure 3: Visualization of the overall procedure to produce full-resolution anomaly heatmaps with FCDD. $X$ denotes the input, $\phi$ the network, $A$ the produced anomaly heatmap and $A ^ { \prime }$ the upsampled version of $A$ using a transposed Gaussian convolution.
FCDD is trained using samples that are labeled as nominal or anomalous. As before, let $X _ { 1 } , \ldots , X _ { n }$ denote a collection of samples with labels $y _ { 1 } , \ldots , y _ { n }$ where $y _ { i } = 1$ denotes an anomaly and $y _ { i } = 0$ denotes a nominal sample. Anomalous samples can simply be a collection of random images which are not from the nominal collection, e.g. one of the many large collections of images which are freely available like 80 Million Tiny Images (Torralba et al., 2008) or ImageNet (Deng et al., 2009). The use of such an auxiliary corpus has been recommended in recent works on deep AD, where it is termed Outlier Exposure (OE) (Hendrycks et al., 2019a;b). When one has access to “true” examples of the anomalous dataset, i.e. something that is likely to be representative of what will be seen at test time, we find that even using a few examples as the corpus of labeled anomalies performs exceptionally well. Furthermore, in the absence of any sort of known anomalies, one can generate synthetic anomalies, which we find is also very effective.
With an $\operatorname { F C N } \phi : \mathbb { R } ^ { c \times h \times w } \to \mathbb { R } ^ { u \times v }$ the FCDD objective utilizes a pseudo-Huber loss on the FCN output matrix $A ( X ) = \left( { \sqrt { \phi ( X ; \mathcal { W } ) ^ { 2 } + 1 } } - 1 \right)$ , where all operations are applied element-wise. The FCDD objective is then defined as (cf., (1)):
$$\operatorname* { m i n } _ { \mathcal { W } } \quad \frac { 1 } { n } \sum _ { i = 1 } ^ { n } ( 1 - y _ { i } ) \frac { 1 } { u \cdot v } \left\| A ( X _ { i } ) \right\| _ { 1 } - y _ { i } \log \left( 1 - \exp \left( - \frac { 1 } { u \cdot v } \left\| A ( X _ { i } ) \right\| _ { 1 } \right) \right) .$$
Here $\| A ( X ) \| _ { 1 }$ is the sum of all entries in $A ( X )$ , which are all positive. FCDD is the utilization of an FCN in conjunction with the novel adaptation of the HSC loss we propose in (2). The objective maximizes $\| A ( X ) \| _ { 1 }$ for anomalies and minimizes it for nominal samples, thus we use $\| A ( X ) \| _ { 1 }$ as the anomaly score. Entries of $A ( X )$ that contribute to $\| A ( X ) \| _ { 1 }$ correspond to regions of the input image that add to the anomaly score. The shape of these regions depends on the receptive field of the FCN. We include a sensitivity analysis on the size of the receptive field in Appendix A, where we find that performance is not strongly affected by the receptive field size. Note that $A ( X )$ has spatial dimensions $u \times v$ and is smaller than the original image dimensions $h \times w$ . One could use $A ( X )$ directly as a low-resolution heatmap of the image, however it is often desirable to have full-resolution heatmaps. Because we generally lack ground-truth anomaly maps in an AD setting during training, it is not possible to train an FCN in a supervised way to upsample the low-resolution heatmap $A ( X )$ (e.g. as in (Noh et al., 2015)). For this reason we introduce an upsampling scheme based on the properties of receptive fields.
Heatmap Upsampling Since we generally do not have access to ground-truth pixel annotations in anomaly detection during training, we cannot learn how to upsample using a deconvolutional type of structure. We derive a principled way to upsample our lower resolution anomaly heatmap instead. For every output pixel in $A ( \bar { X ( ) }$ there is a unique input pixel which lies at the center of its receptive field. It has been observed before that the effect of the receptive field for an output pixel decays in a Gaussian manner as one moves away from the center of the receptive field (Luo et al.,
# Algorithm 1 Receptive Field Upsampling
Input: $A \in \mathbb { R } ^ { u \times v }$ (low-res anomaly heatmap) Output: $A ^ { \prime } \in \mathbb { R } ^ { h \times w }$ (full-res anomaly heatmap) Define: $\begin{array} { r } { [ G _ { 2 } ( \mu , \sigma ) ] _ { x , y } \triangleq \frac { 1 } { 2 \pi \sigma ^ { 2 } } \exp \left( - \frac { ( x - \mu _ { 1 } ) ^ { 2 } + ( y - \mu _ { 2 } ) ^ { 2 } } { 2 \sigma ^ { 2 } } \right) } \end{array}$ $A ^ { \prime } 0$ for all output pixels $a$ in $A$ do $f \gets$ receptive field of $a$ $c \gets$ center of field $f$ $A ^ { \prime } A ^ { \prime } + a \cdot G _ { 2 } ( \overset { . } { c } , \sigma )$ end for return $A ^ { \prime }$
2016). We use this fact to upsample $A ( X )$ by using a strided transposed convolution with a fixed Gaussian kernel (see Figure 2 right side). We describe this operation and procedure in Algorithm 1 which simply corresponds to a strided transposed convolution. The kernel size is set to the receptive field range of FCDD and the stride to the cumulative stride of FCDD. The variance of the distribution can be picked empirically (see Appendix B for details). Figure 3 shows a complete overview of our FCDD method and the process of generating full-resolution anomaly heatmaps.
# 4 EXPERIMENTS
In this section, we experimentally evaluate the performance of FCDD both quantitatively and qualitatively. For a quantitative evaluation, we use the Area Under the ROC Curve (AUC) (Spackman, 1989) which is the commonly used measure in AD. For a qualitative evaluation, we compare the heatmaps produced by FCDD to existing deep AD explanation methods. As baselines, we consider gradient-based methods (Simonyan et al., 2013) applied to hypersphere classifier (HSC) models (Ruff et al., 2020a) with unrestricted network architectures (i.e. networks that also have fully connected layers) and autoencoders (Bergmann et al., 2019) where we directly use the pixel-wise reconstruction error as an explanation heatmap. We slightly blur the heatmaps of the baselines with the same Gaussian kernel we use for FCDD, which we found results in less noisy, more interpretable heatmaps. We include heatmaps without blurring in Appendix G. We adjust the contrast of the heatmaps per method to highlight interesting features; see Appendix C for details. For our experiments we don’t consider model-agnostic explanations, such as LIME (Ribeiro et al., 2016) or anchors (Ribeiro et al., 2018), because they are not tailored to the AD task and performed poorly.
# 4.1 STANDARD ANOMALY DETECTION BENCHMARKS
We first evaluate FCDD on the Fashion-MNIST, CIFAR-10, and ImageNet datasets. The common AD benchmark is to utilize these classification datasets in a one-vs-rest setup where the “one” class is used as the nominal class and the rest of the classes are used as anomalies at test time. For training, we only use nominal samples as well as random samples from some auxiliary Outlier Exposure (OE) (Hendrycks et al., 2019a) dataset, which is separate from the ground-truth anomaly classes following Hendrycks et al. (2019a;b). We report the mean AUC over all classes for each dataset.
Fashion-MNIST We consider each of the ten Fashion-MNIST (Xiao et al., 2017) classes in a one-vs-rest setup. We train Fashion-MNIST using EMNIST (Cohen et al., 2017) or grayscaled CIFAR-100 (Krizhevsky et al., 2009) as OE. We found that the latter slightly outperforms the former ${ \sim } 3$ AUC percent points). On Fashion-MNIST, we use a network that consists of three convolutional layers with batch normalization, separated by two downsampling pooling layers.
CIFAR-10 We consider each of the ten CIFAR-10 (Krizhevsky et al., 2009) classes in a one-vs-rest setup. As OE we use CIFAR-100, which does not share any classes with CIFAR-10. We use a model similar to LeNet-5 (LeCun et al., 1998), but decrease the kernel size to three, add batch normalization, and replace the fully connected layers and last max-pool layer with two further convolutions.
ImageNet We consider 30 classes from ImageNet1k (Deng et al., 2009) for the one-vs-rest setup following Hendrycks et al. (2019a). For OE we use ImageNet22k with ImageNet1k classes removed (Hendrycks et al., 2019a). We use an adaptation of VGG11 (Simonyan and Zisserman, 2015) with batch normalization, suitable for inputs resized to $2 2 4 \times 2 2 4$ (see Appendix D for model details).
State-of-the-art Methods We report results from state-of-the-art deep anomaly detection methods. Methods that do not incorporate known anomalies are the autoencoder (AE), DSVDD (Ruff et al., 2018), Geometric Transformation based AD (GEO) (Golan and El-Yaniv, 2018), and a variant of GEO by Hendrycks et al. (2019b) $\mathrm { ( G E O + ) }$ ). Methods that use OE are a Focal loss classifier (Hendrycks et al., 2019b), also $\mathrm { G E O + }$ , Deep SAD (Ruff et al., 2020b), and HSC (Ruff et al., 2020a).
Table 1: Mean AUC (over all classes and 5 seeds per class) for Fashion-MNIST, CIFAR-10, and ImageNet. Results from existing literature are marked with an asterisk (Bergman and Hoshen, 2020; Golan and El-Yaniv, 2018; Hendrycks et al., 2019b; Ruff et al., 2020a).
<table><tr><td></td><td colspan="4">without OE</td><td colspan="5">with OE</td></tr><tr><td>Dataset</td><td>AE</td><td>DSVDD*</td><td>GEO*</td><td>Geo+*</td><td>Focal*</td><td>Geo+*</td><td>Deep SAD*</td><td>HSC*</td><td>FCDD</td></tr><tr><td>Fashion-MNIST</td><td>0.82</td><td>0.93</td><td>0.94</td><td>×</td><td>×</td><td>×</td><td>×</td><td>×</td><td>0.89</td></tr><tr><td>CIFAR-10</td><td>0.59*</td><td>0.65</td><td>0.86</td><td>0.90</td><td>0.87</td><td>0.96</td><td>0.95</td><td>0.96</td><td>0.95</td></tr><tr><td>ImageNet</td><td>0.56</td><td>×</td><td>×</td><td>×</td><td>0.56</td><td>0.86</td><td>0.97</td><td>0.97</td><td>0.94</td></tr></table>
Quantitative Results The mean AUC detection performance on the three AD benchmarks are reported in Table 1. We can see that FCDD, despite using a restricted FCN architecture to improve explainability, achieves a performance that is close to state-of-the-art methods and outperforms autoencoders, which yield a detection performance close to random on more complex datasets. We provide detailed results for all individual classes in Appendix F.
 Figure 4: Anomaly heatmaps for anomalous test samples of a Fashion-MNIST model trained on nominal class “trousers” (nominal samples are shown in (a)). In (b) CIFAR-100 was used for OE and in (c) EMNIST. Columns are ordered by increasing anomaly score from left to right, i.e. what FCDD finds the most nominal looking anomaly on the left to the most anomalous looking anomaly on the right.
Qualitative Results Figures 4 and 5 show the heatmaps for Fashion-MNIST and ImageNet respectively. For a Fashion-MNIST model trained on the nominal class “trousers,” the heatmaps show that FCDD correctly highlights horizontal elements as being anomalous, which makes sense since trousers are vertically aligned. For an ImageNet model trained on the nominal class “acorns,” we observe that colors seem to be fairly relevant features with green and brown areas tending to be seen as more nominal, and other colors being deemed anomalous, for example the red barn or the white snow. Nonetheless, the method also seems capable of using more semantic features, for example it recognizes the green caterpillar as being anomalous and it distinguishes the acorn to be nominal despite being against a red background.
Figure 6 shows heatmaps for CIFAR-10 models with varying amount of OE, all trained on the nominal class “airplane.” We can see that, as the number of OE samples increases, FCDD tends to concentrate the explanations more on the primary object in the image, i.e. the bird, ship, and truck. We provide further heatmaps for additional classes from all datasets in Appendix G.
 Figure 5: Anomaly heatmaps of an ImageNet model trained on nominal class “acorns.” Here (a) are nominal samples and (b) are anomalous samples. Columns are ordered by increasing anomaly score from left to right, i.e. what FCDD finds the most nominal looking on the left to the most anomalous looking on the right for (a) nominal samples and (b) anomalies.
 Figure 6: Anomaly heatmaps for three anomalous test samples on a CIFAR-10 model trained on nominal class “airplane.” The second, third, and fourth blocks show the heatmaps of FCDD, gradientbased heatmaps of HSC, and AE heatmaps respectively. For Ours and Grad, we grow the number of OE samples from 2, 8, 128, 2048 to full OE. AE is not able to incorporate OE.
Baseline Explanations We found the gradient-based heatmaps to mostly produce centered blobs which lack spatial context (see Figure 6) and thus are not useful for explaining. The AE heatmaps, being directly tied to the reconstruction error anomaly score, look reasonable. We again note, however, that it is not straightforward how to include auxiliary OE samples or labeled anomalies into an AE approach, which leaves them with a poorer detection performance (see Table 1). Overall we find that the proposed FCDD anomaly heatmaps yield a good and consistent visual interpretation.
# 4.2 EXPLAINING DEFECTS IN MANUFACTURING
Here we compare the performance of FCDD on the MVTec-AD dataset of defects in manufacturing (Bergmann et al., 2019). This datasets offers annotated ground-truth anomaly segmentation maps for testing, thus allowing a quantitative evaluation of model explanations. MVTec-AD contains 15 object classes of high-resolution RGB images with up to $1 0 2 4 \times 1 0 2 4$ pixels, where anomalous test samples are further categorized in up to 8 defect types, depending on the class. We follow Bergmann et al. (2019) and compute an AUC from the heatmap pixel scores, using the given (binary) anomaly segmentation maps as ground-truth pixel labels. We then report the mean over all samples of this “explanation” AUC for a quantitative evaluation. For FCDD, we use a network that is based on a VGG11 network pre-trained on ImageNet, where we freeze the first ten layers, followed by additional fully convolutional layers that we train.
Synthetic Anomalies OE with a natural image dataset like ImageNet is not informative for MVTec-AD since anomalies here are subtle defects of the nominal class, rather than being out of class (see Figure 1). For this reason, we generate synthetic anomalies using a sort of “confetti noise,” a simple noise model that inserts colored blobs into images and reflects the local nature of anomalies. See Figure 7 for an example.
 Figure 7: Confetti noise.
Semi-Supervised FCDD A major advantage of FCDD in comparison to reconstruction-based methods is that it can be readily used in a semi-supervised AD setting (Ruff et al., 2020b). To see the effect of having even only a few labeled anomalies and their corresponding ground-truth anomaly maps available for training, we pick for each MVTec-AD class just one true anomalous sample per defect type at random and add it to the training set. This results in only 3–8 anomalous training samples. To also take advantage of the ground-truth heatmaps, we train a model on a pixel level. Let $X _ { 1 } , \ldots , X _ { n }$ again denote a batch of inputs with corresponding ground-truth heatmaps $Y _ { 1 } , \dots , Y _ { n }$ , each having $m = h \cdot w$ number of pixels. Let $A ( X )$ also again denote the corresponding output anomaly heatmap of $X$ . Then, we can formulate a pixel-wise objective by the following:
$$\operatorname* { m i n } _ { W } \frac { 1 } { n } \sum _ { i = 1 } ^ { n } \left( \frac { 1 } { m } \sum _ { j = 1 } ^ { m } ( 1 - ( Y _ { i } ) _ { j } ) A ^ { \prime } ( X _ { i } ) _ { j } \right) - \log \left( 1 - \exp \left( - \frac { 1 } { m } \sum _ { j = 1 } ^ { m } ( Y _ { i } ) _ { j } A ^ { \prime } ( X _ { i } ) _ { j } \right) \right) .$$
Results Figure 1 in the introduction shows heatmaps of FCDD trained on MVTec-AD. The results of the quantitative explanation are shown in Table 2. We can see that FCDD outperforms its competitors in the unsupervised setting and sets a new state of the art of 0.92 pixel-wise mean AUC. In the semi-supervised setting —using only one anomalous sample with corresponding anomaly map per defect class— the explanation performance improves further to 0.96 pixel-wise mean AUC. FCDD also has the most consistent performance across classes.
Table 2: Pixel-wise mean AUC scores for all classes of the MVTec-AD dataset (Bergmann et al., 2019). For competitors we include the baselines presented in the original MVTec-AD paper and previously published works from peer-reviewed venues that include the MVTec-AD benchmark. The competitors are Self-Similarity and L2 Autoencoder (Bergmann et al., 2019), AnoGAN (Schlegl et al., 2017; Bergmann et al., 2019), CNN Feature Dictionaries (Napoletano et al., 2018; Bergmann et al., 2019), Visually Explained Variational Autoencoder (Liu et al., 2020), Superpixel Masking and Inpainting (Li et al., 2020), Gradient Descent Reconstruction with VAEs (Dehaene et al., 2020), and Encoding Structure-Texture Relation with P-Net for AD (Zhou et al., 2020).
<table><tr><td colspan="10">unsupervised</td><td rowspan="2">semi-supervised FCDD</td></tr><tr><td></td><td>AE-SS*</td><td>AE-L2*</td><td>AnoGAN*</td><td>CNNFD*</td><td>VEVAE*</td><td>SMAI*</td><td>GDR*</td><td>P-NET*</td><td>FCDD</td></tr><tr><td>Bottle</td><td>0.93</td><td>0.86</td><td>0.86</td><td>0.78</td><td>0.87</td><td>0.86</td><td>0.92</td><td>0.99</td><td>0.97</td><td>0.96</td></tr><tr><td>Cable</td><td>0.82</td><td>0.86</td><td>0.78</td><td>0.79</td><td>0.90</td><td>0.92</td><td>0.91</td><td>0.70</td><td>0.90</td><td>0.93</td></tr><tr><td>Capsule</td><td>0.94</td><td>0.88</td><td>0.84</td><td>0.84</td><td>0.74</td><td>0.93</td><td>0.92</td><td>0.84</td><td>0.93</td><td>0.95</td></tr><tr><td>Carpet</td><td>0.87</td><td>0.59</td><td>0.54</td><td>0.72</td><td>0.78</td><td>0.88</td><td>0.74</td><td>0.57</td><td>0.96</td><td>0.99</td></tr><tr><td>Grid</td><td>0.94</td><td>0.90</td><td>0.58</td><td>0.59</td><td>0.73</td><td>0.97</td><td>0.96</td><td>0.98</td><td>0.91</td><td>0.95</td></tr><tr><td>Hazelnut</td><td>0.97</td><td>0.95</td><td>0.87</td><td>0.72</td><td>0.98</td><td>0.97</td><td>0.98</td><td>0.97</td><td>0.95</td><td>0.97</td></tr><tr><td>Leather</td><td>0.78</td><td>0.75</td><td>0.64</td><td>0.87</td><td>0.95</td><td>0.86</td><td>0.93</td><td>0.89</td><td>0.98</td><td>0.99</td></tr><tr><td>Metal Nut</td><td>0.89</td><td>0.86</td><td>0.76</td><td>0.82</td><td>0.94</td><td>0.92</td><td>0.91</td><td>0.79</td><td>0.94</td><td>0.98</td></tr><tr><td>Pill</td><td>0.91</td><td>0.85</td><td>0.87</td><td>0.68</td><td>0.83</td><td>0.92</td><td>0.93</td><td>0.91</td><td>0.81</td><td>0.97</td></tr><tr><td>Screw</td><td>0.96</td><td>0.96</td><td>0.80</td><td>0.87</td><td>0.97</td><td>0.96</td><td>0.95</td><td>1.00</td><td>0.86</td><td>0.93</td></tr><tr><td>Tile</td><td>0.59</td><td>0.51</td><td>0.50</td><td>0.93</td><td>0.80</td><td>0.62</td><td>0.65</td><td>0.97</td><td>0.91</td><td>0.98</td></tr><tr><td>Toothbrush</td><td>0.92</td><td>0.93</td><td>0.90</td><td>0.77</td><td>0.94</td><td>0.96</td><td>0.99</td><td>0.99</td><td>0.94</td><td>0.95</td></tr><tr><td>Transistor</td><td>0.90</td><td>0.86</td><td>0.80</td><td>0.66</td><td>0.93</td><td>0.85</td><td>0.92</td><td>0.82</td><td>0.88</td><td>0.90</td></tr><tr><td>Wood</td><td>0.73</td><td>0.73</td><td>0.62</td><td>0.91</td><td>0.77</td><td>0.80</td><td>0.84</td><td>0.98</td><td>0.88</td><td>0.94</td></tr><tr><td>Zipper</td><td>0.88</td><td>0.77</td><td>0.78</td><td>0.76</td><td>0.78</td><td>0.90</td><td>0.87</td><td>0.90</td><td>0.92</td><td>0.98</td></tr><tr><td>Mean</td><td>0.86</td><td>0.82</td><td>0.74</td><td>0.78</td><td>0.86</td><td>0.89</td><td>0.89</td><td>0.89</td><td>0.92</td><td>0.96</td></tr><tr><td>0</td><td>0.10</td><td>0.13</td><td>0.13</td><td>0.10</td><td>0.09</td><td>0.09</td><td>0.09</td><td>0.12</td><td>0.04</td><td>0.02</td></tr></table>
# 4.3 THE CLEVER HANS EFFECT
Lapuschkin et al. (2016; 2019) revealed that roughly one fifth of all horse images in PASCAL VOC (Everingham et al., 2010) contain a watermark in the lower left corner. They showed that a classifier recognizes this as the relevant class pattern and fails if the watermark is removed. They call this the “Clever Hans” effect in memory of the horse Hans, who could correctly answer math problems by reading its master2. We adapt this experiment to one-class classification by swapping our standard setup and train FCDD so that the “horse” class is anomalous and use ImageNet as nominal samples. We choose this setup so that one would expect FCDD to highlight horses in its heatmaps and so that any other highlighting makes FCDD reveal a Clever Hans effect.
 Figure 8: Heatmaps for horses on PASCAL VOC. Here (a) shows anomalous samples ordered from most nominal to most anomalous from left to right, and (b) shows examples that indicate that the model is a “Clever Hans,” i.e. has learned a characterization based on spurious features (watermarks).
Figure 8 (b) shows that a one-class model is indeed also vulnerable to learning a characterization based on spurious features: the watermarks in the lower left corner which have high scores whereas other regions have low scores. We also observe that the model yields high scores for bars, grids, and fences in Figure 8 (a). This is due to many images in the dataset containing horses jumping over bars or being in fenced areas. In both cases, the horse features themselves do not attain the highest scores because the model has no way of knowing that the spurious features, while providing good discriminative power at training time, would not be desirable upon deployment/test time. In contrast to traditional black-box models, however, transparent detectors like FCDD enable a practitioner to recognize and remedy (e.g. by cleaning or extending the training data) such behavior or other undesirable phenomena (e.g. to avoid unfair social bias).
# 5 CONCLUSION
In conclusion we find that FCDD, in comparison to previous methods, performs well and is adaptable to both semantic detection tasks (Section 4.1) and more subtle defect detection tasks (Section 4.2). Finally, directly tying an explanation to the anomaly score should make FCDD less vulnerable to attacks (Anders et al., 2020) in contrast to a posteriori explanation methods. We leave an analysis of this phenomenon for future work.
# ACKNOWLEDGEMENTS
MK, PL, and BJF acknowledge support by the German Research Foundation (DFG) award KL 2698/2- 1 and by the German Federal Ministry of Science and Education (BMBF) awards 01IS18051A, 031B0770E, and 01MK20014U. LR acknowledges support by the German Federal Ministry of Education and Research (BMBF) in the project ALICE III (01IS18049B). RV acknowledges support by the Berlin Institute for the Foundations of Learning and Data (BIFOLD) sponsored by the German Federal Ministry of Education and Research (BMBF). KRM was supported in part by the Institute of Information & Communications Technology Planning & Evaluation (IITP) grants funded by the Korea Government (No. 2017-0-00451 and 2019-0-00079) and was partly supported by the German Federal Ministry of Education and Research (BMBF) for the Berlin Center for Machine Learning (01IS18037A-I) and under the Grants 01IS14013A-E, 01GQ1115, 01GQ0850, 01IS18025A, and 031L0207A-D; the German Research Foundation (DFG) under Grant Math+, EXC 2046/1, Project ID 390685689. Finally, we thank all reviewers for their constructive feedback, which helped to improve this work.
REFERENCES C. J. Anders, P. Pasliev, A.-K. Dombrowski, K.-R. Muller, and P. Kessel. Fairwashing explanations with ¨ off-manifold detergent. In ICML, pages 6757–6766, 2020. V. Barnett and T. Lewis. Outliers in Statistical Data. Wiley, 3rd edition, 1994. L. Bergman and Y. Hoshen. Classification-based anomaly detection for general data. In ICLR, 2020. P. Bergmann, M. Fauser, D. Sattlegger, and C. Steger. MVTec AD–A comprehensive real-world dataset for unsupervised anomaly detection. In CVPR, pages 9592–9600, 2019. F. Berkenkamp, M. Turchetta, A. Schoellig, and A. Krause. Safe model-based reinforcement learning with stability guarantees. In NeurIPS, pages 908–918, 2017. L. Bottou. Large-scale machine learning with stochastic gradient descent. In Proceedings of COMPSTAT’2010, pages 177–186. Springer, 2010. R. Chalapathy, A. K. Menon, and S. Chawla. Anomaly detection using one-class neural networks. arXiv preprint arXiv:1802.06360, 2018. V. Chandola, A. Banerjee, and V. Kumar. Anomaly detection: A survey. ACM Computing Surveys, 41(3):1–58, 2009. G. Cohen, S. Afshar, J. Tapson, and A. Van Schaik. EMNIST: Extending MNIST to handwritten letters. In IJCNN, pages 2921–2926, 2017. D. Dehaene, O. Frigo, S. Combrexelle, and P. Eline. Iterative energy-based projection on a normal data manifold for anomaly localization. In ICLR, 2020. J. Deng, W. Dong, R. Socher, L.-J. Li, K. Li, and L. Fei-Fei. ImageNet: A large-scale hierarchical image database. In CVPR, pages 248–255, 2009. F. Y. Edgeworth. On discordant observations. The London, Edinburgh, and Dublin Philosophical Magazine and Journal of Science, 23(5):364–375, 1887. M. Everingham, L. Van Gool, C. K. Williams, J. Winn, and A. Zisserman. The pascal visual object classes (VOC) challenge. International Journal of Computer Vision, 88(2):303–338, 2010. I. Golan and R. El-Yaniv. Deep anomaly detection using geometric transformations. In NeurIPS, pages 9758–9769, 2018. S. Goyal, A. Raghunathan, M. Jain, H. V. Simhadri, and P. Jain. DROCC: Deep robust one-class classification. In ICML, pages 11335–11345, 2020. A. Gupta, J. Johnson, L. Fei-Fei, S. Savarese, and A. Alahi. Social GAN: Socially acceptable trajectories with generative adversarial networks. In CVPR, pages 2255–2264, 2018. S. Hawkins, H. He, G. Williams, and R. Baxter. Outlier Detection Using Replicator Neural Networks. In DaWaK, volume 2454, pages 170–180, 2002. D. Hendrycks, M. Mazeika, and T. G. Dietterich. Deep anomaly detection with outlier exposure. In ICLR, 2019a. D. Hendrycks, M. Mazeika, S. Kadavath, and D. Song. Using self-supervised learning can improve model robustness and uncertainty. In NeurIPS, pages 15637–15648, 2019b. P. J. Huber et al. Robust estimation of a location parameter. The Annals of Mathematical Statistics, 35(1): 73–101, 1964. M. H. Jarrahi. Artificial intelligence and the future of work: Human-AI symbiosis in organizational decision making. Business Horizons, 61(4):577–586, 2018. G. Katz, C. Barrett, D. L. Dill, K. Julian, and M. J. Kochenderfer. Reluplex: An efficient SMT solver for verifying deep neural networks. In International Conference on Computer Aided Verification, pages 97–117. Springer, 2017. J. Kauffmann, K.-R. Muller, and G. Montavon. Towards Explaining Anomalies: A Deep Taylor Decomposition ¨ of One-Class Models. Pattern Recognition, 101:107198, 2020. D. P. Kingma and J. Ba. Adam: A method for stochastic optimization. In ICLR, 2015. A. Krizhevsky, G. Hinton, et al. Learning multiple layers of features from tiny images. Technical report, 2009. S. Lapuschkin, A. Binder, G. Montavon, K.-R. Muller, and W. Samek. Analyzing classifiers: Fisher vectors and deep neural networks. In CVPR, pages 2912–2920, 2016. S. Lapuschkin, S. Waldchen, A. Binder, G. Montavon, W. Samek, and K.-R. M ¨ uller. Unmasking clever hans ¨ predictors and assessing what machines really learn. Nature Communications, 10:1096, 2019. Y. LeCun, L. Bottou, Y. Bengio, and P. Haffner. Gradient-based learning applied to document recognition. Proceedings of the IEEE, 86(11):2278–2324, 1998. Z. Li, N. Li, K. Jiang, Z. Ma, X. Wei, X. Hong, and Y. Gong. Superpixel masking and inpainting for selfsupervised anomaly detection. In BMVC, 2020. W. Liu, R. Li, M. Zheng, S. Karanam, Z. Wu, B. Bhanu, R. J. Radke, and O. Camps. Towards visually explaining variational autoencoders. In CVPR, pages 8642–8651, 2020. J. Long, E. Shelhamer, and T. Darrell. Fully convolutional networks for semantic segmentation. In CVPR, pages 3431–3440, 2015. W. Luo, Y. Li, R. Urtasun, and R. Zemel. Understanding the effective receptive field in deep convolutional neural networks. In NeurIPS, pages 4898–4906, 2016. G. Montavon, S. Lapuschkin, A. Binder, W. Samek, and K.-R. Muller. Explaining nonlinear classification ¨ decisions with deep Taylor decomposition. Pattern Recognition, 65:211–222, 2017. G. Montavon, W. Samek, and K.-R. Muller. Methods for interpreting and understanding deep neural networks. ¨ Digital Signal Processing, 73:1–15, 2018. M. M. Moya, M. W. Koch, and L. D. Hostetler. One-class classifier networks for target recognition applications. In World Congress on Neural Networks, pages 797–801, 1993. P. Napoletano, F. Piccoli, and R. Schettini. Anomaly detection in nanofibrous materials by CNN-based selfsimilarity. Sensors, 18(1):209, 2018. H. Noh, S. Hong, and B. Han. Learning deconvolution network for semantic segmentation. In ICCV, pages 1520–1528, 2015. G. Quellec, M. Lamard, M. Cozic, G. Coatrieux, and G. Cazuguel. Multiple-instance learning for anomaly detection in digital mammography. IEEE Transactions on Medical Imaging, 35(7):1604–1614, 2016. M. T. Ribeiro, S. Singh, and C. Guestrin. “Why should i trust you?” Explaining the predictions of any classifier. In KDD, pages 1135–1144, 2016. M. T. Ribeiro, S. Singh, and C. Guestrin. Anchors: High-precision model-agnostic explanations. In AAAI, volume 18, pages 1527–1535, 2018. L. Ruff, R. A. Vandermeulen, N. Gornitz, L. Deecke, S. A. Siddiqui, A. Binder, E. M ¨ uller, and M. Kloft. Deep ¨ one-class classification. In ICML, volume 80, pages 4390–4399, 2018. L. Ruff, Y. Zemlyanskiy, R. Vandermeulen, T. Schnake, and M. Kloft. Self-attentive, multi-context one-class classification for unsupervised anomaly detection on text. In ACL, pages 4061–4071, 2019. L. Ruff, R. A. Vandermeulen, B. J. Franks, K.-R. Muller, and M. Kloft. Rethinking assumptions in deep anomaly ¨ detection. arXiv preprint arXiv:2006.00339, 2020a. L. Ruff, R. A. Vandermeulen, N. Gornitz, A. Binder, E. M ¨ uller, K.-R. M ¨ uller, and M. Kloft. Deep semi-supervised ¨ anomaly detection. In ICLR, 2020b. L. Ruff, J. R. Kauffmann, R. A. Vandermeulen, G. Montavon, W. Samek, M. Kloft, T. G. Dietterich, and K.-R. Muller. A unifying review of deep and shallow anomaly detection. ¨ Proceedings of the IEEE, 2021. doi: 10.1109/JPROC.2021.3052449. M. Sabokrou, M. Fayyaz, M. Fathy, Z. Moayed, and R. Klette. Deep-anomaly: Fully convolutional neural network for fast anomaly detection in crowded scenes. Computer Vision and Image Understanding, 172: 88–97, 2018.
M. Sakurada and T. Yairi. Anomaly detection using autoencoders with nonlinear dimensionality reduction. In Proceedings of the MLSDA 2014 2nd Workshop on Machine Learning for Sensory Data Analysis, pages 4–11, 2014.
W. Samek, G. Montavon, S. Lapuschkin, C. J. Anders, and K.-R. Muller. Toward interpretable machine learning: ¨ Transparent deep neural networks and beyond. arXiv preprint arXiv:2003.07631, 2020.
T. Schlegl, P. Seebock, S. M. Waldstein, U. Schmidt-Erfurth, and G. Langs. Unsupervised anomaly detection ¨ with generative adversarial networks to guide marker discovery. In International conference on information processing in medical imaging, pages 146–157. Springer, 2017.
K. Simonyan and A. Zisserman. Very deep convolutional networks for large-scale image recognition. In ICLR, 2015.
K. Simonyan, A. Vedaldi, and A. Zisserman. Deep inside convolutional networks: Visualising image classification models and saliency maps. arXiv preprint arXiv:1312.6034, 2013.
K. A. Spackman. Signal detection theory: Valuable tools for evaluating inductive learning. In Proceedings of the Sixth International Workshop on Machine Learning, pages 160–163, 1989.
M. Sundararajan, A. Taly, and Q. Yan. Axiomatic attribution for deep networks. In ICML, pages 3319–3328, 2017.
I. Sutskever, J. Martens, G. Dahl, and G. Hinton. On the importance of initialization and momentum in deep learning. In ICML, pages 1139–1147, 2013.
D. M. J. Tax. One-class classification. PhD thesis, Delft University of Technology, 2001.
D. M. J. Tax and R. P. W. Duin. Support Vector Data Description. Machine Learning, 54(1):45–66, 2004.
A. Torralba, R. Fergus, and W. T. Freeman. 80 million tiny images: A large data set for nonparametric object and scene recognition. IEEE Transactions on Pattern Analysis and Machine Intelligence, 30(11):1958–1970, 2008.
S. Venkataramanan, K.-C. Peng, R. V. Singh, and A. Mahalanobis. Attention guided anomaly detection and localization in images. arXiv preprint arXiv:1911.08616, 2019.
H. Xiao, K. Rasul, and R. Vollgraf. Fashion-MNIST: A novel image dataset for benchmarking machine learning algorithms. arXiv preprint arXiv:1708.07747, 2017.
Y. Zhao, B. Deng, C. Shen, Y. Liu, H. Lu, and X.-S. Hua. Spatio-temporal autoencoder for video anomaly detection. In Proceedings of the 25th ACM International Conference on Multimedia, pages 1933–1941, 2017.
C. Zhou and R. C. Paffenroth. Anomaly detection with robust deep autoencoders. In KDD, pages 665–674, 2017.
K. Zhou, Y. Xiao, J. Yang, J. Cheng, W. Liu, W. Luo, Z. Gu, J. Liu, and S. Gao. Encoding structure-texture relation with p-net for anomaly detection in retinal images. In ECCV, 2020.
# A RECEPTIVE FIELD SENSITIVITY ANALYSIS
The receptive field has an impact on both detection performance and explanation quality. Here we provide some heatmaps and AUC scores for networks with different receptive field sizes. We observe that the detection performance is only minimally affected, but larger receptive fields cause the explanation heatmap to become less concentrated and more “blobby.” For MVTec-AD we see that this can also negatively affect pixel-wise AUC scores, see Table 4.
CIFAR-10 For CIFAR-10 we create eight different network architectures to study the impact of the receptive field size. Each architecture has four convolutional layers and two max-pool layers. To change the receptive field we vary the kernel size of the first convolutional layer between 3 and 17. When this kernel size is 3 then the receptive field contains approximately one quarter of the image; for a kernel size of 17 the receptive field is the entire image. Table 3 shows the detection performance of the networks. Figure 9 contains example heatmaps.
Table 3: Mean AUC (over all classes and 5 seeds per class) for CIFAR-10 and neural networks with varying receptive field size.
<table><tr><td>Receptive field size</td><td>18</td><td>20</td><td>22</td><td>24</td><td>26</td><td>28</td><td>30</td><td>32</td></tr><tr><td>AUC</td><td>0.9328</td><td>0.9349</td><td>0.9344</td><td>0.9320</td><td>0.9303</td><td>0.9283</td><td>0.9257</td><td>0.9235</td></tr></table>
 Figure 9: Anomaly heatmaps for three anomalous test samples on CIFAR-10 models trained on nominal class “airplane.” We grow the receptive field size from 18 (left) to 32 (right).
 Figure 10: Anomaly heatmaps for seven anomalous test samples of MVTec-AD. We grow the receptive field size from 53 (left) to 243 (right).
Table 4: Pixel-wise mean AUC (over all classes and 5 seeds per class) for MVTec-AD and neural networks with varying receptive field size.
<table><tr><td>Receptive field size</td><td>53</td><td>91</td><td>129</td><td>167</td><td>205</td><td>243</td></tr><tr><td>AUC</td><td>0.88</td><td>0.85</td><td>0.79</td><td>0.76</td><td>0.75</td><td>0.75</td></tr></table>
MVTec-AD We create six different network architectures for MVTec-AD. They have six convolutional layers and three max-pool layers. We vary the kernel size for all of the convolutional layers between 3 and 13, which corresponds to a receptive field containing $1 / 1 6$ of the image to the full image respectively. Table 4 shows the explanation performance of the networks in terms of pixel-wise mean AUC. Figure 10 contains some example heatmaps. We observe that a smaller receptive field yields better explanation performance.
# B IMPACT OF THE GAUSSIAN VARIANCE
Using the proposed heatmap upsampling in Section 3 FCDD provides full-resolution anomaly heatmaps. However, this upsampling involves the choice of $\sigma$ for the Gaussian kernel. In this section, we demonstrate the effect of this hyperparameter on the explanation performance of FCDD on MVTec-AD. Table 5 shows the pixel-wise mean AUC, Figure 11 corresponding heatmaps.
 Figure 11: Anomaly heatmaps for seven anomalous test samples of MVTec-AD. We grow $\sigma$ from 4 (left) to 16 (right).
Table 5: Pixel-wise mean AUC (over all classes and 5 seeds per class) for MVTec-AD and different $\sigma$ .
<table><tr><td>0</td><td>4</td><td>6</td><td>8</td><td>10</td><td>12</td><td>14</td><td>16</td></tr><tr><td>AUC</td><td>0.8567</td><td>0.8836</td><td>0.9030</td><td>0.9124</td><td>0.9164</td><td>0.9217</td><td>0.9208</td></tr></table>
# C ANOMALY HEATMAP VISUALIZATION
For anomaly heatmap visualization, the FCDD anomaly scores $A ^ { \prime } ( X )$ need to be rescaled to values in $[ 0 , 1 ]$ . Instead of applying standard min-max scaling that would divide all heatmap entries by max $A ^ { \prime } ( X )$ , we use anomaly score quantiles to adjust the contrast in the heatmaps. For a collection of inputs ${ \mathcal { X } } = \{ X _ { 1 } , \ldots , X _ { n } \}$ with corresponding full-resolution anomaly heatmaps $\mathcal { A } = \{ A ^ { \prime } ( X _ { 1 } ) , \ldots , A ^ { \prime } ( X _ { n } ) \}$ , the normalized heatmap $I ( X )$ for some $A ^ { \prime } ( X )$ is computed as
$$I ( X ) _ { j } = \operatorname* { m i n } \left\{ \frac { A ^ { \prime } ( X ) _ { j } - \operatorname* { m i n } ( A ) } { q _ { \eta } ( \{ A ^ { \prime } - \operatorname* { m i n } ( A ) \mid A ^ { \prime } \in \mathcal { A } \} ) } , 1 \right\} ,$$
where $j$ denotes the $j$ -th pixel and $q _ { \eta }$ the $\eta$ -th percentile over all pixels and examples in $\mathcal { A }$ . The subtraction and min operation are applied on a pixel level, i.e. the minimum is extracted over all pixels and all samples of $\mathcal { A }$ and subtraction is then applied elementwise. Using the $\eta$ -th percentile might leave some of the values above 1, which is why we finally clamp the pixels at 1.
The specific choice of $\eta$ and set of samples $\mathcal { X }$ differs per figure. We select them to highlight different properties of the heatmaps. In general, the lower $\eta$ the more red (anomalous) regions we have in the heatmaps because more values are left above one (before clamping to 1) and vice versa. The choice of $\mathcal { X }$ ranges from just one sample $X$ , such that $A ^ { \prime } ( X )$ is normalized only w.r.t. to its own scores (highlighting the most anomalous regions within the image), to the complete dataset (highlighting which regions look anomalous compared to the whole dataset). For the latter visualization we rebalance the dataset so that $\mathcal { X }$ contains an equal amount of nominal and anomalous images to maintain consistent scaling. The choice of $\eta$ and $\mathcal { X }$ is consistent per figure. In the following we list the choices made for the individual figures.
MVTec-AD Figures 1, 10, and 11 use $\eta = 0 . 9 7$ and set $\mathcal { X }$ to $X$ for each heatmap $I ( X )$ to show relative anomalies. So each image is normalized with respect to itself only.
Fashion-MNIST Figure 4 uses $\eta = 0 . 8 5$ and sets $\mathcal { X }$ to the complete balanced test set.
CIFAR-10 Figures 6 and 9 use $\eta = 0 . 8 5$ and set $\mathcal { X }$ to $X$ for each heatmap $I ( X )$ to show relative anomalies. So each image is normalized with respect to itself only.
ImageNet Figure 5 uses $\eta = 0 . 9 7$ and sets $\mathcal { X }$ to the complete balanced test set.
Pascal VOC Figure 8 uses $\eta = 0 . 9 9$ and sets $\mathcal { X }$ to the complete balanced test set.
Heatmap Upsampling For the Gaussian kernel heatmap upsampling described in Algorithm 1, we set $\sigma$ to 1.2 for CIFAR-10 and Fashion-MNIST, to 8 for ImageNet and Pascal VOC, and to 12 for MVTec-AD.
# D DETAILS ON THE NETWORK ARCHITECTURES
Here we provide the complete FCDD network architectures we used on the different datasets.
# Fashion-MNIST
<table><tr><td>Layer (type) Output Shape Param #</td></tr><tr><td>Conv2d-1 [-1, 128, 28, 28] 3,328</td></tr><tr><td>BatchNorm2d-2 [-1, 128, 28, 28] 256</td></tr><tr><td>LeakyReLU-3 [-1, 128, 28, 28] 0</td></tr><tr><td>MaxPool2d-4 [-1, 128, 14, 14] 0</td></tr><tr><td>Conv2d-5 [-1, 128, 14, 14] 409,728</td></tr><tr><td>MaxPool2d-6 [-1,128, 7, 71 0</td></tr><tr><td>Conv2d-7 [-1,1, 7, 71 129</td></tr></table>
Total params: 413,441 Trainable params: 413,441 Non-trainable params: 0 Receptive field (pixels): 16 x 16
CIFAR-10
<table><tr><td>Layer (type) Output Shape Param #</td></tr><tr><td>Conv2d-1 32, 32] 3,584</td></tr><tr><td>[-1, 128, BatchNorm2d-2 [-1, 128, 32, 32] 256</td></tr><tr><td>LeakyReLU-3 [-1, 128, 32, 32] 0</td></tr><tr><td>MaxPool2d-4 [-1, 128, 16, 16] 0</td></tr><tr><td>Conv2d-5 [-1, 256, 16, 16] 295,168</td></tr><tr><td>BatchNorm2d-6 [-1, 256, 16, 16] 512</td></tr><tr><td>LeakyReLU-7 [-1, 256, 16, 16] 0</td></tr><tr><td>Conv2d-8 [-1, 256, 16, 16] 590,080</td></tr><tr><td>BatchNorm2d-9 [-1, 256, 16, 16] 512</td></tr><tr><td>LeakyReLU-10 [-1, 256, 16, 16] 0</td></tr><tr><td>MaxPool2d-11 [-1, 256, 8, 8] 0</td></tr><tr><td>Conv2d-12 [-1,128, 8, 8] 295,040</td></tr><tr><td>Conv2d-13 [-1,1, 8, 8] 129</td></tr></table>
Total params: 1,185,281 Trainable params: 1,185,281 Non-trainable params: 0 Receptive field (pixels): 22 x 22
# ImageNet, MVTec-AD, and Pascal VOC
<table><tr><td rowspan=1 colspan=7>Layer(type) OutputShape Param #</td></tr><tr><td rowspan=1 colspan=7>Conv2d-1 [-1,64,224,224] 1,792</td></tr><tr><td rowspan=1 colspan=7>BatchNorm2d-2 [-1,64,224,224] 128</td></tr><tr><td rowspan=1 colspan=7>ReLU-3 [-1,64,224,224] 0</td></tr><tr><td rowspan=1 colspan=1>MaxPool2d-4</td><td rowspan=1 colspan=6>[-1,64,112,112] 0</td></tr><tr><td rowspan=1 colspan=1>Conv2d-5</td><td rowspan=1 colspan=5>[-1,128,112,112]</td><td rowspan=1 colspan=1>73,856</td></tr><tr><td rowspan=1 colspan=1>BatchNorm2d-6</td><td rowspan=1 colspan=4>[-1,128,112,</td><td rowspan=1 colspan=1>112]</td><td rowspan=1 colspan=1>256</td></tr><tr><td rowspan=1 colspan=1>ReLU-7</td><td rowspan=1 colspan=4>[-1,128,112,</td><td rowspan=1 colspan=1>112]</td><td rowspan=1 colspan=1>0</td></tr><tr><td rowspan=1 colspan=1>MaxPool2d-8</td><td rowspan=1 colspan=4>[-1,128,56,</td><td rowspan=1 colspan=1>56]</td><td rowspan=1 colspan=1>0</td></tr><tr><td rowspan=1 colspan=1>Conv2d-9</td><td rowspan=1 colspan=4>[-1,256,56,</td><td rowspan=1 colspan=1>56]</td><td rowspan=1 colspan=1>295,168</td></tr><tr><td rowspan=1 colspan=1>BatchNorm2d-10</td><td rowspan=1 colspan=4>[-1,256,56,</td><td rowspan=1 colspan=1>56]</td><td rowspan=1 colspan=1>512</td></tr><tr><td rowspan=1 colspan=1>ReLU-11</td><td rowspan=1 colspan=4>[-1,256,56,</td><td rowspan=1 colspan=1>56]</td><td rowspan=1 colspan=1>0</td></tr><tr><td rowspan=1 colspan=1>Conv2d-12</td><td rowspan=1 colspan=4>[-1,256,56,</td><td rowspan=1 colspan=1>56]</td><td rowspan=1 colspan=1>590,080</td></tr><tr><td rowspan=1 colspan=1>BatchNorm2d-13</td><td rowspan=1 colspan=4>[-1,256,56,</td><td rowspan=1 colspan=1>56]</td><td rowspan=1 colspan=1>512</td></tr><tr><td rowspan=2 colspan=1>ReLU-14MaxPool2d-15</td><td rowspan=1 colspan=4>[-1,256,56,</td><td rowspan=1 colspan=1>56]</td><td rowspan=1 colspan=1>0</td></tr><tr><td rowspan=1 colspan=1></td><td rowspan=1 colspan=2>[-1,256,</td><td rowspan=1 colspan=1>28,</td><td rowspan=1 colspan=1>28]</td><td rowspan=1 colspan=1>0</td></tr><tr><td rowspan=7 colspan=1>Conv2d-16BatchNorm2d-17ReLU-18Conv2d-19BatchNorm2d-20ReLU-21Conv2d-22</td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=2>[-1,512,</td><td rowspan=1 colspan=1>28,</td><td rowspan=1 colspan=1>28]</td><td rowspan=1 colspan=1>1,180,160</td></tr><tr><td rowspan=1 colspan=1></td><td rowspan=1 colspan=2>[-1,512,</td><td rowspan=1 colspan=1>28,</td><td rowspan=1 colspan=1>28]</td><td rowspan=1 colspan=1>1,024</td></tr><tr><td rowspan=1 colspan=1></td><td rowspan=1 colspan=2>[-1,512,</td><td rowspan=1 colspan=1>28,</td><td rowspan=1 colspan=1>28]</td><td rowspan=1 colspan=1>0</td></tr><tr><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>[-1,</td><td rowspan=1 colspan=1>512,</td><td rowspan=1 colspan=2>28,28]</td><td rowspan=1 colspan=1>2,359,808</td></tr><tr><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>[-1,</td><td rowspan=1 colspan=1>512,</td><td rowspan=1 colspan=2>28,28]</td><td rowspan=1 colspan=1>1,024</td></tr><tr><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>[-1,</td><td rowspan=1 colspan=1>512,</td><td rowspan=1 colspan=2>28,28]</td><td rowspan=1 colspan=1>0</td></tr><tr><td rowspan=1 colspan=1></td><td rowspan=1 colspan=2>[-1,</td><td rowspan=1 colspan=2>1,28,28]</td><td rowspan=1 colspan=1>513</td></tr></table>
Total params: 4,504,833 Trainable params: 4,504,833 Non-trainable params: 0 Receptive field (pixels): 62 x 62
# E TRAINING AND OPTIMIZATION
Here we provide the training and optimization details for the individual experiments from Section 4.
We apply common pre-processing (e.g. data normalization) and data augmentation steps in our data loading pipeline. To sample auxiliary anomalies in an online manner during training, each nominal sample of a batch has a $50 \%$ chance of being replaced by a randomly picked auxiliary anomaly. This leads to balanced training batches for sufficiently large batch sizes. One epoch in our implementation still refers to the original nominal data training set size, so that approximately $50 \%$ of the nominal samples have been seen per training epoch. Below, we list further details for the specific datasets.
Fashion-MNIST We train for 400 epochs using a batch size of 128 samples. We optimize the network parameters using SGD (Bottou, 2010) with Nesterov momentum $\mathbf { \chi } _ { \mathcal { \mu } } = 0 . 9$ ) (Sutskever et al., 2013), weight decay of $1 0 ^ { - 6 }$ and an initial learning rate of 0.01, which decreases the previous learning rate per epoch by a factor of 0.98. The pre-processing pipeline is: (1) Random crop to size 28 with beforehand zero-padding of 2 pixels on all sides (2) random horizontal flipping with a chance of $50 \%$ (3) data normalization.
CIFAR-10 We train for 600 epochs using a batch size of 200 samples. We optimize the network using Adam (Kingma and Ba, 2015) $( \beta = ( 0 . 9 , 0 . 9 9 9 ) )$ with weight decay $\mathrm { \dot { 1 } 0 ^ { - 6 } }$ and an initial learning rate of 0.001 which is decreased by a factor of 10 at epoch 400 and 500. The pre-processing pipeline is: (1) Random color jitter with all parameters3 set to 0.01 (2) random crop to size 32 with beforehand zero-padding of 4 pixels on all sides (3) random horizontal flipping with a chance of $50 \%$ (4) additive Gaussian noise with $\sigma = 0 . 0 0 1$ (5) data normalization.
ImageNet We use the same setup as in CIFAR-10, but resize all images to size $2 5 6 \times 2 5 6$ before forwarding them through the pipeline and change the random crop to size 224 with no padding. Test samples are center cropped to a size of 224 before being normalized.
Pascal VOC We use the same setup as in CIFAR-10, but resize all images to size $2 2 4 \times 2 2 4$ before forwarding them through the pipeline and remove the Random Crop step.
MVTec-AD For MVTec-AD we redefine an epoch to be ten times an iteration of the full dataset because this improves the computational performance of the data pipeline. We train for 200 epochs using SGD with Nesterov momentum $\langle \mu = 0 . 9 \rangle$ ), weight decay $1 0 ^ { - \bar { 4 } }$ , and an initial learning rate of 0.001, which decreases per epoch by a factor of 0.985. The pre-processing pipeline is: (1) Resize to $2 4 0 \times 2 4 0$ pixels (2) random crop to size 224 with no padding (3) random color jitter with either all parameters set to 0.04 or 0.0005, randomly chosen (4) $50 \%$ chance to apply additive Gaussian noise (5) data normalization.
# F QUANTITATIVE DETECTION RESULTS FOR INDIVIDUAL CLASSES
Table 6 shows the class-wise results on Fashion-MNIST for AE, Deep Support Vector Data Description (DSVDD) (Ruff et al., 2018; Bergman and Hoshen, 2020) and Geometric Transformation based AD (GEO) (Golan and El-Yaniv, 2018).
Table 6: AUC scores for all classes of Fashion-MNIST (Xiao et al., 2017).
<table><tr><td></td><td colspan="3">without OE</td><td>with OE</td></tr><tr><td></td><td>AE</td><td>DSVDD*</td><td>Geo*</td><td>FCDD</td></tr><tr><td>T-Shirt/Top</td><td>0.85</td><td>0.98</td><td>0.99</td><td>0.82</td></tr><tr><td>Trouser</td><td>0.91</td><td>0.90</td><td>0.98</td><td>0.98</td></tr><tr><td>Pullover</td><td>0.78</td><td>0.91</td><td>0.91</td><td>0.84</td></tr><tr><td>Dress</td><td>0.88</td><td>0.94</td><td>0.90</td><td>0.92</td></tr><tr><td>Coat</td><td>0.88</td><td>0.89</td><td>0.92</td><td>0.87</td></tr><tr><td>Sandal</td><td>0.45</td><td>0.92</td><td>0.93</td><td>0.90</td></tr><tr><td>Shirt</td><td>0.70</td><td>0.83</td><td>0.83</td><td>0.75</td></tr><tr><td>Sneaker</td><td>0.96</td><td>0.99</td><td>0.99</td><td>0.99</td></tr><tr><td>Bag</td><td>0.87</td><td>0.92</td><td>0.91</td><td>0.86</td></tr><tr><td>Ankle Boot</td><td>0.96</td><td>0.99</td><td>0.99</td><td>0.94</td></tr><tr><td>Mean</td><td>0.82</td><td>0.93</td><td>0.94</td><td>0.89</td></tr></table>
In Table 7 the class-wise results for CIFAR-10 are reported. Competitors without OE are AE (Ruff et al., 2018), DSVDD (Ruff et al., 2018), GEO (Golan and El-Yaniv, 2018) and an adaptation of GEO $\mathrm { ( G E O + ) }$ (Hendrycks et al., 2019b). Competitors with OE are the focal loss classifier (Hendrycks et al., 2019b), again $\mathrm { G E O + }$ (Hendrycks et al., 2019b), Deep Semi-supervised Anomaly Detection (Deep SAD) (Ruff et al., 2020b;a) and the hypersphere Classifier (Ruff et al., 2020a).
In Table 8 the class-wise results for Imagenet are shown, where competitors are the AE, the focal loss classifier (Hendrycks et al., 2019b), Geo $^ +$ (Hendrycks et al., 2019b), Deep SAD (Ruff et al., 2020b) and HSC (Ruff et al., 2020a). Results from the literature are marked with an asterisk.
Table 7: AUC scores for all classes of CIFAR-10 (Krizhevsky et al., 2009).
<table><tr><td></td><td colspan="4">without OE</td><td colspan="5">with OE</td></tr><tr><td></td><td>AE*</td><td>DSVDD*</td><td>GEO*</td><td>Geo+*</td><td>Focal*</td><td>Geo+*</td><td>Deep SAD*</td><td>HSC*</td><td>FCDD</td></tr><tr><td>Airplane</td><td>0.59</td><td>0.62</td><td>0.75</td><td>0.78</td><td>0.88</td><td>0.90</td><td>0.94</td><td>0.97</td><td>0.95</td></tr><tr><td>Automobile</td><td>0.57</td><td>0.66</td><td>0.96</td><td>0.97</td><td>0.94</td><td>0.99</td><td>0.98</td><td>0.99</td><td>0.96</td></tr><tr><td>Bird</td><td>0.49</td><td>0.51</td><td>0.78</td><td>0.87</td><td>0.79</td><td>0.94</td><td>0.90</td><td>0.93</td><td>0.91</td></tr><tr><td>Cat</td><td>0.58</td><td>0.59</td><td>0.72</td><td>0.81</td><td>0.80</td><td>0.88</td><td>0.87</td><td>0.90</td><td>0.90</td></tr><tr><td>Deer</td><td>0.54</td><td>0.61</td><td>0.88</td><td>0.93</td><td>0.82</td><td>0.97</td><td>0.95</td><td>0.97</td><td>0.94</td></tr><tr><td>Dog</td><td>0.62</td><td>0.66</td><td>0.88</td><td>0.90</td><td>0.86</td><td>0.94</td><td>0.93</td><td>0.94</td><td>0.93</td></tr><tr><td>Frog</td><td>0.51</td><td>0.68</td><td>0.83</td><td>0.91</td><td>0.93</td><td>0.97</td><td>0.97</td><td>0.98</td><td>0.97</td></tr><tr><td>Horse</td><td>0.59</td><td>0.67</td><td>0.96</td><td>0.97</td><td>0.88</td><td>0.99</td><td>0.97</td><td>0.98</td><td>0.96</td></tr><tr><td>Ship</td><td>0.77</td><td>0.76</td><td>0.93</td><td>0.95</td><td>0.93</td><td>0.99</td><td>0.97</td><td>0.98</td><td>0.97</td></tr><tr><td>Truck</td><td>0.67</td><td>0.73</td><td>0.91</td><td>0.93</td><td>0.92</td><td>0.99</td><td>0.96</td><td>0.97</td><td>0.96</td></tr><tr><td>Mean</td><td>0.59</td><td>0.65</td><td>0.86</td><td>0.90</td><td>0.87</td><td>0.96</td><td>0.95</td><td>0.96</td><td>0.95</td></tr></table>
Table 8: AUC scores for 30 classes of ImageNet (Deng et al., 2009).
<table><tr><td rowspan="2"></td><td rowspan="2">without OE AE</td><td colspan="5">with OE</td></tr><tr><td>Focal*</td><td>Geo+*</td><td>Deep SAD*</td><td>HSC*</td><td>FCDD</td></tr><tr><td>Acorn</td><td>0.45</td><td>×</td><td>×</td><td>0.99</td><td>0.99</td><td>0.97</td></tr><tr><td>Airliner</td><td>0.80</td><td>×</td><td>×</td><td>0.97</td><td>1.00</td><td>0.98</td></tr><tr><td>Ambulance</td><td>0.25</td><td>×</td><td>×</td><td>0.99</td><td>1.00</td><td>0.99</td></tr><tr><td>American alligator</td><td>0.61</td><td>×</td><td>×</td><td>0.93</td><td>0.98</td><td>0.97</td></tr><tr><td>Banjo</td><td>0.45</td><td>×</td><td>×</td><td>0.97</td><td>0.98</td><td>0.91</td></tr><tr><td>Barn</td><td>0.59</td><td>×</td><td>×</td><td>0.99</td><td>1.00</td><td>0.97</td></tr><tr><td>Bikini</td><td>0.46</td><td>×</td><td>×</td><td>0.97</td><td>0.99</td><td>0.94</td></tr><tr><td>Digital clock</td><td>0.63</td><td>×</td><td>×</td><td>0.99</td><td>0.97</td><td>0.92</td></tr><tr><td>Dragonfly</td><td>0.62</td><td>×</td><td>×</td><td>0.99</td><td>0.98</td><td>0.98</td></tr><tr><td>Dumbbell</td><td>0.42</td><td>×</td><td>×</td><td>0.93</td><td>0.92</td><td>0.88</td></tr><tr><td>Forklift</td><td>0.28</td><td>×</td><td>×</td><td>0.91</td><td>0.99</td><td>0.94</td></tr><tr><td>Goblet</td><td>0.63</td><td>×</td><td>×</td><td>0.92</td><td>0.94</td><td>0.90</td></tr><tr><td>Grand piano</td><td>0.45</td><td>×</td><td>×</td><td>1.00</td><td>0.97</td><td>0.95</td></tr><tr><td>Hotdog</td><td>0.48</td><td>×</td><td>×</td><td>0.96</td><td>0.99</td><td>0.97</td></tr><tr><td>Hourglass</td><td>0.58</td><td>×</td><td>×</td><td>0.96</td><td>0.97</td><td>0.92</td></tr><tr><td>Manhole cover</td><td>0.70</td><td>×</td><td>×</td><td>0.99</td><td>1.00</td><td>1.00</td></tr><tr><td>Mosque</td><td>0.72</td><td>×</td><td>×</td><td>0.99</td><td>0.99</td><td>0.97</td></tr><tr><td>Nail</td><td>0.57</td><td>×</td><td>×</td><td>0.93</td><td>0.94</td><td>0.92</td></tr><tr><td>Parking meter</td><td>0.45</td><td>×</td><td>×</td><td>0.99</td><td>0.93</td><td>0.87</td></tr><tr><td>Pillow</td><td>0.40</td><td>×</td><td>×</td><td>0.99</td><td>0.94</td><td>0.94</td></tr><tr><td>Revolver</td><td>0.60</td><td>×</td><td>×</td><td>0.98</td><td>0.98</td><td>0.93</td></tr><tr><td>Rotary dial telephone</td><td>0.58</td><td>×</td><td>×</td><td>0.90</td><td>0.98</td><td>0.91</td></tr><tr><td>Schooner</td><td>0.65</td><td>×</td><td>×</td><td>0.99</td><td>0.99</td><td>0.96</td></tr><tr><td>Snowmobile</td><td>0.54</td><td>×</td><td>×</td><td>0.98</td><td>0.99</td><td>0.97</td></tr><tr><td>Soccer ball</td><td>0.46</td><td>×</td><td>×</td><td>0.97</td><td>0.93</td><td>0.86</td></tr><tr><td>Stingray</td><td>0.84</td><td>×</td><td>×</td><td>0.99</td><td>0.99</td><td>0.97</td></tr><tr><td>Strawberry</td><td>0.44</td><td>×</td><td>×</td><td>0.98</td><td>0.99</td><td>0.97</td></tr><tr><td>Tank</td><td>0.57</td><td>×</td><td>×</td><td>0.97</td><td>0.99</td><td>0.96</td></tr><tr><td>Toaster</td><td>0.59</td><td>×</td><td>×</td><td>0.98</td><td>0.92</td><td>0.79</td></tr><tr><td>Volcano</td><td>0.90</td><td>×</td><td>×</td><td>0.90</td><td>1.00</td><td>0.97</td></tr><tr><td>Mean</td><td>0.56</td><td>0.56</td><td>0.86</td><td>0.97</td><td>0.97</td><td>0.94</td></tr></table>
# G FURTHER QUALITATIVE ANOMALY HEATMAP RESULTS
In this section we report some further anomaly heatmaps, unblurred baseline heatmaps, as well as class-wise heatmaps for all datasets.
Unblurred Anomaly Heatmap Baselines Here we show unblurred baseline heatmaps for the figures in Section 4.1. Figures 12, 13, and 14 show the unblurred heatmaps for Fashion-MNIST, ImageNet, and CIFAR-10 respectively.
 Figure 12: Anomaly heatmaps for anomalous test samples of a Fashion-MNIST model trained on nominal class “trousers.” In (a) CIFAR-100 was used for OE and in (b) EMNIST.
 Figure 13: Anomaly heatmaps of an ImageNet model trained on nominal class “acorns.” (a) are nominal and (b) anomalous samples.
 Figure 14: Anomaly heatmaps for three anomalous test samples (Input left) on a CIFAR-10 model trained on nominal class “airplane.” The second, third, and fourth blocks show the heatmaps of FCDD (Ours), gradient-based heatmaps of HSC, and AE heatmaps respectively. For Ours and Grad, we grow the number of OE samples from 2, 8, 128, 2048 to full OE. AE is not able to incorporate OE.
Class-wise Anomaly Heatmaps Due to space restrictions we have only shown heatmaps for some of the classes in the main paper. Here we also report a collection of heatmaps for all classes.
We show heatmaps with adjusted contrast curves by setting $\mathcal { X }$ to the balanced set of all samples for all datasets in this section. Further, we set $\eta = 0 . 8 5$ for Fashion-MNIST and CIFAR-10, $\eta = 0 . 9 9$ for MVTec-AD, and $\eta = 0 . 9 7$ for ImageNet. Note that, to keep the heatmaps for different classes comparable, we use a unified normalization for all heatmaps in one figure. However, since for each class a separate anomaly detector is trained, this yields suboptimal visualizations for some of the classes (for example, the “toothbrush” images for MVTec-AD in Figure 18 where the heatmaps just show a huge red blob). Tweaking the normalization for such classes reveals that the heatmaps actually tend to mark the correct anomalous regions, which in the case of “toothbrushes” can be seen in the explanation performance evaluation in Table 2.
The rows in all heatmaps show the following: (1) Input samples (2) FCDD heatmaps (3) gradient heatmaps with HSC (4) autoencoder reconstruction heatmaps. Heatmaps for MVTec-AD add a fifth row containing the ground-truth anomaly map.
Heatmaps for Fashion-MNIST using auxiliary anomalies from CIFAR-100 are in Figure 15, using EMNIST for OE instead are in Figure 16. CIFAR-10 heatmaps are in Figure 17, and heatmaps for all classes of MVTec-AD are in Figure 18. Finally, we present ImageNet heatmaps in Figures 19 and 20.
 Figure 15: Anomaly heatmaps for anomalous test samples in Fashion-MNIST using CIFAR-100 OE. Columns are ordered by increasing anomaly score from left to right. The subcaptions refer to the nominal class that each model is trained on, for which some examples are also displayed as a separate column on the left.
 Figure 16: Anomaly heatmaps for anomalous test samples in Fashion-MNIST using EMNIST OE. Columns are ordered by increasing anomaly score from left to right. The subcaptions refer to the nominal class that each model is trained on, for which some examples are also displayed as a separate column on the left.
 Figure 17: Anomaly heatmaps for anomalous test samples in CIFAR-10. Columns are ordered by increasing anomaly score from left to right. The subcaptions refer to the nominal class that each model is trained on, for which some examples are also displayed as a separate column on the left.
 Figure 18: Anomaly heatmaps for anomalous test samples in MVTec-AD. Columns are ordered by increasing anomaly score from left to right. The subcaptions refer to the nominal class that each model is trained on.
 Figure 19: Anomaly heatmaps for anomalous test samples in ImageNet, where classes 1-21 are shown. Columns are ordered by increasing anomaly score from left to right. The subcaptions refer to the nominal class that each model is trained on, for which some examples are also displayed as a separate column on the left.
 Figure 20: Anomaly heatmaps for anomalous test samples in ImageNet, where classes 22-30 are shown. Columns are ordered by increasing anomaly score from left to right. The subcaptions refer to the nominal class that each model is trained on, for which some examples are also displayed as a separate column on the left.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344# REAL-VALUED (MEDICAL) TIME SERIES GENERATION WITH RECURRENT CONDITIONAL GANS
Anonymous authors Paper under double-blind review
# ABSTRACT
Generative Adversarial Networks (GANs) have shown remarkable success as a framework for training models to produce realistic-looking data. In this work, we propose a Recurrent GAN (RGAN) and Recurrent Conditional GAN (RCGAN) to produce realistic real-valued multi-dimensional time series, with an emphasis on their application to medical data. RGANs make use of recurrent neural networks (RNNs) in the generator and the discriminator. In the case of RCGANs, both of these RNNs are conditioned on auxiliary information. We demonstrate our models in a set of toy datasets, where we show visually and quantitatively (using sample likelihood and maximum mean discrepancy) that they can successfully generate realistic time-series. We also describe novel evaluation methods for GANs, where we generate a synthetic labelled training dataset, and evaluate on a real test set the performance of a model trained on the synthetic data, and vice-versa. We illustrate with these metrics that RCGANs can generate time-series data useful for supervised training, with only minor degradation in performance on real test data. This is demonstrated on digit classification from ‘serialised’ MNIST and by training an early warning system on a medical dataset of 17,000 patients from an intensive care unit. We further discuss and analyse the privacy concerns that may arise when using RCGANs to generate realistic synthetic medical time series data, and demonstrate results from differentially private training of the RCGAN.
# 1 INTRODUCTION
Access to data is one of the bottlenecks in the development of machine learning solutions to domainspecific problems. The availability of standard datasets (with associated tasks) has helped to advance the capabilities of learning systems in multiple tasks. However, progress appears to lag in other fields, such as medicine. It is tempting to suggest that tasks in medicine are simply harder - the data more complex, more noisy, the prediction problems less clearly defined. Regardless of this, the dearth of data accessible to researchers hinders model comparisons, reproducibility and ultimately scientific progress. However, due to the highly sensitive nature of medical data, its access is typically highly controlled, or require involved and likely imperfect de-identification. The motivation for this work is therefore to exploit and develop the framework of generative adversarial networks (GANs) to generate realistic synthetic medical data. This data could be shared and published without privacy concerns, or even used to augment or enrich similar datasets collected in different or smaller cohorts of patients. Moreover, building a system capable of synthesizing realistic medical data implies modelling the processes that generates such information, and therefore it can represent the first step towards developing a new approach for creating predictive systems in medical environments.
Beyond the utility to the machine learning research community, such a tool stands to benefit the medical community for use in training simulators. In this work, we focus on synthesising real-valued time-series data as from an Intensive Care Unit (ICU). In ICUs, doctors have to make snap decisions under time pressure, where they cannot afford to hesitate. It is already standard in medical training to use simulations to train doctors, but these simulations often rely on hand-engineered rules and physical props. Thus, a model capable of generating diverse and realistic ICU situations could have an immediate application, especially when given the ability to condition on underlying ‘states’ of the patient.
The success of GANs in generating realistic-looking images (Radford et al., 2015; Ledig et al., 2016; Gauthier, 2014; Reed et al., 2016) suggests their applicability for this task, however limited work has exploited them for generating time-series data. In addition, evaluation of GANs remains a largely-unsolved problem, with researchers often relying on visual evaluation of generated examples, an approach which is both impractical and inappropriate for multi-dimensional medical time series. For example (Vondrick et al., 2016) present a method to use convolutional GANs specifically designed to generate video sequences, and the results were visually evaluated with Amazon Mechanical Turk. In (Oord et al., 2016a), authors present a method for voice synthesis based on dilated convolutions, which is also evaluated by humans. This voice synthesis model has been very recently improved by introducing an RNN-based network that generates the spectrogram of the signal (Shen et al., 2017).
The primary contributions of this work are:
1. Demonstration of a method to generate multivariate real-valued sequences using adversarial training and recurrent neural networks. 2. Showing novel approaches for evaluating GANs. 3. Generating synthetic medical time series data. 4. Empirical privacy analysis of both GANs and differential private GANs.
# 2 RELATED WORK
Since their inception in 2014 (Goodfellow et al., 2014), the GAN framework has attracted significant attention from the research community, and much of this work has focused on image generation (Radford et al., 2015; Ledig et al., 2016; Gauthier, 2014; Reed et al., 2016). Notably, (Choi et al., 2017) designed a GAN to generate synthetic electronic health record (EHR) datasets. These EHRs contain binary and count variables, such as ICD-9 billing codes, medication, and procedure codes. Their focus on discrete-valued data and generating snapshots of a patient is complementary to our real-valued, time series focus. Future work could combine these approaches to generate multi-modal synthetic medical time-series data.
The majority of sequential data generation with GANs has focused on discrete tokens useful for natural language processing (Yu et al., 2016), where an alternative approach based on Reinforcement Learning (RL) is used to train the GAN. We are aware of only one preliminary work using GANs to generate continuous-valued sequences, which aims to produce polyphonic music using a GAN with LSTM generator and discriminator (Mogren, 2016). The primary differences are architectural: we do not use a bidirectional discriminator, and outputs of the generator are not fed back as inputs at the next time step. Moreover, we introduce also a conditional version of this Recurrent GAN.
Conditional GANs (Mirza & Osindero, 2014; Gauthier, 2014) condition the model on additional information and therefore allow us to direct the data generation process. This approach has been mainly used for image generation tasks (Radford et al., 2015; Mirza & Osindero, 2014; Antipov et al., 2017). Recently, Conditional GAN architectures have been also used in natural language processing, including translation (Yang et al., 2017) and dialogue generation (Li et al., 2017), where none of them uses an RNN as the preferred choice for the discriminator and, as previously mentioned, a RL approach is used to train the models due to the discrete nature of the data.
In this work, we also introduce some novel approaches to evaluate GANs, using the capability of the generated synthetic data to train supervised models. In a related fashion, a GAN-based semisupervised learning approach was introduced in (Salimans et al., 2016). However, our goal is to generate data that can be used to train models for tasks that are unknown at the moment the GAN is trained.
We briefly explore the use of differentially private stochastic gradient descent (Abadi et al., 2016) to produce a RGAN with stronger privacy guarantees, which is especially relevant for sensitive medical data. An alternate method would be to use the PATE approach (Papernot et al., 2016) to train the discriminator. In this case, rather than introducing noise into gradients (as in (Abadi et al., 2016)), a student classifier is trained to predict the noisy votes of an ensemble of teachers, each trained on disjoint sets of the data.
# 3 MODELS: RECURRENT GAN AND RECURRENT CONDITIONAL GAN
The model presented in this work follows the architecture of a regular GAN, where both the generator and the discriminator have been substituted by recurrent neural networks. Therefore, we present a Recurrent GAN (RGAN), which can generate sequences of real-valued data, and a Recurrent Conditional GAN (RCGAN), which can generate sequences of real-value data subject to some conditional inputs. As depicted in Figure 1a, the generator RNN takes a different random seed at each time step, plus an additional input if we want to condition the generated sequence with additional data. In Figure 1b, we show how the discriminator RNN takes the generated sequence, together with an additional input if it is a RCGAN, and produces a classification as synthetic or real for each time step of the input sequence.
Specifically, the discriminator is trained to minimise the average negative cross-entropy between its predictions per time-step and the labels of the sequence. If we denote by $\mathrm { R N N } ( X )$ the vector or matrix comprising the $T$ outputs from a RNN receiving a sequence of $T$ vectors $\{ \dot { \mathbf { x } } _ { t } \} _ { t = 1 } ^ { T } ( \mathbf { x } _ { t } \in \mathbb { R } ^ { d } )$ and by $\mathrm { C E } ( \mathbf { a } , \mathbf { b } )$ the average cross-entropy between sequences a and $\mathbf { b }$ , then the discriminator loss for a pair $\{ X _ { n } , \mathbf { y } _ { n } \}$ (with $\breve { X } _ { n } \in \mathbb { R } ^ { T \times d }$ and ${ \bf y } _ { n } \in \{ 1 , 0 \} ^ { \dot { T } } )$ is:
$$\operatorname { D } _ { \mathrm { l o s s } } ( X _ { n } , \mathbf { y } _ { n } ) = - \mathrm { C E } ( \mathrm { R N N } _ { \mathrm { D } } ( X _ { n } ) , \mathbf { y } _ { n } )$$
For real sequences, ${ \bf y } _ { n }$ is a vector of 1s, or 0s for synthetic sequences. In each training minibatch, the discriminator sees both real and synthetic sequences.
The objective for the generator is then to ‘trick’ the discriminator into classifying its outputs as true, that is, it wishes to minimise the (average) negative cross-entropy between the discriminator’s predictions on generated sequences and the ‘true’ label, the vector of 1s (we write as 1);
$$\operatorname { G } _ { \mathrm { l o s s } } ( Z _ { n } ) = \operatorname { D } _ { \mathrm { l o s s } } ( \operatorname { R N N } _ { \mathrm { G } } ( Z _ { n } ) , \mathbf { 1 } ) = - \operatorname { C E } ( \operatorname { R N N } _ { \mathrm { D } } ( \operatorname { R N N } _ { \mathrm { G } } ( Z _ { n } ) ) , \mathbf { 1 } )$$
Here $Z _ { n }$ is a sequence of $T$ points $\{ \mathbf { z } _ { t } \} _ { t = 1 } ^ { T }$ sampled independently from the latent/noise space $\mathbf { Z }$ , thus $Z _ { n } \in \mathbb { R } ^ { T \times \bar { m } }$ since $\mathbf { Z } = \mathbb { R } ^ { m }$ . Initial experimentation with non-independent sampling did not indicate any obvious benefit, but would be a topic for further investigation.
In this work, the architecture selected for both discriminator and generator RNNs is the LSTM (Hochreiter & Schmidhuber, 1997).
In the conditional case (RCGAN), the inputs to each RNN are augmented with some conditional information $\mathbf { c } _ { n }$ (for sample $n$ , say) by concatenation at each time-step;
$$\mathbf { z } _ { n t } \to [ \mathbf { z } _ { n t } ; \mathbf { c } _ { n } ] \qquad \mathbf { x } _ { n t } \to [ \mathbf { x } _ { n t } ; \mathbf { c } _ { n } ]$$
In this way the RNN cannot discount the conditional information through forgetting.
Promising research into alternative GAN objectives, such as the Wasserstein GAN (Arjovsky et al., 2017; Gulrajani et al., 2017) unfortunately do not find easy application to RGANs in our experiments. Enforcing the Lipschitz constraint on an RNN is a topic for further research, but may be aided by use of unitary RNNs (Arjovsky et al., 2016; Hyland & Rätsch, 2017).
All models and experiments were implemented in python with scikit-learn (Pedregosa et al., 2011) and Tensorflow (Abadi et al., 2015), and the code is available in a public git repository: ANON.
# 3.1 EVALUATION
Evaluating the performance of a GAN is challenging. As illustrated in (Theis et al., 2015) and (Wu et al., 2016), evaluating likelihoods, with Parzen window estimates (Wu et al., 2016) or otherwise can be deceptive, and the generator and discriminator losses do not readily correspond to ‘visual quality’. This nebulous notion of quality is best assessed by a human judge, but it is impractical and costly to do so. In the imaging domain, scores such as the Inception score (Salimans et al., 2016) have been developed to aid in evaluation, and Mechanical Turk exploited to distribute the human labour. However, in the case of real-valued sequential data, is not always easy or even possible to visually evaluate the generated data. For example, the ICU signals with which we work in this paper, could look completely random to a non-medical expert.
Therefore, in this work, we start by demonstrating our model with a number of toy datasets that can be visually evaluated. Next, we use a set of quantifiable methods (description below) that can be used as an indicator of the data quality.

(a) The generator RNN takes a different random seed at each temporal input, and produces a synthetic signal. In the case of the RCGAN, it also takes an additional input on each time step that conditions the output.

(b) The discriminator RNN takes real/synthetic sequences and produces a classification into real/synthetic for each time step. In the case of the RCGAN, it also takes an additional input on each time step that conditions the output.
Figure 1: Architecture of Recurrent GAN and Conditional Recurrent GAN models.
# 3.1.1 MAXIMUM MEAN DISCREPANCY
We consider a GAN successful if it implicitly learns the distribution of the true data. We assess this by studying the samples it generates. This is the ideal setting for maximum mean discrepancy (MMD) (Gretton et al., 2007), and has been used as a training objective for generative moment matching networks (Li et al., 2015). MMD asks if two sets of samples - one from the GAN, and one from the true data distribution, for example - were generated by the same distribution. It does this by comparing statistics of the samples. In practice, we consider the squared difference of the statistics between the two sets of samples (the $\mathrm { \dot { \bf M } M D ^ { 2 } }$ ), and replace inner products between (functions of) the two samples by a kernel. Given a kernel $K : X \times Y \mathbb { R }$ , and samples $\{ x _ { i } \} _ { i = 1 } ^ { N } , \{ y _ { j } \} _ { j = 1 } ^ { M }$ , an unbiased estimate of $\mathrm { { \bf M M D } ^ { 2 } }$ is:
$$\widehat { \mathrm { M M D } } _ { u } ^ { 2 } = \frac { 1 } { n ( n - 1 ) } \sum _ { i = 1 } ^ { n } \sum _ { j \neq i } ^ { n } K ( x _ { i } , x _ { j } ) - \frac { 2 } { m n } \sum _ { i = 1 } ^ { n } \sum _ { j = 1 } ^ { m } K ( x _ { i } , y _ { j } ) + \frac { 1 } { m ( m - 1 ) } \sum _ { i = 1 } ^ { m } \sum _ { j \neq i } ^ { m } K ( y _ { i } , y _ { j } )$$
Defining appropriate kernels between time series is an area of active research. However, much of the challenge arises from the need to align time series. In our case, the generated and real samples are already aligned by our fixing of the ‘time’ axis. We opt then to treat our time series as vectors (or matrices, in the multidimensional case) for comparisons, and use the radial basis function (RBF) kernel using the squared $\ell _ { 2 }$ -norm or Frobenius norm between vectors/matrices; $K ( x , y ) = \exp ( - \| x - y \| ^ { 2 } / ( 2 \sigma ^ { 2 } ) )$ . To select an appropriate kernel bandwidth $\sigma$ we maximise the estimator of the t-statistic of the power of the MMD test between two distributions (Sutherland et al., 2016); $\begin{array} { r } { { \hat { t } } = \frac { \widehat { \mathrm { M M D } } ^ { 2 } } { \sqrt { \hat { V } } } } \end{array}$ , where $V$ is the asymptotic variance of the estimator of $\mathbf { M M D ^ { 2 } }$ . We do this using a split of the validation set during training - the rest of the set is used to calculate the $\mathrm { { \bf M M D } ^ { 2 } }$ using the optimised bandwidth. Following (Sutherland et al., 2016), we define a mixed kernel as a sum of RBF kernels with two different $\sigma \mathbf { s }$ , which we optimise simultaneously. We find the $\mathbf { M M D ^ { 2 } }$ to be more informative than either generator or discriminator loss, and correlates well with quality as assessed by visualising.
# 3.1.2 TRAIN ON SYNTHETIC, TEST ON REAL (TSTR)
We propose a novel method for evaluating the output of a GAN when a supervised task can be defined on the domain of the training data. We call it “Train on Synthetic, Test on Real” (TSTR). Simply put, we use a dataset generated by the GAN to train a model, which is then tested on a held-out set of true examples. This requires the generated data to have labels - we can either provide these to a conditional GAN, or use a standard GAN to generate them in addition to the data features. In this work we opted for the former, as we describe below. For using GANs to share synthetic ‘de-identified’ data, this evaluation metric is ideal, because it demonstrates the ability of the synthetic data to be used for real applications. We present the pseudocode for this GAN evaluation strategy in Algorithm 1.
# Algorithm 1 (TSTR) Train on Synthetic, Test on Real
1: train, test $=$ split(data) 2: discriminator, generator $=$ train_GAN(train) 3: with labels from train: 4: synthetic $=$ generator.generate_synthetic(labels) 5: classifier $=$ train_classifier(synthetic, labels) 6: If validation set available, optionally optimise GAN over classifier performance. 7: with labels and features from test: 8: predictions $=$ classifier.predict(features) 9: TSTR_score $=$ score(predictions, labels)
Train on Real, Test on Synthetic (TRTS): Similar to the TSTR method proposed above, we can consider the reverse case, called “Train on Real, Test on Synthetic” (TRTS). In this approach, we use real data to train a supervised model on a set of tasks. Then, we use the RCGAN to generate a synthetic test set for evaluation. In the case (as for MNIST) where the true classifier achieves high accuracy, this serves to act as an evaluation of the RCGAN’s ability to generate convincing examples of the labels, and that the features it generates are realistic. Unlike the TSTR setting however, if the GAN suffers mode collapse, TRTS performance will not degrade accordingly, so we consider TSTR the more interesting evaluation.
# 4 LEARNING TO GENERATE REALISTIC SEQUENCES
To demonstrate the model’s ability to generate ‘realistic-looking’ sequences in controlled environments, we consider several experiments on synthetic data. In the experiments that follow, unless otherwise specified, the synthetic data consists of sequences of length 30. We focus on the nonconditional model RGAN in this section.
# 4.1 SINE WAVES
The quality of generated sine waves are easily confirmed by visual inspection, but by varying the amplitudes and frequencies of the real data, we can create a dataset with nonlinear variations. We generate waves with frequencies in [1.0, 5.0], amplitudes in [0.1, 0.9], and random phases between $[ - \pi , \pi ]$ . The left of Figure 2a shows examples of these signals, both real and generated (although they are hard to distinguish).
We found that, despite the absence of constraints to enforce semantics in the latent space (as in (Chen et al., 2016)), we could alter the frequency and phase of generated samples by varying the latent dimensions, although the representation was not ‘disentangled’, and one dimension of the latent space influenced multiple aspects of the signal.
At this point, we tried to train a recurrent version of the Variational Autoencoder (VAE) (Kingma & Welling, 2013) with the goal of comparing its performance with the RGAN. We tried the implementation proposed in (Fabius & van Amersfoort, 2014), which is arguably the most straightforward solution to implement a Recurrent Variational Autoencoder (RVAE). It consists of replacing the encoder and decoder of a VAE with RNNs, and then using the last hidden state of the encoder RNN as the encoded representation of the input sequence. After performing the reparametrization trick, the resulting encoded representation is used to initialize the hidden state of the decoder RNN. Since in this simple dataset all sequences are of the same length, we also tried an alternative approach in which the encoding of the input sequence is computed as the concatenation of all the hidden states of the encoder RNN. Using these architechtures, we were only capable of generating sine waves with inconsistent amplitudes and frequencies, with a quality clearly inferior than the ones produced by the RGAN. The source code to reproduce these experiments is included in the git repository mentioned before. We believe that this approach needs further research, specially for the task of generating
<table><tr><td></td><td>Accuracy</td></tr><tr><td>Real</td><td>0.991± 0.001</td></tr><tr><td>TSTR</td><td>0.975 ± 0.002</td></tr><tr><td>TRTS</td><td>0.988 ± 0.005</td></tr></table>
Table 1: Scores obtained by a convolutional neural network when: a) trained and tested on real data, b) trained on synthetic and tested on real data, and c) trained on real and tested on synthetic. In all cases, early stopping and (in the case of the synthetic data) epoch selection were determined using a validation set.
labeled data that will be presented later in this paper, which we also failed to accomplish with the RVAE so far.
# 4.2 SMOOTH FUNCTIONS
Sine waves are simple signals, easily reproduced by the model. In our ultimate medical application, we wish the model to reproduce complex physiological signals which may not follow simple dynamics. We therefore consider the harder task of learning arbitrary smooth signals. Gaussian processes offer a method to sample values of such smooth functions. We use a RBF kernel with to specify a GP with zero-valued mean function. We then draw 30 equally-spaced samples. This amounts to a single draw from a multivariate normal distribution with covariance function given by the RBF kernel evaluated on a grid of equally-spaced points. In doing so, we have specified exactly the probability distribution generated the true data, which enables us to evaluate generated samples under this distribution. The right of Figure 2a shows examples (real and generated) of this experiment. The main feature of the real and generated time series is that they exhibit smoothness with local correlations, and this is rapidly captured by the RGAN.
Because we have access to the data distribution, in Figure 3 we show how the average (log) likelihood of a set of generated samples increases under the data distribution during training. This is an imperfect measure, as it is blind to the diversity of the generated samples - the oft-observed mode collapse, or ‘Helvetica Scenario’ (Goodfellow et al., 2014) of GANs - hence we prefer the $\mathrm { { \bf M M D } ^ { 2 } }$ measure (see Figure 3). It is nonetheless encouraging to observe that, although the GAN objective is unaware of the underlying data distribution, the likelihood of the generated samples improves with training.
# 4.3 MNIST AS A TIME SERIES
The MNIST hand-written digit dataset is ubiquitous in machine learning research. Accuracy on MNIST digit classification is high enough to consider the problem ‘solved’, and generating MNIST digits seems an almost trivial task for traditional GANs. However, generating MNIST sequentially is less commonly done (notable examples are PixelRNN (Oord et al., 2016b), and the serialisation of MNIST in the long-memory RNN literature (Le et al., 2015)). To serialise MNIST, each $2 8 \times 2 8$ digit forms a 784-dimensional vector, which is a sequence we can aim to generate with the RGAN. This gives the added benefit of producing samples we can easily assess visually.
To make the task more tractable and to explore the RGAN’s ability to generate multivariate sequences, we treat each $2 8 \mathbf { x } 2 8$ image as a sequence of 28, 28-dimensional outputs. We show two types of
 (b) Left top: real MNIST digits. Left bottom: unrealistic digits generated at epoch 27. Right: digits with minimal distortion generated at epoch 100.
(a) Examples of real (coloured, top) and generated (black, lower two lines) samples.
 Figure 2: RGAN is capable of generating realistic-looking examples.
 Figure 3: Trace of generator (dotted), discriminator (solid) loss, $\mathrm { { \bf M M D } ^ { 2 } }$ score and log likelihood of generated samples under the data distribution during training for RGAN generating smooth sequences (output in Figure 2a.)
 Figure 4: Back-projecting training examples into the latent space and linearly interpolating them produces smooth variation in the sample space. Top plot shows sample-space distance from top (green, dashed) sample to bottom (orange, dotted). Distance measure is RBF kernel with bandwidth chosen as median pairwise distance between training samples. The original training examples are shown in dotted lines in the bottom and second-from-top plots.
experiment with this dataset. In the first one, we train a RGAN to generate MNIST digits in this sequential manner. Figure 2b demonstrates how realistic the generated digits appear.
For the second experiment, we downsample the MNIST digits to 14x14 pixels, and consider the first three digits (0, 1, and 2). With this data we train a RCGAN and subsequently perform the TSTR (and TRTS) evaluations explained above, for the task of classifying the digits. That is, for the TSTR evaluation, we generate a synthetic dataset using the GAN, using the real training labels as input. We then train a classifier (a convolutional neural network) on this data, and evaluate its performance on the real held-out test set. Conversely, for TRTS we train a classifier on the real data, and evaluate it on a synthetic test dataset generated by the GAN. Results of this experiment are show in Table 1. To obtain error bars on the accuracies reported, we trained the RCGAN five times with different random initialisations. The TSTR result shows that the RCGAN generates synthetic datasets realistic enough to train a classifier which then achieves high performance on real test data. The TRTS result shows that the synthetic examples in the test set match their labels to a high degree, given the accuracy of the classifier trained on real data is very high.
# 5 LEARNING TO GENERATE REALISTIC ICU DATA
One of the main goals of this paper is to build a model capable of generating realistic medical datasets, and specifically ICU data. For this purpose, we based our work on the recently-released Philips eICU database1. This dataset was collected by the critical care telehealth program provided by Philips. It contains around 200,000 patients from 208 care units across the US, with a total of 224,026,866 entries divided in 33 tables.
From this data, we focus on generating the four most frequently recorded, regularly-sampled variables measured by bedside monitors: oxygen saturation measured by pulse oximeter $( { \tt S p O 2 } )$ , heart rate (HR), respiratory rate (RR) and mean arterial pressure (MAP). In the eICU dataset, these variables are measured every five minutes. To reduce the length of the sequences we consider, we downsample to one measurement every fifteen minutes, taking the median value in each window. This greatly speeds up the training of our LSTM-based GAN while still capturing the relevant dynamics of the data (see Figure 6 in the appendix.)
In the following experiments, we consider the beginning of the patient’s stay in the ICU, considering this a critical time in their care. We focus on the first 4 hours of their stay, which results in 16 measurements of each variable. While medical data is typically fraught with missing values, in this work we circumvented the issue by discarding patients with missing data (after downsampling). After preprocessing the data this way, we end up with a cohort of 17,693 patients. Most restrictive was the requirement for non-missing MAP values, as these measurements are taken invasively.
# 5.1 TSTR TASKS IN EICU
The data generated in a ICU is complex, so it is challenging for non-medical experts to spot patterns or trends on it. Thus, one plot showing synthetic ICU data would not provide enough information to evaluate its actual similarity to the real data. Therefore, we evaluate the performance of the ICU RCGAN using the TSTR method.
To perform the TSTR evaluation, we need a supervised task (or tasks) on the data. A relevant question in the ICU is whether or not a patient will become ‘critical’ in the near future - a kind of early warning system. For a model generating dynamic time-series data, this is especially appropriate, as trends in the data are likely most predictive. Based on our four variables (SpO2, HR, RR, MAP) we define ‘critical thresholds’ and generate binary labels of whether or not that variable will exceed the threshold in the next hour of the patient’s stay - that is, between hour 4 and 5, since we consider the first four hours ‘observed’. The thresholds are shown in the columns of Table 2a. There is no upper threshold for SpO2, as it is a percentage with $100 \%$ denoting ideal conditions. These critical thresholds were selected as follows: starting from rough healthy ranges for adults, we compared with the distributions in our data (ICU patients are not healthy), selected several candidate values for each cutoff, and then ran a grid search over these cutoffs to determine tasks which were sufficiently easy for a random forest (assessed using F1 score). The reasoning here was to ensure that the task would be possible given real data, and to provide a strong baseline against the synthetic data.
As for MNIST, we ‘sample’ labels by drawing them from the real data labels, and use these as conditioning inputs for the RCGAN. This ensures the label distribution in the synthetic dataset and the real dataset is the same, respecting the fact that the labels are not independent (a patient is unlikely to simultaneously suffer from high and low blood pressure).
Following Algorithm 1, we train the RCGAN for 1000 epochs, saving one version of the dataset every 50 epochs. Afterwards, we evaluate the synthetic data using TSTR. We use cross validation to select the best synthetic dataset based on the classifier performance, but since we assume that it might be also used for unknown tasks, we use only 3 of the 7 tasks of interest to perform this cross validation step (denoted in italics in Table 2a). The results of this experiment are presented in Table 2a, which compares the performance achieved by a random forest classifier that has been trained to predict the 7 tasks of interest, in one experiment with real data and in a different experiment with the synthetically generated data.
# 6 IS THE GAN JUST MEMORISING THE TRAINING DATA?
One explanation for the TSTR performance in MNIST and eICU could be that the GAN is simply "memorising" the training data and reproducing it. If this were the case, then the (potentially private) data used to train the GAN would be leaked, raising privacy concerns when used on sensitive medical data. It is key that the training data for the model should not be recoverable by an adversary. In addition, while the typical GAN objective incentivises the generator to reproduce training examples, we hope that it does not overfit to the training data, and learn an implicit distribution which is peaked at training examples, and negligible elsewhere.
To answer this question we perform three tests - one qualitative, two statistical, outlined in the following subsections. While these evaluations are empirical in nature, we still believe that the proposed and tested privacy evaluation measures can be very useful to quickly check privacy properties of RGAN generated data – but without strong privacy guarantees.
# 6.1 COMPARING THE DISTRIBUTION OF RECONSTRUCTION ERRORS
To test if the generated samples look "too similar" to the training set, we could generate a large number of samples and calculate the distance to the nearest neighbour (in the training set) to each generated sample. We could compare the distribution of these distances with those comparing the generated samples and a held-out test set. However, to get an accurate estimate of the distances, we may need to generate many samples, and correspondingly calculate many pairwise distances. Instead, we intentionally generate the nearest neighbour to each training (or test) set point, and then compare the distances.
<table><tr><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>Sp02<95</td><td rowspan=1 colspan=1>HR<70</td><td rowspan=1 colspan=1>HR>100</td></tr><tr><td rowspan=1 colspan=1>AUROC</td><td rowspan=1 colspan=1>realTSTR</td><td rowspan=1 colspan=1>0.9587±0.00040.88± 0.01</td><td rowspan=1 colspan=1>0.9908±0.00050.96 ± 0.01</td><td rowspan=1 colspan=1>0.9919±0.00020.95 ± 0.01</td></tr><tr><td rowspan=1 colspan=1>AUPRC</td><td rowspan=1 colspan=1>realTSTRrandom</td><td rowspan=1 colspan=1>0.9059± 0.00050.66 ± 0.020.16</td><td rowspan=1 colspan=1>0.9855±0.00020.90 ±0.020.26</td><td rowspan=1 colspan=1>0.9778±0.00020.84±0.030.18</td></tr></table>
<table><tr><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>RR<13</td><td rowspan=1 colspan=1>RR>20</td><td rowspan=1 colspan=1>MAP<70</td><td rowspan=1 colspan=1>MAP>110</td></tr><tr><td rowspan=1 colspan=1>AUROC</td><td rowspan=1 colspan=1>realTSTR</td><td rowspan=1 colspan=1>0.9735± 0.00010.86 ± 0.01</td><td rowspan=1 colspan=1>0.963±0.0010.84 ± 0.02</td><td rowspan=1 colspan=1>0.9717±0.00010.875 ± 0.007</td><td rowspan=1 colspan=1>0.960±0.0010.87 ± 0.04</td></tr><tr><td rowspan=1 colspan=1>AUPRC</td><td rowspan=1 colspan=1>realTSTRrandom</td><td rowspan=1 colspan=1>0.9557 ± 0.00020.73 ± 0.020.26</td><td rowspan=1 colspan=1>0.891 ± 0.0010.50 ± 0.060.1</td><td rowspan=1 colspan=1>0.9653 ±0.00010.82 ±0.020.39</td><td rowspan=1 colspan=1>0.8629± 0.00070.42 ± 0.070.05</td></tr></table>
(a) Performance of random forest classifier for eICU tasks when trained with real data and when trained with synthetic data (test set is real), including random prediction baselines. AUPRC stands for area under the precision-recall curve, and AUROC stands for area under ROC curve.
<table><tr><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>Sp02 <95</td><td rowspan=1 colspan=1>HR<70</td><td rowspan=1 colspan=1>HR>100</td></tr><tr><td rowspan=1 colspan=1>AUROC</td><td rowspan=1 colspan=1>TSTR (DP)</td><td rowspan=1 colspan=1>0.861±0.006</td><td rowspan=1 colspan=1>0.86±0.02</td><td rowspan=1 colspan=1>0.90±0.01</td></tr><tr><td rowspan=1 colspan=1>AUPRC</td><td rowspan=1 colspan=1>TSTR (DP)random</td><td rowspan=1 colspan=1>0.61±0.010.16</td><td rowspan=1 colspan=1>0.76±0.040.27</td><td rowspan=1 colspan=1>0.76± 0.030.16</td></tr></table>
<table><tr><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>RR<13</td><td rowspan=1 colspan=1>RR>20</td><td rowspan=1 colspan=1>MAP<70</td><td rowspan=1 colspan=1>MAP>110</td></tr><tr><td rowspan=1 colspan=1>AUROC</td><td rowspan=1 colspan=1>TSTR (DP)</td><td rowspan=1 colspan=1>0.85± 0.01</td><td rowspan=1 colspan=1>0.85 ±0.02</td><td rowspan=1 colspan=1>0.789± 0.005</td><td rowspan=1 colspan=1>0.85±0.02</td></tr><tr><td rowspan=1 colspan=1>AUPRC</td><td rowspan=1 colspan=1>TSTR (DP)random</td><td rowspan=1 colspan=1>0.71 ± 0.020.26</td><td rowspan=1 colspan=1>0.46±0.030.09</td><td rowspan=1 colspan=1>0.70±0.010.39</td><td rowspan=1 colspan=1>0.28±0.030.05</td></tr></table>
(b) Performance of random forest classifier trained on synthetic data generated by differentially private GAN, tested on real data. In each replicate, the GAN was trained with $( \epsilon , \delta )$ differential privacy for $\epsilon = 1$ and $\delta \in [ 3 . 5 5 \times 1 0 ^ { - 1 2 } , 2 . 2 6 \times 1 0 ^ { - 5 } ]$
Table 2: TSTR results on eICU tasks using normal (a) and differentially private (b) training. In both cases, epoch from which data is generated was selected using a validation set, considering performance on a subset of the tasks $\mathrm { S p O } 2 < 9 5$ , $\mathrm { H R } > 1 0 0$ , and $\mathrm { R R } < 1 3$ , denoted in italics). For details on the differentially private setting, see section 7.
We generate these nearest neighbours by minimising the reconstruction error between target $y$ and the generated point; $\bar { \mathcal { L } } _ { \mathrm { r e c o n } ( y ) } ( Z ) = \bar { 1 } - K ( G ( Z ) , y )$ where $K$ is the RBF kernel described in Section 3.1.1, with bandwidth $\sigma$ chosen using the median heuristic (Bounliphone et al., 2015). We find $Z$ by minimising the error until approximate convergence (when the gradient norm drops below a threshold).
We can then ask if we can distinguish the distribution of reconstruction errors for different input data. Specifically, we ask if we can distinguish the distribution of errors between the training set and the test set. The intuition is that if the model has "memorised" training data, it will achieve identifiably lower reconstruction errors than with the test set. We use the Kolmogorov-Smirnov two-sample test to test if these distributions differ. For the RGAN generating sine waves, the p-value is $0 . 2 \pm 0 . 1$ , for smooth signals it is $0 . 0 9 \pm 0 . 0 4$ , and for the MNIST experiment shown in Figure 2b it is $0 . 3 8 \pm 0 . 0 6$ . For the MNIST trained with RCGAN (TSTR results in Table 1), the $\mathsf { p } \cdot$ -value is $0 . 5 7 \pm 0 . 1 8$ . We conclude that the distribution of reconstruction errors is not significantly different between training and test sets in any of these cases, and that the model does not appear to be biased towards reconstructing training set examples.
# 6.2 INTERPOLATION
Suppose that the model has overfit (the implicit distribution is highly peaked in the region of training examples), and most points in latent space map to (or near) training examples. If we take a smooth path in the latent space, we expect that at each point, the corresponding generated sample will have the appearance of the "closest" (in latent space) training example, with little variation until we reach the attractor basin of another training example, at which point the samples switch appearance.
We test this qualitatively as follows: we sample a pair of training examples (we confirm by eye that they don’t look "too similar"), and then "back-project" them into the latent space to find the closest corresponding latent point, as described above. We then linearly interpolate between those latent points, and produce samples from the generator at each point. Figure 4 shows an example of this procedure using the "smooth function" dataset. The samples show a clear incremental variation between start and input sequences, contrary to what we would expect if the model had simply memorised the data.
# 6.3 COMPARING THE GENERATED SAMPLES
Rather than using a nearest-neighbours approach (as in Section 6.1), we can use the MMD threesample test (Bounliphone et al., 2015) to compare the full set of generated samples. With $X$ being the generated samples, $Y$ and $Z$ being the test and training set respectively, we ask if the MMD between $X$ and $Y$ is less than the MMD between $X$ and $Z$ . The test is constructed in this way because we expect that if the model has memorised the training data, that the MMD between the synthetic data and the training data will be significantly lower than the MMD between the synthetic data and test data. In this case, the hypothesis that MMD(synthetic, test) $\leq \mathbf { M M D }$ (synthetic, train) will be false. We are therefore testing (as in Section 6.1) if our null hypothesis (that the model has not memorised the training data) can be rejected. The average p-values we observed were: for the eICU data in Section 5.1: $0 . 4 0 \pm 0 . 0 5$ , for MNIST data in Section 4.3: $0 . 4 7 \pm 0 . 1 6$ , for sine waves: $0 . 4 1 \pm 0 . 0 7$ , for smooth signals: $0 . 0 7 \pm 0 . 0 4$ , and for the higher-resolution MNIST RGAN experiments in Section 4: $0 . 5 9 \pm 0 . 1 2$ (before correction for multiple hypothesis testing). We conclude that we cannot reject the null hypothesis that the MMD between the synthetic set and test set is at most as large as the MMD between the synthetic set and training set, indicating that the synthetic samples do not look more similar to the training set than they do to the test set.
# 7 TRAINING RGANS WITH DIFFERENTIAL PRIVACY
Although the analyses described in Section 6 indicate that the GAN is not preferentially generating training data points, we are conscious that medical data is often highly sensitive, and that privacy breaches are costly. To move towards stronger guarantees of privacy for synthetic medical data, we investigated the use of a differentially private training procedure for the GAN. Differential privacy is concerned with the influence of the presence or absence of individual records in a database. Intuitively, differential privacy places bounds on the probability of obtaining the same result (in our case, an instance of a trained GAN) given a small perturbation to the underlying dataset. If the training procedure guarantees $( \epsilon , \delta )$ differential privacy, then given two ‘adjacent’ datasets (differing in one record) $D , D ^ { \prime }$ ,
$$P [ \mathcal { M } ( D ) \in S ] \leq e ^ { \epsilon } P [ \mathcal { M } ( D ^ { \prime } ) \in S ] + \delta$$
where $\mathcal { M } ( D )$ is the GAN obtained from training on $D$ , $S$ is any subset of possible outputs of the training procedure (any subset of possible GANs), and the probability $P$ takes into account the randomness in the procedure $\mathcal { M } ( D )$ . Thus, differential privacy requires that the distribution over GANs produced by $\mathcal { M }$ must vary ‘slowly’ as $D$ varies, where $\epsilon$ and $\delta$ bound this ‘slowness’. Inspired by a recent preprint (Beaulieu-Jones et al., 2017), we apply the differential private stochastic gradient descent (DP-SGD) algorithm of (Abadi et al., 2016) to the discriminator (as the generator does not ‘see’ the private data directly). For further details on the algorithm (and the above definition of differential privacy), we refer to (Abadi et al., 2016) and (Dwork et al., 2006).
In practice, DP-SGD operates by clipping per-example gradients and adding noise in batches. This means the signal obtained from any individual example is limited, providing differential privacy. Some privacy budget is ‘spent’ every time the training procedure calculates gradients for the discriminator, which enables us to evaluate the effective values of $\epsilon$ and $\delta$ throughout training. We use the moments accountant method from (Abadi et al., 2016) to track this privacy spending. Finding hyperparameters which yield both acceptable privacy and realistic GAN samples proved challenging. We focused on the MNIST and eICU tasks with RCGAN, using the TSTR evaluation.
For MNIST, we clipped gradients to 0.05 and added Gaussian noise with mean zero and standard deviation $0 . 0 5 \times 2$ . For $\epsilon = 1$ and $\delta \leq 1 . 8 \times 1 0 ^ { - 3 }$ , we achieved an accuracy of $0 . 7 5 { \pm } 0 . 0 3$ . Sacrificing more privacy, with $\epsilon = 2$ and $\delta \leq 2 . 5 \times 1 0 ^ { - 4 }$ , the accuracy is $0 . 7 7 { \pm } 0 . 0 3$ . These results are far below the performance reported by the non-private GAN (Table 1), highlighting the compounded difficulty of generating a realistic dataset while maintaining privacy. For comparison, in (Abadi et al., 2016) they report an accuracy of 0.95 for training an MNIST classifier (on the full task) on a real dataset in a differentially private manner. (Please note, however, that our GAN model had to solve the more challenging task of modeling digits as a time series.)
For eICU, the results are shown in Table 2b. For this case, we clipped gradients to 0.1 and added noise with standard deviation $0 . 1 \times 2$ . In surprising contrast to our findings on MNIST, we observe that performance on the eICU tasks remains high with differentially private training. We fixed $\delta < 1 / | D | \overset { } { ( } = 5 . 6 5 \times 1 0 ^ { - 5 } )$ (where $| D | = 1 7 \bar { 6 } 9 3$ is the number of training examples in eICU) for $\epsilon = 1$ by limiting to epochs before 64 (see Figure 5). While the best values for $\epsilon$ and $\delta$ ultimately depend on the use-case, setting $\delta < 1 / | D |$ is a common heuristic Dwork et al. (2014).
The true value of $\delta$ for the results in Table 2b is lower because the optimal epoch (assessed using the validation set) for most replicates was below 30.
 Figure 5: Probability of violating - differential privacy $( \delta )$ during training, for different values of $\epsilon$ . Gaussian noise is added with mean zero and standard deviation $0 . 1 \times 2$ . Dotted line shows $\delta = 1 / | D |$ , where $| D |$ is the number of training examples.
Visual assessment of samples generated by the differentially-private GAN indicate that while it is prone to producing less-realistic sequences, the mistakes it introduces appear to be unimportant for the tasks we consider. In particular, the DP-GAN produces more extreme-valued sequences, but as the tasks are to predict extreme values, it may be that the most salient part of the sequence is preserved. The possibility to introduce privacy preserving noise which nonetheless allows for the training of downstream models suggests interestin directions of research in the intersection of privacy and GANs.
# 8 CONCLUSION
We have described, trained and evaluated a recurrent GAN architecture for generating real-valued sequential data, which we call RGAN. We have additionally developed a conditional variant (RCGAN) to generate synthetic datasets, consisting of real-valued time-series data with associated labels. As this task poses new challenges, we have presented novel solutions to deal with evaluation and questions of privacy. By generating labelled training data - by conditioning on the labels and generating the corresponding samples, we can evaluate the quality of the model using the ‘TSTR technique‘, where we train a model on the synthetic data, and evaluate it on a real, held-out test set. We have demonstrated this approach using ‘serialised’ multivariate MNIST, and on a dataset of real ICU patients, where models trained on the synthetic dataset achieved performance at times comparable to that of the real data. In domains such as medicine, where privacy concerns hinder the sharing of data, this implies that with refinement of these techniques, models could be developed on synthetic data that are still valuable for real tasks. This could enable the development of synthetic ‘benchmarking’ datasets for medicine (or other sensitive domains), of the kind which have enabled great progress in other areas. We have additionally illustrated that such a synthetic dataset does not pose a major privacy concern or constitute a data leak for the original sensitive training data, and that for stricter privacy guarantees, differential privacy can be used in training the RCGAN with some loss to performance.
# REFERENCES
Martín Abadi, Ashish Agarwal, Paul Barham, Eugene Brevdo, Zhifeng Chen, Craig Citro, Greg S. Corrado, Andy Davis, Jeffrey Dean, Matthieu Devin, Sanjay Ghemawat, Ian Goodfellow, Andrew Harp, Geoffrey Irving, Michael Isard, Yangqing Jia, Rafal Jozefowicz, Lukasz Kaiser, Manjunath Kudlur, Josh Levenberg, Dan Mané, Rajat Monga, Sherry Moore, Derek Murray, Chris Olah, Mike Schuster, Jonathon Shlens, Benoit Steiner, Ilya Sutskever, Kunal Talwar, Paul Tucker, Vincent Vanhoucke, Vijay Vasudevan, Fernanda Viégas, Oriol Vinyals, Pete Warden, Martin Wattenberg, Martin Wicke, Yuan Yu, and Xiaoqiang Zheng. TensorFlow: Large-scale machine learning on heterogeneous systems, 2015. URL http://tensorflow.org/. Software available from tensorflow.org.
Martín Abadi, Andy Chu, Ian Goodfellow, H Brendan McMahan, Ilya Mironov, Kunal Talwar, and Li Zhang. Deep learning with differential privacy. In Proceedings of the 2016 ACM SIGSAC
Conference on Computer and Communications Security, pp. 308–318. ACM, 2016.
Grigory Antipov, Moez Baccouche, and Jean-Luc Dugelay. Face aging with conditional generative adversarial networks. arXiv preprint arXiv:1702.01983, 2017.
Martin Arjovsky, Amar Shah, and Yoshua Bengio. Unitary evolution recurrent neural networks. In International Conference on Machine Learning, pp. 1120–1128, 2016.
Martin Arjovsky, Soumith Chintala, and Léon Bottou. Wasserstein GAN. 26 January 2017.
Brett K. Beaulieu-Jones, Zhiwei Steven Wu, Chris Williams, and Casey S. Greene. Privacy-preserving generative deep neural networks support clinical data sharing. bioRxiv, 2017. doi: 10.1101/159756. URL https://www.biorxiv.org/content/early/2017/07/05/159756.
Wacha Bounliphone, Eugene Belilovsky, Matthew B Blaschko, Ioannis Antonoglou, and Arthur Gretton. A test of relative similarity for model selection in generative models. 14 November 2015.
Xi Chen, Yan Duan, Rein Houthooft, John Schulman, Ilya Sutskever, and Pieter Abbeel. InfoGAN: Interpretable representation learning by information maximizing generative adversarial nets. 12 June 2016.
Edward Choi, Siddharth Biswal, Bradley Malin, Jon Duke, Walter F Stewart, and Jimeng Sun. Generating multi-label discrete electronic health records using generative adversarial networks. 19 March 2017.
Cynthia Dwork, Krishnaram Kenthapadi, Frank McSherry, Ilya Mironov, and Moni Naor. Our data, ourselves: Privacy via distributed noise generation. In Eurocrypt, volume 4004, pp. 486–503. Springer, 2006.
Cynthia Dwork, Aaron Roth, et al. The algorithmic foundations of differential privacy. Foundations and Trends $\textsuperscript { \textregistered }$ in Theoretical Computer Science, 9(3–4):211–407, 2014.
Otto Fabius and Joost R van Amersfoort. Variational recurrent auto-encoders. arXiv preprint arXiv:1412.6581, 2014.
Jon Gauthier. Conditional generative adversarial nets for convolutional face generation. Class Project for Stanford CS231N: Convolutional Neural Networks for Visual Recognition, Winter semester, 2014(5):2, 2014.
Ian J Goodfellow, Jean Pouget-Abadie, Mehdi Mirza, Bing Xu, David Warde-Farley, Sherjil Ozair, Aaron Courville, and Yoshua Bengio. Generative adversarial networks. 10 June 2014.
Arthur Gretton, Karsten M Borgwardt, Malte Rasch, Bernhard Schölkopf, and Alex J Smola. A kernel method for the two-sample-problem. In Advances in neural information processing systems, pp. 513–520, 2007.
Ishaan Gulrajani, Faruk Ahmed, Martin Arjovsky, Vincent Dumoulin, and Aaron Courville. Improved training of wasserstein GANs. 31 March 2017.
Sepp Hochreiter and Jürgen Schmidhuber. Long short-term memory. Neural computation, 9(8): 1735–1780, 1997.
Stephanie L Hyland and Gunnar Rätsch. Learning unitary operators with help from u (n). In AAAI 2017, 2017.
Diederik P Kingma and Max Welling. Auto-encoding variational bayes. arXiv preprint arXiv:1312.6114, 2013.
Quoc V Le, Navdeep Jaitly, and Geoffrey E Hinton. A simple way to initialize recurrent networks of rectified linear units. arXiv preprint arXiv:1504.00941, 2015.
Christian Ledig, Lucas Theis, Ferenc Huszár, Jose Caballero, Andrew Cunningham, Alejandro Acosta, Andrew Aitken, Alykhan Tejani, Johannes Totz, Zehan Wang, et al. Photo-realistic single image super-resolution using a generative adversarial network. arXiv preprint arXiv:1609.04802, 2016.
Jiwei Li, Will Monroe, Tianlin Shi, Alan Ritter, and Dan Jurafsky. Adversarial learning for neural dialogue generation. arXiv preprint arXiv:1701.06547, 2017.
Yujia Li, Kevin Swersky, and Richard Zemel. Generative moment matching networks. 10 February 2015.
Mehdi Mirza and Simon Osindero. Conditional generative adversarial nets. arXiv preprint arXiv:1411.1784, 2014.
Olof Mogren. C-RNN-GAN: Continuous recurrent neural networks with adversarial training. 29 November 2016.
Aaron van den Oord, Sander Dieleman, Heiga Zen, Karen Simonyan, Oriol Vinyals, Alex Graves, Nal Kalchbrenner, Andrew Senior, and Kavukcuoglus Koray. Wavenet: A generative model for raw audio. arXiv preprint arXiv:1609.03499, 2016a.
Aaron van den Oord, Nal Kalchbrenner, and Koray Kavukcuoglu. Pixel recurrent neural networks. arXiv preprint arXiv:1601.06759, 2016b.
Nicolas Papernot, Martín Abadi, Úlfar Erlingsson, Ian Goodfellow, and Kunal Talwar. Semisupervised knowledge transfer for deep learning from private training data. arXiv preprint arXiv:1610.05755, 2016.
F. Pedregosa, G. Varoquaux, A. Gramfort, V. Michel, B. Thirion, O. Grisel, M. Blondel, P. Prettenhofer, R. Weiss, V. Dubourg, J. Vanderplas, A. Passos, D. Cournapeau, M. Brucher, M. Perrot, and E. Duchesnay. Scikit-learn: Machine learning in Python. Journal of Machine Learning Research, 12:2825–2830, 2011.
Alec Radford, Luke Metz, and Soumith Chintala. Unsupervised representation learning with deep convolutional generative adversarial networks. arXiv preprint arXiv:1511.06434, 2015.
Scott Reed, Zeynep Akata, Xinchen Yan, Lajanugen Logeswaran, Bernt Schiele, and Honglak Lee. Generative adversarial text to image synthesis. In Proceedings of The 33rd International Conference on Machine Learning, volume 3, 2016.
Tim Salimans, Ian Goodfellow, Wojciech Zaremba, Vicki Cheung, Alec Radford, and Xi Chen. Improved techniques for training GANs. 10 June 2016.
Jonathan Shen, Ruoming Pang, Ron J. Weiss, Mike Schuster, Navdeep Jaitly, Zongheng Yang, Zhifeng Chen, Yu Zhang, Yuxuan Wang, RJ Skerry-Ryan, Rif A. Saurous, Yannis Agiomyrgiannakis, and Yonghui Wu. Natural tts synthesis by conditioning wavenet on mel spectrogram predictions, 2017.
Dougal J Sutherland, Hsiao-Yu Tung, Heiko Strathmann, Soumyajit De, Aaditya Ramdas, Alex Smola, and Arthur Gretton. Generative models and model criticism via optimized maximum mean discrepancy. 14 November 2016.
Lucas Theis, Aäron van den Oord, and Matthias Bethge. A note on the evaluation of generative models. 5 November 2015.
Carl Vondrick, Hamed Pirsiavash, and Antonio Torralba. Generating videos with scene dynamics. In Advances In Neural Information Processing Systems, pp. 613–621, 2016.
Yuhuai Wu, Yuri Burda, Ruslan Salakhutdinov, and Roger Grosse. On the quantitative analysis of Decoder-Based generative models. 14 November 2016.
Zhen Yang, Wei Chen, Feng Wang, and Bo Xu. Improving neural machine translation with conditional sequence generative adversarial nets. arXiv preprint arXiv:1703.04887, 2017.
Lantao Yu, Weinan Zhang, Jun Wang, and Yong Yu. SeqGAN: Sequence generative adversarial nets with policy gradient. 18 September 2016.
# APPENDIX
 Figure 6: Data from three real eICU patients (purple, blue, gold) of the first five hours after admission. Noise from $\textstyle \mathcal { N } ( 0 , \sigma _ { e } ^ { 2 } )$ for $\sigma _ { e } = 0 . 1 \sigma$ has been added to protect privacy, where $\sigma$ is the standard deviation of the true data (for that variable). We compare the data at its original sampling resolution with downsampled to one measurement every 15 minutes (the setting used in this paper) and $3 0 \ \mathrm { \ m i n } -$ utes. High-frequency fluctuations are lost through downsampling, but general trends and some variability are preserved in the 15 minute case. These patients were selected randomly from the set of patients with minimal missing data during the time period and so are representative of the cohort used to generate the training data.
 Figure 7: Three random samples from the generator trained on eICU data. These samples are from the synthetic datasets used in the TSTR experiments in section 5.1. The generator produces data in $[ - 1 , 1 ]$ , so to obtain medically relevant values, the inverse of the scaling transformation used on the training data has been applied. This transformation was to scale each variable at each time-point independently to the range $[ - 1 , 1 ]$ . An unusually high value (likely an artefact) in the mean arterial pressure at 135 minutes after admission is responsible for the apparent downward spike in the generated data.
 (a) Real and synthetic data in the (b) Real and synthetic data in medi- (c) Figure 8b zoomed into the rerange $[ - 1 , 1 ]$ . A scaling transforma- cally meaningful units. For the real gions of most variation. That $\mathrm { \bf S p O 2 }$ tion $T$ is applied to the real data (in- data, this is its original form. The is integer-valued in the original data dependently for each variable at each synthetic data receives the inverse is now apparent. timepoint), and the synthetic data is of the transformation $T$ , producing as produced by the generator. some apparent discontinuities.
Figure 8: Marginal distributions for each variable at each timepoint: Colour intensity shows the fraction of samples at that time point falling within a bin of values (25 bins over the full range) for that variable. Each subfigure shows the same data under different transformations (to and from $[ - 1 , 1 ] )$ , and zooming in. The synthetic data consists of the generated datasets from all five replicates of the TSTR experiment in eICU described in section 5.1 with TSTR results reported in Table 2a. The real data is the training set for those expeirments.
 (a) Over the full range of real values. (b) Zoomed in on the regions of most variation. Figure 9: Histograms comparing the marginal distributions of each eICU variable (over all timepoints) between synthetic and real data. The synthetic data is that used in the TSTR experiments (five replicates) in section 5.1.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522# PROGRAM GUIDED AGENT
Shao-Hua Sun, Te-Lin Wu, Joseph J. Lim University of Southern California {shaohuas,telinwu,limjj}@usc.edu
# ABSTRACT
Developing agents that can learn to follow natural language instructions has been an emerging research direction. While being accessible and flexible, natural language instructions can sometimes be ambiguous even to humans. To address this, we propose to utilize programs, structured in a formal language, as a precise and expressive way to specify tasks. We then devise a modular framework that learns to perform a task specified by a program – as different circumstances give rise to diverse ways to accomplish the task, our framework can perceive which circumstance it is currently under, and instruct a multitask policy accordingly to fulfill each subtask of the overall task. Experimental results on a 2D Minecraft environment not only demonstrate that the proposed framework learns to reliably accomplish program instructions and achieves zero-shot generalization to more complex instructions but also verify the efficiency of the proposed modulation mechanism for learning the multitask policy. We also conduct an analysis comparing various models which learn from programs and natural language instructions in an end-to-end fashion.
# 1 INTRODUCTION
Humans are capable of leveraging instructions to accomplish complex tasks. A comprehensive instruction usually comprises a set of descriptions detailing a variety of situations and the corresponding subtasks that are required to be fulfilled. To accomplish a task, we can leverage instructions to estimate the progress, recognize the current state, and perform corresponding actions. For example, to make a gourmet dish, we can follow recipes and procedurally create the desired dish by recognizing what ingredients and tools are missing, what alternatives are available, and what corresponding preparations are required. With sufficient practice, we can improve our ability to perceive (e.g. knowing when food is well-cooked) as well as master cooking skills (e.g. cutting food into same-sized pieces), and eventually accomplish difficult recipes.
Can machines likewise learn to follow and exploit comprehensive instructions like humans? Utilizing expert demonstrations to instruct agents has been widely studied in (Finn et al., 2017; Yu et al., 2018b; Xu et al., 2018; Pathak et al., 2018; Stadie et al., 2017; Duan et al., 2017; Wang et al., 2017b). However, demonstrations could be expensive to obtain and are less flexible (e.g. altering subtask orders in demonstrations is nontrivial). On the other hand, natural language instructions are flexible and expressive (Malmaud et al., 2014; Jermsurawong & Habash, 2015; Kiddon et al., 2015; Misra et al., 2018; Fried et al., 2018; Kaplan et al., 2017; Bahdanau et al., 2019). Yet, language has the caveat of being ambiguous even to humans, due to its lacking of structure as well as unclear coreferences and entities. Andreas et al. (2017a); Oh et al. (2017) investigate a hierarchical approach, where the instructions consist of a set of symbolically represented subtasks. Nonetheless, those instructions are not a function of states (i.e. describe a variety of circumstances and the corresponding desired subtasks), which substantially limits their expressiveness.
We propose to utilize programs, written in a formal language, as a structured, expressive, and unambiguous representation to specify tasks. Specifically, we consider programs, which are composed of control flows (e.g. if/else and loops), environmental conditions, as well as corresponding subtasks, as shown in Figure 1. Not only do programs have expressiveness by describing diverse situations (e.g. a river exists) and the corresponding subtasks which are required to be executed (e.g. mining wood), but they are also unambiguous due to their explicit scoping. To study the effectiveness of using programs as task specifications, we introduce a new problem, where we aim to develop a framework which learns to comprehend a task specified by a program as well as perceive and interact with the environment to accomplish the task.
 Figure 1: An illustration of the proposed problem. We are interested in learning to fulfill tasks specified by written programs. A program consists of control flows (e.g. if, while), branching conditions (e.g. is_there[River]), and subtasks (e.g. mine(Wood)).
 Figure 2: The domain-specific language (DSL) for constructing programs. Each program is composed of domain dependent perception, subtasks, and control flows.
To address this problem, we propose a modular framework, program guided agent, which exploits the structural nature of programs to decompose and execute them as well as learn to ground program tokens with the environment. Specifically, our framework consists of three modules: (1) a program interpreter that leverages a grammar provided by the programming language to parse and execute a program, (2) a perception module that learns to respond to conditional queries (e.g. is_there[River]) produced by the interpreter, and (3) a policy that learns to fulfill a variety of subtasks (e.g. mine(Wood)) extracted from the program by the interpreter. To effectively instruct the policy with symbolically represented subtasks, we introduce a learned modulation mechanism that leverages a subtask to modulate the encoded state features instead of concatenating them. Our framework (shown in Figure 3) utilizes a rule-based program interpreter to deal with programs as well as learning perception module and policy when it is necessary to perceive or interact with the environment. With this modularity, our framework can generalize to more complex program-specified tasks without additional learning.
To evaluate the proposed framework, we consider a Minecraft-inspired 2D gridworld environment, where an agent can navigate itself across different terrains and interact with objects, similar to Andreas et al. (2017a); Sohn et al. (2018). A corresponding domain-specific language (DSL) defines the rules of constructing programs for instructing an agent to accomplish certain tasks. Our proposed framework demonstrates superior generalization ability – learning from simpler tasks while generalizing to complex tasks. We also conduct extensive analysis on various end-to-end learning models which learns from not only program instructions but also natural language descriptions. Furthermore, our proposed learned policy modulation mechanism yields a better learning efficiency compared to other commonly used methods that simply concatenate a state and goal.
# 2 RELATED WORK
Learning from language instructions. Prior works have investigated leveraging natural languages to specify tasks on a wide range of applications, including navigation (Misra et al., 2018; Tellex et al., 2011; Fried et al., 2018; Vogel & Jurafsky, 2010; Shimizu & Haas, 2009; Branavan et al., 2009; 2012; Misra et al., 2017; Tellex et al., 2011), spatial reasoning for goal reaching (Janner et al., 2018), game playing (Kaplan et al., 2017; Fried et al., 2017; Co-Reyes et al., 2019), and grounding visual concepts (Kaplan et al., 2017; Bahdanau et al., 2019; Andreas et al., 2017b). However, natural language descriptions can often be ambiguous even to humans. Moreover, it is not clear how end-toend learning agents trained with simpler instructions can generalize well to much more complex ones. In contrast, we propose to utilize a precise and structured representation, programs, to specify tasks.
Learning from demonstrations. When a task cannot be easily described in languages (e.g. object texture or geometry), expert demonstrations offer an alternative way to provide instructions. Prior works have explored learning from video demonstrations (Finn et al., 2017; Yu et al., 2018b; Xu et al., 2018; Pathak et al., 2018; Stadie et al., 2017; Aytar et al., 2018) or expert trajectories (Duan et al., 2017; Wang et al., 2017b). However, demonstrations can be expensive to obtain and are less expressive about diverging behaviors of a complex task, which are better captured by control flow in programs. Moreover, editing demonstrations such as rearranging the order of subtasks is often difficult.
Program induction and synthesis. To learn acquire programmatic skills such as digit addition and string transformations and achieve better generalization, program induction methods (Xu et al., 2018; Devlin et al., 2017a; Neelakantan et al., 2015; Graves et al., 2014; Kaiser & Sutskever, 2016; Reed & De Freitas, 2016; Cai et al., 2017; Xiao et al., 2018) aim to implicitly induce the underlying programs to mimic the behaviors demonstrated in task specifications (e.g. input/output pairs, demonstrations). On the other hand, program synthesis methods (Bošnjak et al., 2017; Parisotto et al., 2017; Devlin et al., 2017b; Chen et al., 2019; Shin et al., 2018; Bunel et al., 2018; Liu et al., 2019; Sun et al., 2018; Lin et al., 2018; Liao et al., 2019) explicitly synthesize the underlying programs and execute the programs to perform the tasks. Instead of trying to infer programs from task specifications, we are interested in explicitly executing programs. Also, our framework can potentially be leveraged to obtain program execution results for evaluating program synthesis frameworks when no program executor is available (e.g. programs describe real-world activities instead of behaviors in simulation).
Symbolic planing and programmable agent. Classical symbolic planning concerns the problem of achieving a goal state from an initial state through a series of symbolically represented executions (Ghallab et al.; Konidaris et al., 2018). Our work shares a similar spirit but assume a task (i.e. a program) is given, where the agent is required to learn to ground symbolic concepts (Mao et al., 2019; Han et al., 2019) and follow the control flow. Executing programs with reinforcement learning has been studied in programmable hierarchies of abstract machines (Parr & Russell, 1998; Andre & Russell, 2001; 2002), which provide partial descriptions and subroutines of the desired task. Denil et al. (2017); Lázaro-Gredilla et al. (2018) train agents to execute declarative programs by grounding these well-structured languages in their learning environments. In contrast, our modular framework consists of modules for perceiving the environment and interacting with it by following an imperative program which specifies the task. An extended discussion on the related work can be found in Section C.
# 3 PROBLEM FORMULATION
We are interested in learning to comprehend and execute an instruction specified by a program to fulfill the desired task. In this section, we formally describe our definition of programs, the family of Markov Decision Processes (MDPs), and the problem formulation.
Program. The programs considered in this work are defined based on a Domain Specific Language (DSL) as shown in Figure 2. The DSL is composed of perception primitives, action primitives, and control flow. A perception primitive indicates circumstances in the environment (e.g. is_there(River), and agent $[ \mathsf { G o l d } ] < 3 \rangle$ ) that can be perceived by an agent, while an action primitive defines a subtask that describes a certain behavior (e.g. mine(Gold), and goto(1,1)). Control flow includes $\boldsymbol { \mathrm { i } } \in / \mathrm { e } \boldsymbol { \mathrm { 1 } } \mathrm { s } \mathrm { e }$ statements, loops, and Boolean/logical operators to compose more sophisticated conditions. A program $p$ is a deterministic function that outputs a desired behavior (i.e. subtask) given a history of states $o _ { t } = p \left( H _ { j } \right)$ , where $H _ { j } = \{ s _ { 1 } , . . . , s _ { t } \}$ is a state history with $s \in S$ denoting a state of the environment, and $o \in \mathcal { O }$ denotes an instructed behavior (subtask). We denote a program as $p \sim \mathcal { P }$ , an infinite program set containing all executable programs given a DSL. Note that a discussion on the DSL design principle can be found in Section B.
MDPs. We consider a family of finite-horizon discounted MDPs in a shared environment, specified by a tuple $( \mathcal { S } , \mathcal { A } , \mathcal { P } , \mathcal { T } , \mathcal { R } , \rho , \gamma )$ , where $s$ denotes a set of states, $\mathcal { A }$ denotes a set of low-level actions an agent can take, $\mathcal { P }$ denotes a set of programs specifying instructions, $\mathcal { T } : \mathcal { S } \times \mathcal { A } \times \mathcal { S } \mathbb { R }$ denotes a transition probability distribution, $\mathcal { R }$ denotes a task-specific reward function, $\rho$ denotes an initial state distribution, and $\gamma$ denotes a discount factor. For a fixed sequence $\left\{ { \left( { { s _ { 0 } } , { a _ { 0 } } } \right) , . . . , { \left( { { s _ { t } } , { a _ { t } } } \right) } } \right\}$ of states and actions obtained from a rollout of a given policy $\pi$ , the performance of the policy is evaluated based on a discounted return $\scriptstyle \sum _ { t = 0 } ^ { T } \gamma ^ { t } r _ { t }$ , where $T$ is the horizon of the episode.
 Figure 3: Program Guided Agent. The proposed modular framework comprehends and fulfills a desired task specified by a program. The program interpreter executes the program by altering between querying the perception module with a query $q$ when an environment condition is encountered (e.g. env[Gold] ${ > } 0$ , is_there[River]) and instructing a policy when it needs to fulfill a goal/subtask $g$ (e.g. mine(Gold), build_bridge()). The perception module produces a response $h$ to answer the query, determining which paths in the program should be chosen. The policy takes a sequence of low-level actions $a$ (e.g. moveUp, moveLeft, Pickup) interacting with the environment to accomplish the given subtask (e.g. mine(Gold)).
Problem Formulation. We consider developing a framework which can comprehend and fulfill an instruction specified by a program. Specifically, we consider a sampled MDP with a program describing the desired task. Addressing this task requires the ability to keep track of which parts of the program are finished and which parts are not, perceiving the environment and deciding which paths in the program to take, and performing actions interacting with the environment to fulfill subtasks.
# 4 APPROACH
Accomplishing an instructed task described by a program requires (1) executing the program control flow and conditions, (2) recognizing the situations to infer which path in the program should be chosen, and (3) executing a series of actions interacting with the environment to fulfill the subtasks. Based on this intuition, we design a modular framework with three modules:
• Program interpreter (Section 4.1) reads a program and executes it by querying a perception module with environment conditions (e.g. env $[ \mathsf { G o l d } ] > 0 $ ) and instructing the policy with subtasks (e.g. mine(Gold)). • Perception module (Section 4.2) responds to perception queries (e.g. env[Gold] ${ > } 0$ ) by examining the observation and predicting responses (e.g. true). • Policy (action module) (Section 4.3) performs low-level actions (e.g. moveUp, moveLeft, pickUp) to fulfill the symbolically represented subtasks (e.g. mine(Gold)) provided by the program interpreter.
Our key insight is to only learn a module when its input or output is associated with the environment (i.e. a function approximator is needed) – the perception module learns to ground the queries to its observation and answer them; the policy learns to ground the symbolically represented subtasks and interact with the environment in a trial-and-error way (Section 4.4). On the other hand, we do not learn the program interpreter; instead, we utilize a rule-based parser to execute programs An overview of the proposed framework is illustrated in Figure 3.
# 4.1 PROGRAM INTERPRETER
To execute a program instruction, we group program tokens into three main categories: (1) subtasks indicate what the agent should perform (e.g. mine(Gold)), (2) perceptions the essential information extracted from the environment (e.g. env $[ \mathsf { G o l d } ] > 0 $ ), and (3) control flows determine which paths in a program should be taken according to the perceived information (i.e. perceptions). Then, we devise a program interpreter, which can execute and keep track of the progress by leveraging the structure of programs. Specifically, it consists of a program line parser and a program executor. The parser first transforms the program into a program tree by representing each line of a program as a tree node. Each node is either a leaf node (subtask) or a non-leaf node (perception or control flow) that has various subroutines as children nodes. The executor then performs a pre-order traversal on the program tree to execute the program, utilizing the parsed contents to alternate between querying the perception module when an environment condition is encountered and instructing the policy when it reaches to a leaf node (subtask). The details and the algorithm are summarized in section A. Note that the program interpreter is a rule-based algorithm instead of a learning module.
# 4.2 PERCEPTION MODULE
Determining which paths should be chosen when executing a program requires grounding a symbolically represented query (e.g. is_there[River] can be represented as a sequence of symbols) and perceiving the environment. To this end, we employ a perception module $\Phi$ that learns to map a query and current observation to a response: $h = \Phi ( q , s )$ , where $q$ denotes a query, and $h$ denotes the corresponding perception output (e.g. true/false). Note that we focus on Boolean perception outputs in this paper, but a more generic perception type can be used (e.g. object attributes such as color, shape, and size).
# 4.3 POLICY
When program execution reaches a subtask/leaf node (e.g. mine(Gold)), the agent is required to take a sequence of low-level actions (e.g. moveUp, moveLeft, Pickup) to interact with the environment to fulfill it. To enable the execution, we employ a multitask policy $\pi$ (i.e. action module) which is instructed by a symbolic goal (e.g. mine(Gold)) provided by the program interpreter indicating the details of the corresponding subtask. To learn to perform different subtasks, we train the policy using actor-critic reinforcement learning, which takes a goal vector $g$ and an environment state $s$ and outputs a probabilistic distribution $a$ for low-level actions $a \sim \pi ( s _ { t } , g _ { t } | \theta )$ . The value estimator used for our policy optimization is also goal-conditioned: $\begin{array} { r } { V _ { \pi } ( s _ { t } , g _ { t } ) = \mathbb E [ \sum _ { t } \gamma ^ { t } R _ { t } | s _ { 0 } = s , \pi , g _ { t } ] } \end{array}$ .
While the most common way to feed a state and goal to a policy parameterized by a neural network is to concatenate them in a raw space or a latent space, we find this less effective when the policy has to learn a diverse set of tasks. Therefore, we propose a modulation mechanism to effectively learn the policy. Specifically, we employ a goal network to encode the goal and compute affine transform parameters $\gamma$ and $\beta$ , which are used to modulate state features $e _ { s }$ to $\hat { e } _ { s } = \gamma \cdot e _ { s } + \beta$ . Then, the modulated features $\hat { e } _ { s }$ are used to predict action $a$ and value $V$ . With the modulation mechanism, the goal network learns to activate state features related to the current goal and deactivate others. An illustration is shown in Figure 4 (a). A more detailed discussion of the related works that utilize similar learned modulation mechanisms can be found in Section D.
# 4.4 LEARNING
To follow a program by perceiving the environment and taking actions to interact with it, we employ two learning modules: a perception module and a policy. In this section, we discuss how each module is trained, their training objectives, and optimization methods. More training details and the architectures can be found in section E.4.1.
# 4.4.1 PERCEPTION MODULE
We formulate training the perception module as a supervised learning task. Given tuples of (query $q$ state $s$ , ground truth perception $h _ { g t }$ ), we train a neural network $\Phi$ to predict the perception output $h$ by optimizing the binary cross-entropy loss: $\mathcal { L } _ { C E } = - h _ { g t } l o g ( h ) - \bar { ( 1 - h _ { g t } ) l o g ( 1 - h ) }$ . A query such as is_there[River] is represented as a sequence of symbols. Note that when perception describes more than a Boolean, training the perception module can be done by optimizing other losses such as categorical cross-entropy loss. We train the perception module only on the queries appearing in the training programs with randomly sampled states, requiring it to generalize to novel queries to perform well in executing testing programs.
 Figure 4: Learning a multitask policy via learned modulation. (a) A multitask policy takes both a state $s$ and a goal specification $g$ as inputs and produces an action distribution $a \sim \pi ( s , g )$ . Instead of simply concatenating the state and goal in a raw space or a latent space, we propose to modulate state features $e _ { s }$ using the goal. Specifically, the goal network learns to predict affine transform parameters $\gamma$ and $\beta$ to modulate the state features ${ \hat { e } } _ { s } = \gamma \cdot e _ { s } + \beta$ . Then, the final layers use the modulated features to predict actions. (b) We experiment different ways of feeding a state and goal for learning a multitask policy. The training curves demonstrate that all modulation variants, including modulating state feature maps of convolutional layers (Modulation conv), modulating state feature vectors of fully-connected layers (Modulation fc), or both (Modulation conv $f { \boldsymbol { c } }$ ), are more efficient than concatenating the state and the goal in a raw space (Concat raw) or a latent space (Concat).
# 4.4.2 POLICY
We train the policy using Advantage Actor-Critic (A2C) (Mnih et al., 2016; Dhariwal et al., 2017), which is commonly used for gridworld environments with discrete action spaces. A2C computes policy gradients $A _ { t } \nabla _ { \theta } \log \pi _ { \theta } \left( a _ { t } | s _ { t } , g _ { t } \right)$ , where $A _ { t } = R _ { t } - V \big ( s _ { t } , g _ { t } \big )$ is the advantage function based on empirical return $R _ { t }$ starting from $s _ { t }$ and learned value estimator $V ( s _ { t } , g _ { t } )$ conditioning on the goal vector $g _ { t }$ . We denote the learning rate as $\alpha$ , and the policy update rule is as follows:
$$\begin{array} { r } { \theta \theta + \alpha ( A _ { t } \nabla _ { \theta } \log \pi _ { \theta } ( a _ { t } | s _ { t } , g _ { t } ) + \beta \nabla _ { \theta } H _ { \pi _ { \theta } } ) , } \end{array}$$
where $H _ { \pi _ { \theta } }$ denotes the policy entropy, where maximizing it improves overall exploration, and $\beta$ determines the strength of the entropy regularization term.
# 5 EXPERIMENTS
Our experiments aim to answer the following questions: (1) Can our proposed framework learn to perform tasks specified by programs? (2) Can our modular framework generalize better to more complex tasks compared to end-to-end learning models? (3) How well can a variety of end-to-end learning models (e.g. LSTM, Tree-RNN, Transformer) learn from programs and natural language instructions? (4) Is the proposed learned modulation more efficient to learn a multitask (multi-goal) policy than simply concatenating a state and goal?
# 5.1 EXPERIMENTAL SETUPS
# 5.1.1 ENVIRONMENT
To evaluate the proposed framework in an environment where an agent can perceive diverse scenarios and interact with the environment to perform various subtasks, we construct a discrete Minecraftinspired gridworld environment, similar to Andreas et al. (2017a); Sohn et al. (2018). As illustrated in Figure 1, the agent can navigate through a grid world and interact with resources (e.g. Wood, Iron, Gold) and obstacles (e.g. River, Wall), build tools (e.g. Bridge), and sell resources to a merchant visualized as an alpaca. The environment gives a sparse task completion reward of $+ 1$ when an instruction (i.e. an entire program or natural language instruction) is successfully executed. More details can be found in Section E.1.
Table 1: Task completion rate. For each method, we iterate over all the programs in a testing set by randomly sampling ten initial environment states and running three models trained using different random seeds for this method. The averaged task completion rates and their standard deviations are reported. Note that all the end-to-end learning models learning from natural language descriptions and programs suffer from a significant performance drop when evaluated on the more complex testing set.
<table><tr><td rowspan="2" colspan="2">Instruction Method</td><td colspan="4">Natural language descriptions</td><td rowspan="2" colspan="4">Programs</td></tr><tr><td>Seq-LSTM</td><td>Transformer</td><td>Seq-LSTM Tree-RNN</td><td>Transformer</td><td>Ours (concat)</td></tr><tr><td rowspan="2">Dataset</td><td>test</td><td>54.9±1.8%</td><td>52.5±2.6%</td><td>56.7±1.9%</td><td>50.1±1.2%</td><td>49.4±1.6%</td><td>88.6±0.8%</td><td>Ours 94.0±0.5%</td></tr><tr><td>test-complex</td><td>32.4±4.9%</td><td>38.2±2.6%</td><td>38.8±1.2%</td><td>42.2±2.4%</td><td>40.9±1.5%</td><td>85.2±0.8%</td><td>91.8±0.2%</td></tr><tr><td colspan="2">Generalization gap</td><td>40.9%</td><td>27.2%</td><td>31.6%</td><td>15.8%</td><td>17.2%</td><td>3.8%</td><td>2.3%</td></tr></table>
# 5.1.2 TASK INSTRUCTIONS
Programs. We sample 4,500 programs using our DSL and split them into 4,000 training programs (train) and 500 testing programs (test). To examine the framework’s ability to generalize to more complex instructions, we generate 500 programs which are twice longer and contains more condition branches on average to construct a harder testing set (test-complex).
Natural language instructions. To obtain the natural language counterparts of those instructions, we asked annotators to construct natural language translations of all the programs. The data collection details, as well as sample programs and their corresponding natural language translations, can be found in Section E.3, and figure 10 respectively. We include a brief discussion on how annotated natural language instructions can be ambiguously interpreted as several valid programs.
# 5.2 TRAINING
During training, we randomly sample programs from the training set as well as randomly sample an environment state to execute the program interpreter. The program interpreter produces a goal to instruct the policy when encountering a subtask in the program. The policy takes actions $a \sim \pi ( s , g )$ and receive reward $+ 1$ only when the entire program is completed. While we do not explicitly introduce a curriculum like Andreas et al. (2017a), this setup naturally induces a curriculum where the policy first learns to solve simpler programs and gain a better understanding of subtasks by obtaining the task completion, which eventually allows the policy to complete more complex programs. Note that the perception module is pre-trained beforehand in a supervised manner. More training details can be found in section E.7.
# 5.3 END-TO-END LEARNING MODELS
In contrast to the proposed modular framework, we experiment with a variety of end-to-end learning models. Considering programs and natural language instructions as sequences of tokens, we investigate two types of state-of-the-art sequence encoders: LSTM (Hochreiter & Schmidhuber, 1997) (Seq-LSTM), and Transformers (Vaswani et al., 2017; Devlin et al., 2018) (Transformer). To leverage the explicit structure of programs, we also investigate encoding programs using a generalization of RNNs for tree-structured input (Tai et al., 2015; Alon et al., 2019) (Tree-RNN). All the models are trained using A2C. The details of these architectures can be found in Section E.4.2.
# 5.4 RESULTS
# 5.4.1 TASK COMPLETION
We train the proposed framework and the end-to-end learning models on training programs and evaluate their performances using the percentage of completed instructions on test and test-complex sets (shown in Table 1). Our proposed framework achieves a satisfactory test performance and only suffers a negligible drop (i.e. generalization gap) when it is evaluated on test-complex set. This can be attributed to the modular design, which explicitly utilizes the structure and grammar of programs, allowing the two learning modules (i.e. perception and policy) to focus on their local jobs. A more detailed failure analysis can be found in Section E.6.
 Figure 5: Analysis on end-to-end learning models: (a) Models learning from programs generalize better to longer instructions. Transformer is more robust to longer instructions (Upper). Tree-RNN exploiting the program structure generalizes the best, but performs worst for shorter programs (Lower). (b) Seq-LSTM learning from both instructions performs worse as the diversity increases. Transformer learns better from natural language when the instructions are less diverse (Upper). Transformer and Tree-RNN learning from programs are more consistent as the diversity increases, yet perform worse on less diverse instructions (Lower).
On the other hand, all the end-to-end learning models suffer a significant performance drop between test and test-complex sets, while it is less significant for the models learning from programs, potentially indicating that models learning from instructions with explicit structures can generalize to complex instructions better. Among them, Seq-LSTM achieves the best results on test set, but performs the worst on the test-complex set. Transformer has smaller generalization gaps, which could be attributed to their multi-head attention mechanism, capturing the instruction semantics better. By leveraging the explicit structure of programs, Tree-RNN achieves the best generalization performance.
# 5.4.2 ANALYSIS
An analysis on the end-to-end learning models with respect to varying instruction length and complexity is shown in Figure 5, where all the instructions from test and test-complex sets are considered.
Instruction length. As shown in Figure 5 (a), both Seq-LSTM and Transformer suffer from a performance drop as the instruction length increases. Seq-LSTM performs better when instructions are shorter, but suffers from generalizing to longer instructions. On the other hand, Transformer may learn on a more semantic level, which leads to similar overall performances across two types of instructions. Tree-RNN leverages the structure of programs and achieves a better performance.
Instruction diversity. We define the diversity of a program based on the number of control flows it contains (i.e. number of branches). Figure 5 (b) shows a clear trend of performance drop of all the models. Transformer is more robust to diverse instructions which could be attributed to its better ability to learn the semantics. While Seq-LSTM learning from programs are consistently better across different levels of diversities, Tree-RNN demonstrates the most consistent performances.
# 5.5 POLICY MODULATION
We investigate if learning a multitask policy with the learned modulation mechanism is more effective. We compare against the two most commonly used methods: concatenating a state and goal in a raw space (Concat raw) or a latent space (Concat). An illustration is shown in Figure 4 (a). Since our state contains an environment map, which is encoded by a CNN and MLP, we experiment modulating convoluted feature maps (Modulation conv) or feature vectors (Modulation fc) or both (Modulation conv fc). Figure 4 (b) demonstrate that the proposed policy modulation mechanism is more sample efficient. Table 1 shows that the multitask policy learning using modulation achieves better performance on task completion.
# 6 CONCLUSION
We propose to utilize programs, structured in a formal language, as an expressive and precise way to specify tasks instead of commonly used natural language instructions. We introduce the problem of developing a framework that can comprehend a program as well as perceive and interact with the environment to accomplish the desired task. To address this problem, we devise a modular framework, program guided agent, which executes programs with a program interpreter by altering between querying a perception module when a branching condition is encountered and instructing a policy to fulfill subtasks. We employ a policy modulation mechanism to improve the efficiency of learning the multitask policy. The experimental results on a 2D Minecraft environment demonstrate that the proposed framework learns to reliably fulfill program instructions and generalize well to more complex instructions without additional training. We also investigate the performance of various models that learn from programs and natural language descriptions in an end-to-end fashion.
# ACKNOWLEDGMENTS
The authors are grateful for the fruitful discussion with Jiayuan Mao, Yuan-Hong Liao, Youngwoon Lee, Karl Pertsch, and Ayush Jain. The authors would like to thank Sriram Somasundaram for contributing to building the environment and Aleksei Petrenko for the A2C implementation.
# REFERENCES
Martín Abadi, Paul Barham, Jianmin Chen, Zhifeng Chen, Andy Davis, Jeffrey Dean, Matthieu Devin, Sanjay Ghemawat, Geoffrey Irving, Michael Isard, et al. Tensorflow: A system for large-scale machine learning. In USENIX Symposium on Operating Systems Design and Implementation, 2016.
Amjad Almahairi, Sai Rajeswar, Alessandro Sordoni, Philip Bachman, and Aaron Courville. Augmented cyclegan: Learning many-to-many mappings from unpaired data. In International Conference on Machine Learning, 2018.
Uri Alon, Omer Levy, and Eran Yahav. code2seq: Generating sequences from structured representations of code. International Conference on Learning Representations, 2019.
David Andre and Stuart J Russell. Programmable reinforcement learning agents. In Advances in Neural Information Processing Systems, 2001.
David Andre and Stuart J Russell. State abstraction for programmable reinforcement learning agents. In National Conference on Artificial Intelligence, 2002.
Jacob Andreas, Dan Klein, and Sergey Levine. Modular multitask reinforcement learning with policy sketches. In International Conference on Machine Learning, 2017a.
Jacob Andreas, Dan Klein, and Sergey Levine. Learning with latent language. In North American Chapter of the Association for Computational Linguistics, 2017b.
Yusuf Aytar, Tobias Pfaff, David Budden, Thomas Paine, Ziyu Wang, and Nando de Freitas. Playing hard exploration games by watching youtube. In Advances in Neural Information Processing Systems. 2018.
Pierre-Luc Bacon, Jean Harb, and Doina Precup. The option-critic architecture. In Association for the Advancement of Artificial Intelligence, 2017.
Dzmitry Bahdanau, Felix Hill, Jan Leike, Edward Hughes, Pushmeet Kohli, and Edward Grefenstette. Learning to understand goal specifications by modelling reward. In International Conference on Learning Representations, 2019.
Bram Bakker, Jürgen Schmidhuber, et al. Hierarchical reinforcement learning based on subgoal discovery and subpolicy specialization. In Intelligent Autonomous Systems, 2004.
Matko Bošnjak, Tim Rocktäschel, Jason Naradowsky, and Sebastian Riedel. Programming with a differentiable forth interpreter. In International Conference on Machine Learning, 2017.
Satchuthananthavale RK Branavan, Harr Chen, Luke S Zettlemoyer, and Regina Barzilay. Reinforcement learning for mapping instructions to actions. In Association for Computational Linguistics, 2009.
SRK Branavan, Nate Kushman, Tao Lei, and Regina Barzilay. Learning high-level planning from text. In Association for Computational Linguistics, 2012.
Rudy R Bunel, Matthew Hausknecht, Jacob Devlin, Rishabh Singh, and Pushmeet Kohli. Leveraging grammar and reinforcement learning for neural program synthesis. In International Conference on Learning Representations, 2018.
Jonathon Cai, Richard Shin, and Dawn Song. Making neural programming architectures generalize via recursion. In International Conference on Learning Representations, 2017.
Xinyun Chen, Chang Liu, and Dawn Song. Execution-guided neural program synthesis. In International Conference on Learning Representations, 2019.
John D Co-Reyes, Abhishek Gupta, Suvansh Sanjeev, Nick Altieri, John DeNero, Pieter Abbeel, and Sergey Levine. Guiding policies with language via meta-learning. International Conference on Learning Representations, 2019.
Misha Denil, Sergio Gómez Colmenarejo, Serkan Cabi, David Saxton, and Nando de Freitas. Programmable agents. arXiv preprint arXiv:1706.06383, 2017.
Aditya Desai, Sumit Gulwani, Vineet Hingorani, Nidhi Jain, Amey Karkare, Mark Marron, Subhajit Roy, et al. Program synthesis using natural language. In International Conference on Software Engineering, 2016.
Jacob Devlin, Rudy R Bunel, Rishabh Singh, Matthew Hausknecht, and Pushmeet Kohli. Neural program meta-induction. In Advances in Neural Information Processing Systems, 2017a.
Jacob Devlin, Jonathan Uesato, Surya Bhupatiraju, Rishabh Singh, Abdel-rahman Mohamed, and Pushmeet Kohli. Robustfill: Neural program learning under noisy i/o. In International Conference on Machine Learning, 2017b.
Jacob Devlin, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova. Bert: Pre-training of deep bidirectional transformers for language understanding. In North American Chapter of the Association for Computational Linguistics, 2018.
Prafulla Dhariwal, Christopher Hesse, Oleg Klimov, Alex Nichol, Matthias Plappert, Alec Radford, John Schulman, Szymon Sidor, Yuhuai Wu, and Peter Zhokhov. Openai baselines, 2017.
Bhuwan Dhingra, Hanxiao Liu, Zhilin Yang, William W Cohen, and Ruslan Salakhutdinov. Gatedattention readers for text comprehension. In Association for Computational Linguistics, 2017.
Nat Dilokthanakul, Christos Kaplanis, Nick Pawlowski, and Murray Shanahan. Feature control as intrinsic motivation for hierarchical reinforcement learning. arXiv preprint arXiv:1705.06769, 2017.
Yan Duan, Marcin Andrychowicz, Bradly Stadie, OpenAI Jonathan Ho, Jonas Schneider, Ilya Sutskever, Pieter Abbeel, and Wojciech Zaremba. One-shot imitation learning. In Advances in Neural Information Processing Systems, 2017.
Vincent Dumoulin, Jonathon Shlens, and Manjunath Kudlur. A learned representation for artistic style. In International Conference on Learning Representations, 2017.
Chelsea Finn, Tianhe Yu, Tianhao Zhang, Pieter Abbeel, and Sergey Levine. One-shot visual imitation learning via meta-learning. In Conference on Robot Learning, 2017.
Kevin Frans, Jonathan Ho, Xi Chen, Pieter Abbeel, and John Schulman. Meta learning shared hierarchies. In International Conference on Learning Representations, 2018.
Daniel Fried, Jacob Andreas, and Dan Klein. Unified pragmatic models for generating and following instructions. In North American Chapter of the Association for Computational Linguistics, 2017.
Daniel Fried, Ronghang Hu, Volkan Cirik, Anna Rohrbach, Jacob Andreas, Louis-Philippe Morency, Taylor Berg-Kirkpatrick, Kate Saenko, Dan Klein, and Trevor Darrell. Speaker-follower models for vision-and-language navigation. In Neural Information Processing Systems, 2018.
Malik Ghallab, Dana Nau, and Paolo Traverso. Automated Planning: theory and practice. Elsevier.
Alex Graves, Greg Wayne, and Ivo Danihelka. Neural turing machines. arXiv preprint arXiv:1410.5401, 2014.
Chi Han, Jiayuan Mao, Chuang Gan, Josh Tenenbaum, and Jiajun Wu. Visual concept-metaconcept learning. In Neural Information Processing Systems. 2019.
Sepp Hochreiter and Jürgen Schmidhuber. Long short-term memory. Neural Computation, 1997.
Jie Hu, Li Shen, and Gang Sun. Squeeze-and-excitation networks. In IEEE Conference on Computer Vision and Pattern Recognition, 2018.
Minyoung Huh, Shao-Hua Sun, and Ning Zhang. Feedback adversarial learning: Spatial feedback for improving generative adversarial networks. In IEEE Conference on Computer Vision and Pattern Recognition, 2019.
Michael Janner, Karthik Narasimhan, and Regina Barzilay. Representation learning for grounded spatial reasoning. Association for Computational Linguistics, 2018.
Jermsak Jermsurawong and Nizar Habash. Predicting the structure of cooking recipes. In Empirical Methods in Natural Language Processing, 2015.
Łukasz Kaiser and Ilya Sutskever. Neural gpus learn algorithms. In International Conference on Learning Representations, 2016.
Russell Kaplan, Christopher Sauer, and Alexander Sosa. Beating atari with natural language guided reinforcement learning. arXiv preprint arXiv:1704.05539, 2017.
Tero Karras, Samuli Laine, and Timo Aila. A style-based generator architecture for generative adversarial networks. In IEEE Conference on Computer Vision and Pattern Recognition, 2019.
Chloé Kiddon, Ganesa Thandavam Ponnuraj, Luke Zettlemoyer, and Yejin Choi. Mise en place: Unsupervised interpretation of instructional recipes. In Empirical Methods in Natural Language Processing, 2015.
George Konidaris, Leslie Pack Kaelbling, and Tomas Lozano-Perez. From skills to symbols: Learning symbolic representations for abstract high-level planning. Journal of Artificial Intelligence Research, 2018.
Tejas D Kulkarni, Karthik Narasimhan, Ardavan Saeedi, and Josh Tenenbaum. Hierarchical deep reinforcement learning: Integrating temporal abstraction and intrinsic motivation. In Advances in Neural Information Processing Systems, 2016.
Miguel Lázaro-Gredilla, Dianhuan Lin, J Swaroop Guntupalli, and Dileep George. Beyond imitation: Zero-shot task transfer on robots by learning concepts as cognitive programs. arXiv preprint arXiv:1812.02788, 2018.
Yoonho Lee and Seungjin Choi. Gradient-based meta-learning with learned layerwise metric and subspace. In International Conference on Machine Learning, 2018.
Youngwoon Lee, Shao-Hua Sun, Sriram Somasundaram, Edward Hu, and Joseph J. Lim. Composing complex skills by learning transition policies. In International Conference on Learning Representations, 2019.
Yuan-Hong Liao, Xavier Puig, Marko Boben, Antonio Torralba, and Sanja Fidler. Synthesizing environment-aware activities via activity sketches. In IEEE Conference on Computer Vision and Pattern Recognition, 2019.
Xi Victoria Lin, Chenglong Wang, Luke Zettlemoyer, and Michael D Ernst. Nl2bash: A corpus and semantic parser for natural language interface to the linux operating system. In International Conference on Language Resources and Evaluation, 2018.
Yunchao Liu, Jiajun Wu, Zheng Wu, Daniel Ritchie, William T. Freeman, and Joshua B. Tenenbaum. Learning to describe scenes with programs. In International Conference on Learning Representations, 2019.
Jonathan Malmaud, Earl Wagner, Nancy Chang, and Kevin Murphy. Cooking with semantics. In Workshop on Semantic Parsing at Association for Computational Linguistics, 2014.
Jiayuan Mao, Honghua Dong, and Joseph J. Lim. Universal agent for disentangling environments and tasks. In International Conference on Learning Representations, 2018.
Jiayuan Mao, Chuang Gan, Pushmeet Kohli, Joshua B Tenenbaum, and Jiajun Wu. The neurosymbolic concept learner: Interpreting scenes, words, and sentences from natural supervision. In International Conference on Learning Representations, 2019.
Dipendra Misra, John Langford, and Yoav Artzi. Mapping instructions and visual observations to actions with reinforcement learning. In Empirical Methods in Natural Language Processing, 2017.
Dipendra Misra, Andrew Bennett, Valts Blukis, Eyvind Niklasson, Max Shatkhin, and Yoav Artzi. Mapping instructions to actions in 3d environments with visual goal prediction. In Empirical Methods in Natural Language Processing, 2018.
Volodymyr Mnih, Adria Puigdomenech Badia, Mehdi Mirza, Alex Graves, Timothy Lillicrap, Tim Harley, David Silver, and Koray Kavukcuoglu. Asynchronous methods for deep reinforcement learning. In International Conference on Machine Learning, 2016.
Katharina Mülling, Jens Kober, Oliver Kroemer, and Jan Peters. Learning to select and generalize striking movements in robot table tennis. International Journal of Robotics Research, 2013.
Ofir Nachum, Shixiang Shane Gu, Honglak Lee, and Sergey Levine. Data-efficient hierarchical reinforcement learning. In Neural Information Processing Systems, 2018.
Arvind Neelakantan, Quoc V Le, and Ilya Sutskever. Neural programmer: Inducing latent programs with gradient descent. In International Conference on Learning Representations, 2015.
Junhyuk Oh, Satinder Singh, Honglak Lee, and Pushmeet Kohli. Zero-shot task generalization with multi-task deep reinforcement learning. In International Conference on Machine Learning, 2017.
Boris N. Oreshkin, Pau Rodriguez, and Alexandre Lacoste. Tadam: Task dependent adaptive metric for improved few-shot learning. In Neural Information Processing Systems, 2018.
Emilio Parisotto, Abdel-rahman Mohamed, Rishabh Singh, Lihong Li, Dengyong Zhou, and Pushmeet Kohli. Neuro-symbolic program synthesis. In International Conference on Learning Representations, 2017.
Taesung Park, Ming-Yu Liu, Ting-Chun Wang, and Jun-Yan Zhu. Semantic image synthesis with spatially-adaptive normalization. In IEEE Conference on Computer Vision and Pattern Recognition, 2019.
Ronald Parr and Stuart J Russell. Reinforcement learning with hierarchies of machines. In Advances in Neural Information Processing Systems, 1998.
Deepak Pathak, Parsa Mahmoudieh, Guanghao Luo, Pulkit Agrawal, Dian Chen, Yide Shentu, Evan Shelhamer, Jitendra Malik, Alexei A Efros, and Trevor Darrell. Zero-shot visual imitation. In International Conference on Learning Representations, 2018.
Jeffrey Pennington, Richard Socher, and Christopher D. Manning. Glove: Global vectors for word representation. In Empirical Methods in Natural Language Processing, 2014.
Ethan Perez, Harm De Vries, Florian Strub, Vincent Dumoulin, and Aaron Courville. Learning visual reasoning without strong priors. 2017.
Ethan Perez, Florian Strub, Harm de Vries, Vincent Dumoulin, and Aaron Courville. FiLM: Visual Reasoning with a General Conditioning Layer. In Association for the Advancement of Artificial Intelligence, 2018.
Mohammad Raza, Sumit Gulwani, and Natasa Milic-Frayling. Compositional program synthesis from natural language and examples. In International Joint Conference on Artificial Intelligence, 2015.
Scott Reed and Nando De Freitas. Neural programmer-interpreters. In International Conference on Learning Representations, 2016.
Nobuyuki Shimizu and Andrew Haas. Learning to follow navigational route instructions. In International Joint Conference on Artificial Intelligence, 2009.
Richard Shin, Illia Polosukhin, and Dawn Song. Improving neural program synthesis with inferred execution traces. In Neural Information Processing Systems. 2018.
Sungryull Sohn, Junhyuk Oh, and Honglak Lee. Hierarchical reinforcement learning for zero-shot generalization with subtask dependencies. In Advances in Neural Information Processing Systems, 2018.
Bradly C. Stadie, Pieter Abbeel, and Ilya Sutskever. Third person imitation learning. In International Conference on Learning Representations, 2017.
Shao-Hua Sun, Hyeonwoo Noh, Sriram Somasundaram, and Joseph Lim. Neural program synthesis from diverse demonstration videos. In International Conference on Machine Learning, 2018.
Kai Sheng Tai, Richard Socher, and Christopher D Manning. Improved semantic representations from tree-structured long short-term memory networks. Association for Computational Linguistics, 2015.
Stefanie Tellex, Thomas Kollar, Steven Dickerson, Matthew R Walter, Ashis Gopal Banerjee, Seth J Teller, and Nicholas Roy. Understanding natural language commands for robotic navigation and mobile manipulation. In Association for the Advancement of Artificial Intelligence, 2011.
Richard Socher Tianmin Shu, Caiming Xiong. Hierarchical and interpretable skill acquisition in multi-task reinforcement learning. International Conference on Learning Representations, 2018.
Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N Gomez, Łukasz Kaiser, and Illia Polosukhin. Attention is all you need. In Advances in Neural Information Processing Systems, 2017.
Alexander Sasha Vezhnevets, Simon Osindero, Tom Schaul, Nicolas Heess, Max Jaderberg, David Silver, and Koray Kavukcuoglu. Feudal networks for hierarchical reinforcement learning. arXiv preprint arXiv:1703.01161, 2017.
Adam Vogel and Daniel Jurafsky. Learning to follow navigational directions. In Association for Computational Linguistics, 2010.
Risto Vuorio, Shao-Hua Sun, Hexiang Hu, and Joseph J. Lim. Toward multimodal model-agnostic meta-learning. In Meta-Learning Workshop at Neural Information Processing Systems, 2018.
Risto Vuorio, Shao-Hua Sun, Hexiang Hu, and Joseph J Lim. Multimodal model-agnostic metalearning via task-aware modulation. In Neural Information Processing Systems, 2019.
Sida I Wang, Samuel Ginn, Percy Liang, and Christoper D Manning. Naturalizing a programming language via interactive learning. In Association for Computational Linguistics, 2017a.
Ziyu Wang, Josh S Merel, Scott E Reed, Nando de Freitas, Gregory Wayne, and Nicolas Heess. Robust imitation of diverse behaviors. In Advances in Neural Information Processing Systems, 2017b.
Da Xiao, Jo-Yu Liao, and Xingyuan Yuan. Improving the universality and learnability of neural programmer-interpreters with combinator abstraction. In International Conference on Learning Representations, 2018.
Saining Xie, Sainan Liu, Zeyu Chen, and Zhuowen Tu. Attentional shapecontextnet for point cloud recognition. In IEEE Conference on Computer Vision and Pattern Recognition, 2018.
Danfei Xu, Suraj Nair, Yuke Zhu, Julian Gao, Animesh Garg, Li Fei-Fei, and Silvio Savarese. Neural task programming: Learning to generalize across hierarchical tasks. In International Conference on Robotics and Automation, 2018.
Pengcheng Yin and Graham Neubig. Tranx: A transition-based neural abstract syntax parser for semantic parsing and code generation. In Empirical Methods in Natural Language Processing, 2018.
Tao Yu, Rui Zhang, Kai Yang, Michihiro Yasunaga, Dongxu Wang, Zifan Li, James Ma, Irene Li, Qingning Yao, Shanelle Roman, et al. Spider: A large-scale human-labeled dataset for complex and cross-domain semantic parsing and text-to-sql task. In Empirical Methods in Natural Language Processing, 2018a.
Tianhe Yu, Chelsea Finn, Annie Xie, Sudeep Dasari, Tianhao Zhang, Pieter Abbeel, and Sergey Levine. One-shot imitation from observing humans via domain-adaptive meta-learning. In Robotics: Science and Systems, 2018b.
# A PROGRAM EXECUTION
We describe our program interpreter in Section 4.1 and provide more details in this section. The program instruction considered in this work contains the following three components: (1) subtasks, (2) perceptions, and (3) control flows. Accordingly, our Program Interpreter is designed to consist of (1) a parser to parse each line of the program following the grammar defined by our DSL in figure 2, and (2) a program executor which executes the program conditioning on the parsed contents. The interpreter transforms the program into a tree-like object by exploiting its structure (i.e. scopes) and then utilizes the parsed contents to traverse it to execute the program.
A program tree is built by representing each line of a program as a tree node. Each tree node is a data structure containing members: (1) node.line, the original line in the program, (2) node.isLeaf(), if the current node is a leaf node (i.e. subtask), and (3) node.children, all the subroutines of the current node (i.e. the processes under the scope of the current line of program). The interpreter will parse according to the original line contained in the node, and decide whether to call the policy if it is a leaf node (subtask) or produce a query to call the perception module, deciding which child node (subroutine) to go into.
The subroutines of a node should correspond to proper scoping of the program. For example, in Figure 1 in the main paper, the line if is_there[River] has subroutines mine(Wood), build_bridge(), if agent $\mathtt { \tau } _ { \mathtt { T r o n } } ] < 3$ , and place(Iron,1,1), but not mine(Iron), which should be if agent[Iron] $< 3$ ’s subroutine.
Once the program tree is built, the program executor will perform a pre-order traversal to initiate the execution. Algorithm 1 summarizes the details of the program execution utilizing the transformed program tree.
# Algorithm 1 Program Execution
Require: $P$ : program to be executed Require: $s$ : environmental state Require: $\pi$ : agent policy parameterized by $\theta , \Phi$ : perception module Require: node: has member node.line as the original program line and children nodes node.children 1: procedure EXECUTE(node) 2: if node.isLeaf() then 3: subtask $=$ parse_subtask(node.line) 4: $\pi$ (subtask, θ) . Calls the agent policy to execute the subtask 5: else 6: control_flow, perception_query $=$ parse_ctrl_percept(node.line) 7: $h = \Phi$ (perception_query, s) $\triangleright$ Calls the perception module with a query and state 8: control_flow $h$ . e.g. if, while, loop, calls the subroutines depending on $h$ 9: for child in node.children do 10: EXECUTE(child) 11: end for 12: end if 13: end procedure
# B DSL DESIGN PRINCIPLE
Since different domains require different DSLs, we aim to design our DSL by following a design principle that would potentially allow us to easily adapt our DSL to different domain. Specifically, we develop a DSL design principle that considers a general setting where an agent can perceive and interact with the environment to fulfill some tasks. Accordingly, our DSL consist of control flows, perceptions, and actions. While control flows are domain independent, perceptions and actions can be designed based on the domain of interest, which would require certain expertise and domain knowledge. We aim to design our DSL that is (1) intuitive: the actions and perceptions are intuitively align with human common sense, (2) modular: actions are reasonably distinct and can be used to compose more complex behaviors, and (3) hierarchical: a proper level of abstraction that enables describing long-horizon tasks.
# C EXTENDED RELATED WORK
We present an extended discussion of the related work in this section.
Multitask reinforcement learning. To achieve multi-task reinforcement learning, previous works devised hierarchical approaches where an RL agent is trained to achieve a series of subtasks to accomplish the task. In Andreas et al. (2017a), a sequence of policy sketches is predefined to guide an agent towards the desired goal by leveraging modularized neural network policies. Oh et al. (2017) propose to learn a controller to predict to either proceed, revert, or stay at a current subgoal, which is sampled from a list of simple symbolic instructions. In this paper, hierarchical tasks are described by programs with increased diversity through branching conditions, and therefore our framework is required to determine which branches in a program should be executed. On the other hand, the framework proposed by Sohn et al. (2018) requires a subtask graph describing a set of subtasks and their dependencies and aims to find the optimal subtask to execute. This is different from our problem formulation where the agent is asked to follow a given program/procedure.
Hierarchical reinforcement learning. Our work is also closely related to hierarchical reinforcement learning, where a meta-controller learns to predict which sub-policy to take at each time step (Kulkarni et al., 2016; Bacon et al., 2017; Dilokthanakul et al., 2017; Frans et al., 2018; Vezhnevets et al., 2017; Lee et al., 2019; Bakker et al., 2004; Nachum et al., 2018; Mao et al., 2018). Previous works also investigated in explicitly specifying sub-policy with symbolic representations for meta-controller to utilize, or an explicit selection process of lower-level motor skills (Mülling et al., 2013; Tianmin Shu, 2018).
Programmable agents. We would like to emphasize that our work differs from programmable agents (Denil et al., 2017) in motivation, problem formulations, proposed methods, and contributions. First, Denil et al. (2017) concern declarative programs which specify what to be computed (e.g. a target object in a reaching task). However, the programs considered in our work are imperative, which how this is to be computed (i.e. a procedure). Also, Denil et al. (2017) consider only one-liner programs that contain only AND, OR, and object attributes. On the other hand, we consider programs that are much longer and describe more complex procedures. While Denil et al. (2017) aim to generalize to novel combinations of object attributes, our work is mainly interested in generalizing to more complex tasks (i.e. programs) by leveraging the structure of programs.
Programs vs. natural language instructions. In this work, we advocate utilizing programs as a task representation and propose a modular framework that can leverage the structure of programs to address this problem. Yet, natural language instructions enjoy better accessibility and are more intuitive to users who do not have experience in programming languages. While addressing the accessibility of programs or converting a natural language instruction to a more structural form is beyond the scope of this work, we look forward to future research that leverages the strengths of both programs and natural language instructions by bridging the gap between these two representations, such as synthesizing programs from natural language (Lin et al., 2018; Desai et al., 2016; Raza et al., 2015), semantic parsing that bridges unstructured languages and structural formal languages (Yu et al., 2018a; Yin & Neubig, 2018), and naturalizing program (Wang et al., 2017a).
# D DISCUSSIONS ON LEARNED MODULATION MECHANISMS
To fuse the information from an input domain (e.g. an image) with another condition domain (e.g. a language query, image such as segmentation map, noise, etc.), a wide range of works have demonstrated the effectiveness of predicting affine transforms based on the condition to scale and bias the input in visual question answering (Perez et al., 2018; 2017), image synthesis (Almahairi et al., 2018; Karras et al., 2019; Park et al., 2019; Huh et al., 2019), style transfer (Dumoulin et al., 2017), recognition (Hu et al., 2018; Xie et al., 2018), reading comprehension (Dhingra et al., 2017), few-shot learning (Oreshkin et al., 2018; Lee & Choi, 2018), etc. Many of those works present an extensive ablation study to compare the learned modulation against traditional ways to merge the information from the input and condition domains.
Recently, a few works have employed a similar learned modulation technique to reinforcement learning frameworks on learning to follow language instruction (Bahdanau et al., 2019) and metareinforcement learning (Vuorio et al., 2018; 2019). However, there has not been a comprehensive ablation study that suggests fusing the information from the input domain (e.g. a state) and the condition domain (e.g. a goal or a task embedding) for the reinforcement learning setting. In this work, we conduct an ablation study in our 2D Minecraft environment where an agent is required to fulfill a navigational task specified by a program and show the effectiveness of learning to modulate input features with symbolically represented goal as well as present a number of modulation variations (i.e. modulating the fully-connected layers or the convolutional layers or both). We look forward to future research that verifies if this learned modulation mechanism is effective in dealing with more complex domains such as robot manipulation or locomotion.
# E ADDITIONAL EXPERIMENTAL DETAILS
# E.1 ENVIRONMENT DETAILS
In the following paragraphs, we provide some details of the environment used in this work.
Objects in the environment. The major environmental resources that the agent can interact with are: wood, gold, and iron. There is a certain probability that the environment will contain a river, which the agent cannot go across unless a bridge is built (or pre-built). The environment is surrounded by brick walls, which draws the boundaries of the world.
Agent action space. The agent’s actions are (1) crafting actions: including mining (collecting resources), placing, building a bridge, and selling an item; and (2) motor actions: including moving to four directions (up, down, left, right). The crafting actions are only allowed on the current grid cell the agent is standing on, e.g. the subtask mine(gold) requires the agent to navigate to a specific location containing a gold with motor actions, and then perform the crafting action mine at the current location. To build a bridge, the agent should consume one of the wood it possesses. To sell an item, the agent needs to travel to a merchant. With certain probabilities, there can be 2 to 4 merchants at different locations.
Initialization. During training, when each training program is sampled, a valid environment will be randomly initialized, where validity refers to the property that the agent will be able to successfully follow the program with sufficiently provided environmental resources. At test time, we pre-sample 20 valid initialization of the environment with 20 different random seeds to ensure the validity of the two test sets.
Agent observation space (state representations). The state used in our reinforcement learning policy consists of an environment map $s _ { \mathrm { m a p } }$ and an inventory status of the agent $s _ { \mathrm { i n v } }$ . $s _ { \mathrm { m a p } }$ is of size $1 0 \times 1 0 \times 9$ , where each channel-wise slice of size $1 0 \times 1 0 \times 1$ represents the binary existence of certain objects at a specific location, e.g. if $( 3 , 4 , 2 )$ is 1, it means there is a ${ \tt g o l d }$ at location $( 3 , 4 )$ (environment objects in channel dimension are zero-indexed). The objects represented by the channels are ordered as follows: wood, iron, gold, agent, wall, goal (2-D representation of intended goal coordinates), river, bridge, and merchant. The agent inventory status $s _ { \mathrm { i n v } }$ is augmented with the agent location, resulting in a 1-d integer vector of size 5. The ordered entry of such vector is as follows: agent’s wood counts, agent’s iron counts, agent’s gold counts, agent’s location coordinate $\mathbf { X }$ , and then y.
Goal representations. For our proposed framework, we represent the goal of the subtask as an 1-D vector of size 10, produced by the program interpreter. The first five entries of the goal vector is a one-hot representation of the subtask: goto, place, mine, sell, build_bridge. The 6th to 8th entries are one-hot representation of the resources: wood, iron, and gold. The last two entries are the intended goal locations. For example, place(iron,3,5) will be represented as $[ 0 , 1 , 0 , 0 , 0 , 0 , 1 , 0 , 3 , 5 ]$ . For end-to-end learning models, such goal representation is produced by the input encoder as a continuous latent vector representation.
Exemplar environment maps. We show several exemplary rendered environment maps in Figure 6. As can be seen, the essential resources such as wood, gold, iron are represented as block objects, where the merchant is depicted by an alpaca. The agent is shown as a female human character. River grids, with bridge blocks built on it is shown as the blue grid cells, where the bridge which should be transformed by wood is of wooden texture. The Boundaries can be seen in the surroundings represented as brick wall grids.
 Figure 6: Exemplar rendered environment map. The agent, objects, and stuff are represented as blocks with their corresponding textures. Specifically, the agent is represented as a female character. ${ \tt g o l d }$ is represented as a golden block, wood is shown as a tree, and iron is represented as a sliver block. River is shown as a blue grid with water texture while bridge is presented as wooden grid. merchant is shown as an alpaca, which is supposed to transport the sold objects. Notice that there are 2 merchants in (a) and (b), while (c) and (d) contains 3 and 4 of them, respectively. The boundaries of the map are shown as brick walls.
# E.2 GROUND TRUTH PERCEPTIONS FOR END-TO-END LEARNING BASELINES
Since we train our perception module using ground truth information, we provide the ground truth perception information to all our baselines yet failed to elaborate this in the original paper. Specifically, at every time step, we feed the ground truth perception (i.e. the answer to the queries such as env $[ \mathsf { G o l d } ] > 0$ and is_there[River]) to the baseline models. The ground truth perception is represented as a vector that has a dimension of the number of all possible queries, and each element corresponds to a binary answer to a query. Therefore, the baseline models can learn to utilize this ground truth information to infer the desired subtasks. During testing time, the baseline models can still access to all this ground truth perception information, even though it is usually not possible in practice. On the contrary, during testing time, our perception module predicts the answer to given queries and the performance of the whole framework depends on the predicted answers.
# E.3 TASK INSTRUCTIONS DETAILS
Programs. We generate the program sets by sampling program tokens with normal distributions, and constructing them according to the DSL grammar we define. The training set is composed of on average 32 tokens and 4.6 lines; the more complex test set, i.e. test-complex, contains on average 65 tokens and 9.8 lines. We include the plotted statistics of various essential properties for the three datasets in Figure 11, Figure 12, and Figure 13, respectively. Note that the maximum indent of a program is the maximum depth of its scope or the height of its transformed program tree. The number of recurring procedures includes both while and loop.
Natural language instructions. For each of the three program sets, we chunked them into several subsets of programs and assign them to annotators for their corresponding natural language translations. The annotators were instructed to read the provided DSL to understand the details of program syntax as well as some exemplary translations before they are allowed to start the task. The annotators were encouraged to give diverse and colloquial translations to avoid constantly giving dull line-by-line translations. The collected (translated) natural language instructions were then cleansed with spell checks and grammatical errors fixes. On average, the annotators used 27, 28, and 61 words to describe the instructions for the train, test, and test-complex sets respectively. The total vocabulary size of the natural language instructions is of 448.
Qualitative results on natural language analysis. We show several example data points from our testing sets in Figure 10. The leftmost column displays natural language instructions, the middle column shows our sampled ground truth programs, while the rightmost column illustrates how language can be ambiguous and lead to possible alternative interpreted programs.
# E.4 NETWORK ARCHITECTURES
The proposed framework and the end-to-end learning baselines are implemented in TensorFlow (Abadi et al., 2016).
# E.4.1 OUR FRAMEWORK
Perception module. The perception module takes a query $q$ and a state $s$ as input and outputs a response $h$ . A query has a size of $6 \times 1 8 6$ , since the longest query has a length of 6 and 186 is the dimension of one-hot program tokens. Shorter queries are zero-padded to this size.
The state map $s _ { \mathrm { m a p } }$ is encoded by a CNN with four layers with channel size of 32, 64, 96, and 128. Each convolutional layer has kernel size 3 and stride 2 and is followed by ReLU nonlinearity. The final feature map is flattened to a feature vector, denoted as $f _ { m }$ .
The state inventory $s _ { \mathrm { i n v } }$ is encoded by a two-layer MLP with a channel size of 32 for both layers. Each fully-connected layer is followed by ReLU nonlinearity. The resulting feature vector is denoted as $f _ { i }$ .
Each token in the query is first encoded by a two-layer MLP with a channel size of 32 for both layers. Each fully-connected layer is followed by ReLU nonlinearity. Then, all the query token features are concatenated along the feature dimension to a single vector. This vector is then encoded by another two-layer MLP with a channel size of 32 for both layers. Each fully-connected layer is followed by ReLU nonlinearity. The resulting feature vector is denoted as $f _ { q }$ .
All encoded features $( f _ { m } , f _ { i }$ , and $f _ { q }$ ) are then concatenated along the feature dimensions to a single vector. This vector is processed by a three-layer MLP with a channel size of 128, 64, and 32. Each fully-connected layer is followed by ReLU nonlinearity. Finally, a linear fully-connected layer produces an output with a size of 1, which should have a higher value if the response of the query is true and lower otherwise.
Policy. The policy takes a goal $g$ and a state $s$ as input and outputs an action distribution $a$ , where the state is encoded by two types of modules: (1) a four-layer CNN encoder to encode the state map $s _ { \mathrm { m a p } }$ and (2) a two-layer MLP to encode the agent inventory status $s _ { \mathrm { i n v } }$ .
The goal $g$ is encoded by a two-layer MLP with a channel size of 64 for both layers. Each fullyconnected layer is followed by ReLU nonlinearity. The resulting feature vector is denoted as $f _ { g }$ Given the encoded goal vector, we employ four linear fully-connected layers to predict modulation parameters $\{ \gamma _ { i } , \beta _ { i } \} _ { \{ 1 , \dots , 4 \} }$ for the state CNN encoder, where $\gamma _ { 1 }$ and $\beta _ { 1 }$ have size 32, $\gamma _ { 2 }$ and $\beta _ { 2 }$ have size 64, $\gamma _ { 3 }$ and $\beta _ { 3 }$ have size 96, and $\gamma _ { 4 }$ and $\beta _ { 4 }$ have size 128. Note that these modulation parameters are predicted for modulating convolutional features (i.e. modulation conv). For modulation $f c$ , a linear fully-connected layer is used to produce $\gamma ^ { f c }$ and $\beta ^ { f c }$ with size 64.
A state map $s _ { \mathrm { m a p } }$ is encoded by four-layer CNN with channel size of 32, 64, 96, and 128. Each convolutional layer has kernel size 3, strides 2, and is followed by ReLU nonlinearity. After each convolutional layer, the produced feature maps $e$ are modulated to $\gamma \cdot e + \beta$ , where $\gamma$ and $\beta$ are broadcast along spatial dimensions. The final feature map is flattened to a feature vector and denoted as $f _ { m } ^ { \pi }$ .
A state inventory $s _ { \mathrm { i n v } }$ is encoded by a two-layer MLP with channel size of 64 for both layers. Each fully-connected layer is followed by ReLU nonlinearity. The resulting feature vector is denoted as $f _ { i } ^ { \pi }$ .
The two encoded features ( $f _ { m } ^ { \pi }$ and $f _ { i } ^ { \pi }$ ) are then concatenated along the feature dimension. Two fully-connected layers are used to process the feature with a channel size of 64 for both layers. Each layer is followed by ReLU nonlinearity. The final encoded feature $u$ is then modulated to $\gamma ^ { \bar { f } c } \cdot u + \beta ^ { f c }$ if modulation fc is used.
Finally, the modulated features $\hat { u }$ are used to produce an action distribution $a$ and a predicted value $V$ using two separated MLPs. Each MLP has two fully-connected layers with a channel size of 64 for both layers. A linear layer then outputs a vector with a size of 8 (the number of low-level actions). Another linear layer outputs a vector with a size of 1 as the predicted value.
# E.4.2 END-TO-END LEARNING MODELS
In addition to the input encoder, the end-to-end learning models can utilize a mechanism to remember what subtasks from the instructions have been accomplished. The agent can then explicitly memorize where it stands in the instruction while completing the task. We augment such memorization mechanism utilizing the memory of another LSTM network, taking as inputs the encoded states throughout the execution trajectory. After agent taking each action, the last hidden state encoding the trajectory up to the current step is used to compute attention scores to pool the outputs of the input encoders. For Tree-RNN encoder, we simply concatenate the hidden representation from memorization LSTM with the root representation of Tree-RNN before feeding them to subsequent layers. The agent policy network then learns to perform task conditioning on this attention-pooled latent instruction vector.
We provide details of our various end-to-end learning models in Table 2. Program token embedding is jointly trained with learning the whole module, while GloVe Pennington et al. (2014) (50-D version) is used for word embedding when instructions are natural languages.
Table 2: Architectural details for end-to-end learning models
<table><tr><td>Model</td><td>Parameters</td><td>Details</td></tr><tr><td>Seq-LSTM</td><td>0.62M</td><td>LSTM size of 128,both program and word embeddings are of dimension 50.Attention LSTM size of 128.Attention weights of size [256 × 128],with bias of size [128].Word embeddings utilize pre-trained Glo Ve.</td></tr><tr><td>Tree-RNN</td><td>0.51M</td><td>Program embeddings are of dimension 128.Attention LSTM size of128.Composition module (to aggregate all the children repre- sentation of a node) is of size [128 × 128],and output projection weights of size [128 × 128],with bias of size [128].The program embeddings are average pooled across the same program line, so that each line will be mapped to a fixed dimension representa- tion.The composition layer is applied when combining pooled</td></tr><tr><td>Transformer2.63M</td><td></td><td>embedding from all the children of a node. Number of hidden layers:2,with 8 attention heads,and intermedi- ate size of 256.Hidden size is 128.No dropout is applied.</td></tr></table>
# E.5 RAW RGB INPUT
To verify if our framework can be extended to using high-dimensional raw state inputs (i.e. RGB image) as inputs where a hand-crafted policy or perception module might not be easy to obtain, we performed an additional experiment where the perception module and the policy are trained on raw RGB inputs instead of the symbolic state representation. The results suggest that our framework can utilize RGB inputs while maintaining similar performance $9 3 . 2 \%$ on the test set) and generalization ability $9 1 . 4 \%$ on the test-complex set).
# E.6 FAILURE ANALYSIS
To gain a better understanding of how our proposed framework and the end-to-end learning models work or fail, we conduct detailed failure analysis on the execution traces of our model. The analysis is organized as follows:
• We first present an analysis of our framework on the subtasks that appear to be the first failed subtask, which immediately leads to failing the whole task. This analysis sheds some light on which subtasks most commonly cause the failure of task execution. (Section E.6.1) • We show an analysis of how many time steps each successfully executed subtask takes on average for our framework, through which we explain which subtasks we find to be harder than others. (Section E.6.2) • We show additional visualizations on the completion rates of different end-to-end learning models plotted with metrics not shown in the main paper, where we aim to deliver a more complete view of how these models perform. (Section E.6.3)
# E.6.1 FIRST FAILURE RATE OF SUBTASKS
As the first step of failure analysis, we want to get an idea of which subtasks cause the failure of the model in executions more often. To make this possible, we define “first failed subtask” as the first subtask that ends as a failure in an unsuccessful execution of a program. Based on this definition, we further define “first failure rate” as the percentage that an occurrence of a specific subtask turns out to be the first failed subtask of the execution that includes it.
 Figure 7: First failure rate of subtasks. Every colored grid shows the first failure rate of each subtask. From topleft to bottom-right, each block of grids show the results for subtask category goto, place, build_bridge, mine, and sell. Warmer colors indicate higher first failure rate; while colder colors indicate lower first failure rate. White grids indicate subtasks that either never occurs as first failed task in any execution or do not exist in the executions that lead to this figure.
 Figure 8: Average time cost of subtasks. The setup of this plot is similar to that of Figure 7. Warmer colors indicate higher average subtask time cost; while colder colors indicate lower average subtask time cost. White grids indicate subtasks that do not exist in the executions that lead to this figure.
We collect the first failure rate of all subtasks for the result we obtain from running our full model over the more complex test set, i.e. test-complex. The results are plotted in a visually interpretable format in Figure 7. As seen in the figure, subtasks in goto and $\mathtt { p l a c e }$ categories are more likely to be the first failed subtask than subtasks in build_bridge, mine, and $\mathtt { S e l l }$ categories. Within the goto and place subtask categories, subtasks requiring the agent to navigate to grid cells nearby the border of the world has a higher first failure rate than ones nearby the center of the world. This shows that these tasks mentioned above are more prone to failure than other subtasks.
# E.6.2 AVERAGE TIME COST OF SUBTASKS
Continuing from the previous analysis, we show the average time cost of all successful subtask executions in Figure 8. As can be seen in the figure, subtasks in build_bridge, mine, and $\mathtt { S e l l }$ categories take relatively smaller number of time steps to complete. In goto and place categories, the closer to border the subtask requires the agent to reach, the more time consuming it gets for the agent to complete the subtask. This corresponds to the finding in the analysis of first failure rates that subtasks with destinations close to the border are more likely to fail. In other words, the closer to border the agent has to reach, the more likely it is to fail the subtask.
# E.6.3 ADDITIONAL ANALYSIS ON END-TO-END LEARNING MODELS COMPLETION RATES
To conclude failure analysis, we focus on the variation of completion rates of program executions with respect to different conditioning variables. As shown in Figure 9, plots showing the trends of completion rates while evaluating with different independent variables show that execution failure is more common in cases when the program consists of larger number of lines, more loops and while statements, and larger number of subtasks. Note that this subtask count is only a summation of the occurrence counts of each subtask in a program, which does not accurately reflect the number of executions each subtask is being invoked (i.e. it does not reflect the repetitive counts when there is a loop).
 Figure 9: Additional analysis on completion rates. The results of executing program instructions on both datasets are used to produce the six plots above. In each plot, each color corresponds to a different model that we propose. For the two rightmost plots, there is a very small number of outliers that extends out of the right boundary of the plot that we omit for visual interpretability reasons. Please note that the use of colors in this figure is not the same as that in Figure 5 of the main paper.
Meanwhile, the effect of the number of if and else statements and the maximum indent values of programs on completion rates seem to vary across different models. For Seq-LSTM model, having a larger number of if and else statements or having a larger max indent value results in more failures; while for Transformer and Tree-RNN models, having larger values above results instead in fewer failures. This is probably since Transformer and Tree-RNN models are designed in a way that deals with hierarchical structures with jumps in instruction executions better (this point is also mentioned in the main paper). Despite this difference in effects, the overall change in performance when the number of if and else statements and the maximum indent value change is much less significant than that in the previous case.
During our analysis, we also designed an algorithm to calculate an estimate to the number of branches a program has. Here, the number of branches is defined by the number of distinct sets of lines that a program can be executed. For a program without control flows (no if, else-if, else, loop, and while statements), the number of branches is always 1. For if, else-if, and else statements, the exact number of branches these statements incur can be calculated easily. In cases of the loop and while statements, we treat loops as being executed only once and while statements as if statements when we calculate the number of branches. The result shown in the analysis does not reveal a clear trend. We attribute this result to two possibilities – either the metric we create is not accurate enough, or it is not a very suitable metric to be inspected.
# E.7 HYPERPARAMETERS
We use the following hyperparameters to train A2C agents for our model and all the end-to-end learning models: learning rate: $1 \times 1 0 ^ { - 3 }$ , number of environment: 64, number of workers: 64, and number of update roll-out steps: 5.
# E.8 COMPUTATIONAL RESOURCES
We train all our models on a single Nvidia Titan-X GPU, in a 40 core Ubuntu 16.04 Linux server.
<table><tr><td rowspan=1 colspan=1>#</td><td rowspan=1 colspan=1>Language Instructions</td><td rowspan=1 colspan=1>Ground Truth Program</td><td rowspan=1 colspan=1>Alternative Interpretation</td></tr><tr><td rowspan=1 colspan=1>(a)</td><td rowspan=1 colspan=1>If there is a river,build abridge.Repeat the followings3 times: mine a gold,and ifenvironment hasnomorethan 8 gold,mine iron,andthen sell an iron.</td><td rowspan=1 colspan=1>def run():if is_there[River]:build_bridge()loop(3):mine(Gold)if env[Gold] <= 8:mine(Gold)sell(Iron)</td><td rowspan=1 colspan=1>def run():if is_there[River]:build_bridge()loop(3):mine(Gold)if env[Gold] <= 8:mine(Gold)sell(Iron)</td></tr><tr><td rowspan=1 colspan=1>(b)</td><td rowspan=1 colspan=1>Place an iron on(7,2)andrepeat 4 times,if agent has nomore than 9 iron then sell agold.</td><td rowspan=1 colspan=1>def run():place(Iron,7,2)loop(4):if agent[Iron] <= 9:sell(Gold)</td><td rowspan=1 colspan=1>def run():loop(5):place(Iron,7,2)if agent[Iron] <= 9:sell(Gold)</td></tr><tr><td rowspan=1 colspan=1>(c)</td><td rowspan=1 colspan=1>Mine wood first. If agent hasmore than 3 iron, mine wood.If thereisgoldin theenvironment,placeiron at(3,7).</td><td rowspan=1 colspan=1>def run():mine(Wood)if agent[Iron] >= 4:mine(Wood)if is_there[Gold]:place(Iron,3,7)</td><td rowspan=1 colspan=1>def run():mine(Wood)if agent[Iron] >= 4:mine(Wood)if is_there[Gold]:place(Iron,3,7)</td></tr></table>
 Figure 10: Exemplar data and languages ambiguity. The goal of the examples above is to show that natural language instructions while being flexible enough to capture the high-level semantics of the task, can be ambiguous in different ways and thus might lead to impaired performance. In example (a), the modifier "repeat the following 3 times" has an unclear scope, resulting in two possible interpretations shown in program format on the right side; in example (b), "repeat 4 times" can be used to modify either the previous part of the description or the latter part of it, resulting in ambiguity; in example (c), the last sentence starting with "If" has unclear scope. In all of the above cases, a model that learns to execute instructions presented in natural language format might fail to execute the instructions successfully because of the ambiguity of the language instructions. Figure 11: Program set statistics for training set (train).
 Figure 12: Program set statistics for same complexity testing set (test).
 Figure 13: Program set statistics for more complex testing set (test-complex).123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499# SEMI-SUPERVISED NAMED ENTITY RECOGNITIONWITH CRF-VAES
Anonymous authors Paper under double-blind review
# ABSTRACT
We investigate methods for semi-supervised learning (SSL) of a neural linearchain conditional random field (CRF) for Named Entity Recognition (NER) by treating the tagger as the amortized variational posterior in a generative model of text given tags. We first illustrate how to incorporate a CRF in a VAE, enabling end-to-end training on semi-supervised data. We then investigate a series of increasingly complex deep generative models of tokens given tags enabled by end-to-end optimization, comparing the proposed models against supervised and strong CRF SSL baselines on the Ontonotes5 NER dataset. We find that our best proposed model consistently improves performance by $\approx 1 \%$ F1 in low- and moderate-resource regimes and easily addresses degenerate model behavior in a more difficult, partially supervised setting.
# 1 INTRODUCTION
Named entity recognition (NER) is a critical subtask of many domain-specific natural language understanding tasks in NLP, such as information extraction, entity linking, semantic parsing, and question answering. State-of-the-art models treat NER as a tagging problem (Lample et al., 2016; Ma & Hovy, 2016; Strubell et al., 2017; Akbik et al., 2018), and while they have become quite accurate on benchmark datasets in recent years (Lample et al., 2016; Ma & Hovy, 2016; Strubell et al., 2017; Akbik et al., 2018; Peters et al., 2018; Devlin et al., 2018), utilizing them for new tasks is still expensive, requiring a large corpus of exhaustively annotated sentences (Snow et al., 2008). This problem has been largely addressed by extensive pretraining of high-capacity sentence encoders on massive-scale language modeling tasks (Peters et al., 2018; Devlin et al., 2018; Howard & Ruder, 2018; Radford et al., 2019; Liu et al., 2019b), but it is natural to ask if we can squeeze more signal from our unlabeled data.
Latent-variable generative models of sentences are a natural approach to this problem: by treating the tags for unlabeled data as latent variables, we can appeal to the principle of maximum marginal likelihood (Berger, 1985; Bishop, 2006) and learn a generative model on both labeled and unlabeled data. For models of practical interest, however, this presents multiple challenges: learning and prediction both require an intractable marginalization over the latent variables and the specification of the generative model can imply a posterior family that may not be as performant as the current state-of-the-art discriminative models.
We address these challenges using a semi-supervised Variational Autoencoder (VAE) (Kingma et al., 2014), treating a neural tagging CRF as the approximate posterior. We address the issue of optimization through discrete latent tag sequences by utilizing a differentiable relaxation of the Perturb-andMAP algorithm (Papandreou & Yuille, 2011; Mensch & Blondel, 2018; Corro & Titov, 2018), allowing for end-to-end optimization via backpropagation (Rumelhart et al., 1988) and SGD (Robbins & Monro, 1951). Armed with this learning approach, we no longer need to restrict the generative model family (as in Ammar et al. (2014); Zhang et al. (2017)), and explore the use of rich deep generative models of text given tag sequences for improving NER performance. We also demonstrate how to use the VAE framework to learn in a realistic annotation scenario where we only observe a biased subset of the named entity tags.
Our contributions can be summarized as follows:
1. We address the problem of semi-supervised learning (SSL) for NER by treating a neural CRF as the amortized approximate posterior in a discrete structured VAE. To the best of our knowledge, we are the first to utilize VAEs for NER. 2. We explore several variants of increasingly complex deep generative models of text given tags with the goal of improving tagging performance. We find that a joint tag-encoding Transformer (Vaswani et al., 2017) architecture leads to an $\approx 1 \%$ improvement in F1 score over supervised and strong CRF SSL baselines. 3. We demonstrate that the proposed approach elegantly corrects for degenerate model performance in a more difficult partially supervised regime where sentences are not exhaustively annotated and again find improved performance. 4. Finally, we show the utility of our method in realistic low- and high-resource scenarios, varying the amount of unlabeled data. The resulting high-resource model is competitive with state-of-the-art results and, to the best of our knowledge, achieves the highest reported F1 score $( 8 8 . 4 \% )$ for models that do not use additional labeled data or gazetteers.
# 2 METHODS
We first introduce the tagging problem and tagging model. We then detail our proposed modeling framework and architectures.
# 2.1 PROBLEM STATEMENT
NER is the task of assigning coarsely-typed categories to contiguous spans of text. State-of-the-art approaches (Lample et al., 2016; Ma & Hovy, 2016; Strubell et al., 2017; Akbik et al., 2018; Liu et al., 2019a) do so by treating span extraction as a tagging problem, which we now formally define.
We are given a tokenized text sequence $\boldsymbol { x } _ { 1 : N } \in \mathcal { X } ^ { N }$ and would like to predict the corresponding tag sequence $y _ { 1 : N } \in \mathcal { V } ^ { N }$ which correctly encodes the observed token spans. 1 In this work, we use the BILOU (Ratinov & Roth, 2009) tag-span encoding, which assigns four tags for each of the $C$ span categories (e.g., B-PER, I-PER, L-PER, U-PER for the PERSON category.) The tag types B, I, $\mathbb { L }$ , U respectively encode beginning, inside, last, and unary tag positions in the original span. Additionally we have one $\bigcirc$ tag for tokens that are not in any named entity span. Thus our tag space has size $| \mathcal { V } | = 4 C + 1$ .
# 2.2 TAGGING CRF
We call the NER task of predicting tags for tokens inference, and model it with a discriminative distribution $q _ { \phi } \big ( y _ { 1 : N } \big | x _ { 1 : N } \big )$ having parameters $\phi$ . Following state-of-the-art NER approaches (Lample et al., 2016; Ma & Hovy, 2016; Strubell et al., 2017; Akbik et al., 2018), we use a neural encoding of the input followed by a linear-chain CRF (Lafferty et al., 2001) decoding layer on top.
We use the same architecture for $q _ { \phi }$ throughout this work, as follows:
1. Encode the token sequence, represented as byte-pairs, with a fixed pretrained language model. 2 That is, we first calculate:
$$h _ { 1 : N } ^ { 0 } = \mathrm { { P r e t r a i n e d - L M } } ( x _ { 1 : N } ) , h _ { 1 : N } ^ { 0 } \in \mathbb { R } ^ { N \times d _ { \mathrm { L M } } }$$
In our first experiments exploring the use of pretrained autoregressive information for generation (§3.1), we use the GPT2-SM model (Radford et al., 2019; Hugging Face, 2019). In the experiments after (§3.2) we use the RoBERTa-LG model (Liu et al., 2019b; Hugging Face, 2019).
$$h _ { 1 : N } ^ { 1 } = h _ { 1 : N } ^ { 0 } W _ { 1 } + b _ { 1 } , W _ { 1 } \in \mathbb { R } ^ { d _ { \mathrm { L M } } \times d _ { y _ { q } } } , b _ { 1 } \in \mathbb { R } ^ { d _ { y _ { q } } }$$
4. Combine local and transition potentials: $\psi _ { y _ { i } , y _ { i + 1 } } = s _ { y _ { i } } + T _ { y _ { i } , y _ { i + 1 } } , \ T _ { y _ { i } , y _ { i + 1 } } \in \mathbb { R }$
5. Using special start and end states $y _ { 0 } ~ = ~ * , y _ { N + 1 } ~ = ~ \diamond$ with binary potentials $\psi _ { * , y } ~ =$ $T _ { * , y } , \psi _ { y , \diamond } = T _ { y , \diamond }$ and the forward algorithm (Lafferty et al., 2001) to compute the the partition function $Z$ , we can compute the joint distribution:
$$q _ { \phi } \big ( y _ { 1 : N } \big | x _ { 1 : N } \big ) = \exp \{ \sum _ { i = 0 } ^ { N } \psi _ { y _ { i } , y _ { i + 1 } } - \log Z ( \psi ) \}$$
Our tagging CRF has trainable parameters $\phi = \{ W _ { 1 } , b _ { 1 } , V , b _ { 2 } , T \} $ 3 and we learn them on a dataset of fully annotated sentences $\bar { \mathcal { D } _ { S } } = \{ ( x _ { 1 : N ^ { i } } ^ { i } , y _ { 1 : N ^ { i } } ^ { i } ) \}$ using stochastic gradient descent (SGD) and maximum likelihood estimation.
$$\mathcal { L } _ { S } ^ { q } ( \phi ; \mathcal { D } _ { S } ) = \sum _ { ( x , y ) \in \mathcal { D } _ { S } } \log q _ { \phi } ( y | x )$$
# 2.3 SEMI-SUPERVISED CRF-VAE
We now present the CRF-VAE, which treats the tagging CRF as the amortized approximate posterior in a Variational Autoencoder. We first describe our loss formulations for semi-supervised and partially supervised data. We then address optimizing these objectives end-to-end using backpropagation and the Relaxed Perturb-and-MAP algorithm. Finally, we propose a series of increasingly complex generative models to explore the potential of our modeling framework for improving tagging performance.
# 2.3.1 SEMI-SUPERVISED VAE
The purpose of this work is to consider methods for estimation of $q _ { \phi }$ in semi-supervised data regimes, as in Kingma et al. (2014); Miao & Blunsom (2016); Yang et al. (2017), where there is additional unlabeled data $\mathcal { D } _ { U } = \{ ( \boldsymbol { x } _ { 1 : N ^ { i } } ^ { i } ) \}$ . To learn in this setting, we consider generative models of tags and tokens $p _ { \theta } ( x _ { 1 : N } | y _ { 1 : N } ) p ( \vec { y } _ { 1 : N } )$ and, for unobserved tags, aim to optimize the marginal likelihood of the observed tokens under the generative model.
$$\log p _ { \theta } ( x _ { 1 : N } ) = \log \sum _ { y _ { 1 : N } } p _ { \theta } ( x _ { 1 : N } | y _ { 1 : N } ) p ( y _ { 1 : N } )$$
This marginalization is intractable for models that are not factored among $y _ { i }$ , so we resort to optimizing the familiar evidence lower bound (ELBO) (Jordan et al., 1999; Blei et al., 2017) with an approximate variational posterior distribution, which we set to our tagging model $q _ { \phi }$ . We maximize the ELBO on unlabeled data in addition to maximum likelihood losses for both the inference and generative models on labeled data, yielding the following objectives:
$$\mathcal { L } _ { S } = \sum _ { ( x , y ) \in \mathcal { D } _ { S } } \log p _ { \theta } ( x | y ) + \log q _ { \phi } ( y | x )$$
$$\mathcal { L } _ { U } = \sum _ { x \in \mathcal { D } _ { U } } \mathbb { E } _ { q _ { \phi } } [ \log p _ { \theta } ( x | y ) ] - \beta \mathrm { K L } ( q _ { \phi } | | p ( y ) )$$
$$\mathcal { L } ( \boldsymbol { \theta } , \boldsymbol { \phi } ; \mathcal { D } _ { S } \cup \mathcal { D } _ { U } , \boldsymbol { \alpha } , \beta ) = \mathcal { L } _ { S } + \alpha \mathcal { L } _ { U }$$
where $\alpha$ is scalar hyper-parameter used to balance the supervised loss $\mathcal { L } _ { S }$ and the unsupervised loss $\mathcal { L } _ { U }$ (Kingma et al., 2014). $\beta$ is a scalar hyper-parameter used to balance the reconstruction and KL terms for the unsupervised loss (Bowman et al., 2015; Higgins et al., 2017). We note that, unlike a traditional VAE, this model contains no continuous latent variables.
# 2.3.2 PARTIALLY SUPERVISED LEARNING (PSL)
Assuming that supervised sentences are completely labeled is a restrictive setup for semi-supervised learning of a named entity tagger. It would be useful to be able to learn the tagger on sentences which are only partially labeled, where we only observe some named entity spans, but are not guaranteed all entity spans in the sentence are annotated and no O tags are manually annotated. 4 This presents a challenge in that we are no longer able to assume the usual implicit presence of $\bigcirc$ tags, since unannotated tokens are ambiguous. While it is possible to optimize the marginal likelihood of the CRF on only the observed tags $y _ { \mathcal { O } }$ , $\mathcal { O } \subset \{ 1 , \ldots , N \}$ in the sentence (Tsuboi et al., 2008), doing so naively will result in a degenerate model that never predicts $\bigcirc$ , by far the most common tag (Jie et al., 2019). Interestingly, this scenario is easily addressed by the variational framework via the KL term. We do this by reformulating the objective in Equation 5 to account for partially observed tag sequences:
Let $\mathcal { D } _ { P } ~ = ~ \{ ( x _ { 1 : N _ { i } } ^ { i } , y _ { \mathcal { O } } ^ { i } ) \}$ be the partially observed dataset where, for some sentence $i$ , $\scriptscriptstyle \textit { O C }$ $\{ 1 , \ldots , N _ { i } \}$ is the set of observed positions and $\mathcal { U } = \left\{ { 1 , \dots , N _ { i } } \right\} \backslash \mathcal { O }$ is the set of unobserved positions. Our partially supervised objective is then
$$\mathcal { L } _ { P } = \sum _ { ( x , y _ { \mathcal { O } } ) \in \mathcal { D } _ { P } } \left[ \log q _ { \phi } ( y _ { \mathcal { O } } | x ) + \alpha \mathbb { E } _ { q _ { \phi } } [ \log p _ { \theta } ( x | y _ { \mathcal { O } } \cup y _ { \mathcal { U } } ) ] - \alpha \beta \mathrm { K L } \big ( q _ { \phi } ( y _ { \mathcal { U } } | x , y _ { \mathcal { O } } ) | | p ( y _ { \mathcal { U } } ) \big ) \right]$$
which can be optimized as before using the constrained forward-backward and $\mathrm { K L }$ algorithms detailed in Appendix $\mathbf { B }$ .
We also explore using this approach simply for regularization of the CRF posterior by omitting the token model $p _ { \theta } ( x | y )$ . Since we do not have trainable parameters for the generative model in this case, the reconstruction likelihood drops out of the objective and we have, for a single datum $( x ^ { i } , y _ { \mathcal { O } } ^ { i } ) \in \mathcal { D } _ { P }$ , the following loss:
$$\mathcal { L } _ { P } ^ { i } = \log q _ { \phi } ( y _ { \mathcal { O } } ^ { i } | x ^ { i } ) - \alpha \beta \mathbf { K L } ( q _ { \phi } ( y _ { \mathcal { U } } ^ { i } | x ^ { i } , y _ { \mathcal { O } } ^ { i } ) | | p ( y _ { \mathcal { U } } ^ { i } ) )$$
# 2.3.3 DIFFERENTIABLE PERTURB-AND-MAP
Optimizing Equations 5 and 6 with respect to $\theta$ and $\phi$ using backpropagation and SGD is straightforward for every term except for the expectation terms $\mathbb { E } _ { q _ { \phi } ( y | x ) } [ \log p _ { \theta } ( x | y ) ]$ . To optimize these expectations, we first make an Monte Carlo approximation using a single sample drawn from $q _ { \phi }$ . This discrete sample, however, is not differentiable with respect to $\phi$ and blocks gradient computation. While we may appeal to score function estimation (Miller, 1967; Williams, 1992; Paisley et al., 2012; Ranganath et al., 2014; Miao & Blunsom, 2016; Mohamed et al., 2019) to work around this, its high-variance gradients make successful optimization difficult.
Following Papandreou & Yuille (2011); Mensch & Blondel (2018); Corro & Titov (2018); Kim et al. (2019), we can compute approximate samples from $q _ { \phi }$ that are differentiable with respect to $\phi$ using the Relaxed Perturb-and-MAP algorithm (Corro & Titov, 2018; Kim et al., 2019). Due to space limitations, we leave the derivation of Relaxed Perturb-and-MAP for linear-chain CRFs to Appendix A and detail the resulting CRF algorithms in Appendix B.
# 2.4 PROPOSED GENERATIVE MODELS
We model the prior distribution of tag sequences $y _ { 1 : N }$ as the per-tag product of a fixed categorical distribution $\begin{array} { r } { p ( \dot { y } _ { 1 : N } ) = \prod _ { i } p ( y _ { i } ) } \end{array}$ . The KL between $q _ { \phi }$ and this distribution can be computed in polynomial time using a modification of the forward recursion derived in Mann & McCallum (2007), detailed in Appendix B.
We experiment with several variations of architectures for $p _ { \theta } \big ( x _ { 1 : N } \big | y _ { 1 : N } \big )$ , presented in order of increasing complexity.
Baseline - CRF-Autoencoder (AE): The CRF Autoencoder (Ammar et al., 2014; Zhang et al., 2017) is the previous state-of-the-art semi-supervised linear-chain CRF, which we consider a strong baseline. This model uses a tractable, fully factored generative model of tokens given tags and does not require approximate inference. Due to space limitations, we have detailed our implementation in Appendix C.
MF: This is our simplest proposed generative model. We first embed the relaxed tag samples, represented as simplex vectors $\bar { y } _ { i } \in \bar { \Delta ^ { \vert \mathcal { N } \vert } }$ , into $\mathbb { R } ^ { d _ { y _ { p } } }$ as the weighted combination of the input vector representations for each possible tag:
$$u _ { i } = U y _ { i } , ~ U \in \mathbb { R } ^ { d _ { y _ { p } } \times | \mathcal { V } | }$$
We then compute factored token probabilities with an inner product
$$p _ { \theta } ( x _ { i } | y _ { i } ) = \sigma _ { \mathcal { X } } ( w _ { x _ { i } } ^ { \top } u _ { i } )$$
where $\sigma _ { \mathcal { X } }$ is the softmax function normalized over $\mathcal { X }$ . This model is generalization of the CRF Autoencoder architecture in Appendix $\textrm { C }$ where the tag-token parameters $\theta _ { x , y }$ are computed with a low-rank factorization $W U ^ { \top }$ .
MT: The restrictive factorization of MF is undesirable, since we expect that information about nearby tags may be discriminative of individual tokens. To test this, we extend MF to use the full tag context by encoding the embedded tag sequence jointly using a two-layer transformer (Vaswani et al., 2017) with four attention heads per layer before predicting the tokens independently. That is,
$$p _ { \theta } ( x _ { i } | y _ { 1 : N } ) = \sigma _ { \mathcal { X } } ( w _ { x _ { i } } ^ { \top } v _ { i } ) , v _ { 1 : N } = \mathrm { T r a n s f o r m e r } _ { \theta } ( u _ { 1 : N } )$$
MF-GPT2: Next, we see if we can leverage information from a pretrained language model to provide additional training signal to $p _ { \theta }$ . We extend MF by adding the fixed pretrained language modeling parameters from GPT2 to the token scores:
$$p _ { \theta } ( x _ { i } | y _ { i } , x _ { < i } ) = \sigma _ { \mathcal { X } } \left( \frac { w _ { x _ { i } } ^ { \top } u _ { i } } { \sqrt { d _ { y _ { p } } } } + \frac { z _ { x _ { i } } ^ { \top } h _ { i } ^ { 0 } } { \sqrt { d _ { \mathrm { G P T 2 } } } } \right)$$
where $z _ { x _ { i } }$ and $h _ { i } ^ { 0 }$ are the input token embeddings and hidden states from GPT2, respectively. We additionally normalize the scales of the factors by the square root of the vector dimensionalities to prevent the GPT2 scores from washing out the tag-encoding scores $\boldsymbol { d } _ { y _ { p } } = 3 0 0$ and $d _ { G P T 2 } = 7 6 8 )$ .
MT-GPT2: We add the same autoregressive extention to MT, using the tag encodings $v$ instead of embeddings $u$ .
$$p _ { \theta } ( x _ { i } | y _ { 1 : N } , x _ { < i } ) = \sigma _ { \mathcal { X } } \left( \frac { w _ { x _ { i } } ^ { \top } v _ { i } } { \sqrt { d _ { y _ { p } } } } + \frac { z _ { x _ { i } } ^ { \top } h _ { i } ^ { 0 } } { \sqrt { d _ { \mathrm { G P T 2 } } } } \right)$$
MT-GPT2-PoE: We also consider an autoregressive extension of MT, similar to MT-GPT2, that uses a product of experts (PoE) (Hinton, 2002) factorization instead
$$\begin{array} { r l } & { p _ { \theta } ( x _ { i } | y , x _ { < i } ) = \sigma _ { \mathcal { X } } \big ( p _ { \theta } ( x _ { i } | y _ { 1 : N } ) p _ { \mathrm { G P T 2 } } ( x _ { i } | x _ { < i } ) \big ) } \\ & { p _ { \theta } ( x _ { i } | y _ { 1 : N } ) = \sigma _ { \mathcal { X } } ( w _ { x _ { i } } ^ { \top } v _ { i } ) , \ p _ { \mathrm { G P T 2 } } ( x _ { i } | x _ { < i } ) = \sigma _ { \mathcal { X } } ( z _ { x _ { i } } ^ { \top } h _ { i } ^ { 0 } ) } \end{array}$$
MT-GPT2-Residual: Our last variation directly couples GPT2 with $p _ { \theta }$ by predicting a residual via a two-layer MLP based on the tag encoding and GPT2 state:
$$p _ { \theta } ( x _ { i } | y _ { 1 : N } , x _ { < i } ) = \sigma _ { \mathcal { X } } ( z _ { x _ { i } } ^ { \top } \bar { h } _ { i } ^ { 0 } ) , ~ \bar { h } _ { i } ^ { 0 } = h _ { i } ^ { 0 } + f _ { \mathrm { M L P } } ( \langle h _ { i } ^ { 0 } , v _ { i } \rangle )$$
For the MF-GPT2, MT-GPT2, and MT-GPT2-PoE models, we choose these factorizations specifically to prevent the trainable parameters from conditioning on previous word information, removing the possibility of the model learning to ignore the noisy latent tags in favor of the strong signal provided by pretrained encodings of the sentence histories (Bowman et al., 2015; Yang et al., 2017; Kim et al., 2018). We further freeze the GPT2 parameters for all models, forcing the only path for improving the generative likelihood to be through the improved estimation and encoding of the tags $y _ { 1 : N }$ .
# 3 EXPERIMENTS AND RESULTS
We experiment first with the proposed models generative models for SSL and PSL in a moderately resourced regime (keeping $10 \%$ labeled data) to explore their relative merits. We then evaluate our best generative model from these experiments, (MT), with an improved bidirectional encoder language model in a low- and high-resource settings, varying the amount of unlabeled data.5
For data, we use the OntoNotes 5 (Hovy et al., 2006) NER corpus, which consists of 18 entity types annotated in 82,120 train, 12,678 validation, and 8,968 test sentences.
# 3.1 EXPLORATION OF GENERATIVE ARCHITECTURES
We begin by comparing the proposed generative models, $\mathbf { M } ^ { \ast }$ along with the following baselines:
1. Supervised (S): The supervised tagger trained only on the $10 \%$ labeled data. 2. Supervised $100 \%$ $( \mathbf { S } ^ { * } )$ : The supervised tagger trained on the $100 \%$ labeled data, used for quantifying the performance loss from using less data. 3. AE-Exact: The CRF Autoencoder using exact inference (detailed in Appendix C.) 4. AE-Approx: The same tag-token pair parameterization used by the CRF Autoencoder, but trained with the approximate ELBO objective as in Equation 11 instead of the exact objective in Equation 12. The purpose here is to see if we lose anything by resorting to the approximate ELBO objective.
To simulate moderate-resource SSL, we keep annotations for only $10 \%$ of the sentences, yielding 8, 212 labeled sentences with 13, 025 annotated spans and 73, 908 unlabeled sentences. Results are shown in Table 1. All models except $\mathbf { S } ^ { \ast }$ use this $10 \%$ labeled data.
We first evaluate the proposed models and baselines without the use of a prior, since the use of a locally normalized factored prior can encourage overly uncertain joint distributions and degrade performance (Jiao et al., 2006; Mann & McCallum, 2007; Corro & Titov, 2018). We then explore the inclusion of the priors for the supervised and MT models with $\beta = 0 . 0 1$ .6
We explore two varieties of prior tag distributions: (1) the “gold” empirical tag distribution (Emp) from the full training dataset and (2) a simple, but informative, hand-crafted prior (Sim) that places $50 \%$ mass on the $\bigcirc$ tag and distributes the rest of its mass evenly among the remaining tags. We view (2) as a practical approach, since it does not require knowledge of the gold tag distribution, and use (1) to quantify any relative disadvantage from not using the gold prior. We find that including the prior with a small weight, $\beta = 0 . 0 1$ , marginally improved performance and interestingly, the simple prior outperforms the empirical prior, most likely because it is slightly smoother and does not emphasize the O tag as heavily.7
Curiously, we found that the approximate training of the CRF Autoencoder AE-Approx outperformed the exact approach AE-Exact by nearly $2 \%$ F1.
We also note that our attempts to leverage signal from the pretrained autoregressive GPT2 states had negligible or negative effects on performance, thus we conclude that it is the addition of the joint encoding transformer architecture MT that provides the most gains $( + 0 . 8 \%$ F1).
PSL: We also evaluate the supervised and transformer-based generative models, S and MT, on the more difficult PSL setup, where naively training the supervised model on the marginal likelihood of observed tags produces a degenerate model, due to the observation bias of never having O tags. In this setting we drop $90 \%$ of the annotations from sentences randomly, resulting in 82,120 incompletely annotated sentences with 12,883 annotations total. We compare the gold and simple priors for each model. From the bottom of Table 1, we see that again our proposed transformer model MT outperforms the supervised-only model, this time by $+ 1 . 3 \%$ F1. We also find that in this case, the MT models need to be trained with higher prior weights $\beta = 0 . 1$ , otherwise they diverge towards using the O tag more uniformly with the other tags to achieve better generative likelihoods.
<table><tr><td rowspan=1 colspan=1>Model</td><td rowspan=1 colspan=1>α 阝</td><td rowspan=1 colspan=1>P R F1</td></tr><tr><td rowspan=1 colspan=1>Supervised 100% (S*)</td><td rowspan=1 colspan=1>- 0.0</td><td rowspan=1 colspan=1>0.808 0.798 0.803</td></tr><tr><td rowspan=1 colspan=1>Supervised (S)AE-ExactAE-Approx</td><td rowspan=1 colspan=1>- 0.01 0.00.1 0.0</td><td rowspan=1 colspan=1>0.761 0.738 0.7490.736 0.721 0.7280.767 0.728 0.747</td></tr><tr><td rowspan=7 colspan=1>MF (Factored)MT(Transformer)MF-GPT2MT-GPT2MT-GPT2 (no-scale)MT-GPT2-PoEMT-GPT2-Residual</td><td rowspan=1 colspan=1>0.1 0.0</td><td rowspan=1 colspan=1>0.761 0.719 0.739</td></tr><tr><td rowspan=1 colspan=1>0.1 0.0</td><td rowspan=3 colspan=1>0.758 0.756 0.7570.754 0.710 0.7310.762 0.755 0.759</td></tr><tr><td rowspan=1 colspan=1>0.1 0.0</td></tr><tr><td rowspan=1 colspan=1>0.1 0.0</td></tr><tr><td rowspan=1 colspan=1>0.1 0.0</td><td rowspan=1 colspan=1>0.766 0.734 0.751</td></tr><tr><td rowspan=1 colspan=1>0.1 0.0</td><td rowspan=2 colspan=1>0.766 0.742 0.7530.766 0.740 0.753</td></tr><tr><td rowspan=1 colspan=1>0.1 0.0</td></tr><tr><td rowspan=3 colspan=1>S (Emp)S (Sim)MT (Emp)MT (Sim)</td><td rowspan=1 colspan=1>0.1 0.01</td><td rowspan=3 colspan=1>0.754 0.733 0.7430.754 0.734 0.7430.760 0.756 0.7580.762 0.757 0.760</td></tr><tr><td rowspan=1 colspan=1>0.1 0.01</td></tr><tr><td rowspan=1 colspan=1>0.1 0.010.1 0.01</td></tr><tr><td rowspan=4 colspan=1>S (Emp) - PSLS (Sim) - PSLMT (Emp) - PSLMT (Sim) - PSL</td><td rowspan=1 colspan=1>0.1 0.01</td><td rowspan=3 colspan=1>0.741 0.725 0.7330.730 0.740 0.7350.731 0.761 0.746</td></tr><tr><td rowspan=1 colspan=1>0.1 0.01</td></tr><tr><td rowspan=1 colspan=1>0.1 0.1</td></tr><tr><td rowspan=1 colspan=1>0.1 0.1</td><td rowspan=1 colspan=1>0.724 0.774 0.748</td></tr></table>
Table 1: Semi-supervised and partially-supervised models on $10 \%$ supervised training data: best in bold, second best underlined. The proposed $\mathbf { M T ^ { * } }$ improves performance in SSL and PSL by $+ 1 . 1 \%$ F1 and $+ 1 . 3 \%$ F1, respectively.
# 3.2 VARYING RESOURCES
Next we explore our best proposed architecture MT and the supervised baseline in low- and highresource settings ( $1 \%$ and $100 \%$ training data, respectively) and study the effects of training with an additional 100K unlabeled sentences sampled from Wikipedia (detailed in Appendix E).
Since we found no advantage from using pretrained GPT2 information in the previous experiment, we evaluate the use of the bidirectional pretrained language model, RoBERTa (Liu et al., 2019b), since we expect bidirectional information to highly benefit performance (Strubell et al. (2017); Akbik et al. (2018), among others). We also experiment with a higher-capacity tagging model, S-LG, by adding more trainable Transformers $L = 4$ , $A = 8$ , $H = 1 0 2 4 ^ { \cdot }$ ) between the RoBERTa encodings and down-projection layers.
From Table 2 we see that, like in the $10 \%$ labeled data setting, the CRF-VAE improves upon the supervised model by $0 . 9 \%$ F1 in this $1 \%$ setting, but we find that including additional data from Wikipedia has a negative impact. A likely reason for this is the domain mismatch between Ontonotes5 and Wikipedia (news and encyclopedia, respectively).
In the high-resource setting, we find that using RoBERTa significantly improves upon GPT2 $( + 5 . 7 \%$ F1) and the additional capacity of S-LG further improves performance by $+ 2 . 2 \%$ F1. Although we do not see a significant improvement from semi-supervised training with Wikipedia sentences, our model is competitive with previous state-of-the-art NER approaches and outperforms all previous approaches that do not use additional labeled data or gazetteers.
# 4 RELATED WORK
Utilizing unlabeled data for semi-supervised learning in NER has been studied considerably in the literature. A common approach is a two-stage process where useful features are learned from unsupervised data, then incorporated into models which are then trained only on the supervised data (Fernandes & Brefeld, 2011; Kim et al., 2015). With the rise of neural approaches, large-scale word vector (Mikolov et al., 2013; Pennington et al., 2014) and language model pretraining methods (Peters et al., 2018; Akbik et al., 2018; Devlin et al., 2018) can be regarded in the same vein.
Table 2: Low- and high-resource results with RoBERTa, varying available unlabeled data. Best scores not using additional labeled data in bold. $\dagger$ Uses additional labeled data or gazetteers.
<table><tr><td>Model</td><td>Ds</td><td>Du</td><td>α</td><td>β</td><td>P</td><td>R</td><td>F1</td></tr><tr><td>S MT (Sim)</td><td>13K 13K</td><td>0 82K</td><td>- 0.01</td><td>1 0.1</td><td>0.744 0.752</td><td>0.712 0.739</td><td>0.728 0.737</td></tr><tr><td>MT (Sim) + Wiki Strubell et al. (2017)</td><td>13K 82K</td><td>182K</td><td>0.01</td><td>0.1</td><td>0.746</td><td>0.721</td><td>0.733</td></tr><tr><td>Clark et al. (2018)†</td><td>82K</td><td>0 >1M</td><td>1</td><td>-</td><td></td><td>-</td><td>0.869</td></tr><tr><td>Chen et al. (2019)</td><td>82K</td><td>0</td><td>-</td><td>1</td><td>=</td><td>1</td><td>0.888</td></tr><tr><td></td><td></td><td></td><td>=</td><td>1</td><td>0.878</td><td>0.876</td><td>0.877</td></tr><tr><td>Akbik et al. (2018)+</td><td>95K</td><td>0</td><td></td><td></td><td></td><td></td><td>0.891</td></tr><tr><td>Liu et al. (2019a)†</td><td>82K</td><td>0</td><td></td><td>1</td><td>1</td><td>1</td><td>0.899</td></tr><tr><td>S (GPT2)</td><td>82K</td><td>0</td><td></td><td></td><td>0.808</td><td>0.798</td><td>0.803</td></tr><tr><td>S</td><td>82K</td><td>0</td><td></td><td></td><td>0.864</td><td>0.855</td><td>0.860</td></tr><tr><td>S-LG</td><td>82K</td><td>0</td><td>=</td><td>=</td><td>0.873</td><td>0.892</td><td>0.882</td></tr><tr><td>MT-LG(Sim) + Wiki</td><td>82K</td><td>182K</td><td>0.1</td><td>0.01</td><td>0.880</td><td>0.890</td><td>0.884</td></tr></table>
Another approach is to automatically create silver-labeled data using outside resources, whose low recall induces a partially supervised learning problem. Bellare & McCallum (2007) approach the problem by distantly supervising (Mintz et al., 2009) spans using a database. Carlson et al. (2009) similarly use a gazetteer and adapt the structured perceptron (Collins, 2002) to handle partially labeled sequences, while Yang et al. (2018) optimize the marginal likelihood (Tsuboi et al., 2008) of the distantly annotated tags. Yang et al. (2018)’s method, however, still requires some fully labeled data to handle proper prediction of the O tag. The problem setup from Jie et al. (2019) is the same as our PSL regime, but they use a cross-validated self-training approach. Greenberg et al. (2018) use a marginal likelihood objective to pool overlapping NER tasks and datasets, but must exploit datasetspecific constraints, limiting the allowable latent tags to debias the model from never predicting O tags.
Generative latent-variable approaches also provide an attractive approach to learning on unsupervised data. Ammar et al. (2014) present an approach that uses the CRF for autoencoding and Zhang et al. (2017) extend it to neural CRFs, but both require the use of a restricted factored generative model to make learning tractable. Deep generative models of text have shown promise in recent years, with demonstrated applications to document representation learning (Miao et al., 2016), sentence generation (Bowman et al., 2015; Yang et al., 2017; Kim et al., 2018), compression (Miao & Blunsom, 2016), translation (Deng et al., 2018), and parsing (Corro & Titov, 2018). However, to the best of our knowledge, this framework has yet to be utilized for NER and tagging CRFs. A key challenge for learning VAEs with discrete latent variables is optimization with respect to the inference model parameters $\phi$ . While we may appeal to score function estimation (Williams, 1992; Paisley et al., 2012; Ranganath et al., 2014; Miao & Blunsom, 2016), its empirical high-variance gradients make successful optimization difficult. Alternatively, obtaining gradients with respect to $\phi$ can be achieved using the relaxed Gumbel-max trick (Jang et al., 2016; Maddison et al., 2016) and has been recently extended to latent tree-CRFs by (Corro & Titov, 2018), which we make use of here for sequence CRFs.
# 5 CONCLUSIONS
We proposed a novel generative model for semi-supervised learning in NER. By treating a neural CRF as the amortized variational posterior in the generative model and taking relaxed differentiable samples, we were able to utilize a transformer architecture in the generative model to condition on more context and provide appreciable performance gains over supervised and strong baselines on both semi-supervised and partially-supervised datasets. We also found that inclusion of powerful pretrained autoregressive language modeling states had neglible or negative effects while using a pretrained bidirectional encoder offers significant performance gains. Future work includes the use of larger in-domain unlabeled corpora and the inclusion of latent-variable CRFs in more interesting joint semi-supervised models of annotations, such as relation extraction and entity linking.
# REFERENCES
Alan Akbik, Duncan Blythe, and Roland Vollgraf. Contextual string embeddings for sequence labeling. In Proceedings of the 27th International Conference on Computational Linguistics, pp. 1638–1649, 2018.
Waleed Ammar, Chris Dyer, and Noah A Smith. Conditional random field autoencoders for unsupervised structured prediction. In Advances in Neural Information Processing Systems, pp. 3311–3319, 2014.
Kedar Bellare and Andrew McCallum. Learning extractors from unlabeled text using relevant databases. In Sixth international workshop on information integration on the web, 2007.
James O Berger. Statistical decision theory and Bayesian analysis; 2nd ed. Springer Series in Statistics. Springer, New York, 1985. doi: 10.1007/978-1-4757-4286-2. URL https://cds. cern.ch/record/1327974.
Christopher M. Bishop. Pattern Recognition and Machine Learning (Information Science and Statistics). Springer-Verlag, Berlin, Heidelberg, 2006. ISBN 0387310738.
David M Blei, Alp Kucukelbir, and Jon D McAuliffe. Variational inference: A review for statisticians. Journal of the American Statistical Association, 112(518):859–877, 2017.
Samuel R Bowman, Luke Vilnis, Oriol Vinyals, Andrew M Dai, Rafal Jozefowicz, and Samy Bengio. Generating sentences from a continuous space. arXiv preprint arXiv:1511.06349, 2015.
Andrew Carlson, Scott Gaffney, and Flavian Vasile. Learning a named entity tagger from gazetteers with the partial perceptron. In AAAI Spring Symposium: Learning by Reading and Learning to Read, pp. 7–13, 2009.
Hui Chen, Zijia Lin, Guiguang Ding, Jianguang Lou, Yusen Zhang, and Borje Karlsson. Grn: Gated relation network to enhance convolutional neural network for named entity recognition. In Proceedings of AAAI, 2019.
Kevin Clark, Minh-Thang Luong, Christopher D Manning, and Quoc V Le. Semi-supervised sequence modeling with cross-view training. arXiv preprint arXiv:1809.08370, 2018.
Michael Collins. Discriminative training methods for hidden markov models: Theory and experiments with perceptron algorithms. In Proceedings of the ACL-02 conference on Empirical methods in natural language processing-Volume 10, pp. 1–8. Association for Computational Linguistics, 2002.
Caio Corro and Ivan Titov. Differentiable perturb-and-parse: Semi-supervised parsing with a structured variational autoencoder. arXiv preprint arXiv:1807.09875, 2018.
Yuntian Deng, Yoon Kim, Justin Chiu, Demi Guo, and Alexander Rush. Latent alignment and variational attention. In Advances in Neural Information Processing Systems, pp. 9712–9724, 2018.
Jacob Devlin, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova. Bert: Pre-training of deep bidirectional transformers for language understanding. arXiv preprint arXiv:1810.04805, 2018.
Eraldo R Fernandes and Ulf Brefeld. Learning from partially annotated sequences. In Joint European Conference on Machine Learning and Knowledge Discovery in Databases, pp. 407–422. Springer, 2011.
Matt Gardner, Joel Grus, Mark Neumann, Oyvind Tafjord, Pradeep Dasigi, Nelson Liu, Matthew Peters, Michael Schmitz, and Luke Zettlemoyer. Allennlp: A deep semantic natural language processing platform. arXiv preprint arXiv:1803.07640, 2018.
Nathan Greenberg, Trapit Bansal, Patrick Verga, and Andrew McCallum. Marginal likelihood training of bilstm-crf for biomedical named entity recognition from disjoint label sets. In Proceedings of the 2018 Conference on Empirical Methods in Natural Language Processing, pp. 2824–2829, 2018.
Emil Julius Gumbel. Statistical theory of extreme values and some practical applications: a series of lectures, volume 33. US Government Printing Office, 1954.
Irina Higgins, Loic Matthey, Arka Pal, Christopher Burgess, Xavier Glorot, Matthew Botvinick, Shakir Mohamed, and Alexander Lerchner. beta-vae: Learning basic visual concepts with a constrained variational framework. In International Conference on Learning Representations, volume 3, 2017.
Geoffrey E Hinton. Training products of experts by minimizing contrastive divergence. Neural computation, 14(8):1771–1800, 2002.
Eduard Hovy, Mitchell Marcus, Martha Palmer, Lance Ramshaw, and Ralph Weischedel. Ontonotes: The $90 \%$ solution. In Proceedings of the Human Language Technology Conference of the NAACL, Companion Volume: Short Papers, NAACL-Short ’06, pp. 57–60, Stroudsburg, PA, USA, 2006. Association for Computational Linguistics. URL http://dl.acm.org/citation.cfm? id=1614049.1614064.
Jeremy Howard and Sebastian Ruder. Universal language model fine-tuning for text classification. arXiv preprint arXiv:1801.06146, 2018.
Inc. Hugging Face. PyTorch Pretrained BERT: The Big & Extending Repository of pretrained Transformers, May 2019. URL https://github.com/huggingface/ pytorch-pretrained-BERT.
Eric Jang, Shixiang Gu, and Ben Poole. Categorical reparameterization with gumbel-softmax. arXiv preprint arXiv:1611.01144, 2016.
Feng Jiao, Shaojun Wang, Chi-Hoon Lee, Russell Greiner, and Dale Schuurmans. Semi-supervised conditional random fields for improved sequence segmentation and labeling. In Proceedings of the 21st International Conference on Computational Linguistics and the 44th annual meeting of the Association for Computational Linguistics, pp. 209–216. Association for Computational Linguistics, 2006.
Zhanming Jie, Pengjun Xie, Wei Lu, Ruixue Ding, and Linlin Li. Better modeling of incomplete annotations for named entity recognition. In Proceedings of NAACL, 2019.
Michael I Jordan, Zoubin Ghahramani, Tommi S Jaakkola, and Lawrence K Saul. An introduction to variational methods for graphical models. Machine learning, 37(2):183–233, 1999.
Yoon Kim, Carl Denton, Luong Hoang, and Alexander M Rush. Structured attention networks. arXiv preprint arXiv:1702.00887, 2017.
Yoon Kim, Sam Wiseman, Andrew C Miller, David Sontag, and Alexander M Rush. Semi-amortized variational autoencoders. arXiv preprint arXiv:1802.02550, 2018.
Yoon Kim, Alexander M Rush, Lei Yu, Adhiguna Kuncoro, Chris Dyer, and Gabor Melis. Unsuper- ´ vised recurrent neural network grammars. arXiv preprint arXiv:1904.03746, 2019.
Young-Bum Kim, Minwoo Jeong, Karl Stratos, and Ruhi Sarikaya. Weakly supervised slot tagging with partially labeled sequences from web search click logs. In Proceedings of the 2015 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, pp. 84–92, 2015.
Diederik P Kingma and Jimmy Ba. Adam: A method for stochastic optimization. arXiv preprint arXiv:1412.6980, 2014.
Durk P Kingma, Shakir Mohamed, Danilo Jimenez Rezende, and Max Welling. Semi-supervised learning with deep generative models. In Advances in neural information processing systems, pp. 3581–3589, 2014.
John Lafferty, Andrew McCallum, and Fernando CN Pereira. Conditional random fields: Probabilistic models for segmenting and labeling sequence data. 2001.
Guillaume Lample, Miguel Ballesteros, Sandeep Subramanian, Kazuya Kawakami, and Chris Dyer. Neural architectures for named entity recognition. arXiv preprint arXiv:1603.01360, 2016.
Tianyu Liu, Jin-ge Yao, and Chin-Yew Lin. Towards improving neural named entity recognition with gazetteers. In Proceedings of the 57th Annual Meeting of the Association for Computational Linguistics, pp. 5301–5307, 2019a.
Yinhan Liu, Myle Ott, Naman Goyal, Jingfei Du, Mandar Joshi, Danqi Chen, Omer Levy, Mike Lewis, Luke Zettlemoyer, and Veselin Stoyanov. Roberta: A robustly optimized bert pretraining approach. arXiv preprint arXiv:1907.11692, 2019b.
Xuezhe Ma and Eduard Hovy. End-to-end sequence labeling via bi-directional lstm-cnns-crf. arXiv preprint arXiv:1603.01354, 2016.
Chris J Maddison, Andriy Mnih, and Yee Whye Teh. The concrete distribution: A continuous relaxation of discrete random variables. arXiv preprint arXiv:1611.00712, 2016.
Gideon S Mann and Andrew McCallum. Efficient computation of entropy gradient for semisupervised conditional random fields. In Human Language Technologies 2007: The Conference of the North American Chapter of the Association for Computational Linguistics; Companion Volume, Short Papers, pp. 109–112. Association for Computational Linguistics, 2007.
Arthur Mensch and Mathieu Blondel. Differentiable dynamic programming for structured prediction and attention. arXiv preprint arXiv:1802.03676, 2018.
Yishu Miao and Phil Blunsom. Language as a latent variable: Discrete generative models for sentence compression. arXiv preprint arXiv:1609.07317, 2016.
Yishu Miao, Lei Yu, and Phil Blunsom. Neural variational inference for text processing. In International conference on machine learning, pp. 1727–1736, 2016.
Tomas Mikolov, Ilya Sutskever, Kai Chen, Greg S Corrado, and Jeff Dean. Distributed representations of words and phrases and their compositionality. In Advances in neural information processing systems, pp. 3111–3119, 2013.
Laurence B Miller. Monte carlo analysis of reactivity coefficients in fast reactors general theory and applications. Technical report, Argonne National Lab.(ANL), Argonne, IL (United States), 1967.
Mike Mintz, Steven Bills, Rion Snow, and Dan Jurafsky. Distant supervision for relation extraction without labeled data. In Proceedings of the Joint Conference of the 47th Annual Meeting of the ACL and the 4th International Joint Conference on Natural Language Processing of the AFNLP: Volume 2-Volume 2, pp. 1003–1011. Association for Computational Linguistics, 2009.
Shakir Mohamed, Mihaela Rosca, Michael Figurnov, and Andriy Mnih. Monte carlo gradient estimation in machine learning. arXiv preprint arXiv:1906.10652, 2019.
John Paisley, David Blei, and Michael Jordan. Variational bayesian inference with stochastic search. arXiv preprint arXiv:1206.6430, 2012.
George Papandreou and Alan L Yuille. Perturb-and-map random fields: Using discrete optimization to learn and sample from energy models. In 2011 International Conference on Computer Vision, pp. 193–200. IEEE, 2011.
Adam Paszke, Sam Gross, Soumith Chintala, Gregory Chanan, Edward Yang, Zachary DeVito, Zeming Lin, Alban Desmaison, Luca Antiga, and Adam Lerer. Automatic differentiation in pytorch. In NIPS-W, 2017.
Jeffrey Pennington, Richard Socher, and Christopher Manning. Glove: Global vectors for word representation. In Proceedings of the 2014 conference on empirical methods in natural language processing (EMNLP), pp. 1532–1543, 2014.
Matthew E Peters, Mark Neumann, Mohit Iyyer, Matt Gardner, Christopher Clark, Kenton Lee, and Luke Zettlemoyer. Deep contextualized word representations. arXiv preprint arXiv:1802.05365, 2018.
Martin Popel and Ondˇrej Bojar. Training tips for the transformer model. The Prague Bulletin of Mathematical Linguistics, 110(1):43–70, 2018.
Alec Radford, Jeffrey Wu, Rewon Child, David Luan, Dario Amodei, and Ilya Sutskever. Language models are unsupervised multitask learners. OpenAI Blog, 1:8, 2019.
Rajesh Ranganath, Sean Gerrish, and David Blei. Black box variational inference. In Artificial Intelligence and Statistics, pp. 814–822, 2014.
Lev Ratinov and Dan Roth. Design challenges and misconceptions in named entity recognition. In Proceedings of the thirteenth conference on computational natural language learning, pp. 147– 155. Association for Computational Linguistics, 2009.
Herbert Robbins and Sutton Monro. A stochastic approximation method. The annals of mathematical statistics, pp. 400–407, 1951.
David E Rumelhart, Geoffrey E Hinton, Ronald J Williams, et al. Learning representations by back-propagating errors. Cognitive modeling, 5(3):1, 1988.
Rion Snow, Brendan O’Connor, Daniel Jurafsky, and Andrew Y Ng. Cheap and fast—but is it good?: evaluating non-expert annotations for natural language tasks. In Proceedings of the conference on empirical methods in natural language processing, pp. 254–263. Association for Computational Linguistics, 2008.
Emma Strubell, Patrick Verga, David Belanger, and Andrew McCallum. Fast and accurate entity recognition with iterated dilated convolutions. arXiv preprint arXiv:1702.02098, 2017.
Yuta Tsuboi, Hisashi Kashima, Hiroki Oda, Shinsuke Mori, and Yuji Matsumoto. Training conditional random fields using incomplete annotations. In Proceedings of the 22nd International Conference on Computational Linguistics-Volume 1, pp. 897–904. Association for Computational Linguistics, 2008.
Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N Gomez, Łukasz Kaiser, and Illia Polosukhin. Attention is all you need. In Advances in neural information processing systems, pp. 5998–6008, 2017.
Martin J Wainwright, Michael I Jordan, et al. Graphical models, exponential families, and variational inference. Foundations and Trends $\textsuperscript { \textregistered }$ in Machine Learning, 1(1–2):1–305, 2008.
Ronald J Williams. Simple statistical gradient-following algorithms for connectionist reinforcement learning. Machine learning, 8(3-4):229–256, 1992.
Yaosheng Yang, Wenliang Chen, Zhenghua Li, Zhengqiu He, and Min Zhang. Distantly supervised ner with partial annotation learning and reinforcement learning. In Proceedings of the 27th International Conference on Computational Linguistics, pp. 2159–2169, 2018.
Zichao Yang, Zhiting Hu, Ruslan Salakhutdinov, and Taylor Berg-Kirkpatrick. Improved variational autoencoders for text modeling using dilated convolutions. In Proceedings of the 34th International Conference on Machine Learning-Volume 70, pp. 3881–3890. JMLR. org, 2017.
Xiao Zhang, Yong Jiang, Hao Peng, Kewei Tu, and Dan Goldwasser. Semi-supervised structured prediction with neural crf autoencoder. In Proceedings of the 2017 Conference on Empirical Methods in Natural Language Processing, pp. 1701–1711, 2017.
# A RELAXED PERTURB-AND-MAP FOR LINEAR CHAIN CRFS
Let $\tilde { q } _ { \phi } ( y | x ; \tau )$ be the distribution on $y$ with the potentials $\psi$ for each tag at each position perturbed by Gumbel noise $\gamma \overset { \underset { \mathrm { i i d } } { } } { \sim } \mathcal { G } ( 0 , 1 )$ (Gumbel, 1954) and $\tau \geq 0$ be the temperature:
$$\tilde { q } _ { \phi } ( y | x ; \tau ) = \frac { \exp \big \{ ( \sum _ { i = 0 } ^ { N } \psi _ { y _ { i } , y _ { i + 1 } } + \gamma _ { y _ { i } } ) / \tau \big \} } { \displaystyle \sum _ { y _ { 1 : N } ^ { \prime } } \exp \big \{ ( \sum _ { i = 0 } ^ { N } \psi _ { y _ { i } ^ { \prime } , y _ { i + 1 } ^ { \prime } } + \gamma _ { y _ { i } ^ { \prime } } ) / \tau ) \big \} }$$
We know from Papandreou & Yuille (2011) that the MAP sequence from this perturbed distribution is a sample from the unperturbed distribution. Coupled with the property that the zero temperature limit of the Gibbs distribution is the MAP state (Wainwright et al., 2008), it immediately follows that the zero temperature limit of the perturbed $\tilde { q }$ is a sample from $q$ :
$$\tilde { y } = \arg \operatorname* { m a x } _ { y \in \mathcal { V } } \tilde { q } _ { \phi } ( y | x ; \tau )$$
$$\operatorname * { l i m } _ { \tau \to 0 } q _ { \phi } ( y | x ; \tau ) = \mathrm { o n e - h o t } ( \arg \operatorname* { m a x } _ { y \in \mathcal { V } } q _ { \phi } ( y | x ) )$$
$$\Rightarrow \operatorname * { l i m } _ { \tau 0 } \tilde { q } _ { \phi } ( y | x ; \tau ) = \mathrm { o n e } { - } \mathrm { h o t } ( \tilde { y } )$$
where $q _ { \phi } ( y | x ; \tau )$ is the tempered but unperturbed $q _ { \phi }$ and “one-hot” is a function that converts elements of $\mathcal { V } ^ { N }$ to a one-hot vector representation.
Thus we can use the temperature $\tau$ to anneal the perturbed joint distribution $\tilde { q } _ { \phi } ( y | x ; \tau )$ to a sample from the unperturbed distribution, $\tilde { y } \sim q _ { \phi }$ . When $\tau > 0 , \tilde { q } _ { \phi } ( y | x ; \tau )$ is differentiable and can be used for end-to-end optimization by allowing us to approximate the expectation with a relaxed single-sample Monte Carlo estimate:
$$\begin{array} { r } { { \mathbb E } _ { q _ { \phi } ( y | x ) } [ \log p _ { \theta } ( x | y ) ] \approx \log p _ { \theta } ( x | \tilde { q } _ { \phi } ( y | x ; \tau ) ) } \end{array}$$
where we have modified $\log p \theta ( x | y )$ to accept the simplex representations of $y _ { 1 : N }$ from $\tilde { q } _ { \phi }$ instead of discrete elements, which has the effect of $\bar { \log { p \theta } } ( x | y )$ computing a weighted combination of its input vector representations for $y \in \mathcal { V }$ similarly to an attention mechanism or the annotation function in Kim et al. (2017) (see Equation 7.)
This can be thought of as a generalization of the Gumbel-softmax trick from Jang et al. (2016); Maddison et al. (2016) to structured joint distributions.
The statements in (8-10) also imply something of practical interest: we can compute (1) the argmax (Viterbi decoding) and its differentiable relaxation; (2) a sample and its differentiable relaxation; (3) the partition function; and (4) the marginal tag distributions, all using the same sum-product algorithm implementation, controlled by the temperature and the presence of noise. We have detailed the algorithm in Appendix B.
# B CRF ALGORITHMS
In Algorithm 1 we have detailed the stable, log-space implementation of the generalized forwardbackward algorithm for computing (1) the argmax (Viterbi decoding) and its differentiable relaxation; (2) a sample and its differentiable relaxation; (3) the partition function; and (4) the marginal tag distributions below. While this algorithm does provide practical convenience, we note that real implementations should have separate routines for computing the partition function (running only the forward algorithm), and the discrete $\tau = 0$ Viterbi algorithm, since it is more numerically stable and efficient.
We also have included the dynamic program for computing the constrained KL divergence between $q _ { \phi }$ and a factored $p ( y )$ in Algorithm 2.
# C CRF AUTOENCODER
The idea of using a CRF to reconstruct tokens given tags for SSL has been explored before by Ammar et al. (2014); Zhang et al. (2017), which we consider to be a strong baseline and restate
# Algorithm 1 Relaxed, Constrained, Perturbed Forward-Backward
Notation: $\begin{array} { r } { \mathrm { L S E } : = \log \sum _ { x } \exp } \end{array}$
Input: Local potentials $\Psi _ { y _ { 1 : N } }$ , transition potentials $\Psi _ { y , y ^ { \prime } }$ , perturb boolean, temperature $\tau$ , the special start symbol and end symbols $* , \diamond$ , and the set of allowable tags for each position $\mathcal { V } _ { i } ~ \subseteq \mathcal { V }$ (allows for partially observed/constrained sequences.)
# Procedure:
1: $\log \alpha [ 0 , y ] \psi _ { * , y } / \tau , ~ \log \beta [ N + 1 , y ] \psi _ { y , \diamond } / \tau$ . Initialize recursions bases 2: if perturb then 3: $\psi _ { \underline { { y } } _ { i } } \psi _ { \boldsymbol { y } _ { i } } + \gamma _ { \boldsymbol { y } _ { i } } , \gamma _ { \boldsymbol { y } _ { i } } \overset { \mathrm { i i d } } { \sim } \mathcal { G } ( 0 , 1 )$ . Perturb local potentials 4: end if 5: for $i = 1 , \ldots , N$ do $\triangleright$ Compute forward lattice 6: for $y \in \mathcal { V } _ { i }$ do 7: $\log \alpha [ i , y ] \longleftarrow \operatorname { L S E } _ { y ^ { \prime } \in \mathcal { y } _ { i - 1 } } ( \psi _ { y ^ { \prime } , y } + \psi _ { y } ) / \tau + \log \alpha [ i - 1 , y ^ { \prime } ]$ 8: end for 9: end for 10: for $i = N , \ldots , 1$ do $\triangleright$ Compute backward lattice 11: for $y \in \mathcal { V } _ { i }$ do 12: $\log \beta [ i , y ] \operatorname { L S E } _ { y ^ { \prime } \in \mathcal { y } _ { i + 1 } } ( \psi _ { y , y ^ { \prime } } + \psi _ { y } ) / \tau + \log \beta [ i + 1 , y ^ { \prime } ]$ 13: end for 14: end for 15: $\mu _ { y _ { i } } \gets \sigma y _ { i } \big ( \underset { y _ { i + 1 } \in \mathcal { Y } _ { i + 1 } } { \mathrm { L S E } } \log \alpha [ i , y _ { i } ] + ( \psi _ { y _ { i } } + \psi _ { y _ { i } , y _ { i + 1 } } ) / \tau + \log \beta [ i + 1 , y _ { i + 1 } ] \big )$ . Tag marginals
#
. Converges to sample at $\tau = 0$
If perturb then Relaxed sample q˜φ(y|x; τ ) ← µy1:N Else if $\tau = 1$ then Partition function $Z ( \psi ) \gets \sum _ { \mathbf { \psi } , \mathbf { \psi } ^ { \prime } \in \mathcal { V } _ { - } } \exp \{ \psi _ { y ^ { \prime } , \diamond } + \log \alpha [ N , y ^ { \prime } ] \}$ y0∈YN Tag marginals qφ(y|x) ← µy1:N Else Relaxed argmax $q _ { \phi } ( y | x ; \tau ) \gets \mu _ { y _ { 1 : N } }$
. Converges to Viterbi at $\tau = 0$
# Algorithm 2 Constrained KL
Notation: $\begin{array} { r } { \overline { { \mathrm { L S E } : = \log \sum _ { x } \exp } } } \end{array}$
Input: Local potentials $\Psi _ { y _ { 1 : N } }$ , transition potentials $\Psi _ { y , y ^ { \prime } }$ , prior distribution $p ( y _ { 1 : N } ) = \prod p ( y _ { i } )$ , the special start symbol and end symbols $* , \diamond$ , and the set of allowable tags for each position $\mathcal { V } _ { i } \subseteq \mathcal { V }$ (allows for partially observed/constrained sequences.)
# Procedure:
1: $\begin{array} { r } { \log \alpha [ 0 , y ] \psi _ { * , y } , \quad \mathrm { K L } ^ { \alpha } [ 0 , y ] 0 \forall y \in \mathcal { V } _ { 1 } } \end{array}$ . Initialize recursions bases 2: for $i = 1 , \ldots , N$ do 3: for $y _ { i } \in \mathcal { V } _ { i }$ do $\triangleright$ Same as forward algorithm 4: $\overset { \vartriangle } { \log { \alpha } } [ i , \boldsymbol { y } _ { i } ] \underset { \boldsymbol { y } _ { i - 1 } \in \mathcal { Y } _ { i - 1 } } { \mathrm { L S E } } ( \psi _ { \boldsymbol { y } _ { i - 1 } , \boldsymbol { y } _ { i } } + \psi _ { \boldsymbol { y } _ { i } } ) + \log { \alpha } [ i - 1 , \boldsymbol { y } _ { i - 1 } ]$ 5: end for 6: 7: for $\begin{array} { r l r } & { y _ { i + 1 } \in \mathcal { V } _ { i + 1 } \textbf { d 0 } } & { \triangleright \mathrm { C o m p u t e } \mathrm { K } } \\ & { q ( y _ { i } | y _ { i + 1 } ) \sigma _ { \mathcal { V } _ { i } } ( \log \alpha [ i , y _ { i } ] + \psi _ { y _ { i } , y _ { i + 1 } } + \psi _ { y _ { i + 1 } } ) } & \\ & { \mathrm { K L } ^ { \alpha } [ i , y _ { i + 1 } ] \displaystyle \sum _ { y _ { i } \in \mathcal { V } _ { i } } q ( y _ { i } | y _ { i + 1 } ) \big [ \log q ( y _ { i } | y _ { i + 1 } ) - \log p ( y _ { i } ) + \mathrm { K L } ^ { \alpha } [ i - 1 , y _ { i } ] \big ] } \end{array}$ Compute KL lattice 8: 9: end for 10: end for Output: $\mathrm { K L } ( q | | p ) \gets \mathrm { K L } ^ { \alpha } [ N , \diamond ]$
here for clarity. Termed the CRF Autoencoder, the model treats the the tags as intermediate latent variables in a conditional model and optimizes the marginal conditional likelihood of reconstructing the input.
$$\log p ( \hat { x } | x ) = \log \sum _ { y _ { 1 : N } } p _ { \theta } ( \hat { x } | y _ { 1 : N } ) q _ { \phi } ( y _ { 1 : N } | x )$$
By judiciously choosing $p _ { \theta } ( \hat { x } | y )$ to be factored among positions $i$ , we can compute the marginal reconstruction likelihood exactly:
$$\begin{array} { l } { \displaystyle \log p ( \hat { x } | x ) = \log \sum _ { y _ { 1 : N } } q _ { \phi } ( y _ { 1 : N } | x ) \prod _ { i = 1 } ^ { N } p _ { \theta } ( \hat { x } _ { i } | y _ { i } ) } \\ { = \displaystyle \log \sum _ { y _ { 1 : N } } \exp \{ \sum _ { i = 0 } ^ { N } \psi _ { y _ { i } , y _ { i + 1 } } + \log p _ { \theta } ( \hat { x } _ { i } | y _ { i } ) \} - \log Z ( \psi ) } \\ { = \displaystyle \log Z ( \psi + \log p _ { \theta } ) - \log Z ( \psi ) } \end{array}$$
where $\log Z ( \psi + \log p _ { \theta } )$ is a slight abuse of notation intended to illustrate that the first term in Equation 12 is the same computation as the partition function, but with the generative log-likelihoods added to the CRF potentials.
We note that instead of using the Mixed-EM procedure from Zhang et al. (2017), we model $p _ { \theta } ( \hat { x } _ { i } | y _ { i } )$ using free logit parameters $\theta _ { x , y }$ for each token-tag pair and normalize using a softmax, which allows for end-to-end optimization via backpropagation and SGD.
# D EXPERIMENT HYPERPARAMETER AND OPTIMIZATION SETTINGS
We train each model to convergence using early-stopping on the F1 score of the validation data, with a patience of 10 epochs. For all models that do not have trainable transformers, we train using the Adam optimizer (Kingma & Ba, 2014) with a learning rate of 0.001, and a batch size of 128. For those with transformers $( \mathbf { M T ^ { * } } )$ , we train using Adam, a batch size of 32, and the Noam learning rate schedule from Vaswani et al. (2017) with a model size of $d _ { y _ { p } } = 3 0 0$ and 16, 000 warm-up steps (Popel & Bojar, 2018).
Additionally, we use gradient clipping of 5 for all models and a temperature of $\tau = . 6 6$ for all relaxed sampling models. We implemented our models in PyTorch (Paszke et al., 2017) using the AllenNLP framework (Gardner et al., 2018) and the Hugging Face (2019) implementation of the pretrained GPT2 and RoBERTa.
We have made all code, data, and experiments available online at github.com/ <anonymizedforsubmission> for reproducibility and reuse. All experimental settings can be reproduced using the configuration files in the repo.
# E GATHERING ADDITIONAL UNLABELED DATA
For the experiments in $\ S 3 . 2$ , we gather an additional training corpus of out-of-domain encyclopedic sentences from Wikipedia. To try to get a sample that better aligns with the Ontonotes5 data, these sentences were gathered with an informed process, which was performed as follows:
1. Using the repository <anonymized for submission $>$ , we extract English Wikipedia and align it with Wikidata. 2. We then look up the entity classes from the Ontonotes5 specification (Hovy et al., 2006) in Wikidata and, for each NER class, find all Wikidata classes that are below this class in ontology (all subclasses). 3. We then find all items which are instances of these classes and also have Wikipedia pages. These are the Wikipedia entities which are likely to be instances of the NER classes.
4. Finally, we scan Wikipedia, mapping any available links to these NER classes, and keep the top 100K sentences according to the number of found annotations/token – the most ”densely” annotated sentences.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487# INTEGRATING EPISODIC MEMORY INTO A REINFORCEMENT LEARNING AGENT USING RESERVOIR SAMPLING
Anonymous authors Paper under double-blind review
# ABSTRACT
Episodic memory is a psychology term which refers to the ability to recall specific events from the past. We suggest one advantage of this particular type of memory is the ability to easily assign credit to a specific state when remembered information is found to be useful. Inspired by this idea, and the increasing popularity of external memory mechanisms to handle long-term dependencies in deep learning systems, we propose a novel algorithm which uses a reservoir sampling procedure to maintain an external memory consisting of a fixed number of past states. The algorithm allows a deep reinforcement learning agent to learn online to preferentially remember those states which are found to be useful to recall later on. Critically this method allows for efficient online computation of gradient estimates with respect to the write process of the external memory. Thus unlike most prior mechanisms for external memory it is feasible to use in an online reinforcement learning setting.
Much of reinforcement learning (RL) theory is based on the assumption that the environment has the Markov property, meaning that future states are independent of past states given the present state. This implies the agent has all the information it needs to make an optimal decision at each time and therefore has no need to remember the past. This is however not realistic in general, realistic problems often require significant information from the past to make an informed decision in the present, and there is often no obvious way to incorporate the relevant information into an expanded present state. It is thus desirable to establish techniques for learning a representation of the relevant details of the past (e.g. a memory, or learned state) to facilitate decision making in the present.
A popular approach to integrate information from the past into present decision making is to use some variant of a recurrent neural network, possibly coupled to some form of external memory, trained with backpropagation through time. This can work well for many tasks, but generally requires backpropagating many steps into the past which is not practical in an online RL setting. In purely recurrent architectures one way to make online training practical is to simply truncate gradients after a fixed number of steps. In architectures which include some form of external memory however it is not clear that this is a viable option as the intent of the external memory is generally to capture long term dependencies which would be difficult for a recurrent architecture alone to handle, especially when trained with truncated gradients. Truncating gradients to the external memory would likely greatly hinder this capability.
In this work we explore a method for adding external memory to a reinforcement learning architecture which can be efficiently trained online. We liken our method to the idea of episodic memory from psychology. In this approach the information stored in memory is constrained to consist of a finite set of past states experienced by the agent. In this work, by states we mean observations explicitly provided by the environment. In general, states could be more abstract, such as the internal state of an RNN or predictions generated by something like the Horde architecture of Sutton et al. (2011). By storing states explicitly we enforce that the information recorded also provides the context in which it was recorded. We can therefore assign credit to the recorded state without explicitly backpropagating through time between when the information proves useful and when it was recorded. If a recorded state is found to be useful we train the agent to preferentially remember similar states in the future.
In our approach the set of states in memory at a given time is drawn from a distribution over all $n$ -subsets (subsets of size $n$ ) of visited states, parameterized by a weight value assigned to each state by a trained model. To allow us to draw from such a distribution without maintaining all visited states in memory we introduce a reservoir sampling technique. Reservoir sampling refers to a class of algorithms for sampling from a distribution over $n$ -subsets of items from a larger set streamed one item at a time. The goal is to ensure, through specific add and drop probabilities, that the $n$ items in the reservoir at each time-step correspond to a sample from the desired distribution over $n$ -subsets of all observed items. Two important examples which sample from different distributions are found in Chao (1982) and Efraimidis & Spirakis (2006). In this work we will define our own distribution and sampling procedure to suit our needs.
# 1 RELATED WORK
Deep learning systems which make use of an external memory have received a lot of interest lately. Two prototypical examples are found in Graves et al. (2014) and the follow-up Graves et al. (2016). These systems use an LSTM controller attached to read and write heads of a fully differentiable external memory and train the combined system to perform algorithmic tasks. Contrary to our approach, training is done entirely by backpropagation through time. See also Zaremba & Sutskever (2015), Joulin & Mikolov (2015), Sukhbaatar et al. (2015), Gulcehre et al. (2017) and Kaiser et al. (2017) for more examples of deep learning systems with integrated external memory.
More directly related to the present work is the application of deep RL to non-markov tasks, in particular Oh et al. (2016). They experiment with architectures using a combination of key-value memory and a recurrent neural networks. The memory saves keys and values corresponding to the last $N$ observations for some integer $N$ , thus it is inherently limited in temporal extent but does not require any mechanism for information triage. They test on problems in the Minecraft domain which could provide compelling testbeds for a potential follow-up to the present work. See also Bakker et al. (2003), Wierstra et al. (2010), Zhang et al. (2016) and Hausknecht & Stone (2015) for more examples of applying deep RL to non-markov tasks.
# 2 ARCHITECTURE
Our model is based around an advantage actor critic architecture (Mnih et al., 2016) consisting of separate value and policy networks. In addition we include an external memory $\mathcal { M }$ consisting of a set of $n$ past visited states $( S _ { t _ { 0 } } , . . , S _ { t _ { n - 1 } } )$ with associated importance weights $( w _ { t _ { 0 } } , . . . , w _ { t _ { n - 1 } } )$ . The query network $q ( S _ { t } )$ outputs a vector of size equal to the state size with tanh activation. At each time step a single item $S _ { t _ { i } }$ is drawn from the memory to condition the policy according to:
$$Q ( S _ { t _ { i } } | { \cal M } _ { t } ) = \exp \left( \langle q ( S _ { t } ) | S _ { t _ { i } } \rangle / \tau \right) \Biggl / \sum _ { j = 0 } ^ { n - 1 } \exp \left( \langle q ( S _ { t } ) | S _ { t _ { j } } \rangle / \tau \right)$$
where $\tau$ is a positive learnable temperature parameter. The state, $m _ { t }$ , selected from memory is given as input to the policy network along with the current state, both of which condition the resulting policy. Finally the write network takes the current state as input and outputs a single value with sigmoid activation. This value is used to determine how likely the present state is to be written to and subsequently retained in the memory according to the distribution in equation 7 which will be throughly explained in section 3. An illustration of this architecture is shown in figure 1.
# 3 ALGORITHM
For the most part our model is trained using standard stochastic gradient descent on common RL loss functions. The value network is trained by gradient descent on the squared one step temporal different error $\delta _ { t } ^ { 2 }$ where $\delta _ { t } = r _ { t + 1 } + V ( S _ { t + 1 } ) - V ( S _ { t } )$ , and the gradient is passed only through $V ( S _ { t } )$ . The policy is trained using the advantage loss $- \bar { \delta } _ { t } \log ( \pi ( a _ { t } \mathbf { \bar { | } } S _ { t } , m _ { t } ) )$ with gradients passed only through $\pi ( a _ { t } | S _ { t } , m _ { t } )$ . The query network is trained similarly on the loss $- \delta _ { t } \log ( Q ( m _ { t } | S _ { t } ) )$ with gradients passed only through $Q ( { m } _ { t } | S _ { t } )$ . We train online, performing one update per timestep with no experience replay. The main innovation of this work is in the training method for the write network which is described in sections 3.1 and 3.2. There are two main desiderata we wish to satisfy with the write network. First we want to use the weights $w ( S _ { t } )$ generated by the network in a reservoir sampling algorithm such that the probability of a particular state $S _ { \hat { t } }$ being present in memory at any given future time $t > \hat { t }$ is proportional to the associated weight $w ( S _ { \hat { t } } )$ . Second we want to obtain estimates of the gradient of the return with respect to the weight of each item in memory such that we can perform approximate gradient descent on the generated weights.
 Figure 1: Episodic memory architecture, each grey circle represents a neural network module. Input state (S) is given separately to the query (q), write (w), value (V) and policy $( \pi )$ networks at each time step. The query network outputs a vector of size equal to the input state size which is used (via equation 1) to choose a past state from the memory $( m _ { 1 } \mathrm { ~ } , m _ { 2 }$ or $m _ { 3 }$ in the above diagram) to condition the policy. The write network assigns a weight to each new state determining how likely it is to stay in memory. The policy network assigns probabilities to each action conditioned on current state and recalled state. The value network estimates expected return (value) from the current state.
# 3.1 GRADIENT ESTIMATE
For brevity, in this section we will use the notation $E _ { t } [ x ]$ to denote $E [ x | S _ { 0 } , . . . , S _ { t } ]$ i.e. the expectation conditioned on the entire history of state visitation up to time $t$ . Similarly $P _ { t } ( x )$ will represent probability conditioned on the entire history of state visitation. All expectations and probabilities are assumed to be with respect to the current policy, query and write network. Let $\mathcal { A }$ represent the set of available actions and $A _ { t }$ the action selected at time $t$ .
# 3.1.1 ONE-STATE MEMORY CASE
To introduce the idea we first present our gradient estimation procedure for the case when our memory can store just one state, and thus there is no need to query. Here $m _ { t }$ represents the state in memory at time $t$ and thus, in the one-state memory case, the state read from memory by the agent at time $t$ . Assume the stored memory is drawn from a distribution parameterized as follows by a set of weights $\{ w _ { i } | i \in \{ 0 , . . . , t - 1 \} \}$ associated with each state $S _ { i }$ when the state is first visited:
$$P _ { t } ( m _ { t } = S _ { i } ) = { w _ { i } \Bigg / \sum _ { j = 0 } ^ { t - 1 } w _ { j } }$$
We can then write the expected return $R _ { t } = r _ { t + 1 } + \gamma r _ { t + 2 } + \ldots$ as follows:
$$E _ { t } [ R _ { t } ] = \sum _ { k = 0 } ^ { t - 1 } P _ { t } ( m _ { t } = S _ { k } ) \sum _ { a \in \mathcal { A } } \pi ( a | S _ { t } , S _ { k } ) E _ { t } [ R _ { t } | A _ { t } = a ]$$
In order to perform gradient descent on the weights $w _ { i }$ we wish to estimate the gradient of this expectation value with respect to each weight. In particular we will derive an estimate of this gradient using an actor critic method which is unbiased if the critic’s evaluation is correct. Additionally our estimate will be non-zero only for the $w _ { i }$ associated with the index $i$ such that $m _ { t } ~ = ~ S _ { i }$ . This means if our weights $w _ { i }$ are generated by a neural network, we will only have to propagate gradients through the single stored state. This is crucial to allow our algorithm to run online, as otherwise we would need to store every visited state to compute the gradient estimate.
$$\begin{array} { r l } & { \displaystyle \frac { \partial } { \partial w _ { i } } E _ { t } [ R _ { t } ] = \sum _ { k = 0 } ^ { t - 1 } \Bigg ( \frac { \partial P _ { t } ( m _ { t } = S _ { k } ) } { \partial w _ { i } } \sum _ { a \in \mathcal { A } } \pi ( a | S _ { t } , S _ { k } ) E _ { t } [ R _ { t } | A _ { t } = a ] } \\ & { \quad \quad \quad \quad \quad + P _ { t } ( m _ { t } = S _ { k } ) \sum _ { a \in \mathcal { A } } \pi ( a | S _ { t } , S _ { k } ) \frac { \partial E _ { t } [ R _ { t } | A _ { t } = a ] } { \partial w _ { i } } \Bigg ) } \end{array}$$
We can rewrite this as:
$$\begin{array} { r l r } { { \frac { \partial } { \partial w _ { i } } E _ { t } [ R _ { t } ] = \frac { 1 } { w _ { i } } P _ { t } ( m _ { t } = S _ { i } ) ( \sum _ { a \in A } \pi ( a | S _ { t } , S _ { i } ) E _ { t } [ R _ { t } | A _ { t } = a ] - E _ { t } [ R _ { t } ] ) } } \\ & { } & { + \gamma E _ { t } [ \frac { \partial } { \partial w _ { i } } E _ { t + 1 } [ R _ { t + 1 } ] ] } \end{array}$$
See appendix A for a detailed derivation of this expression. We will use a policy gradient approach, similar to REINFORCE (Williams, 1992), to estimate the this gradient using an estimator $G _ { i , t }$ such that $\begin{array} { r } { E _ { t } [ \sum _ { \hat { t } \ge t } \gamma ^ { \hat { t } - t } G _ { i , \hat { t } } ] \approx { \frac { \partial E _ { t } [ R _ { t } ] } { \partial w _ { i } } } } \end{array}$ ∂Et[Rt]∂w , thus the second term is estimated recursively on subsequent time-steps. In the present work we will focus on the undiscounted episodic case with the start-state value objective, for which it suffices to follow the first term in the above gradient expression for each visited state. This is also true in the continuing case with an average-reward objective. See Sutton et al. (2000) for further discussion of this distinction. Consider the gradient estimator:
$$G _ { i , t } = { \left\{ \begin{array} { l l } { \delta _ { t } / w _ { i } ~ } & { { \mathrm { i f } } \ m _ { t } = S _ { i } } \\ { 0 } & { { \mathrm { o t h e r w i s e } } } \end{array} \right. }$$
which has expectation:
$$\begin{array} { c l } { \displaystyle E _ { t } [ G _ { i , t } ] = \frac { 1 } { w _ { i } } P _ { t } ( m _ { t } = S _ { i } ) \sum _ { a \in \mathcal { A } } \pi ( a | S _ { t } , S _ { i } ) E _ { t } [ r _ { t + 1 } + \gamma V ( S _ { t + 1 } ) - V ( S _ { t } ) | A _ { t } = a ] } \\ { \displaystyle \approx \frac { 1 } { w _ { i } } P _ { t } ( m _ { t } = S _ { i } ) \sum _ { a \in \mathcal { A } } \pi ( a | S _ { t } , S _ { i } ) ( E _ { t } [ r _ { t + 1 } + \gamma E _ { t + 1 } [ R _ { t + 1 } ] | A _ { t } = a ] - E _ { t } [ R _ { t } ] ) } \\ { \displaystyle = \frac { 1 } { w _ { i } } P _ { t } ( m _ { t } = S _ { i } ) \left( \sum _ { a \in \mathcal { A } } \pi ( a | S _ { t } , S _ { i } ) E _ { t } [ R _ { t } | A _ { t } = a ] - E _ { t } [ R _ { t } ] \right) } \end{array}$$
Where the approximation is limited by the accuracy of our value function. In conventional policy gradient subtracting the state value (e.g. using $\delta _ { t } \doteq r _ { t + 1 } + \gamma V ( S _ { t + 1 } ) - V ( S _ { t } )$ instead of $r _ { t + 1 } +$ $\gamma V ( S _ { t + 1 } ) )$ is a means of variance reduction. Here it is critical to avoid computing gradients with respect to the denominator of equation 2, which allows our algorithm to run online while computing the gradient with respect to only the weight stored in memory.
Given these estimated gradients with respect to $w _ { i }$ we apply the chain rule to compute $\begin{array} { r } { \frac { \partial R _ { t } } { \partial \theta _ { w } } = } \end{array}$ $\begin{array} { r } { \frac { \partial R _ { t } } { \partial w _ { i } } \frac { \partial w _ { i } } { \partial \theta _ { w } } \approx \sum _ { \hat { t } \geq t } G _ { i , \hat { t } } \frac { \partial w ( S _ { i } ) } { \partial \theta _ { w } } } \end{array}$ ,tˆ∂w(Si)∂θ , for each parameter θw of the write network. This gradient estimate is used in a gradient descent procedure to emphasize retention of states which improve the return.
Gradient estimates are generated based on the stored values of $w _ { i }$ in memory but applied to the parameters of the network at the present time. With online updating, this introduces a potential multiple timescale issue which we conjecture will vanish in the limit of small learning rate, but leave further investigation to future work.
There are a number of ways to extend the distribution defined in equation 2 to the case where multiple elements of a set must be selected (see for example Efraimidis & Spirakis (2006)). We will focus on a generalization which is less explored but which we will see in the following section results in gradient estimates which are an elegant generalization of the single-state memory case.
# 3.1.2 MULTIPLE-STATE MEMORY CASE
In this section and those that follow we will routinely use the notation $\textstyle { { \binom { Z } { n } } }$ where $Z$ is a set and $n$ an integer to indicate the set of all $n$ -subsets of $Z$ . Note that ${ \binom { Z } { 0 } } = \{ \emptyset \}$ and we adopt the convention Q $x = 1$ thus $\Sigma \ : \ : \ : \prod \ : x = 1$ which will be important in a few places in what follows. $x \in \varnothing$ $\hat { Z } \in \left( \begin{array} { l } { Z } \\ { 0 } \end{array} \right) x \in \hat { Z }$
We will introduce some notation to facilitate reasoning about sets of states. Let $T _ { t } = \{ t ^ { \prime } : 0 \leq t ^ { \prime } \leq$ $t - 1 \}$ be the set of all time indices from 0 to $t - 1$ . Let ${ \hat { T } } \in \left( { \begin{array} { c } { T _ { t } } \\ { n } \end{array} } \right)$ be a set of $n$ indices chosen from $T _ { t }$ where $n$ is the memory size. Let $S _ { \hat { T } }$ be the set of states $\{ S _ { \hat { t } } : \hat { t } \in \hat { T } \}$ . Let $\mathcal { M } _ { t }$ be the set of states in memory at time $t$ . Let $Q ( S _ { \hat { t } } | S _ { \hat { T } } ^ { ' } )$ be the probability of querying $S _ { \hat { t } }$ given $\mathcal { M } _ { t } = S _ { \hat { T } }$ . The probability for a particular set of states being contained in memory is defined to be the following:
$$P _ { t } ( \mathcal { M } _ { t } = S _ { \hat { T } } ) = \prod _ { i \in \hat { T } } w _ { i } \Bigg / \sum _ { \tilde { T } \in \binom { T _ { t } } { n } i \in \tilde { T } } \prod _ { i \in \tilde { T } } w _ { i }$$
A straightforward extension of the derivation of the equation 5 shows that this choice results in a gradient estimate which is an elegant extension of the one-state memory case. The derivation is given in appendix B, the result for $\backslash \frac { \partial } { \partial w _ { i } } E _ { t } [ R _ { t } ]$ is:
$$\frac { \partial } { \partial w _ { i } } E _ { t } [ R _ { t } ] = \sum _ { \hat { T } \in ( \binom { { T _ { t } } } { n } \ni i ) } \frac { 1 } { w _ { i } } P _ { t } ( \mathcal { M } _ { t } = S _ { \hat { T } } ) \left( \sum _ { j \in \hat { T } } Q ( S _ { j } | S _ { \hat { T } } ) \sum _ { a \in \mathcal { A } } \pi ( a | S _ { t } , S _ { j } ) E _ { t } [ R _ { t } | A _ { t } = a ] \right) ,$$
As in the single-state memory case we recursively handle the second term. To estimate the first term we could choose the following estimator $G _ { i , t }$ :
$$G _ { i , t } = \left\{ { \begin{array} { l l } { \delta _ { t } / w _ { i } } & { { \mathrm { ~ i f ~ } } S _ { i } \in { \mathcal { M } } _ { t } } \\ { 0 } & { { \mathrm { ~ o t h e r w i s e } } } \end{array} } \right.$$
This estimator is unbiased under the assumption the critic is perfect, however it scales poorly in terms of both variance and computation time as the memory size increases. This is because it requires updating every state in memory regardless of whether it was queried, spreading credit assignment and requiring compute time proportional to the product of the number of states in memory with the number of parameters in the write network. Instead we will further approximate the second term and perform an update only for the queried item. We rewrite the first term of equation 8 as follows:
$$\begin{array} { r l } & { \displaystyle \frac { 1 } { w _ { i } } P _ { t } ( \mathcal { M } _ { t } \ni S _ { i } ) \Bigg ( P _ { t } ( m _ { t } = S _ { i } | \mathcal { M } _ { t } \ni S _ { i } ) \left( \sum _ { a \in \mathcal { A } } \pi ( a | S _ { t } , S _ { j } ) E _ { t } [ R _ { t } | A _ { t } = a ] - E _ { t } [ R _ { t } ] \right) } \\ & { \displaystyle + P _ { t } ( m _ { t } \neq S _ { i } | \mathcal { M } _ { t } \ni S _ { i } ) \left( \sum _ { a \in \mathcal { A } } P _ { t } ( A _ { t } = a | \mathcal { M } _ { t } \ni S _ { i } , m _ { t } \neq S _ { i } ) E _ { t } [ R _ { t } | A _ { t } = a ] - E _ { t } [ R _ { t } ] \right) \Bigg ) } \\ & { \displaystyle \approx \frac { 1 } { w _ { i } } P _ { t } ( m _ { t } = S _ { i } ) \left( \sum _ { a \in \mathcal { A } } \pi ( a | S _ { t } , S _ { j } ) E _ { t } [ R _ { t } | A _ { t } = a ] - E _ { t } [ R _ { t } ] \right) } \end{array}$$
This approximation is accurate to the extent that our query network is able to accurately select useful states. To see this, note that if querying a state when it’s in memory helps to generate a better expected return a well trained query network should do it with high probability and hence $P _ { t } ( m _ { t } \neq \boldsymbol { S } _ { i } | \mathcal { M } _ { t } \ni \boldsymbol { S } _ { i } )$ will be low. On the other hand if querying a state in memory is unhelpful $\displaystyle \left( \sum _ { a \in { \cal A } } P _ { t } ( A _ { t } = a | { \cal M } _ { t } \ni S _ { i } , m _ { t } \neq S _ { i } ) E _ { t } [ R _ { t } | A _ { t } = a ] - E _ { t } [ R _ { t } ] \right)$ will generally be small. With this approximation the gradient estimate becomes identical to the one-state memory case:
$$G _ { i , t } = { \left\{ \begin{array} { l l } { \delta _ { t } / w _ { i } ~ } & { { \mathrm { i f } } \ m _ { t } = S _ { i } } \\ { 0 } & { { \mathrm { o t h e r w i s e } } } \end{array} \right. }$$
While this justification is not rigorous, this approximation should significantly improve computational and sample efficiency, and is used in our experiments in section 4.
# 3.2 RESERVOIR SAMPLING PROCEDURE
<table><tr><td>1: Ω ← Zeros(n+1)</td><td>1: function UPDATE(w,t)</td></tr><tr><td>2:←Zeros(n)</td><td>2: ε↑ε 3:</td></tr><tr><td>3:W ←Zeros(n)</td><td>T↑t</td></tr><tr><td>4:T ← Zeros(n)</td><td>for0≤i≤n-1do</td></tr><tr><td>5:for time0≤t≤n-1do</td><td>←[i]+ω·Ω2[]</td></tr><tr><td>6: Receive Wt</td><td>if i=n-1 then</td></tr><tr><td>W[t]←Wt 7:</td><td>"← Ω[i+1]</td></tr><tr><td>8: T[←t</td><td>else</td></tr><tr><td>9: end for</td><td>Ω"←Ω[i+1]+ω·Ω[𝑖+1]</td></tr><tr><td>Apply equivalent random permutation to W 10:</td><td>end if "[]</td></tr><tr><td>and T</td><td>P←1-+1 11:</td></tr><tr><td>11: Ω[n] ←1</td><td>12: Swap ω with W[i] and T with T[i]</td></tr><tr><td>12: Ω[n-1] ←1</td><td>with probability P</td></tr><tr><td>forn-1≥i≥0do 13:</td><td>13: Ω[i]←Ω'</td></tr><tr><td>14: 2[i]=W[i]·Ω2[i+1]</td><td>14: end for</td></tr><tr><td>15: end for</td><td>15: forn-2≥i≥0do</td></tr><tr><td>16: forn-2≥i≥0do</td><td>16: Ω[]=[i+1]+W[i]·Ω[i+1]</td></tr><tr><td>17: {[i]=2[i+1]+W[i]·Ω2[i+1]</td><td>17: end for</td></tr><tr><td>18: end for</td><td>18:end function</td></tr><tr><td>19: for all time t ≥ n do</td><td></td></tr><tr><td>20: Receive Wt</td><td></td></tr><tr><td>21: UPDATE(Wt,t)</td><td></td></tr><tr><td>22: end for</td><td></td></tr><tr><td></td><td></td></tr></table>
In the previous section we derived a gradient estimator for our desired memory distribution. in this section we introduce a method for sampling from this distribution online. Specifically we will formulate a reservoir sampling algorithm for drawing a subset $\hat { T }$ of size $n$ from a set of indices $T = \{ 0 , . . . , t - 1 \}$ according to a distribution parameterized by a weight $w _ { i }$ for each index $i \in T$ . Following equation 7 the probability for a given subset $\hat { T }$ is defined as follows:
$$\tilde { P } ( \hat { T } ; T , n ) = \prod _ { i \in \hat { T } } w _ { i } \Bigg / \sum _ { \tilde { T } \in \binom { T } { n } } \prod _ { i \in \tilde { T } } w _ { i }$$
This distribution can be sampled from by selecting members sequentially for $i \in \{ 0 , . . , n - 1 \}$ with the following conditional probabilities:
$$\hat { P } ( \hat { T } [ i ] | \hat { T } [ 0 : i - 1 ] ; T , n ) = w _ { \hat { T } [ i ] } \sum _ { \hat { T } \in \binom { T \setminus \hat { T } [ 0 : i ] } { n - i - 1 } } \prod _ { j \in \bar { T } } w _ { j } \left/ \left( ( n - i ) \sum _ { \hat { T } \in \binom { T \setminus \hat { T } [ 0 : i - 1 ] } { n - i } , j \in \bar { T } } \prod _ { j \in \bar { T } } w _ { j } \right) \right.$$
We abuse notation slightly and use $\hat { T }$ to refer to both an ordered vector and the set of its elements.
Lemma 1. Selecting elements sequentially according to equation $^ { 1 2 }$ will result in a vector $\hat { T }$ whose elements correspond to a sample drawn from equation $1 l$ .
Proof. See appendix C.
We use lemma 1 to derive a reservoir sampling procedure which works online to update the reservoir $\hat { T }$ at each time-step when a new index is added to $T$ along with an associated weight. The result is algorithm 1. At each time-step UPDATE moves through $\hat { T }$ starting from index 0 and chooses whether to swap the item and weight at each index with the ones currently contained in a buffer ( $\mathit { \Pi } _ { \tau }$ and $\omega$ , initially set to contain the newly added item and associated weight). The probability of swapping is chosen such that it corrects the conditional probability of the item at each index (conditioned on the items before it) to compensate for the item in the buffer being added to the set of possible items for that index. After doing this sequentially at each index the overall probability of $\hat { T }$ will be correct with the newly added item. Computing the necessary swap probabilities is nontrivial in itself, however we show that it is possible to do this in $O ( n )$ time per time-step (where here $\mathbf { n }$ is the memory size) by iteratively updating two vectors $\Omega$ and $\tilde { \Omega }$ .
Theorem 1. In algorithm $^ { l }$ let $t$ refer to the parameter of the call to UPDATE, $\hat { T } _ { t } [ i ]$ refer to the value of ${ \hat { T } } [ i ]$ when that call is made, and $T _ { t } = \{ t ^ { \prime } : 0 \leq t ^ { \prime } \leq t - 1 \}$ refer to the set of all time indices from 0 to $t - 1 . \forall t \geq n , 0 \leq i \leq n - 1 .$ :
$$P ( \hat { T } _ { t } [ i ] = t _ { i } | \hat { T } _ { t } [ 0 : i - 1 ] = [ t _ { 0 } , . . . , t _ { i - 1 } ] ) = \hat { P } ( t _ { i } | [ t _ { 0 } , . . . , t _ { i - 1 } ] ; T _ { t } , n )$$
where $[ t _ { 0 } , . . . , t _ { i } ]$ is any arbitrary vector of unique elements of $T _ { t }$ .
Proof. See appendix D.
Corollary 1.1. At the call to UPDATE with parameter $t$ $, \forall t \geq n , \hat { T } \in \binom { T _ { t } } { n }$
$$P ( \{ \hat { T } _ { t } [ 0 ] , . . . , \hat { T } _ { t } [ n - 1 ] \} = \hat { T } ) = \tilde { P } ( \hat { T } ; T _ { t } , n )$$
Proof. The proof follows from theorem 1 and lemma 1.
Corollary 1.1 tells us that for any given time-step algorithm 1 produces reservoirs which are a valid sample from the distribution of equation 11. Note that algorithm 1 runs in $O ( n )$ time per time-step where $n$ is the size of the memory. We use this algorithm along with the weights generated by our write network to manage updating the memory on each new state visitation.
The careful reader will notice that with the use of reservoir sampling equation 7 no longer holds explicitly. This is because certain parts of the history may strongly correlate with certain states being in memory at a particular time in the past, which under reservoir sampling will effect the distribution of the present memory. We do not account for this in this work and simply assume for the purpose of estimating gradients that the history of state visitation arises independently of the history of memory content. Further analysis of the implications of this assumption, and whether it can be weakened is left to future work.
# 4 EXPERIMENTS AND RESULTS
We test our algorithm on a toy problem we call “the secret informant problem”. The problem is intended to highlight the kinds of sharp, long-term dependencies that are often difficult for recurrent models. The problem is such that in order to behave optimally an agent must remember specific, initially unknown past states. An instance of the problem is shown in figure 2 and a detailed explanation of the problem structure is available in the associated caption. In each training episode a new random instance of the problem is created (with the chain length, number of actions and number of decisions held fixed for a particular training run). This consists of randomly choosing the rewarding action sequence, the location of the informative state for each decision, and the implied action and decision state for each of the uninformative states.
All experiments with our episodic memory architecture are run for 3 repetitions with error bars indicating standard error in the mean over these 3 runs. The architecture and hyper-parameters used in each experiment are identical. We use the architecture from section 2 with 1 hidden layer for the value, query and write networks and 2 hidden layers for policy. The value network and query network outputs each use tanh activation, the policy uses softmax, and the write network uses sigmoid. Each hidden layer has 10 units. We train using ordinary stochastic gradient descent with learning rate 0.005 and gradient estimates generated as specified in section 3.

Figure 2: (a) shows an instance of the secret informant problem with 3 actions $\alpha \ =$ $\{ u p , f o r w a r d , d o w n \} \rangle$ and 2 decision states. The start state uniquely contains all zeros. In the final 2 states of an episode (which we call decision states), the agent must select the right sequence of actions to receive a $+ 1$ reward, any other action sequence gives reward 0. At all other states the forward action leads forward along the chain while other actions keep the agent in the same state. The correct action (i.e. the one that leads towards the reward) at each decision state is indicated by a one hot encoding on bits 1-3 of a certain informative state where the pattern in bits 6 and 7 matches those of the decision state itself. Informative states are distinguished from uninformative states by bits 4 and 5. To succeed the agent must learn to remember informative states with the pattern 10 in bits 4 and 5 and subsequently query them at the associated decision state. (b) shows a particular state of the problem. The first 3 bits are action indicators, a one-hot encoding of the action the state is suggesting should be taken at the associated decision state. The next two bits are informative and uninformative indicators. If these bits are 01 the state is uninformative, meaning the decision state and associated action it suggests are uniformly random and give no indications of a correct action. If these bits are 10 then the state is informative and the associated action it suggests is on the path toward the reward at the decision state it indicates. The next two bits are decision state identifiers, in an informative state they indicate it provides information about the decision state with matching identifier, in a decision state they serve as an identifier for that decision state. Thus, the correct thing for an agent to do in each decision state is to take the action suggested by the informative state with matching values of bits 6 and 7. The next bit is a decision state indicator and will be 1 if and only if the state is a decision state. The final bit is a correct path indicator and indicates for a decision state whether all the decisions made so far have been correct. This is necessary for our current system because without it the final decision states all look the same and it is not possible to learn via one step updates which decision is correct at the first decision state, in future work we would like to investigate eliminating the need for information like this by using multi-step updates or eligibility traces. The particular state shown above is informative, it indicates that the correct action for the second decision state will be the up action. Versions of this problem can be created with variable length (which we use to refer to the number of informative states plus the number of uninformative states), number of actions, and number of decision states by modifying the above description in the obvious way.
 Figure 3: Experiment with environment length 10, 1 decision and a 1 state memory. In the 1 state memory case the query module is unnecessary. (a) shows average write weight assigned to informative states (•) and uninformative states $( \_ )$ . (b) shows average return with episodic memory learner (•) and recurrent baseline ().
 Figure 4: Experiment with environment length 10, 1 decision and a 3 state memory. In this case the query module is necessarily. (a) shows average write weight assigned to informative states (•) and uninformative states $( \_ )$ . (b) shows average return with episodic memory learner (•) and recurrent baseline $( \mathbb { L } )$ . (c) shows the value of several relevant query vector elements in the decision state: the uninformative indicator (N), the informative indicator $( \mathbb { L } )$ and the first decision state identifier (•) (unnecessary here since there is only one decision state, but included for uniformity).
 Figure 5: Experiment with environment length 10, 2 decisions and a 3 state memory. (a) shows average write weight assigned to informative states (•) and uninformative states $( \_ )$ . (b) shows average return with episodic memory learner (•) and recurrent baseline (). (c) shows the value of several relevant query vector elements in the first decision state: the uninformative indicator (N), the informative indicator $( \sqcup )$ , the first decision state identifier (•), and the second decision state identifier ${ \bf ( \omega ) }$ . (d) shows the same thing but for the query generated in the second decision state.
We also ran a recurrent baseline with full backpropagation through time which we found required more fine-tuning to train with online updates. To make comparison as meaningful as possible the recurrent baseline used essentially the same architecture but with the entire memory module replaced by a basic GRU (Cho et al., 2014) network of 10 units. Stochastic gradient descent alone was found to give very poor results with the recurrent learner so RMSProp was used instead. Additionally to obtain reasonable results with the recurrent learner, and avoid catastrophic looping behavior, it was necessary to add a discount factor $\gamma = 0 . 9$ , applied only for learning purposes and not used in computing the plotted return) as well as entropy regularization on the policy with a relatively low weight of 0.0005. Perhaps surprisingly neither of these were necessary with the episodic memory based system as it tended to proceed quickly through the chain without significant looping even without discounting or entropy regularization. We tuned the learning rate and layer width (including the number of recurrent units) for each of the 2 environments on which a recurrent baseline was trained according to highest average performance over the last 100 episodes of a single training run of 25000 episodes for the 1 decision environment, and 50000 episodes for the 2 decision environment. In each case learning rate was selected from $\{ 0 . 0 5 \cdot 2 ^ { - x } : x \in \{ 0 , . . . , 9 \} \}$ and layer width was selected from $\{ 5 , 1 0 , 1 5 , 2 0 \}$ . For the 1 decision environment we ran the recurrent baseline for 3 repeats, for the 2 decision environment due to higher variance we ran it for 10 repeats. This baseline is not intended to be representative of the performance of all possible architectures based on RNN variants trained with backpropagation through time, but merely to provide context for the main experimental results of this work.
Results and descriptions of the experiments are shown in figures 3, 4 and 5, in each plot the $\mathbf { X }$ -axis shows number of training episodes. One additional experiment with twice the environment length is shown in appendix E. Notice that in each case the episodic memory learner was is able to learn a good query policy, drive the write weight of the uninformative states to near 0 while keeping the value for informative states much larger, and obtain close to perfect average return. Comparing figures 3 and 4 it appears that the addition of redundant memory size may accelerate initial learning though it has little effect on the overall convergence time. Comparing figures 4 and 5 the number of episodes to converge appears to roughly double from approximately 25, 000 to 50, 000 with the addition of the extra decision state but the training remains quite stable.
# 5 CONCLUSION
We present a novel algorithm for integrating a form of external memory with trainable reading and writing into a RL agent. The method depends on the observation that if we restrict the information stored in memory to be a set of past visited states, the information recorded also provides the context in which it was recorded. This means it is possible to assign credit to useful information without needing to backpropagate through time to when it was recorded. To achieve this we devise a reservoir sampling technique which uses a sampling procedure we introduce to generate a distribution over memory configurations for which we can derive gradient estimates. The whole algorithm is ${ \mathrm { O } } ( { \mathrm { n } } )$ in both the number of trainable parameters and the size of the memory. In particular neither memory required nor computation time increase with history length, making it feasible to run in an online RL setting. We show that the resulting algorithm is able to achieve good performance on a toy problem we introduce designed to have sharp long-term dependencies which can be problematic for recurrent models.
# ACKNOWLEDGEMENTS
We acknowledge the support of the Natural Sciences and Engineering Council of Canada (NSERC).
# REFERENCES
Bram Bakker, Viktor Zhumatiy, Gabriel Gruener, and Jurgen Schmidhuber. A robot that ¨ reinforcement-learns to identify and memorize important previous observations. In International Conference on Intelligent Robots and Systems, 2003. Min-Te Chao. A general purpose unequal probability sampling plan. Biometrika, 69(3):653–656, 1982. Kyunghyun Cho, Bart Van Merrienboer, Dzmitry Bahdanau, and Yoshua Bengio. On the properties ¨ of neural machine translation: Encoder-decoder approaches. In Workshop on Syntax, Semantics and Structure in Statistical Translation, 2014. Pavlos S Efraimidis and Paul G Spirakis. Weighted random sampling with a reservoir. Information Processing Letters, 97(5):181–185, 2006. Alex Graves, Greg Wayne, and Ivo Danihelka. Neural turing machines. arXiv preprint arXiv:1410.5401, 2014. Alex Graves, Greg Wayne, Malcolm Reynolds, Tim Harley, Ivo Danihelka, Agnieszka GrabskaBarwinska, Sergio G ´ omez Colmenarejo, Edward Grefenstette, Tiago Ramalho, John Agapiou, ´ et al. Hybrid computing using a neural network with dynamic external memory. Nature, 538 (7626):471–476, 2016. Caglar Gulcehre, Sarath Chandar, and Yoshua Bengio. Memory augmented neural networks with wormhole connections. arXiv preprint arXiv:1701.08718, 2017. Matthew Hausknecht and Peter Stone. Deep recurrent q-learning for partially observable mdps. In AAAI Fall Symposium on Sequential Decision Making for Intelligent Agents, 2015. Armand Joulin and Tomas Mikolov. Inferring algorithmic patterns with stack-augmented recurrent nets. In Neural Information Processing Systems, 2015. Łukasz Kaiser, Ofir Nachum, Aurko Roy, and Samy Bengio. Learning to remember rare events. In International Conference on Representation Learning, 2017.
Volodymyr Mnih, Adria Puigdomenech Badia, Mehdi Mirza, Alex Graves, Timothy Lillicrap, Tim Harley, David Silver, and Koray Kavukcuoglu. Asynchronous methods for deep reinforcement learning. In International Conference on Machine Learning, 2016.
Junhyuk Oh, Valliappa Chockalingam, Satinder P. Singh, and Honglak Lee. Control of memory, active perception, and action in minecraft. In International Conference on Machine Learning, 2016.
Sainbayar Sukhbaatar, Arthur Szlam, Jason Weston, and Rob Fergus. End-to-end memory networks. In Neural Information Processing Systems, 2015.
Richard S Sutton, David A McAllester, Satinder P Singh, and Yishay Mansour. Policy gradient methods for reinforcement learning with function approximation. In Neural Information Processing Systems, 2000.
Richard S Sutton, Joseph Modayil, Michael Delp, Thomas Degris, Patrick M Pilarski, Adam White, and Doina Precup. Horde: A scalable real-time architecture for learning knowledge from unsupervised sensorimotor interaction. In International Conference on Autonomous Agents and Multiagent Systems, 2011.
Daan Wierstra, Alexander Forster, Jan Peters, and J ¨ urgen Schmidhuber. Recurrent policy gradients. ¨ Logic Journal of IGPL, 18(5):620–634, 2010.
Ronald J Williams. Simple statistical gradient-following algorithms for connectionist reinforcement learning. Machine learning, 8(3-4):229–256, 1992.
Wojciech Zaremba and Ilya Sutskever. Reinforcement learning neural turing machines. arXiv preprint arXiv:1505.00521, 419, 2015.
Marvin Zhang, Sergey Levine, Zoe McCarthy, Chelsea Finn, and Pieter Abbeel. Policy learning with continuous memory states for partially observed robotic control. In International Conference on Robotics and Automation, 2016.
A DERIVATION OF EXPRESSION FOR GRADIENT FOR ONE-STATE MEMORY
$$P _ { t } ( m _ { t } = S _ { i } ) = { w _ { i } \Bigg / \sum _ { j = 0 } ^ { t - 1 } w _ { j } }$$
$$E _ { t } [ R _ { t } ] = \sum _ { k = 0 } ^ { t - 1 } P _ { t } ( m _ { t } = S _ { k } ) \sum _ { a \in \mathcal { A } } \pi ( a | S _ { t } , S _ { k } ) E _ { t } [ R _ { t } | A _ { t } = a ]$$
$$\begin{array} { l } { \displaystyle \frac { \partial } { \partial w _ { i } } E _ { t } [ R _ { t } ] = \sum _ { k = 0 } ^ { t - 1 } \Biggl ( \frac { \partial P _ { t } ( m _ { t } = S _ { k } ) } { \partial w _ { i } } \sum _ { a \in \mathcal { A } } \pi ( a | S _ { t } , S _ { k } ) E _ { t } [ R _ { t } | A _ { t } = a ] } \\ { \displaystyle + P _ { t } ( m _ { t } = S _ { k } ) \sum _ { a \in \mathcal { A } } \pi ( a | S _ { t } , S _ { k } ) \frac { \partial E _ { t } [ R _ { t } | A _ { t } = a ] } { \partial w _ { i } } \Biggr ) } \end{array}$$
Working out the first term:
$$\begin{array} { r l } & \begin{array} { r l } & \frac { 1 } { \sqrt { 2 } } \frac { \partial \xi ( \xi ( \xi ) = 0 , \xi ( \xi ) ) } { \partial \xi ( \xi ) } \underset { \xi \in \mathcal { R } _ { 0 } } { \overset { . . . . } { \sum } } \frac \partial \xi ( \xi ( \xi ) , \xi ( \xi ) , \xi ( \xi ) , \xi ( \xi ) , \xi ( \xi ) , \xi ( \xi ) , \xi ( \xi ) , \xi ( \xi ) , \xi ( \xi ) , \xi ( \xi ) , \xi ( \xi ) , \xi ( \xi ) , \xi ( \xi ) , \xi ( \xi ) , \xi ( \xi ) , \xi ( \xi ) , \xi ( \xi ) , \xi ( \xi ) , \xi ( \xi ) , \xi ( \xi ) , \xi ( \xi ) , \xi ( \xi ) , \xi ( \xi ) , \xi ( \xi ) , \xi ( \xi ) , \xi ( \xi ) , \xi ( \xi ) , \xi ( \xi ) , \xi ( \xi ) , \xi ( \xi ) , \xi ( \xi ) , \xi ( \xi ) , \xi ( \xi ) , \xi ( \xi ) , \xi ( \xi ) , \xi ( \xi ) , \xi ( \xi ) , \xi ( \xi ) , \xi ( \xi ) , \xi ( \xi ) , \xi ( \xi ) , \xi ( \xi ) , \xi ( \xi ) , \xi ( \xi ) , \xi ( \xi ) , \xi ( \xi ) , \xi ( \xi ) , \xi ( \xi ) , \xi ( \xi ) , \xi ( \xi ) , \xi ( \xi ) , \xi ( \xi ) , \xi ( \xi ) , \xi ( \xi ) , \xi , \xi ( \xi ) , \xi ( \xi ) , \xi ( \xi ) , \xi , \xi ( \xi ) , \xi ( \xi ) , \xi , \xi ( \xi ) , \xi ( \xi ) , \xi , \xi ( \xi ) , \xi ( \xi ) , \xi , \xi ( \xi ) , \xi ( \xi ) , \xi , \xi ( \xi ) , \xi , \xi ( \xi ) , \xi , \xi ( \xi ) , \xi , \xi ( \xi ) , \xi , \xi ( \xi ) , \xi , \xi ( \xi ) , \xi , \xi ( \xi ) , \xi , \xi ( \xi ) , \xi , \xi ( \xi ) , \xi , \xi ( \xi ) , \xi , \xi ( \xi ) , \xi , \xi ( \xi ) , \xi , \xi ( \xi ) , \xi , \xi ( \xi ) , \xi , \xi ( \xi ) , \xi , \xi ( \xi ) , \xi , \xi ( \xi ) , \xi , \xi ( \xi ) , \xi , \xi ( \xi ) , \xi , \xi ( \xi ) , \xi , \xi ( \xi ) , \end{array} \end{array}$$
Working out the second term:
$$\begin{array} { r l } & { \displaystyle \sum _ { k = 0 } ^ { t - 1 } P _ { t } ( m _ { t } = S _ { k } ) \sum _ { a \in \mathcal { A } } \pi ( a | S _ { t } , S _ { k } ) \frac { \partial E _ { t } [ R _ { t } | A _ { t } = a ] } { \partial w _ { i } } } \\ & { = \displaystyle \sum _ { k = 0 } ^ { t - 1 } P _ { t } ( m _ { t } = S _ { k } ) \sum _ { a \in \mathcal { A } } \pi ( a | S _ { t } , S _ { k } ) \left( \frac { \partial E _ { t } [ r _ { t + 1 } | A _ { t } = a ] } { \partial w _ { i } } + \gamma \frac { \partial E _ { t } [ R _ { t + 1 } | A _ { t } = a ] } { \partial w _ { i } } \right) } \\ & { = \gamma E _ { t } \left[ \frac { \partial } { \partial w _ { i } } E _ { t + 1 } [ R _ { t + 1 } ] \right] } \end{array}$$
Where we are able to drop ∂Et[rt+1|At=a] because the immediate reward is independent of the state in memory once conditioned on the action. Thus we finally arrive at:
$$\begin{array} { r } { \cfrac { \partial } { \partial w _ { i } } E _ { t } [ R _ { t } ] = \cfrac { 1 } { w _ { i } } P _ { t } ( m _ { t } = S _ { i } ) \left( \displaystyle \sum _ { a \in A } \pi ( a | S _ { t } , S _ { i } ) E _ { t } [ R _ { t } | A _ { t } = a ] - E _ { t } [ R _ { t } ] \right) } \\ { + \left. \gamma E _ { t } \left[ \cfrac { \partial } { \partial w _ { i } } E _ { t + 1 } [ R _ { t + 1 } ] \right] \right. } \end{array}$$
B DERIVATION OF EXPRESSION FOR GRADIENT FOR MULTIPLE-STATE MEMORY
$$\begin{array} { c } { { P _ { t } ( \mathcal { M } _ { t } = S _ { \hat { T } } ) = { \displaystyle { \prod _ { i \in \hat { T } } w _ { i } } } \Bigg / { \displaystyle { \sum _ { \tilde { T } \in \binom { T _ { t } } { n } } \prod _ { i \in \tilde { T } } w _ { i } } } } } \\ { E _ { t } [ R _ { t } ] = \displaystyle { \sum _ { \hat { T } \in \binom { T _ { t } } { n } } P _ { t } ( \mathcal { M } _ { t } = S _ { \hat { T } } ) \displaystyle { \sum _ { j \in \hat { T } } Q ( S _ { j } | S _ { \hat { T } } ) \sum _ { a \in \mathcal { A } } \pi ( a | S _ { t } , S _ { j } ) E _ { t } [ R _ { t } | A _ { t } = a ] } } } \end{array}$$
$$\begin{array} { r } { \frac { \partial } { \partial w _ { i } } E _ { t } [ R _ { t } ] = \displaystyle \sum _ { \hat { T } \in \binom { T _ { t } } { n } } \left( \frac { \partial P _ { t } ( \mathcal { M } _ { t } = S _ { \hat { T } } ) } { \partial w _ { i } } \sum _ { j \in \hat { T } } Q ( S _ { j } | \mathcal { M } _ { t } = S _ { \hat { T } } ) \sum _ { a \in A } \pi ( a | S _ { t } , S _ { j } ) E _ { t } [ R _ { t } | A _ { t } = a ] \right. } \\ { \displaystyle \left. + P _ { t } ( \mathcal { M } _ { t } = S _ { \hat { T } } ) \sum _ { j \in \hat { T } } Q ( S _ { j } | S _ { \hat { T } } ) \sum _ { a \in A } \pi ( a | S _ { t } , S _ { j } ) \frac { \partial E _ { t } [ R _ { t } | A _ { t } = a ] } { \partial w _ { i } } \right) } \end{array}$$
Working out the first term:
$$\begin{array} { r l } & { \begin{array} { r l } & { \gamma _ { 1 } : 2 1 } \\ & { - \frac { 2 } { \sqrt { 2 } \pi \lambda } } \\ & { \gamma _ { 2 } : 2 1 } \\ & { - \frac { 2 } { \sqrt { 2 } \pi \lambda } ( \lambda - \lambda _ { 1 } ^ { 2 } ) ( \lambda - \lambda _ { 2 } ^ { 2 } ) \lambda _ { 1 } ( \lambda _ { 1 } ^ { 2 } - \lambda _ { 2 } ^ { 2 } ) } \end{array} \Biggr \} \frac { \sum _ { i = 1 } ^ { \infty } \lambda _ { i } ^ { 2 } } { 2 \sqrt { 2 } \pi \lambda } \lambda _ { i } ( \lambda _ { 1 } ^ { 2 } - \lambda _ { 2 } ^ { 2 } ) \lambda _ { 2 } ( \lambda _ { 2 } ^ { 2 } - \lambda _ { 1 } ^ { 2 } ) } \\ & { \qquad \quad \times \frac { \lambda } { 2 } \sum _ { i = 1 } ^ { \infty } \lambda _ { i } ^ { 2 } ( \lambda _ { 1 } ^ { 2 } - \lambda _ { 2 } ^ { 2 } ) } \\ & { \qquad \quad + \sum _ { i \neq 2 } ^ { \infty } \lambda _ { i } ^ { 2 } \lambda _ { 1 } ^ { 2 } \lambda _ { 1 } ^ { 2 } \lambda _ { 2 } ^ { 2 } \lambda _ { 1 } ^ { 3 } \lambda _ { 2 } ^ { 3 } \lambda _ { 1 } ^ { 4 } \lambda _ { 2 } ^ { 4 } \lambda _ { 1 } ^ { 4 } \lambda _ { 2 } ^ { 4 } \lambda _ { 2 } ^ { 4 } } \\ & { \qquad \quad + \sum _ { i \neq 2 } ^ { \infty } \lambda _ { i } ^ { 2 } \lambda _ { 1 } ^ { 2 } \lambda _ { 2 } ^ { 4 } \lambda _ { 1 } ^ { 4 } \lambda _ { 1 } ^ { 4 } \lambda _ { 2 } ^ { 4 } \lambda _ { 2 } ^ { 4 } \lambda _ { 2 } ^ { 4 } \lambda _ { 1 } ^ { 4 } \lambda _ { 1 } ^ { 4 } \lambda _ { 2 } ^ { 4 } \lambda _ { 2 } ^ { 4 } } \\ & \qquad \quad \times \frac { \lambda } { 2 } \sum _ { i \neq 3 } ^ { \infty } \lambda _ { i } ^ { 2 } ( \lambda _ { 1 } ^ { 2 } - \lambda _ { 2 } ^ { 2 } ) \lambda _ { i } ^ { 2 } \lambda _ { 2 } ^ { 4 } \lambda _ { 3 } ^ { 2 } \lambda _ { 2 } ^ { 4 } \lambda _ { 3 } ^ { 2 } \lambda _ { 2 } ^ { 4 } \lambda _ { 3 } ^ { 2 } \lambda _ { 2 } \end{array}$$
Working out the second term:
$$\begin{array} { r l } & { \displaystyle \sum _ { \bar { T } \in \{ \binom { T } { n } } } P _ { t } ( M _ { t } = S _ { \hat { T } } ) \displaystyle \sum _ { j \in \bar { T } } Q ( S _ { j } | S _ { \hat { T } } ) \displaystyle \sum _ { a \in \mathcal { A } } \pi ( a | S _ { t } , S _ { j } ) \displaystyle \frac { \partial E _ { t } [ R _ { t } | A _ { t } = a ] } { \partial w _ { i } } \\ & { \displaystyle = \sum _ { \hat { T } \in \binom { T } { n } } P _ { t } ( M _ { t } = S _ { \hat { T } } ) \displaystyle \sum _ { j \in \bar { T } } Q ( S _ { j } | S _ { \hat { T } } ) \displaystyle \sum _ { a \in \mathcal { A } } \pi ( a | S _ { t } , S _ { j } ) \left( \displaystyle \frac { \partial E _ { t } [ r _ { t + 1 } | A _ { t } = a ] } { \partial w _ { i } } \right. } \\ & { \quad \quad \quad \quad \quad \quad \left. + \gamma \displaystyle \frac { \partial E _ { t } [ R _ { t + 1 } | A _ { t } = a ] } { \partial w _ { i } } \right) } \\ & { \displaystyle = \gamma E _ { t } \left[ \displaystyle \frac { \partial } { \partial w _ { i } } E _ { t + 1 } [ R _ { t + 1 } ] \right] } \end{array}$$
So all together we get:
$$\begin{array} { r } { \frac { \partial } { \partial w _ { i } } E _ { t } [ R _ { t } ] = \displaystyle \sum _ { \hat { T } \in ( \binom { T _ { t } } { n } \ni i ) } \frac { 1 } { w _ { i } } P _ { t } ( \boldsymbol { M } _ { t } = \boldsymbol { S } _ { \hat { T } } ) \Bigg ( \displaystyle \sum _ { j \in \hat { T } } Q ( \boldsymbol { S } _ { j } | \boldsymbol { S } _ { \hat { T } } ) \sum _ { a \in \mathcal { A } } \boldsymbol { \pi } ( a | \boldsymbol { S } _ { t } , \boldsymbol { S } _ { j } ) E _ { t } [ R _ { t } | \boldsymbol { A } _ { t } = a ] } \\ { - E _ { t } [ R _ { t } ] \Bigg ) + \gamma E _ { t } \left[ \frac { \partial } { \partial w _ { i } } E _ { t + 1 } [ R _ { t + 1 } ] \right] } \end{array}$$
# C PROOF OF LEMMA 1
Lemma 1. Selecting elements sequentially according to equation 12 will result in a vector $\hat { T }$ whose elements correspond to a sample drawn from equation $1 l$ .
Proof. Selecting elements sequentially according to equation 12 gives the following probability for a given vector $\hat { T }$ .
$$\begin{array} { r l } { P ( \hat { T } ) = P ( \hat { T } [ 0 ] ) P ( \hat { T } [ 1 ] | T [ 0 ] ) . . . P ( \hat { T } [ n - 1 ] | \hat { T } [ 0 : n - 2 ] ) } & { } \\ { \displaystyle } & { = \frac { w _ { \hat { T } [ 0 ] } } { \tilde { T } [ 0 ] } \sum _ { \tilde { T } \in \binom { T \hat { T } [ 0 ] } { n - 1 } , j \in \tilde { T } } \prod _ { \ell = \tilde { T } } w _ { \hat { T } [ 1 ] } \sum _ { \tilde { T } \in \binom { T \hat { T } [ 0 , 1 ] } { n - 2 } , j \in \tilde { T } } w _ { j } } \\ { \displaystyle } & { \qquad \sum _ { \tilde { T } \in \binom { T } { n } , j \in \tilde { T } } \prod _ { \ell = \tilde { T } } w _ { j } \cdot \frac { \tilde { T } \in \binom { T \hat { T } [ 0 , 1 ] } { n - 2 } \tilde { \jmath } \in \tilde { T } } { \tilde { T } \in \binom { T \hat { T } \hat { \imath } - \tilde { T } [ 0 ] } { n - 1 } \jmath \in \tilde { T } } \prod _ { \ell = \tilde { T } } w _ { j } \cdots \frac { w _ { \hat { T } [ n - 1 ] } } { \tilde { T } \in \binom { T \hat { T } \hat { \imath } - \tilde { \imath } - \tilde { \imath } - \tilde { \imath } - \tilde { \jmath } } { 1 } \jmath \in \tilde { T } } \prod _ { \ell = \tilde { T } } w _ { j } } \\ { \displaystyle } & { = \prod _ { \ell \in \tilde { T } } w _ { i } / ( n ! \sum _ { \tilde { T } \in \binom { T } { n } } \prod _ { \ell \in \tilde { T } } w _ { i } ) } \end{array}$$
To complete the proof note that this is one of $n$ ! vectors with the same set of elements in different order, each of which will have equal probability, hence to obtain the probability for the corresponding set we simply have to multiply by $n !$ which gives us equation 11. □
# D PROOF OF THEOREM 1
We divide the proof into a series of lemmas. First we will define some notation to facilitate referencing algorithm 1 in the proofs below. Let $T _ { t }$ be the set $\{ 0 , . . . , t - 1 \}$ and $\hat { T } _ { t } [ 0 : i - 1 ]$ be the value of ${ \hat { T } } [ 0 : i - 1 ]$ at the call to UPDATE with parameter $t$ . Note that $\hat { T } _ { t } [ 0 : - 1 ] = \varnothing$ . Let $\Omega _ { t } [ i ]$ and $\tilde { \Omega } _ { t } [ i ]$ be the values of $\Omega [ i ]$ and $\tilde { \Omega } [ i ]$ respectively, at the call to UPDATE with parameter $t$ . Let $P _ { t , i }$ be the value of $\mathrm { \bf P }$ when it is set in loop index i of the loop starting at line 4 within the call to UPDATE with parameter t. Let $\Omega _ { t , i } ^ { \prime \prime }$ and $\Omega _ { t , i } ^ { \prime }$ be the values of $\Omega ^ { \prime \prime }$ and $\Omega ^ { \prime }$ respectively after they are set within index $i$ of the loop starting at line 4 within the UPDATE call with parameter $t$ . Let $\omega _ { t , i }$ and $\tau _ { t , i }$ be the values of $\omega$ and $\tau$ respectively at the beginning of loop index i of the loop starting at line 4 within the call to UPDATE with parameter t. Note that $\omega _ { t , i } = { w _ { \tau _ { t , i } } }$ .
Lemma 2.
$$\Big ( T _ { t + 1 } \setminus \hat { T } _ { t + 1 } [ 0 : i - 1 ] \Big ) = \Big ( T _ { t } \setminus \hat { T } _ { t } [ 0 : i - 1 ] \Big ) \cup \{ \tau _ { t , i } \}$$
Proof. By design $T _ { t + 1 } = T _ { t } \cup \{ \tau _ { t , 0 } \}$ . Towards a proof by induction assume that after choosing whether or not to swap $\hat { T } _ { t } [ i ]$ we have:
$$\Big ( T _ { t + 1 } \setminus \hat { T } _ { t + 1 } [ 0 : i - 1 ] \Big ) = \Big ( T _ { t } \setminus \hat { T } _ { t } [ 0 : i - 1 ] \Big ) \cup \{ \tau _ { t , i } \}$$
Then on the next iteration either we swap ${ \hat { T } } [ i ]$ for $\tau _ { t , i }$ or we don’t. If we do swap then $\tau _ { t , i + 1 } = \hat { T } _ { t } [ i ]$ and $\hat { T } _ { t + 1 } [ i ] = \tau _ { t , i }$ thus
$$\begin{array} { r l } { \Big ( T _ { t + 1 } \setminus \hat { T } _ { t + 1 } [ 0 : i ] \Big ) = \Big ( T _ { t + 1 } \setminus \hat { T } _ { t + 1 } [ 0 : i - 1 ] \Big ) \setminus \{ T _ { t + 1 } [ i ] \} } & { } \\ { = \Big ( T _ { t } \setminus \hat { T } _ { t } [ 0 : i - 1 ] \Big ) \cup \{ \pi _ { t , i } \} \setminus \{ T _ { t + 1 } [ i ] \} } & { } \\ { = \Big ( T _ { t } \setminus \hat { T } _ { t } [ 0 : i - 1 ] \Big ) \cup \{ \pi _ { t , i } \} \setminus \{ \pi _ { t , i } \} } & { } \\ { = \Big ( T _ { t } \setminus \hat { T } _ { t } [ 0 : i - 1 ] \Big ) } & { } \\ { = \Big ( T _ { t } \setminus \hat { T } _ { t } [ 0 : i ] \Big ) \cup \{ T _ { t } [ i ] \} } & { } \\ { = \Big ( T _ { t } \setminus \hat { T } _ { t } [ 0 : i ] \Big ) \cup \{ T _ { t , i + 1 } \} } & { } \end{array}$$
On the other hand if we do not swap then $\tau _ { t , i + 1 } = \tau _ { t , i }$ and $\hat { T } _ { t + 1 } [ i ] = \hat { T } _ { t } [ i ]$ thus
$$\begin{array} { r l } & { \Big ( T _ { t + 1 } \setminus \hat { T } _ { t + 1 } [ 0 : i ] \Big ) = \Big ( T _ { t + 1 } \setminus \hat { T } _ { t + 1 } [ 0 : i - 1 ] \Big ) \setminus \{ T _ { t + 1 } [ i ] \} } \\ & { \qquad = \Big ( T _ { t } \setminus \hat { T } _ { t } [ 0 : i - 1 ] \Big ) \cup \{ \tau _ { t , i } \} \setminus \{ T _ { t + 1 } [ i ] \} } \\ & { \qquad = \Big ( T _ { t } \setminus \hat { T } _ { t } [ 0 : i - 1 ] \Big ) \cup \{ \tau _ { t + 1 , i } \} \setminus \{ T _ { t } [ i ] \} } \\ & { \qquad = \Big ( T _ { t } \setminus \hat { T } _ { t } [ 0 : i ] \Big ) \cup \{ \tau _ { t , i + 1 } \} } \end{array}$$
Which suffices to complete the inductive proof.
Lemma 3.
$$\sum _ { \tilde { T } \in ( \binom { T \cup \{ \hat { t } \} } { m } \tilde { t } \in \tilde { T } ) } \prod _ { \tilde { t } \in \tilde { T } } w _ { \tilde { t } } = \sum _ { \tilde { T } \in ( \binom { T } { m } \tilde { t } \in \tilde { T } } \prod _ { \tilde { t } \in \tilde { T } } w _ { \tilde { t } } + w _ { \hat { t } } \cdot \sum _ { \tilde { T } \in ( \binom { T } { m - 1 } \tilde { t } \in \tilde { T } } \prod _ { \tilde { t } \in \tilde { T } } w _ { \tilde { t } }$$
Proof. The proof follows from noting that the first sum on the right side includes every term of the left sum where $\tilde { T }$ does not contain $\hat { t }$ , while the second term on the right side is equivalent to summing over those $\tilde { T }$ in the left sum that do contain $\hat { t }$ . □
Lemma 4. For $t \geq n$
$$\Omega _ { t } [ i ] = \sum _ { \tilde { T } \in \binom { T _ { t } \setminus \hat { T } _ { t } [ 0 : i - 1 ] } { n - i } } \prod _ { \tilde { t } \in \tilde { T } } w _ { \tilde { t } } , \forall i \in \{ 0 , . . . , n \}$$
$$\tilde { \Omega } _ { t } [ i ] = \sum _ { \tilde { T } \in \binom { T _ { t } \setminus \tilde { T } _ { t } [ 0 : i - 1 ] } { n - i - 1 } } \prod _ { \tilde { t } \in \tilde { T } } w _ { \tilde { t } } , \forall i \in \{ 0 , . . . , n - 1 \}$$
Proof. Towards a proof by induction, assume the lemma holds at time $t$ , a quick trace through algorithm 1 will show that the update leading to $\Omega _ { t + 1 } [ i ]$ for $i \in \{ 0 , . . . , n - 1 \}$ is always:
$$\Omega _ { t + 1 } [ i ] = \Omega _ { t } [ i ] + \omega _ { t , i } \cdot \tilde { \Omega } _ { t } [ i ]$$
From here we can apply lemma 3, along with lemma 2 as follows to get the desired result:
$$\begin{array} { r l } & { \Omega _ { t + 1 } [ i ] = \Omega _ { t } [ i ] + \omega _ { t , i } \cdot \tilde { \Omega } _ { t } [ i ] } \\ & { \quad \quad = \quad \quad \quad \sum _ { \tilde { T } \in \binom { T _ { t } \setminus \hat { T } _ { t } [ 0 : i - 1 ] } { n - i } } \prod _ { \tilde { t } \in \tilde { T } } w _ { \tilde { t } } + \omega _ { t , i } \cdot \sum _ { \tilde { T } \in \binom { T _ { t } \setminus \hat { T } _ { t } [ 0 : i - 1 ] } { n - i - 1 } } \prod _ { \tilde { t } \in \tilde { T } } w _ { \tilde { t } } } \\ & { \quad \quad \quad = \quad \quad \quad \quad \quad \sum _ { \tilde { T } \in \binom { T _ { t + 1 } \setminus \hat { T } _ { t + 1 } [ 0 : i - 1 ] } { n - i } } \prod _ { \tilde { t } \in \tilde { T } } w _ { \tilde { t } } } \\ & { \quad \quad \quad \quad \tilde { T } \in \binom { T _ { t + 1 } \setminus \hat { T } _ { t + 1 } [ 0 : i - 1 ] } { n - i } \tilde { t } \in \tilde { T } } \end{array}$$
Now note that $\tilde { \Omega } _ { t } [ n ] = 1$ for all $t$ which is also the correct value thus we have completed the induction step for the first half of the lemma.
On the other hand the update leading to $\tilde { \Omega } _ { t + 1 } [ i ]$ is as follows:
$$\tilde { \Omega } _ { t + 1 } [ i ] = \Omega _ { t + 1 } [ i + 1 ] + w _ { \hat { T } _ { t + 1 } [ i ] } \cdot \tilde { \Omega } _ { t + 1 } [ i + 1 ]$$
As a second level of induction assume the lemma holds for $\tilde { \Omega } _ { t + 1 } [ i + 1 ]$ then applying lemma 3 we get:
$$\begin{array} { r l } & { \tilde { \Omega } _ { t + 1 } [ i ] = \Omega _ { t + 1 } [ i + 1 ] + w _ { \hat { T } _ { t + 1 } [ i ] } \cdot \tilde { \Omega } _ { t + 1 } [ i + 1 ] } \\ & { \quad \quad = \quad \quad \displaystyle \sum _ { \tilde { T } \in \binom { T _ { t + 1 } \setminus \hat { T } _ { t + 1 } [ 0 : i ] } { n - i - 1 } } \prod _ { \tilde { t } \in \tilde { T } } w _ { \tilde { t } } + w _ { \hat { T } _ { t + 1 } [ i ] } \cdot \sum _ { \tilde { T } \in \binom { T _ { t + 1 } \setminus \hat { T } _ { t + 1 } [ 0 : i ] } { n - i - 2 } } \prod _ { \tilde { t } \in \tilde { T } } w _ { \tilde { t } } } \\ & { \quad \quad \quad = \quad \quad \displaystyle \sum _ { \tilde { T } \in \binom { T _ { t + 1 } \setminus \hat { T } _ { t + 1 } [ 0 : i - 1 ] } { n - i - 1 } } \prod _ { \tilde { t } \in \tilde { T } } w _ { \tilde { t } } } \\ & { \quad \quad \quad \quad \tilde { T } \in \binom { T _ { t + 1 } \setminus \hat { T } _ { t + 1 } [ 0 : i - 1 ] } { n - i - 1 } \tilde { t } \in \tilde { T } } \end{array}$$
As the base case for this second level of induction, note that $\tilde { \Omega } _ { t + 1 } [ n - 1 ] = 1$ for all $t$ which is also the correct value, thus assuming $\Omega _ { t + 1 }$ is correct we will also get the correct values for $\tilde { \Omega } _ { t + 1 }$ . This completes the induction step for the lemma, it remains to prove the base case.
Note that $\Omega [ n ]$ and $\tilde { \Omega } [ n - 1 ]$ each start at 1. The beginning of the algorithm before line 19 is then intended to initialize all $\Omega$ and $\tilde { \Omega }$ values to have the correct value at time $t = n$ , to see that this is the case, first note $\forall i \in \{ 0 , . . . , n \}$ :
$$\begin{array} { l } { { \displaystyle \Omega _ { n } [ i ] = \prod _ { j = i } ^ { n - 1 } w _ { \hat { T } _ { n } [ j ] } } } \\ { { \displaystyle = \sum _ { \tilde { T } \in \binom { T _ { n } \setminus \hat { T } _ { n } [ 0 : i - 1 ] } { n - i } \tilde { t } \in \tilde { T } } w _ { \tilde { t } } } } \end{array}$$
And also, by induction on the trivial $i = n - 1$ case, $\forall i \in \{ 0 , . . . , n - 2 \} ;$ :
$$\begin{array} { r l } & { \tilde { \Omega } _ { n } [ i ] = \Omega _ { n } [ i + 1 ] + w _ { \hat { T } _ { n } [ i ] } \cdot \tilde { \Omega } _ { n } [ i + 1 ] } \\ & { \quad \quad = \displaystyle \sum _ { \tilde { T } \in \binom { T _ { n } \setminus \hat { T } _ { n } [ 0 : i ] } { n - i - 1 } } \prod _ { \tilde { t } \in \tilde { T } } w _ { \tilde { t } } + w _ { \hat { T } _ { n } [ i ] } \cdot \sum _ { \tilde { T } \in \binom { T _ { n } \setminus \hat { T } _ { n } [ 0 : i ] } { n - i - 2 } } \prod _ { \tilde { t } \in \tilde { T } } w _ { \tilde { t } } } \\ & { \quad \quad = \displaystyle \sum _ { \tilde { T } \in \binom { T _ { n } \setminus \hat { T } _ { n } [ 0 : i - 1 ] } { n - i - 1 } } \prod _ { \tilde { t } \in \tilde { T } } w _ { \tilde { t } } } \\ & { \qquad \tilde { T } \in \binom { T _ { n } \setminus \hat { T } _ { n } [ 0 : i - 1 ] } { n - i - 1 } \tilde { t } \in \tilde { T } } \end{array}$$
Thus indeed the lemma holds at time $n$ which serves as a base case for the rest of the proof.
Lemma 5. Pt,i = 1 − Pˆ(Tˆt[i]|Tˆt+1[0:i−1];Tt+1,n)
Proof. Substituting the definition from equation 12, along with the value assigned to $P _ { t , i }$ and simplifying slightly what we wish to show is:
$$\begin{array}{c} \frac { \Omega _ { t , i } ^ { \prime \prime } \Omega _ { t } \left[ i \right] } { \Omega _ { t , i } ^ { \prime } \Omega _ { t } \left[ i + 1 \right] } = \frac { \underset { n = 1 } { \overset { \sum } { } } \left( \underset { n = i - 1 } { \overset { \sum } { } } \right) \underset { n = 1 } { \overset { } { \prod } } w _ { j } } { \underset { n = 1 } { \overset { } { \sum } } \left( \underset { n = i - 1 } { \overset { } { \prod } } \right) \underset { j \in \tilde { T } } { \overset { } { \prod } } w _ { j } } \underset { \tilde { T } \in \left( \begin{array} { l } { T _ { t } \backslash \hat { T } _ { t } \left[ 0 : i - 1 \right] } \\ { n - i - 1 } \end{array} \right) } { \overset { } { \prod } } w _ { j } \end{array} \overset { \prod } { } { \underset { n = i } { \overset { } { \sum } } } \left[ \underset { n = i - 1 } { \overset { } { \prod } } \right] \underset { j \in \tilde { T } } { \overset { } { \prod } } w _ { j }$$
Substituting in the values of $\Omega _ { t } [ i ]$ and $\Omega _ { t + 1 } [ i ]$ from lemma 4 into the above formula, it will suffice to apply lemma 3 and lemma 4 to additionally show:
$$\begin{array} { r l } & { \Omega _ { t , i } ^ { \prime } = \Omega _ { t } [ i ] + \omega _ { t , i } \cdot \tilde { \Omega } _ { t } [ i ] } \\ & { \quad = \quad \displaystyle \sum _ { \tilde { T } \in \binom { T _ { t } \backslash \hat { T } _ { t } [ 0 : i - 1 ] } { n - i } } \prod _ { \tilde { t } \in \tilde { T } } w _ { \tilde { t } } + \omega _ { t , i } \cdot \sum _ { \tilde { T } \in \binom { T _ { t } \backslash \hat { T } _ { t } [ 0 : i - 1 ] } { n - i - 1 } } \prod _ { \tilde { t } \in \tilde { T } } w _ { \tilde { t } } } \\ & { \quad = \quad \displaystyle \sum _ { \tilde { T } \in \binom { T _ { t + 1 } \backslash \hat { T } _ { t + 1 } [ 0 : i - 1 ] } { n - i } } \prod _ { j \in \tilde { T } } w _ { j } } \\ & { \quad \quad \quad \tilde { T } \in \binom { T _ { t + 1 } \backslash \hat { T } _ { t + 1 } [ 0 : i - 1 ] } { n - i } j \in \tilde { T } } \end{array}$$
and for $0 \leq i \leq n - 2$
$$\begin{array} { r l } & { \Omega _ { t , i } ^ { \prime \prime } = \Omega _ { t } [ i + 1 ] + \omega _ { t , i } \cdot \tilde { \Omega } _ { t } [ i + 1 ] } \\ & { \quad = \quad \displaystyle \sum _ { \tilde { T } \in \binom { T _ { t } \setminus \tilde { T } _ { t } [ 0 : i ] } { n - i - 1 } } \prod _ { \tilde { t } \in \tilde { T } } w _ { \tilde { t } } + \omega _ { t , i } \cdot \sum _ { \tilde { T } \in \binom { T _ { t } \setminus \tilde { T } _ { t } [ 0 : i ] } { n - i - 2 } } \prod _ { \tilde { t } \in \tilde { T } } w _ { \tilde { t } } } \\ & { \quad = \quad \displaystyle \sum _ { \tilde { T } \in \binom { T _ { t + 1 } \setminus ( \tilde { T } _ { t + 1 } [ 0 : i - 1 ] \cup \{ \tilde { T } _ { t } [ i ] \} ) } { n - i - 1 } } \prod _ { j \in \tilde { T } } w _ { j } } \\ & { \quad \quad \tilde { T } \in \binom { T _ { t + 1 } \setminus ( \tilde { T } _ { t + 1 } [ 0 : i - 1 ] \cup \{ \tilde { T } _ { t } [ i ] \} ) } { n - i - 1 } j \in \tilde { T } } \end{array}$$
The first is a simple application of lemma 2. The second follows from a similar observation in addition to noting that $\hat { T } _ { t } [ i ]$ has been removed from each term. For $i = n - 1$ , $\Omega _ { t , i } ^ { \prime \prime } = 1$ which trivially obeys the same formula. □
Lemma 6. $P _ { t , i } \geq 0$
Proof.
$$\begin{array}{c} P _ { t , i } = 1 - \frac { \tilde { T } \in \left( ^ { T _ { t + 1 } \setminus ( \hat { T } _ { t + 1 } \cup : i - 1 ] \cup \{ \hat { T } _ { t } [ i ] \} ) } \right) ^ { \top } } { \tilde { n } - i - 1 } \overset { \prod } { \underset { j \in \tilde { T } } { \prod } } w _ { j } \underset { \tilde { T } \in \left( ^ { T _ { t } \setminus \hat { T } _ { t } [ 0 : i - 1 ] } \right) } { \sum } \overset { \sum } { j \in \tilde { T } } \quad \underset { \tilde { m } _ { j } } { \sum } \quad \underset { \tilde { m } _ { j } } { \sum } \quad \\ { \tilde { T } \in \left( ^ { T _ { t + 1 } \setminus \hat { T } _ { t + 1 } [ 0 : i - 1 ] } \right) j \in \tilde { T } \quad \ } & { \tilde { T } \in \left( ^ { T _ { t } \setminus \hat { T } _ { t } [ 0 : i ] } _ { n - i - 1 } \right) j \in \tilde { T } } \end{array}$$
hence
$$\begin{array} { r l } & \quad \sum _ { j = 1 } ^ { n } \sum _ { i = 1 } ^ { n } \prod _ { j = 1 } ^ { n } \exp ( \frac { 1 } \exp ( \frac \displaystyle \sum _ { j = 1 } ^ { n } \frac \sum _ { j = 1 } ^ { n } \frac \sum _ { i = 1 } ^ { n } \frac \sum _ { j = 1 } ^ { n } \frac \sum _ { i = 1 } ^ { n } \frac \sum _ { j = 1 } ^ { n } \frac \sum _ { i = 1 } ^ { n } \frac \sum _ { j = 1 } ^ { n } \frac \sum _ { i = 1 } ^ { n } \frac \sum _ { i = 1 } ^ { n } \frac \sum _ { i = 1 } ^ { n } \frac \sum _ { i = 1 } ^ { n } \frac \sum { i } \sum _ { i = 1 } ^ { n } \frac \sum _ { i = 1 } ^ { n } \frac \sum { i } \frac { \sum _ { i = 1 } ^ { n } \frac { \sum { i } \sum _ { i = 1 } ^ { n } \frac { \sum { i } \frac { \sum _ { i = 1 } ^ { n } \frac { \sum { i } \sum _ { i = 1 } ^ { n } \frac { \sum { i } \frac { \sum _ { i = 1 } ^ { n } \sum \frac { \sum { i } \frac { \sum _ { i = 1 } { i } ^ \sum { n } \frac { \sum \sum _ { i = 1 } } \frac { \frac { \sum { i \sum _ { i = 1 } ^ { n } \sum \frac { i } { \sum \sum _ { i = 1 } ^ { i } \frac { n \sum \sum _ { i } \frac { i } { i \operatorname { n } \sum \frac { \sum _ { i = 1 } \mathbb { i } \mathbb \mathbb { E } } } { \sum \mathbb \mathbb { E } ( \frac { \frac { 1 1 } { \prod { E _ { i } } \mathbb \mathbb \mathbb { E ( \frac { 1 \sum \sum _ { i } \mathbb \mathbb { E } \mathbb ( \frac { 1 \sum \mathbb { E } \mathbb ( 1 \cdot \sum _ { E } \mathbb \mathbb { E } ) ( \frac { 1 \sum _ { E \mathbb } \mathbb { E [ \mathbb | \sum _ { E \mathbb } \mathbb { E | ( E \frac { 1 } \mathbb { E | \sum \mathbb _ { E } \mathbb ( E [ \sum _ { i } \mathbb \mathbb { E | \mathbb \sum _ { E } \mathbb ( E [ \frac { 1 \sum _ { i = 1 } ^ { n } \mathbb \mathbb { E } \Bigg ) } } } } ) } } } } } } } } } } } } } } } } } } } } } } \\ & \end{array}$$$$\begin{array} { r l } & { \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad } \\ & { \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad } \\ & { \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad } \\ & & { \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad } \\ & & { \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad } \\ & { \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad } \\ & \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \end{array}$$
It is relatively straightforward to show that the lemma holds in this last form. To do so note that except for terms for which $\tilde { T }$ and ${ \tilde { T } } ^ { \prime }$ are identical on the left (which are not possible on the right), each term on the left of the inequality is also present on the right, however the number of repetitions of each term varies between the left and right. In the left sum if a term includes m values shared between $\tilde { T }$ and ${ \tilde { T } } ^ { \prime }$ , this term will appear $\binom { 2 \bar { ( } n - i - 1 - m ) } { n - i - 1 - m }$ times. This is because we can choose $n -$ $i - m$ non-duplicate values to be in $\tilde { T }$ and place the rest in ${ \tilde { T } } ^ { \prime }$ , each of these permutations will correspond to a term in the sum. On the other hand in the left sum if a term includes m values shared between $\tilde { T }$ and ${ \tilde { T } } ^ { \prime }$ , this term will appear 2(n−i−1−m)n−i−2−m times. Similarly this is because in this case we can choose $n - i - 1 - m$ non-duplicate values to be in $\tilde { T }$ and place the rest in ${ \tilde { T } } ^ { \prime }$ , each of these permutations will correspond to a different term in the sum.
Since $\binom { 2 N } { N } > \binom { 2 N } { N - 1 }$ , $\forall N$ every term which is present on the right side is present on the left with more repetitions and thus the left side must be greater than the right and the lemma holds. □
This lemma shows that $P$ is indeed a valid probability, which means that swapping according to it in algorithm 1 is admissible.
Theorem 1. $\forall t \geq n , 0 \leq i \leq n - 1$ :
$$P ( \hat { T } _ { t } [ i ] = t _ { i } | \hat { T } _ { t } [ 0 : i - 1 ] = [ t _ { 0 } , . . . , t _ { i - 1 } ] ) = \hat { P } ( t _ { i } | [ t _ { 0 } , . . . , t _ { i - 1 } ] ; T _ { t } , n )$$
where $[ t _ { 0 } , . . . , t _ { i } ]$ is an arbitrary vector of unique elements of $T _ { t }$ .
Proof. Let $\hat { T } _ { i , t }$ be the value of $\hat { T }$ right before making the swap decision on line 12 in loop index i of the loop starting at line 4 within the call to UPDATE with parameter t. Towards a proof by induction assume that at time index $t$ directly prior to making the swap decision for ${ \hat { T } } [ i ]$ at line 12 of UPDATE we have for any arbitrary vector $[ t _ { 0 } , . . . , t _ { i - 1 } ]$ of unique elements of $T _ { t }$ :
$$P ( \hat { T } _ { i , t } [ j ] = t _ { j } | \hat { T } _ { t } [ 0 : j - 1 ] = [ t _ { 0 } , . . . , t _ { j - 1 } ] ) = \hat { P } ( t _ { j } | [ t _ { 0 } , . . . , t _ { j - 1 } ] ; T _ { t } , n ) ,$$
and for any arbitrary vector $[ t _ { 0 } ^ { \prime } , . . . , t _ { i - 1 } ^ { \prime } ]$ of unique elements of $T _ { t + 1 }$ :
$$\begin{array} { r } { P ( \hat { T } _ { i , t } [ j ] = t _ { j } ^ { \prime } | \hat { T } _ { t + 1 } [ 0 : j - 1 ] = [ t _ { 0 } ^ { \prime } , . . . , t _ { j - 1 } ^ { \prime } ] ) = \hat { P } ( t _ { j } | [ t _ { 0 } ^ { \prime } , . . . , t _ { j - 1 } ^ { \prime } ] ; T _ { t + 1 } , n ) , \quad \quad } \\ { \forall j \ s . t . \ 0 \leq j \leq i - 1 } \end{array}$$
That is all elements of $\hat { T }$ from 0 to $i - 1$ have the desired probability conditioned on proceeding elements of $\hat { T } _ { t + 1 }$ while all elements from $i$ to $n - 1$ still have the desired probability when conditioned on proceeding elements of $\hat { T } _ { t }$ . This is a natural inductive assumption given we have already made our swap decisions up to but not including $i$ and are just about to make our decision for $i$ .
Consider two mutually possible selections of $\hat { T } _ { t + 1 } [ 0 : i - 1 ] = [ t _ { 0 } ^ { \prime } , . . . , t _ { i - 1 } ^ { \prime } ]$ and $\hat { T } _ { t } [ 0 : i - 1 ] =$ $[ t _ { 0 } , . . . , t _ { i - 1 } ]$ and note that together these uniquely determine the value $\tau _ { t , i }$ . Fixing these values, the only possible way to end up with $\hat { T } _ { t + 1 } [ i ] = \hat { t }$ for $\hat { t } \in T _ { t } \setminus \{ t _ { 0 } , . . . , t _ { j - 1 } \}$ is to have $\hat { T } _ { t } [ i ] = \hat { t }$ and then choose not to swap ${ \hat { T } } [ i ]$ at time $t$ . Thus, substituting in $1 - P _ { t , i }$ using the expression for $P _ { t , i }$ obtained in lemma 5 we get:
$$\begin{array} { r l } & { P ( \hat { T } _ { t + 1 } [ i ] = \hat { t } | \hat { T } _ { t + 1 } [ 0 : i - 1 ] = [ t _ { 0 } ^ { \prime } , . . . , t _ { j - 1 } ^ { \prime } ] , \hat { T } _ { t } [ 0 : i - 1 ] = [ t _ { 0 } , . . . , t _ { j - 1 } ] ) } \\ & { = \hat { P } ( \hat { t } | [ t _ { 0 } , . . . , t _ { i - 1 } ] ; T _ { t } , n ) \frac { \hat { P } ( \hat { t } | [ t _ { 0 } ^ { \prime } , . . . , t _ { i - 1 } ^ { \prime } ] ; T _ { t + 1 } , n ) } { \hat { P } ( \hat { t } | [ t _ { 0 } , . . . , t _ { i - 1 } ] ; T _ { t } , n ) } } \\ & { = \hat { P } ( \hat { t } | [ t _ { 0 } ^ { \prime } , . . . , t _ { i - 1 } ^ { \prime } ] ; T _ { t + 1 } , n ) } \end{array}$$
On the other hand to end up with $\hat { T } _ { t + 1 } [ i ] = \tau _ { t , i }$ we may start with any $\hat { t } \in T _ { t } \setminus \left( \{ t _ { 0 } , . . . , t _ { j - 1 } \} \right)$ and then choose to swap ${ \hat { T } } [ i ]$ at time $t$ , in this case we get:
$$\begin{array} { r l } & { P ( \widehat { T } _ { t + 1 } | \{ i \} = \pi _ { t , i } | \widehat { T } _ { t + 1 } | 0 : i - 1 | = [ t _ { 0 } ^ { i } , \dots , t _ { j - 1 } ^ { j } ] , \widehat { T } _ { t } | 0 : i - 1 | = [ \mu _ { 0 } , \dots , t _ { j - 1 } ] ) } \\ & { = \underset { i \in \mathbb { Z } \times \{ i \} } { = } \underset { ( i \in \mathbb { Z } \times \{ i \} \{ [ 0 , \dots , t _ { j - 1 } ] : T _ { t } , n \} } { \sum } \left( 1 - \frac { \widehat { P } _ { i } ( \widehat { \mathbb { I } } | \{ \mathbb { I } } _ { 0 } ^ { t } , \dots , t _ { j - 1 } ^ { j } | \cdot \mathbb { T } _ { t + 1 } , n ) \right)} { \widehat { P } _ { i } ( \widehat { \mathbb { I } } | \{ \mu _ { 0 } , \dots , t _ { j - 1 } \} ; T _ { t } , n ) } \\ & { = \underset { i \in \mathbb { Z } \times \{ i \} \{ \sum _ { j = 1 } ^ { n } \dots \dots \dots \dots \dots \nmid } { \widehat { P } } ( \widehat { i } | [ \mu _ { 0 } , \dots , t _ { j - 1 } ] ; T _ { t } , n ) - \widehat { P } ( \widehat { i } | [ \mu _ { 0 } ^ { j } , \dots , t _ { j - 1 } ^ { j } ] ; T _ { t + 1 } , n ) } \\ & { \overset { ( i \in \mathbb { Z } \times \{ i \} \setminus \{ i \} \{ 0 , \dots , j \} ~ 1 ) } { = } \widehat { P } ( \widehat { i } | [ \mu _ { 0 } ^ { j } , \dots , t _ { j - 1 } ^ { j } ] ; T _ { t + 1 } , n ) } \\ & = 1 - \underset { i \in \mathbb { Z } \times \{ i \} \times \{ i \} = \dots , i \not { = 1 \} } { \overset { } { \sum } } \widehat { P } ( \widehat { \mathbb { I } } | \mu _ { 0 } ^ { t } , \dots , t _ { j - 1 } ^ { j } | ; T _ { t + 1 } , n ) } \\ & = 1 - \underset { i \in \mathbb { Z } \times \{ i \} } { = } \underset { i \in \mathbb { Z } \times \{ i \} } { \overset { } { \sum } } \underset { i \in \mathbb { Z } \times \{ i \} } { \overset { } { \sum } } \widehat { P } ( \widehat { \mathbb { I } } | \mu _ { 0 } ^ { t } \end{array}$$
Thus for any fixed mutually possible selections of $\hat { T } _ { t + 1 } [ 0 : i - 1 ] = [ t _ { 0 } ^ { \prime } , . . . , t _ { j - 1 } ^ { \prime } ]$ and $\hat { T } _ { t } [ 0 : i - 1 ] =$ $[ t _ { 0 } , . . . , t _ { j - 1 } ]$ for both $\tau _ { t , i }$ and all other $\hat { t } \in T _ { t + 1 } \setminus \{ t _ { 0 } ^ { \prime } , . . . , t _ { j - 1 } ^ { \prime } \}$ we end up with correct conditional probabilities for $\hat { T } _ { t + 1 } [ i ]$ assuming they are correct for $\hat { T } _ { t } [ i ]$ . Now note that the resulting probabilities are ultimately independent of $[ t _ { 0 } , . . . , t _ { j - 1 } ]$ , hence we would get the same values by conditioning on $[ t _ { 0 } ^ { \prime } , . . . , t _ { j - 1 } ^ { \prime } ]$ alone. Thus if our inductive assumption holds we have for any arbitrary vector $[ t _ { 0 } ^ { \prime } , . . . , t _ { i - 1 } ^ { \prime } ]$ of unique elements of $T _ { t + 1 }$ :
$$P ( \hat { T } _ { i + 1 , t } [ j ] = t _ { j } ^ { \prime } | \hat { T } _ { t + 1 } [ 0 : j - 1 ] = [ t _ { 0 } ^ { \prime } , . . . , t _ { j - 1 } ^ { \prime } ] ) = \hat { P } ( t _ { j } | [ t _ { 0 } ^ { \prime } , . . . , t _ { j - 1 } ^ { \prime } ] ; T _ { t + 1 } , n ) ,$$
Which completes the inductive step. To prove the base case note that we initialize $\hat { T }$ such that at time $n$ it is filled with all available items in random order. It is easy to show that equation 12 implies that the probability of any ordering of a given set $\hat { T }$ is equal thus if the items in $T$ exactly fill $\hat { T }$ then ordering them at random will give the desired probabilities $\hat { P } ( \hat { T } _ { n } [ i ] | \hat { T } _ { t + 1 } [ 0 \ :$ $i - 1 ] ; T _ { t + 1 } , n )$ , $\forall i$ s.t. $0 \leq i \leq n - 1$ , which gives us the base case to complete the inductive proof. □
# E LENGTH 20 ENVIRONMENT EXPERIMENT
Figure 6 shows the results of an experiment on the secret informant problem with environment length 20. Comparing figures 5 and 6 the number of episodes to convergence increases from 50, 000 to around 80, 000 with a doubling of the environment length while training still remains stable.
 Figure 6: Experiment with environment length 20, 2 decisions and a 3 state memory. (a) shows average write weight assigned to informative states (•) and uninformative states $( \_ )$ . (b) shows average return with episodic memory learner (•), we did not train a recurrent baseline for this problem. (c) shows the value of several relevant query vector elements in the decision state. N corresponds to the uninformative indicator, to the informative indicator, $\bullet$ to the first decision state identifier, $\vee$ to the second decision state identifier. (d) shows the same thing but for the query generated in the second decision state.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251# WHAT SHOULD NOT BE CONTRASTIVE IN CONTRASTIVE LEARNING
Tete Xiao UC Berkeley
Xiaolong Wang UC San Diego
Alexei A. Efros UC Berkeley
Trevor Darrell UC Berkeley
# ABSTRACT
Recent self-supervised contrastive methods have been able to produce impressive transferable visual representations by learning to be invariant to different data augmentations. However, these methods implicitly assume a particular set of representational invariances (e.g., invariance to color), and can perform poorly when a downstream task violates this assumption (e.g., distinguishing red vs. yellow cars). We introduce a contrastive learning framework which does not require prior knowledge of specific, task-dependent invariances. Our model learns to capture varying and invariant factors for visual representations by constructing separate embedding spaces, each of which is invariant to all but one augmentation. We use a multi-head network with a shared backbone which captures information across each augmentation and alone outperforms all baselines on downstream tasks. We further find that the concatenation of the invariant and varying spaces performs best across all tasks we investigate, including coarse-grained, fine-grained, and few-shot downstream classification tasks, and various data corruptions.
# 1 INTRODUCTION
Self-supervised learning, which uses raw image data and/or available pretext tasks as its own supervision, has become increasingly popular as the inability of supervised models to generalize beyond their training data has become apparent. Different pretext tasks have been proposed with different transformations, such as spatial patch prediction (Doersch et al., 2015; Noroozi & Favaro, 2016), colorization (Zhang et al., 2016; Larsson et al., 2016; Zhang et al., 2017), rotation (Gidaris et al., 2018). Whereas pretext tasks aim to recover the transformations between different “views” of the same data, more recent contrastive learning methods (Wu et al., 2018; Tian et al., 2019; He et al., 2020; Chen et al., 2020a) instead try to learn to be invariant to these transformations, while remaining discriminative with respect to other data points. Here, the transformations are generated using classic data augmentation techniques which correspond to common pretext tasks, e.g., randomizing color, texture, orientation and cropping.
Yet, the inductive bias introduced through such augmentations is a double-edged sword, as each augmentation encourages invariance to a transformation which can be beneficial in some cases and harmful in others: e.g., adding rotation may help with view-independent aerial image recognition, but significantly downgrade the capacity of a network to solve tasks such as detecting which way is up in a photograph for a display application. Current self-supervised contrastive learning methods assume implicit knowledge of downstream task invariances. In this work, we propose to learn visual representations which capture individual factors of variation in a contrastive learning framework without presuming prior knowledge of downstream invariances.
Instead of mapping an image into a single embedding space which is invariant to all the handcrafted augmentations, our model learns to construct separate embedding sub-spaces, each of which is sensitive to a specific augmentation while invariant to other augmentations. We achieve this by optimizing multiple augmentation-sensitive contrastive objectives using a multi-head architecture with a shared backbone. Our model aims to preserve information with regard to each augmentation in a unified representation, as well as learn invariances to them. The general representation trained with these augmentations can then be applied to different downstream tasks, where each task is free to selectively utilize different factors of variation in our representation. We consider transfer of either the shared backbone representation, or the concatenation of all the task-specific heads; both outperform all baselines; the former uses same embedding dimensions as typical baselines, while the latter provides greatest overall performance in our experiments. In this paper, we experiment with three types of augmentations: rotation, color jittering, and texture randomization, as visualized in Figure 1. We evaluate our approach across a variety of diverse tasks including large-scale classification (Deng et al., 2009), fine-grained classification (Wah et al., 2011; Van Horn et al., 2018), few-shot classification (Nilsback & Zisserman, 2008), and classification on corrupted data (Barbu et al., 2019; Hendrycks & Dietterich, 2019). Our representation shows consistent performance gains with increasing number of augmentations. Our method does not require hand-selection of data augmentation strategies, and achieves better performance against state-of-the-art MoCo baseline (He et al., 2020; Chen et al., 2020b), and demonstrates superior transferability, generalizability and robustness across tasks and categories. Specifically, we obtain around $1 0 \%$ improvement over MoCo in classification when applied on the iNaturalist (Van Horn et al., 2018) dataset.
 Figure 1: Self-supervised contrastive learning relies on data augmentations as depicted in (a) to learn visual representations. However, current methods introduce inductive bias by encouraging neural networks to be less sensitive to information w.r.t. augmentation, which may help or may hurt. As illustrated in (b), rotation invariant embeddings can help on certain flower categories, but may hurt animal recognition performance; conversely color invariance generally seems to help coarse grained animal classification, but can hurt many flower categories and bird categories. Our method, shown in the following figure, overcomes this limitation.
# 2 BACKGROUND: CONTRASTIVE LEARNING FRAMEWORK
Contrastive learning learns a representation by maximizing similarity and dissimilarity over data samples which are organized into similar and dissimilar pairs, respectively. It can be formulated as a dictionary look-up problem (He et al., 2020), where a given reference image $\mathcal { T }$ is augmented into two views, query and key, and the query token $q$ should match its designated key $k ^ { + }$ over a set of sampled negative keys $\{ k ^ { - } \}$ from other images. In general, the framework can be summarized as the following components: (i) A data augmentation module $\tau$ constituting $n$ atomic augmentation operators, such as random cropping, color jittering, and random flipping. We denote a pre-defined atomic augmentation as random variable $X _ { i }$ . Each time the atomic augmentation is executed by sampling a specific augmentation parameter from the random variable, i.e., $x _ { i } \sim X _ { i }$ . One sampled data augmentation module transforms image $\mathcal { T }$ into a random view $\widetilde { \boldsymbol { \tau } }$ , denoted as $\widetilde { \mathcal { T } } = \mathcal { T } [ x _ { 1 } , x _ { 2 } , \dots , x _ { n } ] \left( \mathcal { T } \right)$ . Positive pair $( q , k ^ { + } )$ is generated by applying two randomly sampled data augmentation on the same reference image. (ii) An encoder network $f$ which extracts the feature $\textbf { { v } }$ of an image $\mathcal { T }$ by mapping it into a $d$ -dimensional space $\mathbb { R } ^ { d }$ . (iii) A projection head $h$ which further maps extracted representations into a hyper-spherical (normalized) embedding space. This space is subsequently used for a specific pretext task, i.e., contrastive loss objective for a batch of positive/negative pairs. A common choice is InfoNCE (Oord et al., 2018):
$$\mathcal { L } _ { q } = - \log \frac { \exp { ( q \cdot k ^ { + } / \tau ) } } { \exp { ( q \cdot k ^ { + } / \tau ) } + \sum _ { k ^ { - } } \exp { ( q \cdot k ^ { - } / \tau ) } } ,$$
where $\tau$ is a temperature hyper-parameter scaling the distribution of distances.
As a key towards learning a good feature representation (Chen et al., 2020a), a strong augmentation policy prevents the network from exploiting na¨ıve cues to match the given instances. However, inductive bias is introduced through the selection of augmentations, along with their hyper-parameters defining the strength of each augmentation, manifested in Equation 1 that any views by the stochastic augmentation module $\tau$ of the same instance are mapped onto the same point in the embedding space. The property negatively affects the learnt representations: 1) Generalizability and transferability are harmed if they are applied to the tasks where the discarded information is essential, e.g., color plays an important role in fine-grained classification of birds; 2) Adding an extra augmentation is complicated as the new operator may be helpful to certain classes while harmful to others, e.g., a rotated flower could be very similar to the original one, whereas it does not hold for a rotated car; 3) The hyper-parameters which control the strength of augmentations need to be carefully tuned for each augmentation to strike a delicate balance between leaving a short-cut open and completely invalidate one source of information.
 Figure 2: Framework of the Leave-one-out Contrastive Learning approach, illustrated with two types of augmentations, i.e., random rotation and color jittering. We generate multiple views with leave-one-out strategy, then project their representations into separate embedding spaces with contrastive objective, where each embedding space is either invariant to all augmentations, or invariant to all but one augmentation. The learnt representation can be the general embedding space $\nu$ (blue region), or the concatenation of embedding sub-spaces $\mathcal { Z }$ (grey region). Our results show that either of our proposed representations are able to outperform baseline contrastive embeddings and do not suffer from decreased performance when adding augmentations to which the task is not invariant (i.e., the red X’s in Figure 1).
# 3 LOOC: LEAVE-ONE-OUT CONTRASTIVE LEARNING
We propose Leave-one-out Contrastive Learning (LooC), a framework for multi-augmentation contrastive learning. Our framework can selectively prevent information loss incurred by an augmentation. Rather than projecting every view into a single embedding space which is invariant to all augmentations, in our LooC method the representations of input images are projected into several embedding spaces, each of which is not invariant to a certain augmentation while remaining invariant to others, as illustrated in Figure 2. In this way, each embedding sub-space is specialized to a single augmentation, and the shared layers will contain both augmentation-varying and invariant information. We learn a shared representation jointly with the several embedding spaces; we transfer either the shared representation alone, or the concatenation of all spaces, to downstream tasks.
View Generation. Given a reference image and $n$ atomic augmentations, we first augment the reference image with two sets of independently sampled augmentation parameters into the query view $\mathcal { T } _ { q }$ and the first key view $\mathcal { T } _ { k _ { 0 } }$ , i.e., $\dot { \mathcal { T } } _ { \{ q , k _ { 0 } \} } = \mathcal { T } [ x _ { 1 } ^ { \{ q , k _ { 0 } \} } , x _ { 2 } ^ { \{ q , k _ { 0 } \} } , \ldots , \dot { x } _ { n } ^ { \{ q , k _ { 0 } \} } ] ( \mathbb { Z } ) .$ x{q,k0}n ] (I ). Additionally, we generate $n$ views from the reference image as extra key views, denoted as ${ \mathcal { T } } _ { k _ { i } }$ , $\forall i \in \left\{ 1 , \ldots , n \right\}$ . For the $i ^ { t h }$ additional key view, the parameter of $i ^ { t h }$ atomic augmentation is copied from it of the query view, i.e., $x _ { i } ^ { k _ { i } } \equiv x _ { i } ^ { q }$ , $\forall i \in \left\{ 1 , \ldots , n \right\}$ ; whereas the parameter of other atomic augmentations are still independently sampled, i.e., $x _ { j } ^ { k _ { i } } \sim X _ { j }$ , $\forall j \ne i$ . For instance, assume that we have a set of two atomic augmentations {random_rotation, color_jitter}, $\mathcal { T } _ { q }$ and $\mathcal { T } _ { k _ { 1 } }$ are always augmented by the same rotation angle but different color jittering; $\mathcal { T } _ { q }$ and $\mathcal { T } _ { k _ { 2 } }$ are always augmented by the same color jittering but different rotation angle; $\mathcal { T } _ { q }$ and ${ \mathcal { T } } _ { k _ { 0 } }$ are augmented independently, as illustrated in the left part of Figure 2.
Contrastive Embedding Space. The augmented views are encoded by a neural network encoder $f ( \cdot )$ into feature vectors $\hat { v ^ { q } } , v ^ { k _ { 0 } } , \cdot \cdot \cdot , v ^ { k _ { n } }$ in a joint embedding space $\gamma \in \mathbb { R } ^ { d }$ . Subsequently, they are projected into $n { + 1 }$ normalized embedding spaces $\mathcal { Z } _ { 0 } , \mathcal { Z } _ { 1 } , \cdot \cdot \cdot , \mathcal { Z } _ { n } \in \mathbb { R } ^ { d ^ { \prime } }$ by projection heads $h : \mathcal { V } \mapsto \mathcal { Z }$ , among which $\mathcal { Z } _ { 0 }$ is invariant to all types of augmentations, whereas $\mathcal { Z } _ { i }$ $( \forall i \in \{ 1 , 2 , \cdots , n \} )$ is dependent on the $i ^ { t h }$ type of augmentation but invariant to other types of augmentations. In other words, in $\mathcal { Z } _ { 0 }$ all features $\textbf { { v } }$ should be mapped to a single point, whereas in $\mathcal { Z } _ { i }$ $( \forall i \in \{ 1 , 2 , \cdot \cdot \cdot , n \} )$ only $v ^ { q }$ and $\mathbf { \boldsymbol { v } } ^ { k _ { i } }$ should be mapped to a single point while $\pmb { v } ^ { k _ { j } } \ \forall j \neq i$ should be mapped to $n { - } 1$ separate points, as only $\mathcal { T } _ { q }$ and $\mathcal { T } _ { k _ { i } }$ share the same $i ^ { t h }$ augmentation.
We perform contrastive learning in all normalized embedding spaces based on Equation 1, as shown in the right part of Figure 2. For each query $z ^ { q }$ , denote $z ^ { k ^ { + } }$ as the keys from the same instance, and $z ^ { k ^ { - } }$ as the keys from other instances. Since all views should be mapped to the single point in $\mathcal { Z } _ { 0 }$ , the positive pair for the query $z _ { 0 } ^ { q }$ is $z _ { 0 } ^ { k _ { 0 } ^ { + } }$ , and the negative pairs are embeddings of other instances in this embedding space $\{ z _ { 0 } ^ { k _ { 0 } ^ { - } } \}$ ; for embedding spaces $\mathcal { Z } _ { 1 } , \cdots , \mathcal { Z } _ { n }$ , the positive pair for the query $z _ { i } ^ { q }$ is $z _ { i } ^ { k _ { i } ^ { + } }$ , while the negative pairs are embeddings of other instances in this embedding spac e {z k ii } , and $\{ \boldsymbol { z } _ { i } ^ { k _ { j } ^ { + } } \mid \forall j \in \{ 0 , 1 , \cdots , n \}$ and $j \neq i \}$ , which are the embeddings of the same instance with different $i ^ { t h }$ augmentation. The network then learns to be sensitive to one type of augmentation while insensitive to other types of augmentations in one embedding space. Denote $\bar { E _ { i , j } ^ { \{ + , - \} } } = \exp { ( z _ { i } ^ { q } \cdot z _ { i } ^ { k _ { j } ^ { \{ + , - \} } } / \tau ) }$ . The overall training objective for $q$ is:
$$\mathcal { L } _ { q } = - \frac { 1 } { n + 1 } \left( \log \frac { E _ { 0 , 0 } ^ { + } } { E _ { 0 , 0 } ^ { + } + \sum _ { k ^ { - } } E _ { 0 , 0 } ^ { - } } + \sum _ { i = 1 } ^ { n } \log \frac { E _ { i , i } ^ { + } } { \sum _ { j = 0 } ^ { n } E _ { i , j } ^ { + } + \sum _ { k ^ { - } } E _ { i , i } ^ { - } } \right) ,$$
The network must preserve information w.r.t. all augmentations in the general embedding space $\nu$ in order to optimize the combined learning objectives of all normalized embedding spaces.
Learnt representations. The representation for downstream tasks can be from the general embedding space $\nu$ (Figure 2, blue region), or the concatenation of all embedding sub-spaces (Figure 2, grey region). LooC method returns $\nu$ ; we term the implementation using the concatenation of all embedding sub-spaces as $\mathrm { L o o C + + }$ .
# 4 EXPERIMENTS
Methods. We adopt Momentum Contrastive Learning (MoCo) (He et al., 2020) as the backbone of our framework for its efficacy and efficiency, and incorporate the improved version from (Chen et al., 2020b). We use three types of augmentations as pretext tasks for static image data, namely color jittering (including random gray scale), random rotation $9 0 ^ { \circ }$ , $1 8 0 ^ { \circ }$ , or $2 7 0 ^ { \circ }$ ), and texture randomization (Gatys et al., 2016; Geirhos et al., 2018) (details in the Appendix). We apply random-resized cropping, horizontal flipping and Gaussian blur as augmentations without designated embedding spaces. Note that random rotation and texture randomization are not utilized in state-of-the-art contrastive learning based methods (Chen et al., 2020a; He et al., 2020; Chen et al., 2020b) and for good reason, as we will empirically show that na¨ıvely taking these augmentations negatively affects the performance on some specific benchmarks. For $\mathrm { L o o C + + }$ , we include Conv5 block into the projection head $h$ , and use the concatenated features at the last layer of Conv5, instead of the last layer of $h$ , from each head. Note than for both LooC and $_ { \mathrm { L o o C + + } }$ the augmented additional keys are only fed into the key encoding network, which is not back-propagated, thus it does not much increase computation or GPU memory consumption.
Datasets and evaluation metrics. We train our model on the 100-category ImageNet (IN-100) dataset, a subset of the ImageNet (Deng et al., 2009) dataset, for fast ablation studies of the proposed framework. We split the subset following (Tian et al., 2019). The subset contains ${ \sim } 1 2 5 \mathrm { k }$ images, sufficiently large to conduct experiments of statistical significance. After training, we adopt linear classification protocol by training a supervised linear classifier on frozen features of feature space $\nu$ for LooC, or concatenated feature spaces $\mathcal { Z }$ for $\mathrm { L o o C + + }$ . This allows us to directly verify the quality of features from a variation of models, yielding more interpretable results. We test the models on various downstream datasets (more information included in the Appendix): 1) IN-100 validation set; 2) The iNaturalist 2019 (iNat-1k) dataset (Van Horn et al., 2018), a large-scale classification dataset containing 1,010 species. Top-1 and top-5 accuracy on this dataset are reported; 3) The CaltechUCSD Birds 2011 (CUB-200) dataset (Wah et al., 2011), a fine-grained classification dataset of 200 bird species. Top-1 and top-5 classification accuracy are reported. 4) VGG Flowers (Flowers-102) dataset (Nilsback & Zisserman, 2008), a consistent of 102 flower categories. We use the dataset for few-shot classification and report 5-shot and 10-shot classification accuracy over 10 trials within $9 5 \%$ confidence interval. Unlike many few-shot classification methods which conduct evaluation on a subset of categories, we use all 102 categories in our study; 5) ObjectNet dataset (Barbu et al., 2019), a test set collected to intentionally show objects from new viewpoints on new backgrounds with different rotations of real-world images. We only use the 13 categories which overlap with IN-100, termed as ON-13; 6) ImageNet-C dataset (Hendrycks & Dietterich, 2019), a benchmark for model robustness of image corruptions. We use the 100 categories as IN-100, termed as IN-C-100. Note that ON and IN-C are test sets, so we do not train a supervised linear classifier exclusively while directly benchmark the linear classifier trained on IN-100 instead.
Table 1: Classification accuracy on 4-class rotation and IN-100 under linear evaluation protocol. Adding rotation augmentation into baseline MoCo significantly reduces its capacity to classify rotation angles while downgrades its performance on IN-100. In contrast, our method better leverages the information gain of the new augmentation.
<table><tr><td>model</td><td>Rotation Acc.</td><td>IN-100</td><td>top-5</td></tr><tr><td>Supervised</td><td>72.3</td><td>top-1 83.7</td><td>95.7</td></tr><tr><td>MoCo</td><td>61.1</td><td>81.0</td><td>95.2</td></tr><tr><td>MoCo+Rotation</td><td>43.3</td><td>79.4</td><td>94.1</td></tr><tr><td>MoCo +Rotation (same for q and k) LooC +Rotation [ours]</td><td>45.5 65.2</td><td>78.1 80.2</td><td>94.3 95.5</td></tr></table>
Table 2: Evaluation on multiple downstream tasks. Our method demonstrates superior generalizability and transferability with increasing number of augmentations.
<table><tr><td>model</td><td>Augmentation ColorRotation</td><td></td><td>iNat-1k top-1 top-5</td><td>CUB-200 top-1</td><td>top-5 5-shot</td><td>Flowers-102 10-shot</td><td>top-1</td><td>IN-100 top-5</td></tr><tr><td>MoCo</td><td>√</td><td></td><td>36.2</td><td>62.0</td><td>36.7 64.7</td><td>67.9 (± 0.5)</td><td>77.3 (± 0.1)</td><td>81.0 95.2</td></tr><tr><td rowspan="3">LooC</td><td>√</td><td></td><td>41.2</td><td>67.0 40.1</td><td>69.7</td><td>68.2 (± 0.6)</td><td>77.6(± 0.1)</td><td>81.1 95.3</td></tr><tr><td></td><td>√</td><td>40.0</td><td>65.4</td><td>38.8 67.0</td><td>70.1 (± 0.4)</td><td>79.3 (± 0.1)</td><td>80.2 95.5</td></tr><tr><td>√</td><td>√</td><td>44.0</td><td>69.3</td><td>39.6 69.2</td><td>70.9(± 0.3)</td><td>80.8(±0.2)</td><td>79.2 94.7</td></tr><tr><td>LooC++</td><td>√</td><td>√</td><td>46.1</td><td>71.5</td><td>39.3 69.3</td><td>68.1(± 0.4)</td><td>78.8(±0.2)</td><td>81.2 95.2</td></tr></table>
Implementation details. We closely follow (Chen et al., 2020b) for most training hyperparameters. We use a ResNet-50 (He et al., 2016) as our feature extractor. We use a two-layer MLP head with a 2048-d hidden layer and ReLU for each individual embedding space. We train the network for 500 epochs, and decrease the learning rate at 300 and 400 epochs. We use separate queues (He et al., 2020) for individual embedding space and set the queue size to 16,384. Linear classification evaluation details can be found in the Appendix. The batch size during training of the backbone and the linear layer is set to 256.
Study on augmentation inductive biases. We start by designing an experiment which allows us to directly measure how much an augmentation affects a downstream task which is sensitive to the augmentation. For example, consider two tasks which can be defined on IN-100: Task A is 4- category classification of rotation degrees for an input image; Task B is 100-category classification of ImageNet objects. We train a supervised linear classifier for task A with randomly rotated IN-100 images, and another classifier for task B with unrotated images. In Table 1 we compare the accuracy of the original MoCo (w/o rotation augmentation), MoCo w/ rotation augmentation, and our model w/ rotation augmentation. A priori, with no data labels to perform augmentation selection, we have no way to know if rotation should be utilized or not. Adding rotation into the set of augmentations for MoCo downgrades object classification accuracy on IN-100, and significantly reduces the capacity of the baseline model to distinguish the rotation of an input image. We further implement a variation enforcing the random rotating angle of query and key always being the same. Although it marginally increases rotation accuracy, IN-100 object classification accuracy further drops, which is inline with our hypothesis that the inductive bias of discarding certain type of information introduced by adopting an augmentation into contrastive learning objective is significant and cannot be trivially resolved by tuning the distribution of input images. On the other hand, our method with rotation augmentation not only sustains accuracy on IN-100, but also leverages the information gain of the new augmentation. We can include all augmentations with our LooC multi-self-supervised method and obtain improved performance across all condition without any downstream labels or a prior knowledged invariance.
Table 3: Evaluation on datasets of real-world corruptions. Rotation augmentation is beneficial for ON-13, and texture augmentation if beneficial for IN-C-100.
<table><tr><td rowspan="2">model</td><td rowspan="2">Aug Rot. Tex.</td><td rowspan="2">ON-13 top-1 top-5</td><td colspan="7">IN-C-100 (top-1)</td><td rowspan="2">IN-100</td></tr><tr><td>Noise</td><td>Blur</td><td>Weather Digital</td><td></td><td>All</td><td>d≥3</td><td>top-1 top-5</td></tr><tr><td>Supervised</td><td></td><td>30.9</td><td>54.8 28.4</td><td>47.1</td><td>44.9</td><td>58.5</td><td>47.2</td><td>36.5</td><td>83.7</td><td>95.7</td></tr><tr><td>MoCo</td><td></td><td>29.2 54.2</td><td>37.9</td><td>38.5</td><td>47.7</td><td>60.1</td><td>48.2</td><td>37.2</td><td>81.0</td><td>95.2</td></tr><tr><td rowspan="3">LooC</td><td>√</td><td>34.2</td><td>59.6</td><td>31.3</td><td>33.1</td><td>42.4</td><td>54.9</td><td>42.7</td><td>31.8</td><td>80.2 95.5</td></tr><tr><td></td><td>30.1</td><td>54.1</td><td>42.4</td><td>39.6 54.0</td><td>61.9</td><td>51.3</td><td>41.9</td><td>81.0</td><td>94.7</td></tr><tr><td>√</td><td>? 33.3</td><td>59.2</td><td>37.0</td><td>35.2</td><td>50.2</td><td>56.9</td><td>46.5</td><td>37.2 79.4</td><td>94.3</td></tr><tr><td>LooC++</td><td>√ √</td><td>32.6</td><td>57.3</td><td>38.3</td><td>37.6</td><td>52.0</td><td>60.0</td><td>48.8</td><td>38.9</td><td>82.1 95.1</td></tr></table>
Table 4: Comparisons of LooC vs. MoCo trained with all augmentations.
<table><tr><td rowspan=1 colspan=1>Model</td><td rowspan=1 colspan=1>IN-100top-1top-5</td><td rowspan=1 colspan=1>iNat-1ktop-1top-5</td><td rowspan=1 colspan=1>Flowers-1025-shot 10-shot</td><td rowspan=1 colspan=1>IN-C-100all-top-1</td></tr><tr><td rowspan=1 colspan=1>MoCoLooC</td><td rowspan=1 colspan=1>77.9 93.778.594.0</td><td rowspan=1 colspan=1>39.5 65.141.7 67.5</td><td rowspan=1 colspan=1>72.1 (± 0.4)81.1 (± 0.2)72.1(± 0.7)81.4(± 0.2)</td><td rowspan=1 colspan=1>47.445.4</td></tr><tr><td rowspan=1 colspan=1>MoCo++LooC++</td><td rowspan=1 colspan=1>80.8 94.682.2 95.3</td><td rowspan=1 colspan=1>43.4 68.545.9 71.4</td><td rowspan=1 colspan=1>70.0 (±0.8)80.5 (±0.3)71.0 (± 0.7)81.9 (± 0.3)</td><td rowspan=1 colspan=1>48.348.0</td></tr></table>
Table 5: Comparisons of concatenating features from different embedding spaces in $\mathbf { L o o C + + }$ jointly trained on color, rotation and texture augmentations. Different downstream tasks show nonidentical preferences for augmentation-dependent or invariant representations.
<table><tr><td rowspan="2">Model</td><td rowspan="2">Col.</td><td rowspan="2">Variance Head Rot.</td><td rowspan="2">Tex.</td><td colspan="2">IN-100</td><td rowspan="2">iNat-1k top-1 top-5</td><td colspan="2">Flowers-102</td><td rowspan="2">IN-C-100 all-top-1</td></tr><tr><td>top-1</td><td>top-5</td><td>5-shot</td><td>10-shot</td></tr><tr><td rowspan="5">LooC++</td><td></td><td></td><td></td><td>78.5</td><td>94.3</td><td>38.5</td><td>64.7</td><td>68.6(± 0.6) 77.6 (± 0.1)</td><td>48.0</td></tr><tr><td>Y</td><td></td><td></td><td>79.7</td><td>94.4</td><td>42.9 68.7</td><td></td><td>69.1 (± 0.7) 79.5 (± 0.2)</td><td>47.1</td></tr><tr><td></td><td>√</td><td></td><td>81.5</td><td>94.9</td><td>41.4 67.4</td><td>70.5 (±0.6)8</td><td>80.0 (± 0.2)</td><td>52.6</td></tr><tr><td></td><td></td><td>√</td><td>80.3</td><td>94.9</td><td>43.0 68.6</td><td>70.4 (± 0.5)</td><td>80.5 (± 0.2)</td><td>44.1</td></tr><tr><td>厂</td><td>√</td><td>√</td><td>82.2</td><td>95.3</td><td>45.9 71.4</td><td>71.0 (± 0.7)</td><td>81.9 (± 0.3)</td><td>48.0</td></tr></table>
Fine-grained recognition results. A prominent application of unsupervised learning is to learn features which are transferable and generalizable to a variety of downstream tasks. To fairly evaluate this, we compare our method with original MoCo on a diverse set of downstream tasks. Table 2 lists the results on iNat-1k, CUB-200 and Flowers-102. Although demonstrating marginally superior performance on IN-100, the original MoCo trails our LooC counterpart on all other datasets by a noticeable margin. Specifically, applying LooC on random color jiterring boosts the performance of the baseline which adopts the same augmentation. The comparison shows that our method can better preserve color information. Rotation augmentation also boosts the performance on iNat-1k and Flowers-102, while yields smaller improvements on CUB-200, which supports the intuition that some categories benefit from rotation-invariant representations while some do not. The performance is further boosted by using LooC with both augmentations, demonstrating the effectiveness in simultaneously learning the information w.r.t. multiple augmentations.
Interestingly, $\mathrm { L o o C + + }$ brings back the slight performance drop on IN-100, and yields more gains on iNat-1k, which indicates the benefits of explicit feature fusion without hand-crafting what should or should not be contrastive in the training objective.
Robustness learning results. Table 3 compares our method with MoCo and supervised model on ON-13 and IN-C-100, two testing sets for real-world data generalization under a variety of noise conditions. The linear classifier is trained on standard IN-100, without access to the testing distribution. The fully supervised network is most sensitive to perturbations, albeit it has highest accuracy on the source dataset IN-100. We also see that rotation augmentation is beneficial for ON-13, but significantly downgrades the robustness to data corruptions in IN-C-100. Conversely, texture randomization increases the robustness on IN-C-100 across all corruption types, particularly significant on “Blur” and “Weather”, and on the severity level above or equal to 3, as the representations must be insensitive to local noise to learn texture-invariant features, but its improvement on ON-13 is marginal. Combining rotation and texture augmentation yields improvements on both datasets, and $\mathrm { L o o C + + }$ further improves its performance on IN-C-100.
 Figure 3: Top nearest-neighbor retrieval results of LooC vs. corresponding invariant MoCo baseline with color (left) and rotation (right) augmentations on IN-100 and iNat-1k. The results show that our model can better preserve information dependent on color and rotation despite being trained with those augmentations.
Qualitative results. In Figure 3 we show nearest-neighbor retrieval results using features learnt with LooC vs. corresponding MoCo baseline. The top retrieval results demonstrate that our model can better preserve information which is not invariant to the transformations presented in the augmentations used in contrastive learning.
Ablation: MoCo w/ all augmentations vs. LooC. We compare our method and MoCo trained with all augmentations. We also add multiple Conv5 heads to MoCo, termed as $\mathrm { M o C o + + }$ , for a fair comparison with $\mathrm { L o o C + + }$ . The results are listed in Table 4. Using multiple heads boosts the performance of baseline MoCo, nevertheless, our method achieves better or comparable results compared with its baseline counterparts.
Note that the results in Table 2 to 5 should be interpreted in the broader context of Table 1. Table 1 illustrates the catastrophic consequences of not separating the varying and invariant factors of an augmentation (in this case, rotation). It can be imagined that if we add “rotation classification” as one downstream task in Table 4, $\mathrm { M o C o + + }$ will perform as poorly as in Table 1. The key of our work is to avoid what has happened in Table 1 and simultaneously boosts performance.
Ablation: Augmentation-dependent embedding spaces vs. tasks. We train a $_ { \mathrm { L o o C + + } }$ with all types of augmentations, and subsequently train multiple linear classifiers with concatenated features from different embedding spaces: all-invariant, color, rotation and texture. Any additional variance features boost the performance on IN-100, iNat-1k and Flowers-102. Adding texture-dependent features decreases the performance on IN-C-100: Textures are (overly) strong cues for ImageNet classification (Geirhos et al., 2018), thus the linear classifier is prone to use texture-dependent features, loosing the gains of texture invariance. Adding rotation-dependent features increases the performance on IN-C-100: Rotated objects of most classes in IN-100 are rare, thus the linear classifier is prone to use rotation-dependent features, so that drops on IN-C-100 triggered by rotation-invariant augmentation are re-gained. Using all types of features yields best performance on IN-100, iNat1k and Flowers-102; the performance on IN-C-100 with all augmentations remains comparable to MoCo, which does not suffer from loss of robustness introduced by rotation invariance.
In Figure 4 we show the histogram of correct predictions (activations $\times$ weights of classifier) by each augmentation-dependent head of a few instances from IN-100 and iNat-1k. The classifier prefers texture-dependent information over other kinds on an overwhelmingly majority of samples from IN-100, even for classes where shape is supposed to be the dominant factor, such as “pickup” and “mixing bowl” ((a), top row). This is consistent with the findings from (Geirhos et al., 2018) that ImageNet-trained CNNs are strongly biased towards texture-like representations. Interestingly, when human or animal faces dominant an image ((a), bottom-left), $\mathrm { L o o C + + }$ sharply prefers rotation-dependent features, which also holds for face recognition of humans. In contrast, on iNat1k $\mathrm { L o o C + + }$ prefers a more diverse set of features, such as color-dependent feature for a dragonfly species, rotation and texture-dependent features for birds, as well as rotation-invariant features for flowers. Averaged over the datasets, the distribution of classifier preferences is more balanced on iNat-1k than IN-100, as can be seen from the entropy that the distribution on iNat-1k is close to 2 bits, whereas it is close to 1 bit on IN-100, as it is dominated by only two elements. It corroborates the large improvements on iNat-1k gained from multi-dependent features learnt by our method.
 Figure 4: Histograms of correct predictions (activations $\times$ weights of classifier) by each augmentation-dependent head from IN-100 and iNat-1k. The classifier on IN-100 heavily relies on texture-dependent information, whereas it is much more balanced on iNat-1k. This is consistent with the improvement gains observed when learning with multiple augmentations.
# 5 RELATED WORK
Pretext Tasks. In computer vision, feature design and engineering used to be a central topic before the wide application of deep learning. Researchers have proposed to utilize cue combination for image retrieval and recognition tasks (Martin et al., 2004; Frome et al., 2007a;b; Malisiewicz & Efros, 2008; Rabinovich et al., 2006). For example, the local brightness, color, and texture features are combined together to represent an image and a simple linear model can be trained to detect boundaries (Martin et al., 2004). Interestingly, the recent development of unsupervised representation learning in deep learning is also progressed by designing different self-supervised pretext tasks (Wang & Gupta, 2015; Doersch et al., 2015; Pathak et al., 2016; Noroozi & Favaro, 2016; Zhang et al., 2016; Gidaris et al., 2018; Owens et al., 2016). For example, relative patch prediction (Doersch et al., 2015) and rotation prediction (Gidaris et al., 2018) are designed to discover the underlined structure of the objects; image colorization task (Zhang et al., 2016) is used to learn representations capturing color information. The inductive bias introduced by each pretext task can often be associated with a corresponding hand-crafted descriptor.
Multi-Task Self-Supervised Learning. Multi-task learning has been widely applied in image recognition (Kokkinos, 2017; Teichmann et al., 2018; He et al., 2017). However, jointly optimizing multiple tasks are not always beneficial. As shown in Kokkinos (2017), training with two tasks can yield better performance than seven tasks together, as some tasks might be conflicted with each other. This phenomenon becomes more obvious in multi-task self-supervised learning (Doersch & Zisserman, 2017; Wang et al., 2017; Pinto & Gupta, 2017; Piergiovanni et al., 2020; Alwassel et al., 2019) as the optimization goal for each task can be very different depending on the pretext task. To solve this problem, different weights for different tasks are learned to optimize for the downstream tasks (Piergiovanni et al., 2020). However, searching the weights typically requires labels, and is time-consuming and does not generalize to different tasks. To train general representations, researchers have proposed to utilize sparse regularization to factorize the network representations to encode different information from different tasks (Doersch & Zisserman, 2017; Misra et al., 2016). In this paper, we also proposed to learn representation which can factorize and unify information from different augmentations. Instead of using sparse regularization, we define different contrastive learning objective in a multi-head architecture.
Contrastive Learning. Instead of designing different pretext tasks, recent work on contrastive learning (Wu et al., 2018; Oord et al., 2018; Tian et al., 2019; He et al., 2020; Misra & van der Maaten, 2020; Chen et al., 2020a) trained networks to be invariant to various corresponding augmentations. Researchers (Chen et al., 2020a) elaborated different augmentations and pointed out which augmentations are helpful or harmful for ImageNet classification. It is also investigated in Tian et al. (2019) that different augmentations can be beneficial to different downstream tasks. Instead of enumerating all the possible selections of augmentations, we proposed a unified framework which captures different factors of variation introduced by different augmentations.
# 6 CONCLUSIONS
Current contrastive learning approaches rely on specific augmentation-derived transformation invariances to learn a visual representation, and may yield suboptimal performance on downstream tasks if the wrong transformation invariances are presumed. We propose a new model which learns both transformation dependent and invariant representations by constructing multiple embeddings, each of which is not contrastive to a single type of transformation. Our framework outperforms baseline contrastive method on coarse-grained, fine-grained, few-shot downstream classification tasks, and demonstrates better robustness of real-world data corruptions.
# ACKNOWLEDGEMENT
Prof. Darrell’s group was supported in part by DoD, NSF, BAIR, and BDD. Prof. Wang’s group was supported, in part, by gifts from Qualcomm and TuSimple. We would like to thank Allan Jabri, Colorado Reed and Ilija Radosavovic for helpful discussions.
# REFERENCES
Humam Alwassel, Dhruv Mahajan, Lorenzo Torresani, Bernard Ghanem, and Du Tran. Selfsupervised learning by cross-modal audio-video clustering. arXiv preprint arXiv:1911.12667, 2019. 8
Andrei Barbu, David Mayo, Julian Alverio, William Luo, Christopher Wang, Dan Gutfreund, Josh Tenenbaum, and Boris Katz. Objectnet: A large-scale bias-controlled dataset for pushing the limits of object recognition models. In Advances in Neural Information Processing Systems, pp. 9448–9458, 2019. 2, 5
Ting Chen, Simon Kornblith, Mohammad Norouzi, and Geoffrey Hinton. A simple framework for contrastive learning of visual representations. arXiv preprint arXiv:2002.05709, 2020a. 1, 2, 4, 8
Xinlei Chen, Haoqi Fan, Ross Girshick, and Kaiming He. Improved baselines with momentum contrastive learning. arXiv preprint arXiv:2003.04297, 2020b. 2, 4, 5, 12
Jia Deng, Wei Dong, Richard Socher, Li-Jia Li, Kai Li, and Li Fei-Fei. Imagenet: A large-scale hierarchical image database. In 2009 IEEE conference on computer vision and pattern recognition, pp. 248–255. Ieee, 2009. 2, 4
Carl Doersch and Andrew Zisserman. Multi-task self-supervised visual learning. In Proceedings of the IEEE International Conference on Computer Vision, pp. 2051–2060, 2017. 8
Carl Doersch, Abhinav Gupta, and Alexei A Efros. Unsupervised visual representation learning by context prediction. In Proceedings of the IEEE International Conference on Computer Vision, pp. 1422–1430, 2015. 1, 8
Andrea Frome, Yoram Singer, and Jitendra Malik. Image retrieval and classification using local distance functions. In Advances in neural information processing systems, pp. 417–424, 2007a. 8
Andrea Frome, Yoram Singer, Fei Sha, and Jitendra Malik. Learning globally-consistent local distance functions for shape-based image retrieval and classification. In 2007 IEEE 11th International Conference on Computer Vision, pp. 1–8. IEEE, 2007b. 8
Leon A Gatys, Alexander S Ecker, and Matthias Bethge. Image style transfer using convolutional neural networks. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 2414–2423, 2016. 4
Robert Geirhos, Patricia Rubisch, Claudio Michaelis, Matthias Bethge, Felix A Wichmann, and Wieland Brendel. Imagenet-trained cnns are biased towards texture; increasing shape bias improves accuracy and robustness. arXiv preprint arXiv:1811.12231, 2018. 4, 7
Spyros Gidaris, Praveer Singh, and Nikos Komodakis. Unsupervised representation learning by predicting image rotations, 2018. 1, 8
Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Deep residual learning for image recognition. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 770–778, 2016. 5
Kaiming He, Georgia Gkioxari, Piotr Dollar, and Ross Girshick. Mask r-cnn. In ´ Proceedings of the IEEE international conference on computer vision, pp. 2961–2969, 2017. 8
Kaiming He, Haoqi Fan, Yuxin Wu, Saining Xie, and Ross Girshick. Momentum contrast for unsupervised visual representation learning. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, 2020. 1, 2, 4, 5, 8
Dan Hendrycks and Thomas Dietterich. Benchmarking neural network robustness to common corruptions and perturbations. Proceedings of the International Conference on Learning Representations, 2019. 2, 5
Iasonas Kokkinos. Ubernet: Training a universal convolutional neural network for low-, mid-, and high-level vision using diverse datasets and limited memory. In IEEE Conf. on Computer Vision and Pattern Recognition (CVPR), 2017. 8
Gustav Larsson, Michael Maire, and Gregory Shakhnarovich. Learning representations for automatic colorization. In European Conference on Computer Vision, pp. 577–593. Springer, 2016. 1
Tomasz Malisiewicz and Alexei A Efros. Recognition by association via learning per-exemplar distances. In 2008 IEEE Conference on Computer Vision and Pattern Recognition, pp. 1–8. IEEE, 2008. 8
David R Martin, Charless C Fowlkes, and Jitendra Malik. Learning to detect natural image boundaries using local brightness, color, and texture cues. IEEE transactions on pattern analysis and machine intelligence, 26(5):530–549, 2004. 8
Ishan Misra and Laurens van der Maaten. Self-supervised learning of pretext-invariant representations. In CVPR, 2020. 8
Ishan Misra, Abhinav Shrivastava, Abhinav Gupta, and Martial Hebert. Cross-stitch networks for multi-task learning. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 3994–4003, 2016. 8
Maria-Elena Nilsback and Andrew Zisserman. Automated flower classification over a large number of classes. In 2008 Sixth Indian Conference on Computer Vision, Graphics & Image Processing, pp. 722–729. IEEE, 2008. 2, 5
Mehdi Noroozi and Paolo Favaro. Unsupervised learning of visual representations by solving jigsaw puzzles. In European Conference on Computer Vision, pp. 69–84. Springer, 2016. 1, 8
Aaron van den Oord, Yazhe Li, and Oriol Vinyals. Representation learning with contrastive predictive coding. arXiv preprint arXiv:1807.03748, 2018. 2, 8
Andrew Owens, Jiajun Wu, Josh H McDermott, William T Freeman, and Antonio Torralba. Ambient sound provides supervision for visual learning. In European conference on computer vision, pp. 801–816. Springer, 2016. 8
Deepak Pathak, Philipp Krahenbuhl, Jeff Donahue, Trevor Darrell, and Alexei A Efros. Context encoders: Feature learning by inpainting. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 2536–2544, 2016. 8
AJ Piergiovanni, Anelia Angelova, and Michael S Ryoo. Evolving losses for unsupervised video representation learning. arXiv preprint arXiv:2002.12177, 2020. 8
Lerrel Pinto and Abhinav Gupta. Learning to push by grasping: Using multiple tasks for effective learning. In 2017 IEEE International Conference on Robotics and Automation (ICRA), pp. 2161– 2168. IEEE, 2017. 8
Andrew Rabinovich, Tilman Lange, Joachim Buhmann, and Serge Belongie. Model order selection and cue combination for image segmentation. In IEEE Conference on Computer Vision and Pattern Recognition (CVPR), New York City, 2006. URL /se3/wp-content/uploads/ 2014/09/650Rabinovich.pdf. 8
Marvin Teichmann, Michael Weber, Marius Zoellner, Roberto Cipolla, and Raquel Urtasun. Multinet: Real-time joint semantic reasoning for autonomous driving. In 2018 IEEE Intelligent Vehicles Symposium (IV), pp. 1013–1020. IEEE, 2018. 8
Yonglong Tian, Dilip Krishnan, and Phillip Isola. Contrastive multiview coding. arXiv preprint arXiv:1906.05849, 2019. 1, 4, 8
Grant Van Horn, Oisin Mac Aodha, Yang Song, Yin Cui, Chen Sun, Alex Shepard, Hartwig Adam, Pietro Perona, and Serge Belongie. The inaturalist species classification and detection dataset. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 8769–8778, 2018. 2, 4
Catherine Wah, Steve Branson, Peter Welinder, Pietro Perona, and Serge Belongie. The caltech-ucsd birds-200-2011 dataset. 2011. 2, 5
Xiaolong Wang and Abhinav Gupta. Unsupervised learning of visual representations using videos. In Proceedings of the IEEE International Conference on Computer Vision, pp. 2794–2802, 2015. 8
Xiaolong Wang, Kaiming He, and Abhinav Gupta. Transitive invariance for self-supervised visual representation learning. In ICCV, 2017. 8
Zhirong Wu, Yuanjun Xiong, Stella X Yu, and Dahua Lin. Unsupervised feature learning via nonparametric instance discrimination. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 3733–3742, 2018. 1, 8
Richard Zhang, Phillip Isola, and Alexei A Efros. Colorful image colorization. In European conference on computer vision, pp. 649–666. Springer, 2016. 1, 8
Richard Zhang, Phillip Isola, and Alexei A Efros. Split-brain autoencoders: Unsupervised learning by cross-channel prediction. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 1058–1067, 2017. 1
# A AUGMENTATION DETAILS
Following (Chen et al., 2020b), we set the probability of color jittering to 0.8, with (brightness, contrast, saturation, hue) as (0.4, 0.4, 0.4, 0.1), and probability of random scale to 0.2. We set the probability of random rotation and texture randomization as 0.5.
# B DATASETS
iNat-1k, a large-scale classification dataset containing 1,010 species with a combined training and validation set of 268,243 images. We randomly reallocate $10 \%$ of training images into the validation set as the original validation set is relatively small.
CUB-200, which contains 5,994 training and 5,794 testing images of 200 bird species.
Flowers-102, which contains 102 flower categories consisting of between 40 and 258 images.
ObjectNet, a test set collected to intentionally show objects from new viewpoints on new backgrounds with different rotations of real-world images. It originally has 313-category. We only use the 13 categories which overlap with IN-100.
ImageNet-C, which consists of 15 diverse corruption types applied to validation images of ImageNet.
# C LINEAR CLASSIFICATION
We train the linear layer for 200 epochs for IN-100 and CUB-200, 100 epochs for iNat-1k, optimized by momentum SGD with a learning rate of 30 decreased by 0.1 at $60 \%$ and $80 \%$ of training schedule; for Flowers-102 we train the linear layer with Adam optimizer for 250 iterations with a learning rate of 0.03.
# D LEAVE-ONE-OUT VS. ADD-ONE AUGMENTATION
Table 6: Leave-one-out vs. add-one Augmentation. \*: Default (none add-one) augmentation strategy.
<table><tr><td rowspan="2">model</td><td colspan="2">Augmentation</td><td colspan="2">IN-100</td></tr><tr><td>Color</td><td>Rotation</td><td>top-1</td><td>top-5</td></tr><tr><td rowspan="2">MoCo</td><td>√</td><td></td><td>81.0</td><td>95.2</td></tr><tr><td>√</td><td>√</td><td>79.4</td><td>94.1</td></tr><tr><td rowspan="2">MoCo+AddOne</td><td>√</td><td></td><td>74.9</td><td>92.5</td></tr><tr><td>*</td><td>√</td><td>79.3</td><td>94.4</td></tr><tr><td rowspan="2">LooC[ours]</td><td>√</td><td></td><td>81.1</td><td>95.3</td></tr><tr><td>*</td><td>√</td><td>80.2</td><td>95.5</td></tr></table>
A straight-forward alternative for our leave-one-out augmentation strategy is add-one augmentation. Instead of applying all augmentations and augmenting two views in the same manner, add-one strategy keeps the query image unaugmentated, while in each augmentation-specific view the designated type of augmentation is applied. The results are shown in Table 6. Add-one strategy oversimplifies the instance discrimination task, e.g., leaving color augmentation out of query view makes it very easy for the network to spot the same instance out of a set of candidates. Our leave-one-out strategy does not suffer such degeneration.
# E IMAGENET-1K EXPERIMENTS
Table 7: Results of models trained on 1000 category ImageNet and fine-tuned on iNat-1k following linear classification protocol.
<table><tr><td rowspan="2">model</td><td colspan="2">iNat-1k</td></tr><tr><td>top-1</td><td>top-5</td></tr><tr><td>MoCo</td><td>47.8</td><td>74.3</td></tr><tr><td>LooC++ [ours]</td><td>51.2</td><td>76.5</td></tr></table>
We conduct experiments on 1000 category full ImageNet dataset. The models are trained by selfsupervised learning on IN-1k, and fine-tuned on iNat-1k following linear classification protocol. Our model is trained with all augmentations, i.e., color, rotation and texture. Results are reported in Table 7.
# F DISCUSSIONS
F.1 THE DIMENSIONS OF MOCO, LOOC, LOOC++
The representations of MoCo and LooC are of exactly the same dimension (2048); same for $\mathrm { M o C o + + }$ and $\mathrm { L o o C + + }$ (2048 \* # augmentations). It is specifically designed for fair comparisons.
F.2 ARE THE HYPER-PARAMETERS TUNED SPECIFICALLY FOR OUR SUBSETS?
No, except that we increase the number of training epochs as the amount of data increases. We did not specifically tune the baseline so that our method can outperform it most; on the contrary, we first made baseline as strong as possible, then directly applied the same hyper-parameters to our method. The subset of ImageNet100 behaviors similarly as ImageNet1k; our baseline already significantly outperforms the best method on the same subset from previous literature ( $7 5 . 8 \%$ CMC vs. $8 1 . 0 \%$ top1 [ours]), and since our method is derived from MoCo, they are directly comparable.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446# FAIR MIXUP: FAIRNESS VIA INTERPOLATION
Ching-Yao Chuang∗ CSAIL, MIT cychuang@mit.edu
Youssef Mroueh IBM Research AI mroueh@us.ibm.com
# ABSTRACT
Training classifiers under fairness constraints such as group fairness, regularizes the disparities of predictions between the groups. Nevertheless, even though the constraints are satisfied during training, they might not generalize at evaluation time. To improve the generalizability of fair classifiers, we propose fair mixup, a new data augmentation strategy for imposing the fairness constraint. In particular, we show that fairness can be achieved by regularizing the models on paths of interpolated samples between the groups. We use mixup, a powerful data augmentation strategy to generate these interpolates. We analyze fair mixup and empirically show that it ensures a better generalization for both accuracy and fairness measurement in tabular, vision, and language benchmarks. The code is available at https://github.com/chingyaoc/fair-mixup.
# 1 INTRODUCTION
Fairness has increasingly received attention in machine learning, with the aim of mitigating unjustified bias in learned models. Various statistical metrics were proposed to measure the disparities of model outputs and performance when conditioned on sensitive attributes such as gender or race. Equipped with these metrics, one can formulate constrained optimization problems to impose fairness as a constraint. Nevertheless, these constraints do not necessarily generalize since they are data-dependent, i.e they are estimated from finite samples. In particular, models that minimize the disparities on training sets do not necessarily achieve the same fairness metric on testing sets (Cotter et al., 2019). Conventionally, regularization is required to improve the generalization ability of a model (Zhang et al., 2016). On one hand, explicit regularization such as weight decay and dropout constrain the model capacity. On the other hand, implicit regularization such as data augmentation enlarge the support of the training distribution via prior knowledge (Hernandez-Garc ´ ´ıa & Konig ¨ , 2018).
In this work, we propose a data augmentation strategy for optimizing group fairness constraints such as demographic parity (DP) and equalized odds (EO) (Barocas et al., 2019). Given two sensitive groups such as male and female, instead of directly restricting the disparity, we propose to regularize the model on interpolated distributions between them. Those augmented distributions form a path connecting the two sensitive groups. Figure 1 provides an illustrative example of the idea. The path simulates how the distribution transitions from one group to another via interpolation. Ideally, if the model is invariant to the sensitive attribute, the expected prediction of the model along the path should have a smooth behavior. Therefore, we propose a regularization that favors smooth transitions along the path, which provides a stronger prior on the model class.
We adopt mixup (Zhang et al., 2018b), a powerful data augmentation strategy, to construct the interpolated samples. Owing to mixup’s simple form, the smoothness regularization we introduce has a closed form expression that can be easily optimized. One disadvantage of mixup is that the interpolated samples might not lie on the natural data manifold. Verma et al. (2019) propose Manifold Mixup, which generate the mixup samples in a latent space. Previous works (Bojanowski et al., 2018; Berthelot et al., 2018) have shown that interpolations between a pair of latent features correspond to semantically meaningful, smooth interpolation in the input space. By constructing the path in the latent space, we can better capture the semantic changes while traveling between the sensitive groups and hence result in a better fairness regularizer that we coin fair mixup. Empirically, fair mixup improves the generalizability for both DP and EO on tabular, computer- vision, and natural language benchmarks. Theoretically, we prove for a particular case that fair mixup corresponds to a Mahalanobis metric in the feature space in which we perform the classification. This metric ensures group fairness of the model, and involves the Jacobian of the feature map as we travel along the path.
 Figure 1: (a) Visualization of the path constructed via mixup interpolations between groups that have distribution $P _ { 0 }$ and $P _ { 1 }$ , respectively. (b) Fair mixup penalizes the changes in model’s expected prediction with respect to the interpolated distributions. The regularized model (blue curve) has smaller slopes comparing to the unregularized one (orange curve) along the path from $P _ { 0 }$ to $P _ { 1 }$ , which eventually leads to smaller demographic parity $\Delta \mathbf { D P }$ .
In short, this work makes the following contributions:
• We develop fair mixup, a data augmentation strategy that improves the generalization of group fairness metrics; • We provide a theoretical analysis to deepen our understanding of the proposed method; • We evaluate our approach via experiments on tabular, vision, and language benchmarks;
# 2 RELATED WORK
Machine Learning Fairness To mitigate unjustified bias in machine learning systems, various fairness definitions have been proposed. The definitions can usually be classified into individual fairness or group fairness. A system that is individually fair will treat similar users similarly, where the similarity between individuals can be obtained via prior knowledge or metric learning (Dwork et al., 2012; Yurochkin et al., 2019). Group fairness metrics measure the statistical parity between subgroups defined by the sensitive attributes such as gender or race (Zemel et al., 2013; Louizos et al., 2015; Hardt et al., 2016). While fairness can be achieved via pre- or post-processing, optimizing fair metrics at training time can lead to the highest utility (Barocas et al., 2019). For instance, Woodworth et al. (2017) impose independence via regularizing the covariance between predictions and sensitive attributes. Zafar et al. (2017) regularize decision boundaries of convex margin-based classifier to minimize the disparaty between groups. Zhang et al. (2018a) mitigate the bias via minimizing an adversary’s ability to predict sensitive attributes from predictions.
Nevertheless, these constraints are data-dependent, even though the constraints are satisfied during training, the model may behave differently at evaluation time. Agarwal et al. (2018) analyze the generalization error of fair classifiers obtained via two-player games. To improve the generalizability, Cotter et al. (2019) inherit the two-player setting while training each player on two separated datasets. In spite of the analytical solutions and theoretical guarantees, game-theoretic approaches could be hard to scale for complex model classes. In contrast, our proposed fair mixup, is a general data augmentation strategy for optimizing the fairness constraints, which is easily compatible with any dataset modality or model class.
Data Augmentation and Regularization Data augmentation expands the training data with examples generated via prior knowledge, which can be seen as an implicit regularization (Zhang et al., 2016; Hernandez-Garc ´ ´ıa & Konig ¨ , 2018) where the prior is specified as virtual examples. Zhang et al. (2018b) proposes mixup, which generate augmented samples via convex combinations of pairs of examples. In particular, given two examples $\overline { { z } } _ { i } , z _ { j } \in \mathbb { R } ^ { d }$ where $z$ could include both input and label, mixup constructs virtual samples as $t z _ { i } + ( 1 - t ) z _ { j }$ for $t \in [ 0 , 1 ]$ . State-of-the-art results are obtained via training on mixup samples in different modalities. Verma et al. (2019) introduces manifold mixup and shows that performing mixup in a latent space further improves the generalization. While previous works focus on general learning scenarios, we show that regularizing models on mixup samples can lead to group fairness and improve generalization.
# 3 GROUP FAIRNESS
Without loss of generality, we consider the standard fair binary classification setup where we obtain inputs $\boldsymbol { X } \in \mathcal { X } \bar { \subset } \mathbb { R } ^ { d }$ , labels $Y \in \mathcal { Y } = \{ 0 , 1 \}$ , sensitive attribute $A \in \{ 0 , 1 \}$ , and prediction score $\hat { Y } \in [ 0 , 1 ]$ from model $f : \mathbb { R } ^ { d } [ 0 , 1 ]$ . We will focus on demographic parity (DP) and equalized odds (EO) in this work, while our approach also encompasses other fairness metrics (detailed discussion in section 5). DP requires the predictions $\hat { Y }$ to be independent of the sensitive attribute $A$ , that is, $P ( \hat { Y } | A = 0 ) = P ( \hat { Y } | A = 1 )$ . However, DP ignores the possible correlations between $Y$ and $A$ and could rule out the perfect predictor if $Y$ 6⊥⊥ $A$ . EO overcomes the limit of DP by conditioning on the label $Y$ . In particular, EO requires $\hat { Y }$ and $A$ to be conditionally independent with respect to $Y$ , that is, $P ( \hat { Y } | A = 1 , Y = y ) = P ( \hat { Y } | A = 0 , Y = y )$ for $y \in \{ 0 , 1 \}$ . Given the difficulty of optimizing the independency constraints, Madras et al. (2018) propose the following relaxed metrics:
$$\Delta \mathrm { D P } ( f ) = | \mathbb { E } _ { x \sim P _ { 0 } } f ( x ) - \mathbb { E } _ { x \sim P _ { 1 } } f ( x ) | \Delta \mathrm { E O } ( f ) = \sum _ { y \in \{ 0 , 1 \} } \left| \mathbb { E } _ { x \sim P _ { 0 } ^ { y } } f ( x ) - \mathbb { E } _ { x \sim P _ { 1 } ^ { y } } f ( x ) \right|$$
where we define $P _ { a } = P ( \cdot | A = a )$ and $P _ { a } ^ { y } = P ( \cdot | A = a , Y = y ) , a , $ $a , y \in \{ 0 , 1 \}$ . We denote the joint distribution of $X$ and $Y$ by $P$ . Similar metrics have also been used in Agarwal et al. (2018), Wei et al. (2019), and Taskesen et al. (2020). One can formulate a penalized optimization problem to regularize the fairness measurement, for instance,
$$( \mathrm { G a p \ R e g u l a r i z a t i o n } ) ; \quad \operatorname* { m i n } _ { f } \ \mathbb { E } _ { ( x , y ) \sim P } [ \ell ( f ( x ) , y ) ] + \lambda \Delta \mathrm { D P } ( f ) ,$$
where $\ell$ is the classification loss. In spite of its simplicity, our experiments show that small training values of $\Delta \mathrm { D P } ( f )$ do not necessarily generalize well at evaluation time (See section 6). To improve the generalizability, we introduce a data augmentation strategy via a dynamic form of group fairness metrics.
# 4 DYNAMIC FORMULATION OF FAIRNESS: PATHS BETWEEN GROUPS
For simplicity, we will first consider $\Delta \mathbf { D P }$ as the fairness metric, and extend our development to $\Delta \mathrm { E O }$ in section 5. $\Delta \mathbf { D P }$ provides a static measurement by quantifying the expected difference at $P _ { 0 }$ and $P _ { 1 }$ . In contrast, one can consider a dynamic metric that measures the change of $\hat { Y }$ while transitioning gradually from $P _ { 0 }$ to $P _ { 1 }$ . To convert from the static to the dynamic formulations, we start with a simple Lemma that bridges two groups with an interpolator $T ( x _ { 0 } , x _ { 1 } , t )$ , which generates interpolated samples between $x _ { 0 }$ and $x _ { 1 }$ based on step $t$ .
Lemma 1. Let $T : \mathcal { X } ^ { 2 } \times [ 0 , 1 ] \to \mathcal { X }$ be a function continuously differentiable w.r.t. t such that $T ( x _ { 0 } , x _ { 1 } , 0 ) = x _ { 0 }$ and $T ( x _ { 0 } , x _ { 1 } , 1 ) = x _ { 1 }$ . For any differentiable function $f$ , we have
$$\Delta { \bf D } { \bf P } ( f ) = \left| \int _ { 0 } ^ { 1 } \frac { d } { d t } \int f ( \underbrace { T ( x _ { 0 } , x _ { 1 } , t ) } _ { \mathrm { i n t e r p o l a t i o n } } ) d P _ { 0 } ( x _ { 0 } ) d P _ { 1 } ( x _ { 1 } ) d t \right| = : \left| \int _ { 0 } ^ { 1 } \frac { d } { d t } \mu _ { f } ( t ) d t \right| ,$$
where we define $\mu _ { f } ( t ) = \mathbb { E } _ { x _ { 0 } \sim P _ { 0 } , x _ { 1 } \sim P _ { 1 } } { f ( T ( x _ { 0 } , x _ { 1 } , t ) ) }$ , the expected output of $f$ with respect to $T ( x _ { 0 } , x _ { 1 } , t )$ .
Figure 2 provides an illustrative example of the idea. Lemma 1 relaxes the binary sensitive attribute into a continuous variable $t \in [ 0 , 1 ]$ , where $\mu _ { f }$ captures the behavior of $f$ while traveling from group 0 to group 1 along the path constructed with the interpolator $T$ . In particular, given two examples $x _ { 0 }$ and $x _ { 1 }$ drawn from each group, $T$ generates interpolated samples that change smoothly with respect to $t$ .
For instance, given two racial backgrounds in the dataset, $\mu _ { f }$ simulates how the prediction of $f$ changes while the data of one group smoothly transforms to another. We can then detect whether there are “unfair” changes in $\mu _ { f }$ along the path. The dynamic formulation allows us to measure the sensitivity of $f$ with respect to a relaxed continuous sensitive attribute $t$ via the derivative $\begin{array} { r } { \frac { d } { d t } \mu _ { f } ( t ) } \end{array}$ . Ideally, if $f$ is invariant to the sensitive attribute, $\begin{array} { r } { \frac { d } { d t } \mu _ { f } ( t ) } \end{array}$ should be small along the path from $t = 0$ to 1. Importantly, a small $\Delta \mathbf { D P }$ does not imply $\begin{array} { r } { | \frac { d } { d t } \mu _ { f } ( t ) | } \end{array}$ is small for $t \in [ 0 , 1 ]$ since the derivative could fluctuate as it can be seen in Figure 2.
 Figure 2: The expected output $\mu _ { f } ( t )$ gradually changes as $t \to 1$ . Even when $\Delta \mathbf { D P }$ is small, $\begin{array} { r } { | \frac { d } { d t } \mu _ { f } ( t ) | } \end{array}$ could still be large along the path.
# 4.1 SMOOTHNESS REGULARIZATION
To make $f$ invariant to $t$ , we propose to regularize the derivative along the path:
$$\mathrm { ( S m o o t h n e s s ~ R e g u l a r i z e r ) } ; \quad R _ { T } ( f ) = \int _ { 0 } ^ { 1 } \left| \frac { d } { d t } \mu _ { f } ( t ) \right| d t .$$
Interestingly, $R _ { T } ( f )$ is the arc length of the curve defined by $\mu _ { f } ( t )$ for $t \in [ 0 , 1 ]$ . Now, we can interpret the problem from a geometric point of view. The interpolator $T$ defines a curve $\mu _ { f } ( t ) :$ $[ 0 , 1 ] \to \mathbb { R } .$ , and $\Delta \mathrm { D P } ( f ) = | \bar { \mu _ { f } } ( 0 ) - \bar { \mu _ { f } ( 1 ) } |$ is the Euclidean distance between points $t = 0$ and 1. $\Delta \mathrm { D P } ( f )$ fails to capture the behavior of $f$ while transitioning from $P _ { 0 }$ to $P _ { 1 }$ . In contrast, regularizing the arc length $R _ { T } ( f )$ favors a smooth transition from $t = 0$ to 1, which constrains the fluctuation of the function as the sensitive attributes change. By Jensen’s inequality, $\Delta \mathrm { D P } ( f ) \le R _ { T } ( f )$ for any $f$ , which further justifies the validity of regularizing $\Delta \mathrm { D P } ( f )$ with $R _ { T } ( f )$ .
# 5 FAIR MIXUP: REGULARIZING MIXUP PATHS
It remains to determine the interpolator $T$ . A good interpolater shall (1) generate meaningful interpolations, and (2) the derivative of $\mu _ { f } ( . )$ with respect to $t$ should be easy to compute. In this section, we show that mixup (Zhang et al., 2018b), a powerful data augmentation strategy, is itself a valid interpolator that satisfies both criterions.
Input Mixup We first adopt the standard mixup (Zhang et al., 2018b) by setting the interpolator as the linear interpolation in input space: $T ( x _ { 0 } , \dot { x } _ { 1 } , t ) \stackrel { - } { = } t x _ { 0 } + ( 1 - t ) x _ { 1 }$ . It can be verified that $T _ { \mathrm { m i x u p } }$ satisfies the interpolator criterion defined in Lemma 1. The resulting smoothness regularizer has the following closed form expression1:
$$R _ { \mathrm { m i x u p } } ^ { \mathrm { { D P } } } ( f ) = \int _ { 0 } ^ { 1 } \left| \int \left. \nabla _ { x } f ( t x _ { 0 } + ( 1 - t ) x _ { 1 } ) , x _ { 0 } - x _ { 1 } \right. d P _ { 0 } ( x _ { 0 } ) d P _ { 1 } ( x _ { 1 } ) \right| d t .$$
The regularizer can be easily optimized by computing the Jacobian of $f$ on mixup samples. Jacobian regularization is a common approach to regularize neural networks (Drucker $\&$ LeCun, 1992). For instance, regularizing the norm of the Jacobian can improve adversarial robustness (Chan et al., 2019; Hoffman et al., 2019). Here, we regularize the expected inner product between the Jacobian on mixup samples and the difference $x _ { 0 } - x _ { 1 }$ .
Manifold Mixup One disadvantage of input mixup is that the curve is defined with mixup samples, which might not lie on the natural data manifold. Verma et al. (2019) propose Manifold Mixup, which generate the mixup samples in the latent space $\mathcal { Z }$ . In particular, manifold mixup assumes a compositional hypothesis $f \circ g$ where $g : \mathcal { X } \mathcal { Z }$ is the feature encoder and the predictor $f : \mathcal { Z } \to \mathcal { V }$ takes the encoded feature to perform prediction. Similarly, we can establish the equivalence between
$\Delta \mathbf { D P }$ and manifold mixup:
$$\Delta \mathrm { D P } ( f \circ g ) = \left. \int _ { 0 } ^ { 1 } \frac { d } { d t } \int f ( \underbrace { t g ( x _ { 0 } ) + ( 1 - t ) g ( x _ { 1 } ) } _ { \mathrm { M a n i f o l d M i x u p } } ) d P _ { 0 } ( x _ { 0 } ) d P _ { 1 } ( x _ { 1 } ) d t \right. ,$$
which results in the following smoothness regularizer:
$$R _ { \mathrm { m - m i x u p } } ^ { \mathrm { D P } } ( f \circ g ) = \int _ { 0 } ^ { 1 } \left| \int \left. \nabla _ { z } f ( t g ( x _ { 0 } ) + ( 1 - t ) g ( x _ { 1 } ) ) , g ( x _ { 0 } ) - g ( x _ { 1 } ) \right. d P _ { 0 } ( x _ { 0 } ) d P _ { 1 } ( x _ { 1 } ) \right| d t .$$
Previous works (Bojanowski et al., 2018; Berthelot et al., 2018) have showed that interpolations between a pair of latent features correspond to semantically meaningful, smooth interpolations in input space. By constructing a curve in the latent space, we can better capture the semantic changes while traveling from $P _ { 0 }$ to $P _ { 1 }$ .
Extensions and Implementation The derivations presented so far, can be easily extended to Equalized Odds (EO). In particular, Lemma 1 can be extended to $\Delta \mathrm { E O }$ by interpolating $P _ { 0 } ^ { y }$ and $P _ { 1 } ^ { \bar { y } }$ for $y \in \{ 0 , 1 \}$ :
$$\Delta \mathrm { E O } ( f ) = \sum _ { y \in \{ 0 , 1 \} } \left| \int _ { 0 } ^ { 1 } \frac { d } { d t } \int f ( T ( x _ { 0 } , x _ { 1 } , t ) ) d P _ { 0 } ^ { y } ( x _ { 0 } ) d P _ { 1 } ^ { y } ( x _ { 1 } ) d t \right| .$$
The corresponding mixup regularizers can be obtained similarly by substituting $P _ { 0 }$ and $P _ { 1 }$ in $R _ { \mathrm { m i x u p } }$ and $R _ { \mathrm { m - m i x u p } }$ with $\dot { \Gamma } _ { 0 } ^ { y }$ and $P _ { 1 } ^ { \bar { y } }$ :
$$R _ { \mathrm { m i x u p } } ^ { \mathrm { E O } } ( f ) = \sum _ { y \in \{ 0 , 1 \} } \int _ { 0 } ^ { 1 } \Big | \int \langle \nabla _ { x } f ( t x _ { 0 } + ( 1 - t ) x _ { 1 } ) , x _ { 0 } - x _ { 1 } \rangle d P _ { 0 } ^ { y } ( x _ { 0 } ) d P _ { 1 } ^ { y } ( x _ { 1 } ) \Big | d t .$$
Our formulation also encompasses other fairness metrics that quantify the expected difference between groups. This includes group fairness metrics such as accuracy equality which compares the mistreatment rate between groups (Berk et al., 2018). Similar to equation (1), we formulate a penalized optimization problem to enforce fairness via fair mixup:
$$( \mathrm { F a i r } \mathrm { M i x u p } ) { \boldsymbol { : } } \quad \operatorname* { m i n } _ { f } \mathbb { E } _ { ( { \boldsymbol { x } } , { \boldsymbol { y } } ) \sim P } [ \ell ( f ( { \boldsymbol { x } } ) , { \boldsymbol { y } } ) ] + \lambda R _ { \mathrm { m i x u p } } ( f ) .$$
Implementation-wise, we follow Zhang et al. (2018b) where only one $t$ is sampled per batch to perform mixup. This strategy works well in practice and reduce the computational requirements.
# 5.1 THEORETICAL ANALYSIS
To gain deeper insight, we analyze the optimal solution of fair mixup in a simple case. In particular, we consider the classification loss $\ell ( f ( \bar { x ) } , y ) = - y f ( x )$ and the following hypothesis class:
$$\mathcal { H } = \{ f | f ( x ) = \left. v , \Phi ( x ) \right. , v \in \mathbb { R } ^ { m } , \Phi : \mathcal { X } \to \mathbb { R } ^ { m } \} .$$
Define $m _ { \pm } = \mathbb { E } _ { x \sim \mathbb { P } _ { \pm } } \Phi ( x )$ , the label conditional mean embeddings, and $m _ { 0 } = \mathbb { E } _ { x \sim \mathbb { P } _ { 0 } } \Phi ( x )$ and $m _ { 1 } = \mathbb { E } _ { x \sim \mathbb { P } _ { 1 } } \Phi ( x )$ , the group mean embeddings. We then define the expected difference $\delta _ { \pm } = $ $m _ { + } - m _ { - }$ and $\delta _ { 0 , 1 } = m _ { 0 } - m _ { 1 }$ . To derive an interpretable solution, we will consider the L2 variants of the penalized optimization problem. The following proposition gives the analytical solution when we regularize the model with $\Delta \mathbf { D P }$ .
Proposition 2. (Gap Regularization) Consider the following minimization problem
$$\operatorname* { m i n } _ { f \in \mathcal { H } } \mathbb { E } _ { ( x , y ) \sim P } [ \ell ( f ( x ) , y ) ] + \frac { \lambda _ { 1 } } { 2 } \Delta \mathrm { D } \mathbf { P } ( f ) ^ { 2 } + \frac { \lambda _ { 2 } } { 2 } | | f | | _ { \mathcal { H } } ^ { 2 } .$$
For a fixed embedding $\Phi$ , the optimal solution $f ^ { * }$ corresponds to $v ^ { * }$ given by the following closed form:
$$v ^ { \ast } = \frac { 1 } { \lambda _ { 2 } } \left( \delta _ { \pm } - p r o j _ { \delta _ { 0 , 1 } } ^ { \frac { \lambda _ { 2 } } { \lambda _ { 1 } } } ( \delta _ { \pm } ) \right) ,$$
where proj is the soft projection defined as p $\begin{array} { r } { r o j _ { u } ^ { \beta } ( x ) = \frac { u \otimes u } { | | u | | ^ { 2 } + \beta } x } \end{array}$
The solution $v ^ { * }$ can be interpreted as the projection of the label discriminating direction $\delta _ { \pm }$ on the subspace that is orthogonal to the group discriminating direction $\delta _ { 0 , 1 }$ . By projecting to this orthogonal subspace, we can prevent the model from using group specific directions, that are unfair directions when performing prediction. Interestingly, the projection trick has been used in Zhang et al. (2018a), where they subtract the gradient of the model parameters in each update step with its projection on unfair directions. We then prove the optimal solution of fair mixup with the same setup as above. Similarly, we introduce an L2 variant of the fair mixup regularizer defined as follows:
$$R _ { \mathrm { m i x u p } } ^ { \mathrm { D P - 2 } } ( f ) = \int _ { 0 } ^ { 1 } \bigg | \int \left. \nabla _ { x } f ( t x _ { 0 } + ( 1 - t ) x _ { 1 } ) , x _ { 0 } - x _ { 1 } \right. d P _ { 0 } ( x _ { 0 } ) d P _ { 1 } ( x _ { 1 } ) \bigg | ^ { 2 } d t ,$$
where we consider the squared absolute value of the derivative within the integral, in order to get a closed form solution.
Proposition 3. (Fair Mixup) Consider the following minimization problem
$$\operatorname* { m i n } _ { f \in \mathcal { H } } \mathbb { E } _ { ( x , y ) \sim P } [ \ell ( f ( x ) , y ) ] + \frac { \lambda _ { 1 } } { 2 } R _ { \mathrm { m i x u p } } ^ { \mathrm { D P - 2 } } ( f ) + \frac { \lambda _ { 2 } } { 2 } | | f | | _ { \mathcal { H } } ^ { 2 } .$$
Let $m _ { t } = \mathbb { E } _ { x _ { 0 } \sim P _ { 0 } , x _ { 1 } \sim P _ { 1 } } [ \Phi ( t x _ { 0 } + ( 1 - t ) x _ { 1 } ) ]$ be the $t$ dependent mean embedding, and $\dot { m } _ { t }$ its derivative with respect to $t$ . Let $D$ be a positive-semi definite matrix defined as follows: $D =$ $\begin{array} { r } { \int _ { 0 } ^ { 1 } { \dot { m _ { t } } } \otimes { \dot { m } } _ { t } d t } \end{array}$ . Given an embedding $\Phi$ , the optimal solution $v ^ { * }$ has the following form:
$$v ^ { * } = ( \lambda _ { 1 } D + \lambda _ { 2 } I _ { m } ) ^ { - 1 } \delta _ { \pm } .$$
Hence the optimal fair mixup classifier can be finally written as :
$$f ( x ) = \left. \delta _ { \pm } , ( \lambda _ { 1 } D + \lambda _ { 2 } I _ { m } ) ^ { - 1 } \Phi ( x ) \right. ,$$
which means that fair mixup changes the geometry of the decision boundary via a new dot product in the feature space that ensures group fairness, instead of simply projecting on the subspace orthogonal to a single direction as in gap regularization. This dot product leads to a Mahalanobis distance in the feature space that is defined via the covariance of time derivatives of mean embeddings of intermediate densities between the groups. To understand this better, given two points $x _ { 0 }$ in group 0 and $x _ { 1 }$ in group 1, by the mean value theorem, there exists $x _ { c }$ such that:
$$f ( x _ { 0 } ) = f ( x _ { 1 } ) + \langle \nabla f ( x _ { c } ) , x _ { 0 } - x _ { 1 } \rangle = f ( x _ { 1 } ) + \langle \delta _ { \pm } , ( \lambda _ { 1 } D + \lambda _ { 2 } I ) ^ { - 1 } J \Phi ( x _ { c } ) ( x _ { 0 } - x _ { 1 } ) \rangle$$
Note that $D$ provides the correct average conditioning for $J \Phi ( x _ { c } ) ( x _ { 0 } - x _ { 1 } )$ , this can be seen from the expression of $\dot { m } _ { t }$ $\mathrm { D }$ is a covariance of $J \Phi ( x _ { c } ) ( x _ { 0 } - x _ { 1 } ) )$ . This conditioned Jacobian ensures that the function does not fluctuate a lot between the groups, which matches our motivation.
# 6 EXPERIMENTS
We now examine fair mixup with binary classification tasks on tabular benchmarks (Adult), visual recognition (CelebA), and language dataset (Toxicity). For evaluation, we show the trade-offs between average precision (AP) and fairness metrics (∆DP/∆EO) by varying the hyper-parameter $\lambda$ in the objective. We evaluate both AP and fairness metrics on a testing set to assess the generalizability of learned models. For a fair comparison, we will compare fair mixup with baselines that optimize the fairness constraint at training time. In particular, we compare our method with (a) empirical risk minimization (ERM) that trains the model without regularization, (b) gap regularization, which directly regularizes the model as given in Equation (1), and (c) adversarial debiasing (Zhang et al., 2018a) introduced in section 2. Details about the baselines and experimental setups for each dataset can be found in appendix.
# 6.1 ADULT
UCI Adult dataset (Dua & Graff, 2017) contains information about over 40,000 individuals from the 1994 US Census. The task is to predict whether the income of a person is greater than $\$ 50 k$ given attributes about the person. We consider gender as the sensitive attribute to measure the fairness of the algorithms. The models are two-layer ReLU networks with hidden size 200. We only evaluate input mixup for Adult dataset as the network is not deep enough to produce meaningful latent representations. We retrain each model 10 times and report the mean accuracy and fairness measurement. In each trial, the dataset is randomly randomly split into a training, validation, and testing set with partition $6 0 \%$ , $2 0 \%$ , and $2 0 \%$ , respectively. The models are then selected via the performance on the validation set.
 Figure 3: Adult Dataset. (a,b) The tradeoff between AP and $\Delta \mathrm { D P } / \Delta \mathrm { E O }$ . (c) Visualization of the mixup path for models that regularize $\Delta \mathbf { D P }$ with different algorithms. We plot the calibrated curve $\mu _ { f } ^ { \prime } ( t ) : = \mu _ { f } ( t ) - \mu _ { f } ( 0 )$ for a better visualization. In this case, $\mu _ { f } ^ { \prime } ( 0 ) = 0$ and $| \mu _ { f } ^ { \prime } ( 1 ) | = \Delta \mathrm { D P }$ for all the calibrated curves $\mu _ { f } ^ { \prime }$ . Therefore, we can compare the $\Delta \mathbf { D P }$ of each method with the absolute value of the last points $\dot { \boldsymbol { t } } = 1$ ). The flatness of the path is highly correlated with the $\Delta \mathbf { D P }$ .
 Figure 4: CelebA Dataset. The tradeoff between AP and $\Delta \mathrm { D P } / \Delta \mathrm { E O }$ are shown in the first/second row for each task. Manifold mixup consistently outperforms the baseline across tasks.
Figures 3 (a) shows the tradeoff between AP and $\Delta \mathbf { D P }$ . We can see that fair mixup consistently achieves a better tradeoff compared to the baselines. We then show the tradeoff between AP and $\Delta \mathrm { E O }$ in figure 3 (b). For this metric, fair mixup performs slightly better than directly regularizing the EO gap. Interestingly, fair mixup even achieves a better AP compared to ERM, indicating that mixup regularization not only improves the generalization of fairness constraints but also overall accuracy. To understand the effect of fair mixup, we visualize the expected output $\mu _ { f }$ along the path for each method (i.e $\mu _ { f }$ as function of $t$ ). For a fair comparison, we select the models that have similar AP for the visualization. As we can see in figure 3 (c), the flatness of the path is highly correlated to $\Delta \mathbf { D P }$ . Traininig without any regularization leads to the largest derivative along the path, which eventually leads to large $\Delta \mathbf { D P }$ . All the fairness-aware algorithms regularize the slope to some extent, nevertheless, fair mixup achieves the shortest arc length and hence leads to the smallest $\Delta \mathbf { D P }$ .
 Figure 5: Visualization of calibrated paths on attractive classification task for $\Delta \mathbf { D P }$ regularized models. The flatness of both input and latent path plays an important role in regularizing $\Delta \mathbf { D P }$ .
# 6.2 CELEBA
Next, we show that fair mixup generalizes well to high-dimensional tasks with the CelebA face attributes dataset (Liu et al.). CelebA contains over 200,000 images of celebrity faces, where each image is associated with 40 human-labeled binary attributes including gender. Among the attributes, we select attractive, smile, and wavy hair and use them to form three binary classification tasks while treating gender as the sensitive attribute2. The reason we choose these three attributes is that there exists in all these tasks, a sensitive group that has more positive samples than the other one. For each task, we train a ResNet-18 (He et al., 2016) along with two hidden layers for final prediction. To implement manifold fair mixup, we interpolate the representations before the average pooling layer.
The first row in figure 4 shows the tradeoff between AP and $\Delta \mathbf { D P }$ for each task. Again, fair mixup consistently outperforms the baselines by a large margin. We also observe that manifold mixup further boosts the performance for all the tasks. The tradeoffs between AP and $\Delta \mathrm { E O }$ are shown in the second row of figure 4. Again, both input mixup and manifold mixup yields well generalizing classifiers. To gain further insights, we plot the path in both input space and latent space in figure 5 (a) and (b) for the “attractive” attribute classification task. Fair mixup leads to a smoother path in both cases. Without mixup augmentation, gap regularization and adversarial debiasing present similar paths and both have larger $\Delta \mathbf { D P }$ . We also observe that the expected output $\mu _ { f }$ in the latent path is almost linear with respect to the continuous sensitive attribute $t$ , manifold mixup being the curve with the smallest slope and hence smallest $\Delta \mathbf { D P }$ .
# 6.3 TOXICITY CLASSIFICATION
Lastly, we consider comment toxicity classification with Jigsaw toxic comment dataset (Jigsaw, 2018). The data was initially released by Civil Comments platform, which was then extended to a public Kaggle challenge. The task is to predict whether a comment is toxic or not while being fair across groups. A subset of comments have been labeled with identity attributes, including gender and race. It has been shown that some of the identities (e.g., black) are correlated with the toxicity label. In this work, we consider race as the sensitive attribute and select the subset of comments that contain identities black or asian, as these two groups have the largest gap in terms of probability of being associated with a toxic comment. We use pretrained BERT embeddings (Devlin et al., 2019) to encode each comment into a vector of size 768. A three layer ReLU network is then trained to perform the prediction with the encoded feature. We directly adopt manifold mixup since input mixup is equivalent to manifold mixup by simply setting the encoder $g$ to BERT. Similarly, we retrain each model 10 times using randomly split training, validation, and testing sets, and report mean accuracy and fairness measurement.
Figures 6 (a) and (b) show the tradeoff between AP and $\Delta \mathrm { D P } / \Delta \mathrm { E O }$ , respectively. Again, fair mixup consistently achieves a better tradeoff for both $\Delta \mathbf { D P }$ and $\Delta \mathrm { E O }$ . We then show the visualization of calibrated paths for $\Delta \mathbf { D P }$ -regularized models in Figure 6 (c). We can see that even with the powerful BERT embedding, all the baselines present fluctuated paths with similar patterns. In contrast, fair mixup introduces a nearly linear curve with a small slope, which eventually leads to the smallest $\Delta \mathbf { D P }$ .
 Figure 6: Toxic Classification (a,b) The tradeoff between AP and $\Delta \mathrm { D P } / \Delta \mathrm { E O }$ . (c) Visualization of the calibrated paths for models that regularize $\Delta \mathbf { D P }$ with different algorithms. Interestingly, fair mixup presents a nearly linear curve with small slope, while the baselines introduce “inverted-U” shaped curves.
# 7 CONCLUSION
In this work, we propose fair mixup, a data augmentation strategy to optimize fairness constraints. By bridging sensitive groups with interpolated samples, fair mixup consistently improves the generalizability of fairness constraints across benchmarks with different modalities. Interesting future directions include (1) generating interpolated samples that lie on the natural data manifold with generative models or via dynamic optimal transport paths between the groups (Benamou & Brenier, 2000), (2) extending fair mixup to other group fairness metrics such as accuracy equality, and (3) estimating the generalization of fairness constraints (Chuang et al., 2020).
# REFERENCES
Alekh Agarwal, Alina Beygelzimer, Miroslav Dudik, John Langford, and Hanna Wallach. A reductions approach to fair classification. In International Conference on Machine Learning, pp. 60–69, 2018.
Solon Barocas, Moritz Hardt, and Arvind Narayanan. Fairness and Machine Learning. fairmlbook.org, 2019. http://www.fairmlbook.org.
Jean-David Benamou and Yann Brenier. A computational fluid mechanics solution to the MongeKantorovich mass transfer problem. Numerische Mathematik, 2000.
Richard Berk, Hoda Heidari, Shahin Jabbari, Michael Kearns, and Aaron Roth. Fairness in criminal justice risk assessments: The state of the art. Sociological Methods & Research, pp. 0049124118782533, 2018.
David Berthelot, Colin Raffel, Aurko Roy, and Ian Goodfellow. Understanding and improving interpolation in autoencoders via an adversarial regularizer. In International Conference on Learning Representations, 2018.
Piotr Bojanowski, Armand Joulin, David Lopez-Pas, and Arthur Szlam. Optimizing the latent space of generative networks. In International Conference on Machine Learning, pp. 600–609, 2018.
Alvin Chan, Yi Tay, Yew Soon Ong, and Jie Fu. Jacobian adversarially regularized networks for robustness. In International Conference on Learning Representations, 2019.
Ching-Yao Chuang, Antonio Torralba, and Stefanie Jegelka. Estimating generalization under distribution shifts via domain-invariant representations. International Conference on Machine Learning, 2020.
Andrew Cotter, Maya Gupta, Heinrich Jiang, Nathan Srebro, Karthik Sridharan, Serena Wang, Blake Woodworth, and Seungil You. Training well-generalizing classifiers for fairness metrics and other data-dependent constraints. In International Conference on Machine Learning, pp. 1397–1405, 2019.
Jacob Devlin, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova. Bert: Pre-training of deep bidirectional transformers for language understanding. In NAACL-HLT (1), 2019.
Harris Drucker and Yann LeCun. Improving generalization performance using double backpropagation. IEEE Transactions on Neural Networks, 1992.
Dheeru Dua and Casey Graff. UCI machine learning repository, 2017. URL http://archive. ics.uci.edu/ml.
Cynthia Dwork, Moritz Hardt, Toniann Pitassi, Omer Reingold, and Richard Zemel. Fairness through awareness. In Proceedings of the 3rd innovations in theoretical computer science conference, pp. 214–226, 2012.
Moritz Hardt, Eric Price, and Nati Srebro. Equality of opportunity in supervised learning. In Advances in neural information processing systems, pp. 3315–3323, 2016.
Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Deep residual learning for image recognition. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 770–778, 2016.
Alex Hernandez-Garc ´ ´ıa and Peter Konig. Data augmentation instead of explicit regularization. ¨ arXiv preprint arXiv:1806.03852, 2018.
Judy Hoffman, Daniel A Roberts, and Sho Yaida. Robust learning with jacobian regularization. arXiv preprint arXiv:1908.02729, 2019.
Jigsaw. Jigsaw unintended bias in toxicity classification, 2018. URL https://www.kaggle. com/c/jigsaw-unintended-bias-in-toxicity-classification.
Diederik P Kingma and Jimmy Ba. Adam: A method for stochastic optimization. arXiv preprint arXiv:1412.6980, 2014.
Ziwei Liu, Ping Luo, Xiaogang Wang, and Xiaoou Tang. Large-scale celebfaces attributes (celeba) dataset.
Christos Louizos, Kevin Swersky, Yujia Li, Max Welling, and Richard Zemel. The variational fair autoencoder. arXiv preprint arXiv:1511.00830, 2015.
David Madras, Elliot Creager, Toniann Pitassi, and Richard Zemel. Learning adversarially fair and transferable representations. International Conference on Machine Learning, 2018.
Bahar Taskesen, Viet Anh Nguyen, Daniel Kuhn, and Jose Blanchet. A distributionally robust approach to fair classification. arXiv preprint arXiv:2007.09530, 2020.
Vikas Verma, Alex Lamb, Christopher Beckham, Amir Najafi, Ioannis Mitliagkas, David LopezPaz, and Yoshua Bengio. Manifold mixup: Better representations by interpolating hidden states. In International Conference on Machine Learning, pp. 6438–6447. PMLR, 2019.
Dennis Wei, Karthikeyan Natesan Ramamurthy, and Flavio du Pin Calmon. Optimized score transformation for fair classification. arXiv preprint arXiv:1906.00066, 2019.
Blake Woodworth, Suriya Gunasekar, Mesrob I Ohannessian, and Nathan Srebro. Learning nondiscriminatory predictors. In Conference on Learning Theory, pp. 1920–1953, 2017.
Mikhail Yurochkin, Amanda Bower, and Yuekai Sun. Training individually fair ml models with sensitive subspace robustness. In International Conference on Learning Representations, 2019.
Muhammad Bilal Zafar, Isabel Valera, Manuel Gomez Rogriguez, and Krishna P Gummadi. Fairness constraints: Mechanisms for fair classification. In Artificial Intelligence and Statistics, pp. 962–970. PMLR, 2017.
Rich Zemel, Yu Wu, Kevin Swersky, Toni Pitassi, and Cynthia Dwork. Learning fair representations. In International Conference on Machine Learning, pp. 325–333, 2013.
Brian Hu Zhang, Blake Lemoine, and Margaret Mitchell. Mitigating unwanted biases with adversarial learning. In Proceedings of the 2018 AAAI/ACM Conference on AI, Ethics, and Society, pp. 335–340, 2018a.
Chiyuan Zhang, Samy Bengio, Moritz Hardt, Benjamin Recht, and Oriol Vinyals. Understanding deep learning requires rethinking generalization. arXiv preprint arXiv:1611.03530, 2016.
Hongyi Zhang, Moustapha Cisse, Yann N Dauphin, and David Lopez-Paz. mixup: Beyond empirical risk minimization. In International Conference on Learning Representations, 2018b.
# A PROOFS
A.1 PROOF OF LEMMA 1
Lemma 1. Let $T : \mathcal { X } ^ { 2 } \times [ 0 , 1 ] \to \mathcal { X }$ be a function continuously differentiable w.r.t. t such that $T ( x _ { 0 } , x _ { 1 } , 0 ) = x _ { 0 }$ and $T ( x _ { 0 } , x _ { 1 } , 1 ) = x _ { 1 }$ . For any differentiable function $f$ , we have
$$\Delta \mathrm { D P } ( f ) = \left| \int _ { 0 } ^ { 1 } \frac { d } { d t } \int f ( \underbrace { T ( x _ { 0 } , x _ { 1 } , t ) } _ { \mathrm { i n t e r p o l a t i o n } } ) d P _ { 0 } ( x _ { 0 } ) d P _ { 1 } ( x _ { 1 } ) d t \right| .$$
Proof. The result follows from the fundamental theorem of calculus. In particular, given an interpolator $T$ , we first rewrite the $\Delta \mathbf { D P }$ with the $T$ :
$$\begin{array} { r l } & { \Delta \mathrm { D P } ( f ) = | \mathbb { E } _ { x \sim P _ { 0 } } f ( x ) - \mathbb { E } _ { x \sim P _ { 1 } } f ( x ) | } \\ & { \qquad = | \mathbb { E } _ { x _ { 0 } \sim P _ { 0 } , x _ { 1 } \sim P _ { 1 } } f ( x _ { 0 } ) - f ( x _ { 1 } ) | } \\ & { \qquad = | \mathbb { E } _ { x _ { 0 } \sim P _ { 0 } , x _ { 1 } \sim P _ { 1 } } f ( T ( x _ { 0 } , x _ { 1 } , 0 ) ) - \mathbb { E } _ { x _ { 0 } \sim P _ { 0 } , x _ { 1 } \sim P _ { 1 } } f ( T ( x _ { 0 } , x _ { 1 } , 1 ) ) | . } \end{array}$$
Not that $\mathbb { E } _ { x _ { 0 } \sim P _ { 0 } , x _ { 1 } \sim P _ { 1 } } f ( T ( x _ { 0 } , x _ { 1 } , t ) )$ is a real-valued continuous function on $t \in [ 0 , 1 ]$ . Therefore, we have the following equivalence via the fundamental theorem of calculus:
$$\begin{array} { l } { \displaystyle \Delta \mathrm { D P } ( f ) = \left| \mathbb { E } _ { x _ { 0 } \sim P _ { 0 } , x _ { 1 } \sim P _ { 1 } } f ( T ( x _ { 0 } , x _ { 1 } , 0 ) ) - \mathbb { E } _ { x _ { 0 } \sim P _ { 0 } , x _ { 1 } \sim P _ { 1 } } f ( T ( x _ { 0 } , x _ { 1 } , 1 ) ) \right| . } \\ { \displaystyle \qquad = \left| \int _ { 0 } ^ { 1 } \frac { d } { d t } \mathbb { E } _ { x _ { 0 } \sim P _ { 0 } , x _ { 1 } \sim P _ { 1 } } f ( T ( x _ { 0 } , x _ { 1 } , t ) ) \right| . } \end{array}$$
# A.2 PROOF OF PROPOSITION 2
Proposition 2. (Gap Regularization) Consider the following minimization problem
$$\operatorname* { m i n } _ { f \in \mathcal { H } } \mathbb { E } _ { ( x , y ) \sim P } [ \ell ( f ( x ) , y ) ] + \frac { \lambda _ { 1 } } { 2 } \Delta \mathrm { D } \mathbf { P } ( f ) ^ { 2 } + \frac { \lambda _ { 2 } } { 2 } | | f | | _ { \mathcal { H } } ^ { 2 } .$$
For a fixed embedding $\Phi$ , the optimal solution $f ^ { * }$ corresponds to $v ^ { * }$ given by following closed form:
$$v ^ { \ast } = \frac { 1 } { \lambda _ { 2 } } \left( \delta _ { \pm } - p r o j _ { \delta _ { 0 , 1 } } ^ { \frac { \lambda _ { 2 } } { \lambda _ { 1 } } } ( \delta _ { \pm } ) \right) ,$$
where proj is the soft projection defined as pro $\begin{array} { r } { j _ { u } ^ { \beta } ( x ) = \frac { u \otimes u } { | | u | | ^ { 2 } + \beta } x } \end{array}$
Proof. The problem above can be written as follows:
$$\operatorname* { m i n } _ { v \in \mathbb { R } ^ { m } } \mathcal { L } ( v ) : = - ( \langle v , \delta _ { \pm } \rangle ) + \frac { \lambda _ { 1 } } { 2 } | \langle v , \delta _ { 0 , 1 } \rangle | ^ { 2 } + \frac { \lambda _ { 2 } } { 2 } | | v | | _ { 2 } ^ { 2 }$$
Setting first order condition to zero
$$\begin{array} { r } { \nabla _ { v } \mathcal { L } ( v ) = - \delta _ { \pm } + \lambda _ { 1 } \delta _ { 0 , 1 } \otimes \delta _ { 0 , 1 } v + \lambda _ { 2 } v = 0 , } \end{array}$$
we obtain
$$( \lambda _ { 1 } \delta _ { 0 , 1 } \otimes \delta _ { 0 , 1 } + \lambda _ { 2 } I _ { m } ) v ^ { \ast } = \delta _ { \pm } .$$
By inverting and applying the Sherman-Morrison Lemma, we have
$$\begin{array} { l l l } { { v ^ { * } } } & { { = } } & { { \displaystyle ( \lambda _ { 1 } \delta _ { 0 , 1 } \otimes \delta _ { 0 , 1 } + \lambda _ { 2 } I _ { m } ) ^ { - 1 } \delta _ { \pm } } } \\ { { } } & { { = } } & { { \displaystyle \lambda _ { 1 } ^ { - 1 } \left( \frac { \lambda _ { 2 } } { \lambda _ { 1 } } I _ { m } + \delta _ { 0 , 1 } \otimes \delta _ { 0 , 1 } \right) ^ { - 1 } \delta _ { \pm } } } \\ { { } } & { { = } } & { { \displaystyle \lambda _ { 1 } ^ { - 1 } \left( I _ { m } - \frac { ( \lambda _ { 1 } ) ^ { 2 } \delta _ { 0 , 1 } \otimes \delta _ { 0 , 1 } } { 1 + | | \delta _ { 0 , 1 } | | ^ { 2 } \frac { \lambda _ { 1 } } { \lambda _ { 2 } } } \right) \delta _ { \pm } } } \\ { { } } & { { = } } & { { \displaystyle \frac { 1 } { \lambda _ { 2 } } \left( I _ { m } - \frac { \delta _ { 0 , 1 } \otimes \delta _ { 0 , 1 } } { \lambda _ { 2 } } \right) \delta _ { \pm } . } } \end{array}$$
Note the soft projection on a vector $u$ is defined as follows:
$$p r o j _ { u } ^ { \beta } ( x ) = \frac { u \otimes u } { | | u | | ^ { 2 } + \beta } x .$$
It follows that
$$v ^ { \ast } = \frac { 1 } { \lambda _ { 2 } } \left( \delta _ { \pm } - p r o j _ { \delta _ { 0 , 1 } } ^ { \frac { \lambda _ { 2 } } { \lambda _ { 1 } } } ( \delta _ { \pm } ) \right) ,$$
which can be interpreted as the projection of the label discriminating direction $\delta _ { \pm }$ on the subspace that is orthogonal to the group discriminating direction $\delta _ { 0 , 1 }$ . □
# A.3 PROOF OF PROPOSITION 3
Proposition 3. (Fair Mixup) Consider the following minimization problem
$$\operatorname* { m i n } _ { f \in \mathcal { H } } \mathbb { E } _ { ( x , y ) \sim P } [ \ell ( f ( x ) , y ) ] + \frac { \lambda _ { 1 } } { 2 } R _ { \mathrm { m i x u p } } ^ { \mathrm { D P - 2 } } ( f ) + \frac { \lambda _ { 2 } } { 2 } | | f | | _ { \mathcal { H } } ^ { 2 } .$$
Define $m _ { t } = \mathbb { E } _ { x _ { 0 } \sim P _ { 0 } , x _ { 1 } \sim P _ { 1 } } [ \Phi ( t x _ { 0 } + ( 1 - t ) x _ { 1 } ) ]$ be the $t$ dependent mean embedding, and $\dot { m } _ { t }$ its derivative with respect to $t$ . Let $D$ be a positive-semi definite matrix defined as follows: $D =$ $\begin{array} { r } { \int _ { 0 } ^ { 1 } { \dot { m _ { t } } } \otimes { \dot { m } } _ { t } d t } \end{array}$ . Given an embedding $\Phi$ , the optimal solution $v ^ { * }$ has the following form:
$$v ^ { * } = ( \lambda _ { 1 } D + \lambda _ { 2 } I _ { m } ) ^ { - 1 } \delta _ { \pm } .$$
Proof. For $t \in [ 0 , 1 ]$ , we note by $\rho _ { t }$ the distribution of $T ( x _ { 0 } , x _ { 1 } , t )$ , for $x _ { 0 } \sim P _ { 0 } , x _ { 1 } \sim P _ { 1 }$ , and note $m _ { t } = \mathbb { E } _ { x \sim \rho _ { t } } \Phi ( x )$ , and $\dot { m } _ { t }$ its time derivative. We consider the $\ell _ { 2 }$ variant of $R _ { T } ( f )$ in the analysis:
$$\begin{array} { r c l } { { R _ { T } ^ { 2 } ( f ) } } & { { = } } & { { \displaystyle \int _ { 0 } ^ { 1 } \left| \frac { d } { d t } \mu _ { f } ( t ) \right| ^ { 2 } d t = \displaystyle \int _ { 0 } ^ { 1 } \left| \frac { d } { d t } \left. v , m _ { t } \right. \right| ^ { 2 } d t } } \\ { { } } & { { = } } & { { \displaystyle \int _ { 0 } ^ { 1 } | \langle v , \dot { m } _ { t } \rangle | ^ { 2 } d t = \left. v , \left( \displaystyle \int _ { 0 } ^ { 1 } \dot { m } _ { t } \otimes \dot { m } _ { t } d t \right) v \right. , } } \end{array}$$
We then expand $\dot { m } _ { t }$ when $T$ is mixup:
$$\dot { m } _ { t } = \frac { d } { d t } \mathbb { E } _ { x _ { 0 } \sim \mathbb { P } _ { 0 } , x _ { 1 } \sim \mathbb { P } _ { 1 } } \Phi ( t x _ { 0 } + ( 1 - t ) x _ { 1 } ) = \mathbb { E } _ { x _ { 0 } \sim \mathbb { P } _ { 0 } , x _ { 1 } \sim \mathbb { P } _ { 1 } } J \Phi ( t x _ { 0 } + ( 1 - t ) x _ { 1 } ) ( x _ { 0 } - x _ { 1 } )$$
where $J$ denotes the Jacobian. Note that $\begin{array} { r } { D = \int _ { 0 } ^ { 1 } \dot { m _ { t } } \otimes \dot { m } _ { t } d t } \end{array}$ , hence for the classification with fair mixup regularizer, the problem is equivalent to:
$$\operatorname* { m i n } _ { v \in \mathbb { R } ^ { m } } \mathcal { L } ( v ) : = - ( \langle v , \delta _ { \pm } \rangle ) + \frac { \lambda _ { 1 } } { 2 } \langle v , D v \rangle + \frac { \lambda _ { 2 } } { 2 } | | v | | _ { 2 } ^ { 2 }$$
Setting first order condition we obtain $( \lambda _ { 1 } D + \lambda _ { 2 } I _ { m } ) v ^ { \ast } = \delta _ { \pm }$ , which gives the optimal solution
$$v ^ { * } = ( \lambda _ { 1 } D + \lambda _ { 2 } I _ { m } ) ^ { - 1 } \delta _ { \pm } .$$
The corresponding optimal fair mixup classifier can be finally written as
$$f ( x ) = \left. \delta _ { \pm } , ( \lambda _ { 1 } D + \lambda _ { 2 } I _ { m } ) ^ { - 1 } \Phi ( x ) \right. .$$
# B EXPERIMENT DETAILS
Adult We follow the preprocessing procedure of Yurochkin et al. (2019) by removing some features in the dataset3. We then encode the discrete and quantized continuous attributes with one-hot encoding. We retrain each model 10 times with batch size 1000 and report the mean accuracy and fairness measurement. The models are selected via the performance on validation set. In each trial, the dataset is randomly split into training and testing set with partition $8 0 \%$ and $2 0 \%$ , respectively. The models are optimized with Adam optimizer (Kingma & Ba, 2014) with learning rate $\mathrm { \bar { 1 } } \times e ^ { - \mathrm { \bar { 3 } } }$ For DP, we sample 500 datapoints for each $A \in \{ 0 , 1 \}$ to form a batch. Similarly, for EO, we sample 250 datapoints for each $( A , Y )$ pair where $A , Y \in \{ 0 , 1 \}$ .
CelebA Model-wise, we extract the feature of size 512 after the average pooling layer of ResNet18. A two-layer ReLU network with hidden size 512 is then trained to perform prediction. Percentage of positive-labeled datapoints for attractive, wavy hair, and smiling that is male are $2 2 . 7 \%$ , $1 8 . 3 6 \%$ , and $3 4 . 6 \%$ , respectively. We use the original validation set of CelebA to perform model selection and report the accuracy and fairness metrics on the testing set. The visualization paths are also plotted with respect to the testing data. To implement manifold mixup, we interpolate the spatial features before the average pooling layer. Similarly, all the models are optimized with Adam optimizer with learning rate $1 \times e ^ { - 3 }$ .
Toxicity Classification We download the Jigsaw toxic comment dataset from Kaggle website4. Percentage of positive-labeled datapoints for black and asian are $1 8 . 8 \%$ and $6 . 4 \%$ , respectively, which together results in a dataset of size 22835. We retrain each model 10 times with batch size 200 and report the mean accuracy and fairness measurement. The models are selected via the performance on validation set. The batch-sampling and data splitting procedure is the same as the one for Adult dataset. The models are again optimized with Adam optimizer with learning rate $1 \times e ^ { - 3 }$ .
# C ADDITIONAL EXPERIMENTS
# C.1 TRAINING PERFORMANCE
In Figure 7, we show the training performance for Adult dataset. As expected, GapReg outperforms Fair mixup on the training set since it directly optimizes the fairness metric. The results also support our motivation: the constraints that are satisfied during training might not generalize at evaluation time.
 Figure 7: Training Performance on Adult Dataset. The tradeoff between AP and $\Delta \mathrm { D P } / \Delta \mathrm { E O }$ on training set.
# C.2 EVALUATION METRIC
The relaxed evaluation metric could overestimate the performance when the predicted confidence is significantly different between groups. For instance, a classifier $f$ can be completely unfair while satisfying this condition: $f ( x ) { \overset { } { = } } 1$ w.p. $60 \%$ , 0 w.p. $40 \%$ on $P _ { 0 }$ , and $f ( x ) \stackrel { - } { = } 0 . 6$ w.p. $100 \%$ on $P _ { 1 }$ . This satisfies this expectation-based condition. However, it is highly unfair if we binarize the prediction by setting the threshold $= 0 . 5$ .
To overcome this issue, let $f _ { t }$ be the binarized predictor $f _ { t } ( x ) = \mathbb { 1 } ( f ( x ) \geq t )$ , we evaluate the model with average $\Delta \mathrm { D P } ( \overline { { \Delta \mathrm { D P } } } )$ defined as follows:
$$\begin{array} { r l } & { \overline { { \Delta \mathrm { D P } } } ( f ) = \displaystyle \frac { 1 } { | T | } \sum _ { t \in \mathcal { T } } \left| \mathbb { E } _ { \boldsymbol { x } \sim P _ { 0 } } f _ { t } ( \boldsymbol { x } ) - \mathbb { E } _ { \boldsymbol { x } \sim P _ { 1 } } f _ { t } ( \boldsymbol { x } ) \right| ; } \\ & { \overline { { \Delta \mathrm { E O } } } ( f ) = \displaystyle \frac { 1 } { | T | } \sum _ { t \in \mathcal { T } } \sum _ { y \in \{ 0 , 1 \} } \left| \mathbb { E } _ { \boldsymbol { x } \sim P _ { 0 } ^ { y } } f _ { t } ( \boldsymbol { x } ) - \mathbb { E } _ { \boldsymbol { x } \sim P _ { 1 } ^ { y } } f _ { t } ( \boldsymbol { x } ) \right| , } \end{array}$$
where $\tau$ is a set of threshold values. $\overline { { \Delta \mathsf { D P } } }$ averages the $\Delta \mathbf { D P }$ with binarized predictions derived via different thresholds. For instance, by averaging the $\Delta \mathbf { D P }$ with thersholds $\mathcal { T } = [ 0 . 1 , 0 . 2 , \cdot \cdot \cdot , 0 . 9 ] ,$ , $\overline { { \Delta \mathrm { D P } } } = 0 . 5$ instead of 0 for the example above, which captures the unfairness between groups. We report $\overline { { \Delta \mathsf { D P } } }$ for each methods with thersholds $\mathcal { T } = [ 0 . 1 , \bar { 0 } . 2 , \cdot \cdot \cdot . , 0 . 9 ]$ in Figure 8. Similarly, fair mixup exhibits the best tradeoff comparing to the baselines for demographic parity. For equalized odds, the performances of fair mixup and GapReg are similar, where fair mixup achieves a better tradeoff when $\overline { { \Delta \mathrm { E O } } }$ is small.
 Figure 8: Average ∆DP and ∆EO on Adult Dataset.
# C.3 SMALLER MODEL SIZE
To examine the effect of model size, we reduce the hidden size from 200 to 50 and show the result in Figure 9. Overall, the performance does not vary significantly after reducing the model size. We can again observe that fair mixup outperform the baselines for $\Delta \mathbf { D P }$ . Similar to the results in section C.2, the performances of fair mixup and GapReg are similar, where fair mixup achieves a better tradeoff when $\Delta \mathrm { E O }$ is small.
 Figure 9: Reducing the Model Size on Adult Dataset.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357# LEARNING WITH AMIGO:ADVERSARIALLY MOTIVATED INTRINSIC GOALS
Andres Campero∗ Brain and Cognitive Sciences, MIT Cambridge, USA campero@mit.edu
Roberta Raileanu New York University New York, USA raileanu@cs.nyu.edu
Heinrich Kuttler ¨ Facebook AI Research London, UK hnr@fb.com
# Tim Rocktaschel ¨
# Edward Grefenstette
Joshua B. Tenenbaum Brain and Cognitive Sciences, MIT Cambridge, USA jbt@mit.edu
University College London & Facebook AI Research London, UK rockt@fb.com
University College London & Facebook AI Research London, UK egrefen@fb.com
# ABSTRACT
A key challenge for reinforcement learning (RL) consists of learning in environments with sparse extrinsic rewards. In contrast to current RL methods, humans are able to learn new skills with little or no reward by using various forms of intrinsic motivation. We propose AMIGO, a novel agent incorporating—as form of meta-learning—a goal-generating teacher that proposes Adversarially Motivated Intrinsic GOals to train a goal-conditioned “student” policy in the absence of (or alongside) environment reward. Specifically, through a simple but effective “constructively adversarial” objective, the teacher learns to propose increasingly challenging—yet achievable—goals that allow the student to learn general skills for acting in a new environment, independent of the task to be solved. We show that our method generates a natural curriculum of self-proposed goals which ultimately allows the agent to solve challenging procedurally-generated tasks where other forms of intrinsic motivation and state-of-the-art RL methods fail.
# 1 INTRODUCTION
The success of Deep Reinforcement Learning (RL) on a wide range of tasks, while impressive, has so far been mostly confined to scenarios with reasonably dense rewards (e.g. Mnih et al., 2016; Vinyals et al., 2019), or to those where a perfect model of the environment can be used for search, such as the game of Go and others (e.g. Silver et al., 2016; Duan et al., 2016; Moravc´ık et al., 2017). Many real-world environments offer extremely sparse rewards, if any at all. In such environments, random exploration, which underpins many current RL approaches, is likely to not yield sufficient reward signal to train an agent, or be very sample inefficient as it requires the agent to stumble onto novel rewarding states by chance. In contrast, humans are capable of dealing with rewards that are sparse and lie far in the future. For example, to a child, the future adult life involving education, work, or marriage provides no useful reinforcement signal. Instead, children devote much of their time to play, generating objectives and posing challenges to themselves as a form of intrinsic motivation. Solving such self-proposed tasks encourages them to explore, experiment, and invent; sometimes, as in many games and fantasies, without any direct link to reality or to any source of extrinsic reward. This kind of intrinsic motivation might be a crucial feature to enable learning in real-world environments (Schulz, 2012) .
To address this discrepancy between na¨ıve deep RL exploration strategies and human capabilities, we present a novel meta-learning method wherein part of the agent learns to self-propose Adversarially Motivated Intrinsic Goals (AMIGO). In AMIGO, the agent is decomposed into a goal-generating teacher and a goal-conditioned student policy. The teacher acts as a constructive adversary to the student: the teacher is incentivized to propose goals that are not too easy for the student to achieve, but not impossible either. This results in a natural curriculum of increasingly harder intrinsic goals that challenge the agent and encourage learning about the dynamics of a given environment.
 Figure 1: Training with AMIGO consists of combining two modules: a goal-generating teacher and a goal-conditioned student policy, whereby the teacher provides intrinsic goals to supplement the extrinsic goals from the environment. In our experimental set-up, the teacher is a dimensionalitypreserving convolutional network which, at the beginning of an episode, outputs a location in absolute $( x , y )$ coordinates. These are provided as a one-hot indicator in an extra channel of the student’s convolutional neural network, which in turn outputs the agent’s actions.
AMIGO can be viewed as an augmentation of any agent trained with policy gradient-based methods. Under this view, the original policy network becomes the student policy, which only requires its inputprocessing component to be adapted to accept an additional goal specification modality. The teacher policy can then be seen as a “bolt-on” to the original policy network, entailing that this method is—to the extent that the aforementioned goal-conditioning augmentation is possible—architecture-agnostic, and can be used on a variety of RL training model architectures and training settings.
As advocated in recent work (Cobbe et al., 2019; Zhong et al., 2020; Risi & Togelius, 2019; Kuttler ¨ et al., 2020), we evaluate AMIGO for procedurally-generated environments instead of trying to learn to perform a specific task. Procedurally-generated environments are challenging since agents have to deal with a parameterized family of tasks, resulting in large observation spaces where memorizing trajectories is infeasible. Instead, agents have to learn policies that generalize across different environment layouts and transition dynamics (Rajeswaran et al., 2017; Machado et al., 2018; Foley et al., 2018; Zhang et al., 2018). Concretely, we use MiniGrid (Chevalier-Boisvert et al., 2018), a suite of fast-to-run procedurally-generated environments with a symbolic/discrete (expressed in terms of objects like walls, doors, keys, chests and balls) observation space which isolates the problem of exploration from that of visual perception. MiniGrid is a widely recognized challenging benchmark for intrinsic motivation, which was used in many recent publications such as Goyal et al. 2019, Bougie et al. 2019, Raileanu and Rocktaschel 2020, Modhe ¨ et al. 2020 etc. We evaluate our method on six different tasks from the MiniGrid domain with varying degrees of difficulties, in which the agent needs to acquire a diverse range of skills in order to succeed. Furthermore, MiniGrid is complex and competitive baselines such as IMPALA (that achieve SOTA in other domains like Atari) fail. Raileanu & Rocktaschel (2020) found that MiniGrid presents a particular challenge for ¨ existing state-of-the-art intrinsic motivation approaches. Here, AMIGO sets a new state-of-the-art on some of the hardest MiniGrid environments, being the only method capable of successfully obtaining extrinsic reward on some of them.
In summary, we make the following contributions: (i) we propose Adversarially Motivated Intrinsic GOals—an approach for learning a teacher that generates increasingly harder goals, (ii) we show, through 114 experiments on 6 challenging exploration tasks in procedurally generated environments, that agents trained with AMIGO gradually learn to interact with the environment and solve tasks which are too difficult for state-of-the-art methods, and (iii) we perform an extensive qualitative analysis and ablation study.
# 2 RELATED WORK
Our work has connections to many different research areas but due to space constraints, we will focus our discussion on the most closely related topics, namely intrinsic motivation and curriculum learning.
Intrinsic motivation (Oudeyer et al., 2007; Oudeyer & Kaplan, 2009; Schmidhuber, 1991; Barto, 2013) methods have proven effective for solving various hard-exploration tasks (Bellemare et al., 2016; Pathak et al., 2017; Burda et al., 2019b). One prominent formulation is the use of novelty, which in its simplest form can be estimated with state visitation counts (Strehl & Littman, 2008) and has been extended to high-dimensional state spaces (Bellemare et al., 2016; Burda et al., 2019b; Ostrovski et al., 2017). Other sophisticated versions of curiosity (Schmidhuber, 1991) guide the agent to learn about environment dynamics by encouraging it to take actions that reduce the agent’s uncertainty (Stadie et al., 2015; Burda et al., 2019b), have unpredictable consequences (Pathak et al., 2017; Burda et al., 2019a), or a large impact on the environment (Raileanu & Rocktaschel, ¨ 2020). Other forms of intrinsic motivation include empowerment (Klyubin et al., 2005) which encourages control of the environment by the agent, and goal diversity (Pong et al., 2019) which encourages maximizing the entropy of the goal distribution. In Lair et al. (2019), intrinsic goals are discovered from language supervision. The optimal rewards framework presents intrinsic motivation as a mechanism that goes beyond exploration, placing its origin in an evolutionary context (Singh et al., 2009), or framing it as a meta-optimization problem of selecting internal agent goals which optimize the designer’s goals Sorg et al. (2010). More recently Zheng et al. (2018) extend this framework to learn parametric additive intrinsic rewards. Our work differs from all of the above by formulating intrinsic motivation as a ”constructively adversarial” teacher that proposes increasingly harder goals for the agent.
Curriculum learning (Bengio et al., 2009) is another useful technique for tackling complex tasks but the curricula are typically handcrafted which can be time consuming. In our work, the curriculum is generated automatically in an unsupervised fashion. Another automatic curriculum approach learning was proposed by Schmidhuber (2011), where an agent constantly searches the space of problems for the next solvable one. However, this method is not scalable to more complex tasks. Florensa et al. (2017) generate a curriculum by increasing the distance of the starting-point to a goal. In contrast to AMIGO, this method assumes knowledge of the goal location and the ability to reset the agent in any state. A student can also self-propose a goal by hindsight experience replay (HER, Andrychowicz et al., 2017), which has been demonstrated to be effective in alleviating the sparse reward problem. Recent extensions have improved goal selection by balancing the difficulty and diversity (Fang et al., 2019) of goals. In contrast to our work, in HER, there is no explicit incentive for the agent to explore beyond its current reach. Since HER is rewarded for all the states it visits, it is rewarded for easy-to-reach states, even late in the training process. Other related work has trained a teacher to generate a curriculum of environments that maximize the learning process of the student (Portelas et al., 2020a). The question of the complementarity between these and our work is worth pursuing in the future. More similar to our work, Matiisen et al. (2017) train a teacher to select tasks in which the student is improving the most or in which the student’s performance is decreasing to avoid forgetting. Note that AMIGO uses a different objective for training the teacher, which encourages the agent to solve progressively harder tasks. Similarly, Racaniere et al. (2019) train a goal-conditioned policy and a goal-setter network in a non-adversarial way to propose feasible, valid and diverse goals. Their feasibility criteria is similar to ours, but requires training an additional discriminator to rank the difficulty of the goals, while our teacher is directly trained to generate goals with an appropriate level of difficulty.1 Recent surveys of curriculum generation in the context of RL include Narvekar et al. (2020) and Portelas et al. (2020b).
Closer to our work, Sukhbaatar et al. (2017) use an adversarial framework but require two modules that independently act and learn in the environment, where one module is encouraged to propose challenges to the other. This setup can be costly and is restricted to only proposing goals which have already been reached by the policy. Moreover, it requires a resettable or reversible environment. In contrast, our method uses a single agent acting in the environment, and the teacher is less constrained in the space of goals it can propose.
Also similar to ours, Florensa et al. (2018) present GoalGAN, a generator that proposes goals with the appropriate level of difficulty as determined by a learned discriminator. While their work is similar in spirit with ours, there are several key differences. First, GoalGAN was created for and tested on locomotion tasks with continuous goals, whereas our method is designed for discrete action and goal spaces. While not impossible, adapting it to our setting is not trivial due to the GAN objective. Second, the authors do not condition the generator on the observation which is necessary in procedurally-generated environments that change with each episode. GoalGAN generates goals from a buffer, but previous goals can be unfeasible or nonsensical for the current episode. Hence, GoalGAN cannot be easily adapted to procedurally-generated environments.
A concurrent effort, Zhang et al. (2020) complements ours, but in the context of continuous control, by also generating a curriculum of goals which are neither too hard nor too easy using a measure of epistemic uncertainty based on an ensemble of value functions. This requires training multiple networks, which can become too computationally expensive for certain applications.
Finally, our approach is loosely inspired by generative adversarial networks (GANs, Goodfellow et al., 2014), where a generative model is trained to fool a discriminator which is trained to differentiate between the generated and the original examples. In contrast with GANs, AMIGO does not require a discriminator, and is “constructively adversarial”, in that the goal-generating teacher is incentivized by its objective to propose goals which are challenging yet feasible for the student.
# 3 ADVERSARIALLY MOTIVATED INTRINSIC GOALS
AMIGO is composed of two subsystems: a goal-conditioned student policy which “controls” the agent’s actions in the environment, and a goal-generating teacher (see Figure 1) which guides the student’s training. The teacher proposes goals and is rewarded only when the student reaches the goal after a certain number of steps. The student receives reward for reaching the goal proposed by the teacher (discounted by the number of steps needed to reach the goal). The two components are trained adversarially in that the student maximizes reward by reaching goals as fast as possible, while the teacher maximizes reward by proposing goals which the student can reach, though not too quickly. In addition to this intrinsic reward, both modules are rewarded when the agent solves the full task.
# 3.1 TRAINING THE STUDENT
We consider the traditional RL framework of a Markov Decision Process with a state space $S$ , a set of actions $A$ and a transition function $p ( s _ { t + 1 } | s _ { t } , a _ { t } )$ which specifies the distribution over next states given a current state and action. At each time-step $t$ , the agent in state $s _ { t } \in S$ takes an action $a _ { t } \in A$ by sampling from a goal-conditioned stochastic student policy $\pi ( a _ { t } | s _ { t } , g ; \theta _ { \pi } )$ where $g$ is a intrinsic goal provided by the teacher.
The teacher $G ( s _ { 0 } ; \theta _ { g } )$ is a separate policy, operating on a different “granularity” than the student: it takes as input an initial state and outputs as actions a goal $g$ for the student, which stays the same until a new goal is proposed. The teacher proposes a new goal every time an episode begins or whenever the student reaches the intrinsic goal. We assume that some goal verification function $v ( s , g )$ can be specified as an indicator over whether a goal $g$ is achieved in a state $s$ . We use this to define the undiscounted intrinsic reward $r _ { t } ^ { g }$ as:
$$r _ { t } ^ { g } = v ( s _ { t } , g ) = { \left\{ \begin{array} { l l } { + 1 } & { { \mathrm { i f ~ t h e ~ s t a t e ~ } } s _ { t } { \mathrm { ~ s a t i s f i e s ~ t h e ~ g o a l ~ } } g } \\ { 0 } & { { \mathrm { o t h e r w i s e } } } \end{array} \right. }$$
At each time step $t$ , the student receives a reward $\boldsymbol { r } _ { t } = \boldsymbol { r } _ { t } ^ { g } + \boldsymbol { r } _ { t } ^ { e }$ , which is the sum of the intrinsic reward $r _ { t } ^ { g }$ provided by the teacher and the extrinsic reward $\boldsymbol { r } _ { t } ^ { e }$ provided by the environment. The student, reprexpected rew with p where $\theta _ { \pi }$ , is trained to maximize the discounted the discount factor. We consider a finite $\begin{array} { r } { R _ { t } = \mathbb { E } \big [ \sum _ { k = 0 } ^ { H } \gamma ^ { k } r _ { t + k } \big ] } \end{array}$ $\gamma \in [ 0 , 1 )$ $H$
# 3.2 TRAINING THE TEACHER
The teacher $G ( s _ { 0 } ; \theta _ { g } )$ , represented as a neural network with parameters $\theta _ { g }$ , is trained to maximise its expected reward. The teacher’s reward $r ^ { T }$ is a function of the student’s performance on the proposed goal and is computed every time this goal is reached (or at the end of an episode). As a result, the teacher operates at a different temporal frequency, and thus its rewards are not discounted according to the number of steps taken by the agent. To generate an automatic curriculum for the student, we positively reward the teacher if the student achieves the goal with suitable effort, but penalize it if the student either cannot achieve the goal, or can do so too easily. There are different options for measuring the performance of the student here, but for simplicity we will use the number of steps $t ^ { + }$ it takes the student to reach an intrinsic goal since the intrinsic goal was set (with $t ^ { + } = 0$ if the student does not reach the goal before the episode ends). We define a threshold $t ^ { * }$ such that the teacher is positively rewarded by $r ^ { T }$ when the student takes more steps than the threshold to reach the set goal, and negatively if it takes fewer steps or never reaches the goal before the episode ends. We thus define the teacher reward as follows, where $\alpha$ and $\beta$ are hyperparameters (see Section 4.2 for implementation details) specifying the weight of positive and negative teacher reward:
$$r ^ { T } = { \left\{ \begin{array} { l l } { + \alpha } & { { \mathrm { i f } } \quad t ^ { + } \geq t ^ { * } } \\ { - \beta } & { { \mathrm { i f } } \quad t ^ { + } < t ^ { * } } \end{array} \right. }$$
One can try to calibrate a fixed target threshold $t ^ { * }$ to force the teacher to propose increasingly more challenging goals as the student improves. Initial experiments with a fixed threshold indicated that the loss function was sufficient to induce harder goals and curriculum learning. However, this threshold is different across environments and has to be carefully fixed (depending on the size and complexity of the environment). A more adaptive—albeit heuristic—approach we adopt is to linearly increase the threshold $t ^ { * }$ after a fixed number of times in which the student successfully reaches the intrinsic goals. Specifically, the threshold $t ^ { * }$ is increased by 1 whenever the student successfully reaches an intrinsic goal in more than $t ^ { * }$ steps for ten times in a row. This increase in the target threshold provides an additional metric to visualize the improvement of the student through the “difficulty” of its goals (see Figure 3).
# 3.3 TYPES OF GOALS
We can conceive of variants of AMIGO whereby goals are provided in the form of linguistic instructions, images, etc. To prove the concept, in this framework, a goal is formally defined as a change in the observation on a tile, as specified by an $( x , y )$ coordinate. The agent must modify the tile before the end of an episode (e.g. by moving to it, or causing the object in it to move or change state). The verification function $v$ is then trivially the indicator function of whether the cell state is different from its initial state at the beginning of the episode. Proposing $( x , y )$ coordinates as goals can present a diverse set of ways for an agent to achieve the goal, as the coordinates can not only be affected by reaching them but also by modifying what is on them. This includes picking up keys, opening doors, and dropping objects onto empty tiles. In some cases in our setting, moving over a square is not the simplest thing possible (e.g. when an obstacle can be removed or a door can be opened). Similarly, in other tasks and environments it could be easier to affect a cell by throwing something at it, rather than by reaching it. Likewise, simply navigating to a set of coordinates (say, the corner of a locked room) might require solving several non-trivial sub-problems (e.g. identifying the right key, going to it, then going to the door, unlocking it, and finally going to the target location). We give some examples of goals proposed by the teacher, alongside the progression in their difficulty as the student improves, in Figure 3.
# 3.4 AUXILIARY TEACHER LOSSES
To complement our main form of intrinsic reward, we explore a few other criteria, including goal diversity, extrinsic reward, environment change and novelty. We report, in our experiments of Section 4, the results for AMIGO using these auxiliary losses. We present, in Appendix D, an ablation study of the effect of these losses, alongside some alternatives to the reward structure for the teacher network.
Diverse Goals. One desirable property is goal diversity (Pong et al., 2019; Raileanu & Rocktaschel,¨ 2020). In our implementation of AMIGO in the experiments of Section 4, we used entropy regularization to train the teacher and student, which encourages such diversity. This regularization, along with the scheduling of the threshold, helps the teacher avoid getting stuck in local minima. Additionally, we considered rewarding the teacher for proposing novel goals similar to count-based exploration methods (Bellemare et al., 2016; Ostrovski et al., 2017) with the difference that in our case the counts are for goals instead of states, based on the number of times the teacher presents a type of goal to the student. This did not improve performance and is not part of our model for the rest of the paper.
Episode Boundary Awareness. When playing in a procedurally-generated environment, humans will notice the factors of variation and exploit them. In episodic training, RL agents and algorithms are informed if a particular state was an episode end. To bias AMIGO towards learning the factors of variation in an environment, while not giving it any domain knowledge or any privileged information which other comparable intrinsic motivation systems and RL agents would not have access to, we positively reward the teacher if the content of the goal location it proposes changes at an episode boundary, regardless of whether this change was due to the agent. Thus, the teacher is rewarded for selecting goals where the object type changes if the episode changes (for example a door becomes a wall, or a key becomes an empty tile due to the new episode configuration). While this heuristic is quite general and could be effective for many tasks as it encourages agents to note environmental factors of variation, we note it might not be useful in all possible domains and as such is not an essential part of AMIGO. A comparison an extension of this loss other intrinsic motivation methods would interesting, but is not straightforward and is left for future research, we just note that this auxiliary loss on its own is not able to solve even the medium difficulty environments.
Extrinsic Goals. To help transition into the extrinsic task and avoid local minima, we reward both the teacher and the student with environment reward whenever the student reaches the extrinsic goal, even if this does not coincide with the intrinsic goal set by the teacher. This avoids the degenerate case where the student becomes good at satisfying the extrinsic goal, and the teacher is forced to encourage it “away” from it.
# 4 EXPERIMENTS
We follow Raileanu & Rocktaschel (2020) and evaluate our models on several challenging ¨ procedurally-generated environments from MiniGrid (Chevalier-Boisvert et al., 2018). This environment provides a good testbed for exploration in RL since the observations are symbolic rather than high-dimensional, which helps to disentangle the problem of exploration from that of visual understanding. We compare AMIGO with state-of-the-art methods that use various forms of exploration bonuses. We use TorchBeast (Kuttler et al., 2019), a PyTorch platform for RL research ¨ based on IMPALA (Espeholt et al., 2018) for fast, asynchronous parallel training. The code for these experiments is included in the supplementary materials, and has also been released under ”https://anonymous” to facilitate reproduction of our method and its use in other projects.
 Figure 2: Examples of MiniGrid environments. KCharder requires finding the key that can unlock a door which blocks the room where the goal is (the blue ball). OMhard requires a sequence of correct steps usually involving opening a door, opening a chest to find a key of the correct color, picking-up the key to open the door, and opening the door to reach the goal. The configuration and colors of the objects change from one episode to another. To our knowledge, AMIGO is the only algorithm that can solve these tasks. For other examples, see the MiniGrid repository.
# 4.1 ENVIRONMENTS
We evaluate AMIGO on the following MiniGrid environments: KeyCorrS3R3 (KCmedium), ObstrMaze1Dl (OMmedium), ObstrMaze2Dlhb (OMmedhard), KeyCorrS4R3 (KChard), KeyCorrS5R3 (KCharder), and ObstrMaze1Q (OMhard). The agent receives a full observation of the MiniGrid environment. The layout of the environment changes at every episode as it is procedurallygenerated. Examples of these tasks can be found in Figure 2. Each environment is a grid of size $N \times N$ ( $N$ being environment-specific) where each tile contains at most one of the following colored objects: wall, door, key, ball, chest. An object in each episode is selected as an extrinsic goal. If the agent reaches the extrinsic goal, or a maximum number of time-steps is reached, the environment is reset. The agent can take the following actions: turn left, turn right, move forward, pick up an object, drop an object, or toggle (open doors or interact with objects). Each tile is encoded using three integer values: the object, the color, and a type or flag indicating whether doors are open or closed. While policies could be learned from pixel observation alone, we will see below that the exploration problem is sufficiently complex with these semantic layers, owing to the procedurally generated nature of the tasks. The observations are transformed before being fed to agents by embedding each tile of the observed frame into a single representation encoding the object type, color, and type/flag.
The extrinsic reward provided by each environment for reaching the extrinsic goal in $t$ steps is $r _ { t } ^ { e } = 1 - ( . 9 \cdot t ) / t ^ { \mathrm { m a x } }$ , where $t ^ { \mathrm { m a x } }$ is the maximum episode length (which is intrinsic to each environment and set by the MiniGrid designers), if the extrinsic goal is reached at $t$ , and 0 otherwise. Episodes end when the goal is reached, and thus the scale of the positive reward encourages agents to reach the goal as quickly as possible.
# 4.2 AMIGO IMPLEMENTATION
The teacher is a dimensionality-preserving network of four convolutional layers interleaved with exponential linear units. Similarly, the student consists of four convolutional layers interleaved with exponential linear units followed by two linear layers with rectified linear units. Both the student and the teacher are trained using the TorchBeast (Kuttler et al., 2019) implementation of ¨ IMPALA (Espeholt et al., 2018), a distributed actor-critic algorithm. But while the teacher proposes goals only at the beginning of an episode or when the student reaches a goal, the student produces an action and gets a reward at every step. To replicate the structure of reward for reaching extrinsic goals, intrinsic reward for the student is discounted to $r _ { t } ^ { g } = 1 - ( . 9 \underbrace { \cdot t } ) / t ^ { \mathrm { m a x } }$ when $v ( s _ { t } , g ) = 1$ , and 0 otherwise. The hyperparameters for the reward for the teacher $r ^ { T }$ are grid searched, and optimal values are found at $\alpha = . 7$ and $\beta = . 3$ (see Appendix $\mathbf { B }$ for full hyperparameter search details).
# 4.3 BASELINES AND EVALUATION
We use IMPALA (Espeholt et al., 2018) without intrinsic motivation as a standard deep RL baseline. We then compare AMIGO to a series of methods that use intrinsic motivation to supplement extrinsic reward, as listed here. Count is Count-Based Exploration from Bellemare et al. (2016), which computes state visitation counts and gives higher rewards to less visited states. RND is Random Network Distillation Exploration by Burda et al. (2019b) which uses a random network to compute a prediction error used as a bonus to reward novel states; ICM is Intrinsic Curiosity Module from Pathak et al. (2017), which trains forward and inverse models to learn a latent representation used to compare the predicted and actual next states. The Euclidean distance between the representations of predicted and actual states (as measured in the latent space) is used as intrinsic reward. RIDE, from Raileanu & Rocktaschel (2020), defines the intrinsic reward as the (magnitude of the) change between two ¨ consecutive state representations.
We have noted from the literature that some of these baselines were designed for partially observable environments (Raileanu & Rocktaschel, 2020; Pathak et al., 2017) so they might benefit from ¨ observing an agent-centric partial view of the environment rather than a full absolute view (Ye et al., 2020). Despite our environment being fully observable, for the strongest comparison with AMIGO we ran the baselines in each of the following four modes: full observation of the environment for both the intrinsic reward module and the policy network, full observation for the intrinsic reward and partial observation for the policy, partial view for the intrinsic reward and full view for the policy, and partial view for both. We use an LSTM for the student policy network when it is provided with partial observations and a feed-forward network when provided with full observations. In
Section 4.4, we report the best result (across all four modes) for each baseline and environment pair, with a full breakdown of the results in Appendix A. This, alongside a comprehensive hyperparameter search, ensures that AMIGO is compared against the baselines trained under their individually best-performing training arrangement. We also compare AMIGO to the authors’ implementation2 of Asymmetric Self-Play (ASP) (Sukhbaatar et al., 2017). In their reversible mode two policies are trained adversarially: Alice starts from a start-point and tries to reach goals, while Bob is tasked to travel in reverse from the goal to the start-point.
We ran each experiment with five different seeds, and report in Section 4.4 the means and standard deviations. The full hyperparameter sweep for AMIGO and all baselines is reported in Appendix B, alongside best hyperparameters across experiments.
# 4.4 RESULTS AND DISCUSSION
We summarize the main results of our experiments in Table 1. As discussed in Section 4.3, the reported result for each baseline and each environment is that of the best performing configuration for the policy and intrinsic motivation system for that environment, as reported in Tables 2–5 of Appendix A. This aggregation of 114 experiments (not counting the number of times experiments were run for different seeds) ensures that each baseline is given the opportunity to perform in its best setting, in order to fairly benchmark the performance of AMIGO.
Table 1: Comparison of Mean Extrinsic Reward at the end of training (averaging over a batch of episodes as in IMPALA). Each entry shows the result of the best observation configuration, for each baseline, from Tables 2–5 of Appendix A.
<table><tr><td rowspan="2">Model</td><td colspan="3">Medium Difficulty Environments</td><td colspan="3">Hard Environments</td></tr><tr><td>KCmedium</td><td>OMmedium</td><td>OMmedhard</td><td>KChard</td><td>KCharder</td><td>OMhard</td></tr><tr><td>AMIGO</td><td>.93 ± .00</td><td>.92 ± .00</td><td>.83 ± .05</td><td>.54 ± .45</td><td>.44 ± .44</td><td>.17 ± .34</td></tr><tr><td>IMPALA</td><td>.00±.00</td><td>.00 ± .00</td><td>.00± .00</td><td>.00 ± .00</td><td>.00 ± .00</td><td>.00 ± .00</td></tr><tr><td>RND</td><td>.89±.00</td><td>.94± .00</td><td>.88± .03</td><td>.23 ± .40</td><td>.00 ± .00</td><td>.00± .00</td></tr><tr><td>RIDE</td><td>.90 ± .00</td><td>.94± .00</td><td>.86 ± .06</td><td>.19 ± .37</td><td>.00± .00</td><td>.00± .00</td></tr><tr><td>COUNT</td><td>.90± .00</td><td>.04± .04</td><td>.00±.00</td><td>.00 ± .00</td><td>.00 ± .00</td><td>.00 ± .00</td></tr><tr><td>ICM</td><td>.42 ± .21</td><td>.19 ± .19</td><td>.16 ± .32</td><td>.00 ± .00</td><td>.00 ± .00</td><td>.00 ± .00</td></tr><tr><td>ASP</td><td>.00 ± .00</td><td>.00 ± .00</td><td>.00 ± .00</td><td>.00 ± .00</td><td>.00±.00</td><td>.00 ± .00</td></tr></table>
IMPALA and Asymmetric Self-Play are unable to pass any of these medium or hard environments. ICM and Count struggle on the “easier” medium environments, and fail to obtain any reward from the hard ones. Only RND and RIDE perform competitively on the medium environments, but struggle to obtain any reward on the harder environments.
Our results demonstrate that AMIGO establishes a new state of the art in harder exploration problems in MiniGrid. On environments with medium difficulty such as KCmedium, OMmedium, and OMmedhard, AMIGO performs comparably to other state-of-the-art intrinsic motivation methods. AMIGO is often able to successfully reach the extrinsic goal even on the hardest tasks. To showcase results and sample complexity, we illustrate and discuss how mean extrinsic reward changes during training in Appendix C. To analyze which components of the teacher loss were important, we present, in Appendix D, an ablation study over the components presented in Section 3.4. Qualitatively, the learning trajectories of AMIGO display interesting and partially adversarial dynamics. These often involve periods in which both modules cooperate as the student becomes able to reach the proposed goals, followed by others in which the student becomes too good, forcing a drop in the teacher reward, in turn forcing the teacher to increase the difficulty of the proposed goals and forcing the student to further explore. In Appendix E, we provide a more thorough qualitative analysis of AMIGO, wherein we describe the different phases of evolution in the difficulty of the intrinsic goals proposed by the teacher, as exemplified in Figure 3. Further goal examples are shown in Figure 6 of Appendix F.
 Figure 3: Examples of a curriculum of goals proposed for different episodes of a particular learning trajectory on OMhard. The red triangle is the agent, the red square is the goal proposed by the teacher, and the blue ball is the extrinsic goal. The top panel shows the threshold target difficulty, $t ^ { * }$ of the goals proposed by the teacher. The teacher first proposes very easy nearby goals, then it learns to propose goals that involve traversing rooms and opening doors, while in the third phase the teacher proposes goals which involve removing obstacles and interacting with objects.
# 5 CONCLUSION
In this work, we propose AMIGO, a meta-learning framework for generating a natural curriculum of goals that help train an agent as a form of intrinsic reward, to supplement extrinsic reward (or replace it if it is not available). This is achieved by having a goal generator as a teacher that acts as a constructive adversary, and a policy that acts as a student conditioning on those goals to maximize an intrinsic reward. The teacher is rewarded to propose goals that are challenging but not impossible. We demonstrate that AMIGO surpasses state-of-the-art intrinsic motivation methods in challenging procedurally-generated tasks in a comprehensive comparison against multiple competitive baselines, in a series of 114 experiments across 6 tasks. Crucially, it is the only intrinsic motivation method which allows agents to obtain any reward on some of the harder tasks, where non-intrinsic RL also fails.
The key contribution of this paper is a model-agnostic framework for improving the sample complexity and efficacy of RL algorithms in solving the exploration problems they face. In our experiments, the choice of goal type imposed certain constraints on the nature of the observation, in that both the teacher and student need to fully observe the environment, due to the goals being provided as absolute coordinates. Technically, this method could also be applied to partially observed environments where part of the full observation is uncertain or occluded (e.g. “fog of war” in StarCraft), as the only requirement is that absolute coordinates can be provided and acted on. However, this is not a fundamental requirement, and in future work we would wish to investigate the cases where the teacher could provide more abstract goals, perhaps in the form of language instructions which could directly specify sequences of subgoals. Other extensions to this work worth investigating are its applicability to continuous control domains, visually rich domains, or more complex procedurally generated environments such as (Cobbe et al., 2019). Until then, we are confident we have proved the concept in a meaningful way, which other researchers will already be able to easily adapt to their model and RL algorithm of choice, in their domain of choice.
# ACKNOWLEDGMENTS
We thank the anonymous reviewers for their candid and helpful feedback and discussions. Roberta was supported by the DARPA L2M grant.
# REFERENCES
Marcin Andrychowicz, Filip Wolski, Alex Ray, Jonas Schneider, Rachel Fong, Peter Welinder, Bob McGrew, Josh Tobin, OpenAI Pieter Abbeel, and Wojciech Zaremba. Hindsight experience replay. Advances in neural information processing systems, 30:5048–5058, 2017.
Andrew G Barto. Intrinsic motivation and reinforcement learning. In Intrinsically motivated learning in natural and artificial systems, pp. 17–47. Springer, 2013.
Marc Bellemare, Sriram Srinivasan, Georg Ostrovski, Tom Schaul, David Saxton, and Remi Munos. Unifying count-based exploration and intrinsic motivation. In Advances in Neural Information Processing Systems, pp. 1471–1479, 2016.
Yoshua Bengio, Jer´ ome Louradour, Ronan Collobert, and Jason Weston. Curriculum learning. In ˆ Proceedings of the 26th annual international conference on machine learning, pp. 41–48. ACM, 2009.
Yuri Burda, Harri Edwards, Deepak Pathak, Amos Storkey, Trevor Darrell, and Alexei A. Efros. Largescale study of curiosity-driven learning. In International Conference on Learning Representations, 2019a. URL https://openreview.net/forum?id $=$ rJNwDjAqYX.
Yuri Burda, Harrison Edwards, Amos Storkey, and Oleg Klimov. Exploration by random network distillation. In International Conference on Learning Representations, 2019b. URL https: //openreview.net/forum?id $\underline { { \underline { { \mathbf { \Pi } } } } } =$ H1lJJnR5Ym.
Maxime Chevalier-Boisvert, Lucas Willems, and Suman Pal. Minimalistic gridworld environment for OpenAI gym. https://github.com/maximecb/gym-minigrid, 2018.
Karl Cobbe, Christopher Hesse, Jacob Hilton, and John Schulman. Leveraging procedural generation to benchmark reinforcement learning. arXiv preprint arXiv:1912.01588, 2019.
Yan Duan, Xi Chen, Rein Houthooft, John Schulman, and Pieter Abbeel. Benchmarking deep reinforcement learning for continuous control. ArXiv, abs/1604.06778, 2016.
Lasse Espeholt, Hubert Soyer, Remi Munos, Karen Simonyan, Volodymir Mnih, Tom Ward, Yotam Doron, Vlad Firoiu, Tim Harley, Iain Dunning, et al. IMPALA: Scalable distributed deep-rl with importance weighted actor-learner architectures. arXiv preprint arXiv:1802.01561, 2018.
Meng Fang, Tianyi Zhou, Yali Du, Lei Han, and Zhengyou Zhang. Curriculum-guided hindsight experience replay. In Advances in Neural Information Processing Systems, pp. 12623–12634, 2019.
Carlos Florensa, David Held, Markus Wulfmeier, Michael Zhang, and Pieter Abbeel. Reverse curriculum generation for reinforcement learning. arXiv preprint arXiv:1707.05300, 2017.
Carlos Florensa, David Held, Xinyang Geng, and Pieter Abbeel. Automatic goal generation for reinforcement learning agents. In Proceedings of the 35th International Conference on Machine Learning, 2018. URL http://proceedings.mlr.press/v80/florensa18a.html.
John Foley, Emma Tosch, Kaleigh Clary, and David Jensen. Toybox: Better atari environments for testing reinforcement learning agents. arXiv preprint arXiv:1812.02850, 2018.
Ian Goodfellow, Jean Pouget-Abadie, Mehdi Mirza, Bing Xu, David Warde-Farley, Sherjil Ozair, Aaron Courville, and Yoshua Bengio. Generative adversarial nets. In Z. Ghahramani, M. Welling, C. Cortes, N. D. Lawrence, and K. Q. Weinberger (eds.), Advances in Neural Information Processing Systems 27, pp. 2672–2680. Curran Associates, Inc., 2014. URL http://papers.nips. cc/paper/5423-generative-adversarial-nets.pdf.
Alexander S Klyubin, Daniel Polani, and Chrystopher L Nehaniv. Empowerment: A universal agent-centric measure of control. In 2005 IEEE Congress on Evolutionary Computation, volume 1, pp. 128–135. IEEE, 2005.
Heinrich Kuttler, Nantas Nardelli, Thibaut Lavril, Marco Selvatici, Viswanath Sivakumar, Tim ¨ Rocktaschel, and Edward Grefenstette. TorchBeast: A PyTorch platform for distributed RL. ¨ arXiv preprint arXiv:1910.03552, 2019.
Heinrich Kuttler, Nantas Nardelli, Roberta Raileanu, Marco Selvatici, Edward Grefenstette, and Tim ¨ Rocktaschel. The NetHack Learning Environment. In ¨ Workshop on Beyond Tabula Rasa in Reinforcement Learning (BeTR-RL), 2020. URL https://github.com/facebookresearch/ nle.
Nicolas Lair, Cedric Colas, R ´ emy Portelas, Jean-Michel Dussoux, Peter Ford Dominey, and Pierre-´ Yves Oudeyer. Language grounding through social interactions and curiosity-driven multi-goal learning. arXiv preprint arXiv:1911.03219, 2019.
Marlos C Machado, Marc G Bellemare, Erik Talvitie, Joel Veness, Matthew Hausknecht, and Michael Bowling. Revisiting the arcade learning environment: Evaluation protocols and open problems for general agents. Journal of Artificial Intelligence Research, 61:523–562, 2018.
Tambet Matiisen, Avital Oliver, Taco Cohen, and John Schulman. Teacher-student curriculum learning. IEEE transactions on neural networks and learning systems, 2017.
Volodymyr Mnih, Adria Puigdomenech Badia, Mehdi Mirza, Alex Graves, Timothy Lillicrap, Tim Harley, David Silver, and Koray Kavukcuoglu. Asynchronous methods for deep reinforcement learning. In International conference on machine learning, pp. 1928–1937, 2016.
Matej Moravc´ık, Martin Schmid, Neil Burch, Viliam Lisy, Dustin Morrill, Nolan Bard, Trevor ´ Davis, Kevin Waugh, Michael Johanson, and Michael Bowling. DeepStack: Expert-level artificial intelligence in no-limit poker. ArXiv, abs/1701.01724, 2017.
Sanmit Narvekar, Bei Peng, Matteo Leonetti, Jivko Sinapov, Matthew E Taylor, and Peter Stone. Curriculum learning for reinforcement learning domains: A framework and survey. arXiv preprint arXiv:2003.04960, 2020.
Georg Ostrovski, Marc G Bellemare, Aaron van den Oord, and R ¨ emi Munos. Count-based exploration ´ with neural density models. In Proceedings of the 34th International Conference on Machine Learning-Volume 70, pp. 2721–2730. JMLR. org, 2017.
Pierre-Yves Oudeyer and Frederic Kaplan. What is intrinsic motivation? a typology of computational approaches. Frontiers in neurorobotics, 1:6, 2009.
Pierre-Yves Oudeyer, Frdric Kaplan, and Verena V Hafner. Intrinsic motivation systems for autonomous mental development. IEEE transactions on evolutionary computation, 11(2):265–286, 2007.
Deepak Pathak, Pulkit Agrawal, Alexei Efros, and Trevor Darrell. Curiosity-driven exploration by self-supervised prediction. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition Workshops, pp. 16–17, 2017.
Vitchyr H Pong, Murtaza Dalal, Steven Lin, Ashvin Nair, Shikhar Bahl, and Sergey Levine. Skew-fit: State-covering self-supervised reinforcement learning. arXiv preprint arXiv:1903.03698, 2019.
Remy Portelas, C ´ edric Colas, Katja Hofmann, and Pierre-Yves Oudeyer. Teacher algorithms for ´ curriculum learning of deep rl in continuously parameterized environments. In Conference on Robot Learning, pp. 835–853. PMLR, 2020a.
Remy Portelas, C ´ edric Colas, Lilian Weng, Katja Hofmann, and Pierre-Yves Oudeyer. Automatic ´ curriculum learning for deep rl: A short survey. arXiv preprint arXiv:2003.04664, 2020b.
Sebastien Racaniere, Andrew K Lampinen, Adam Santoro, David P Reichert, Vlad Firoiu, and Timothy P Lillicrap. Automated curricula through setter-solver interactions. arXiv preprint arXiv:1909.12892, 2019.
Roberta Raileanu and Tim Rocktaschel. ¨ $\{ \mathrm { R I D E } \}$ : Rewarding impact-driven exploration for procedurally-generated environments. In International Conference on Learning Representations, 2020.
Aravind Rajeswaran, Kendall Lowrey, Emanuel V Todorov, and Sham M Kakade. Towards generalization and simplicity in continuous control. In Advances in Neural Information Processing Systems, pp. 6550–6561, 2017.
Sebastian Risi and Julian Togelius. Procedural content generation: From automatically generating game levels to increasing generality in machine learning. arXiv preprint arXiv:1911.13071, 2019.
Jurgen Schmidhuber. A possibility for implementing curiosity and boredom in model-building neural ¨ controllers. In Proc. of the international conference on simulation of adaptive behavior: From animals to animats, pp. 222–227, 1991.
Jurgen Schmidhuber. Powerplay: Training an increasingly general problem solver by continually¨ searching for the simplest still unsolvable problem. In Front. Psychol., 2011.
Laura Schulz. Finding new facts; thinking new thoughts. In Advances in child development and behavior, volume 43, pp. 269–294. Elsevier, 2012.
David Silver, Aja Huang, Chris J Maddison, Arthur Guez, Laurent Sifre, George Van Den Driessche, Julian Schrittwieser, Ioannis Antonoglou, Veda Panneershelvam, Marc Lanctot, et al. Mastering the game of go with deep neural networks and tree search. nature, 529(7587):484, 2016.
Satinder Singh, Richard L Lewis, and Andrew G Barto. Where do rewards come from. In Proceedings of the annual conference of the cognitive science society, pp. 2601–2606. Cognitive Science Society, 2009.
Jonathan Sorg, Satinder P Singh, and Richard L Lewis. Internal rewards mitigate agent boundedness. In Proceedings of the 27th international conference on machine learning (ICML-10), pp. 1007– 1014, 2010.
Bradly C Stadie, Sergey Levine, and Pieter Abbeel. Incentivizing exploration in reinforcement learning with deep predictive models. arXiv preprint arXiv:1507.00814, 2015.
Alexander L Strehl and Michael L Littman. An analysis of model-based interval estimation for markov decision processes. Journal of Computer and System Sciences, 74(8):1309–1331, 2008.
Sainbayar Sukhbaatar, Zeming Lin, Ilya Kostrikov, Gabriel Synnaeve, Arthur Szlam, and Rob Fergus. Intrinsic motivation and automatic curricula via asymmetric self-play. arXiv preprint arXiv:1703.05407, 2017.
Oriol Vinyals, Igor Babuschkin, Wojciech M Czarnecki, Michael Mathieu, Andrew Dudzik, Junyoung ¨ Chung, David H Choi, Richard Powell, Timo Ewalds, Petko Georgiev, et al. Grandmaster level in StarCraft II using multi-agent reinforcement learning. Nature, 575(7782):350–354, 2019.
Chang Ye, Ahmed Khalifa, Philip Bontrager, and Julian Togelius. Rotation, translation, and cropping for zero-shot generalization. CoRR, abs/2001.09908, 2020. URL https://arxiv.org/abs/ 2001.09908.
Amy Zhang, Nicolas Ballas, and Joelle Pineau. A dissection of overfitting and generalization in continuous reinforcement learning. arXiv preprint arXiv:1806.07937, 2018.
Yunzhi Zhang, Pieter Abbeel, and Lerrel Pinto. Automatic curriculum learning through value disagreement, 2020.
Zeyu Zheng, Junhyuk Oh, and Satinder Singh. On learning intrinsic rewards for policy gradient methods. In Advances in Neural Information Processing Systems, pp. 4644–4654, 2018.
Victor Zhong, Tim Rocktaschel, and Edward Grefenstette. RTFM: generalising to new environment ¨ dynamics via reading. In International Conference on Learning Representations, 2020. URL https://openreview.net/forum?id $\underline { { \underline { { \mathbf { \Pi } } } } } =$ SJgob6NKvH.
Table 2: Fully observed intrinsic reward, fully observed policy.
<table><tr><td rowspan="2">Model</td><td colspan="3">Medium Diffculty Environments</td><td colspan="3">Hard Environments</td></tr><tr><td>KCmedium</td><td>OMmedium</td><td>OMmedhard</td><td>KChard</td><td>KCharder</td><td>OMhard</td></tr><tr><td>AMIGo</td><td>.93± .00</td><td>.92 ± .00</td><td>.83± .05</td><td>.54±.45</td><td>.44± .44</td><td>.17 ± .34</td></tr><tr><td>IMPALA</td><td>.00± .00</td><td>.00± .00</td><td>.00 ± .00</td><td>.00 ± .00</td><td>.00± .00</td><td>.00 ± .00</td></tr><tr><td>RND</td><td>.00 ± .00</td><td>.00±.00</td><td>.00± .00</td><td>.00±.00</td><td>.00 ± .00</td><td>.00 ± .00</td></tr><tr><td>RIDE</td><td>.00±.00</td><td>.04± .04</td><td>.00±.00</td><td>.00 ± .00</td><td>.00 ± .00</td><td>.00 ± .00</td></tr><tr><td>COUNT</td><td>.00±.00</td><td>.00± .00</td><td>.00±.00</td><td>.00±.00</td><td>.00± .00</td><td>.00± .00</td></tr><tr><td>ICM</td><td>.00±.00</td><td>.01±.01</td><td>.00±.00</td><td>.00 ± .00</td><td>.00 ± .00</td><td>.00± .00</td></tr><tr><td>ASP</td><td>.00± .00</td><td>.00± .00</td><td>.00± .00</td><td>.00±.00</td><td>.00±.00</td><td>.00± .00</td></tr></table>
Table 3: Partially observed intrinsic reward, fully observed policy.
<table><tr><td rowspan="2">Model</td><td colspan="3">Medium Difficulty Environments</td><td colspan="3">Hard Environments</td></tr><tr><td>KCmedium</td><td>OMmedium</td><td>OMmedhard</td><td>KChard</td><td>KCharder</td><td>OMhard</td></tr><tr><td>RND</td><td>.64± .09</td><td>.01± .01</td><td>.00±.00</td><td>.00±.00</td><td>.00 ± .00</td><td>.00 ± .00</td></tr><tr><td>RIDE</td><td>.84±.02</td><td>.00± .00</td><td>.00±.00</td><td>.00±.00</td><td>.00± .00</td><td>.00± .00</td></tr><tr><td>COUNT</td><td>.45± .26</td><td>.00 ± .00</td><td>.00± .00</td><td>.00± .00</td><td>.00±.00</td><td>.00±.00</td></tr><tr><td>ICM</td><td>.42 ± .21</td><td>.00± .00</td><td>.00± .00</td><td>.00± .00</td><td>.00±.00</td><td>.00± .00</td></tr></table>
Table 4: Fully observed intrinsic reward, partially observed policy.
<table><tr><td rowspan="2">Model</td><td colspan="3">Medium Difficulty Environments</td><td colspan="3">Hard Environments</td></tr><tr><td>KCmedium</td><td>OMmedium</td><td>OMmedhard</td><td>KChard</td><td>KCharder</td><td>OMhard</td></tr><tr><td>RND</td><td>.00± .00</td><td>.00± .00</td><td>.00 ± .00</td><td>.00±.00</td><td>.00± .00</td><td>.00 ± .00</td></tr><tr><td>RIDE</td><td>.88±.01</td><td>.94±.00</td><td>.18 ± .35</td><td>.19 ± .37</td><td>.00±.00</td><td>.00± .00</td></tr><tr><td>COUNT</td><td>.01 ±.01</td><td>.00 ± .00</td><td>.00 ± .00</td><td>.00±.00</td><td>.00 ± .00</td><td>.00±.00</td></tr><tr><td>ICM</td><td>.06 ± .12</td><td>.05 ± .06</td><td>.16 ± .32</td><td>.00± .00</td><td>.00± .00</td><td>.00± .00</td></tr></table>
Table 5: Partially observed intrinsic reward, partially observed policy.
<table><tr><td></td><td colspan="3">Medium Difficulty Environments</td><td colspan="3">Hard Environments</td></tr><tr><td>Model</td><td>KCmedium</td><td>OMmedium</td><td>OMmedhard</td><td>KChard</td><td>KCharder</td><td>OMhard</td></tr><tr><td>RND</td><td>.89 ± .00</td><td>.94± .00</td><td>.88± .03</td><td>.23±.40</td><td>.00± .00</td><td>.00 ± .00</td></tr><tr><td>RIDE</td><td>.90± .00</td><td>.85±.28</td><td>.86 ± .06</td><td>.00± .00</td><td>.00±.00</td><td>.00 ± .00</td></tr><tr><td>COUNT</td><td>.90 ± .00</td><td>.04 ± .04</td><td>.00± .00</td><td>.00±.00</td><td>.00± .00</td><td>.00± .00</td></tr><tr><td>ICM</td><td>.00± .00</td><td>.19 ± .19</td><td>.00± .00</td><td>.00± .00</td><td>.00± .00</td><td>.00± .00</td></tr></table>
# A FULL RESULTS
Tables 2–5 show the final performance of the intrinsic motivation baselines trained using one of four different training regimes enumerated in Section 4.3. For each baseline, we train on KCMedium and OMmedium, and use the best hyperparameters for each task (for that particular baseline and training regime) to train it on the remaining harder versions of those environments (i.e. on KChard and KCharder or OMmedhard and OMhard, respectively).
For IMPALA, the numbers reported for KCmedium and OMmedium are from the experiments in Raileanu & Rocktaschel (2020), while the numbers for the harder environments are presumed to ¨ be .00 because IMPALA fails to train on simpler environments.
As a sanity check, we also verified that ASP learns successfully in easier environments not considered here, such as MiniGrid-Empty-Random-5x5-v0, and MiniGrid-KeyCorridorS3R1-v0, to validate the official PyTorch implementation.
Tables 2–5 indicate that the best training regime for the intrinsic motivation baselines (for all the tasks they can reliably solve) is the one that uses a partially observed intrinsic reward and a partially observed policy (Table 5). When the intrinsic reward is based on a full view of the environment, Count and RND will consider almost all states to be ”novel” since the environment is procedurallygenerated. Thus, the reward they provide will not be very helpful for the agent since it does not transfer knowledge from one episode to another (as is the case in fixed environments (Bellemare et al., 2016; Burda et al., 2019b)). In the case of RIDE and ICM, the change in the full view of the environment produced by one action is typically a single number in the MiniGrid observation. For ICM, this means that the agent can easily learn to predict the next state representation, so the intrinsic reward might vanish early in training leaving the agent without any guidance for exploring (Raileanu & Rocktaschel, 2020). For RIDE, it means that the intrinsic reward will be largely uniform across all ¨ state-action pairs, thus not differentiating between more and less ”interesting” states (which it can do when the intrinsic reward is based on partial observations (Raileanu & Rocktaschel, 2020)). ¨
# B HYPERPARAMETER SWEEPS AND BEST VALUES
For AMIGO, we grid search over batch size for student and teacher $\in \{ 8 , 3 2 , 1 5 0 \}$ , learning rate for student $\in \{ . 0 0 1 , . 0 0 0 1 \}$ , learning rate for teacher $\in \{ . 0 5 , . 0 1 , . 0 0 0 1 \}$ unroll length $\in \{ 5 0 , 1 0 0 \}$ , entropy cost for student $\in \{ . 0 0 0 5 , . 0 0 1 , . 0 0 0 1 \}$ , entropy cost for teacher $\in \{ . 0 0 1 , . 0 1 , . 0 5 \}$ , embedding dimensions for the observations $\in \{ 5 , 1 0 , 2 0 \}$ , embedding dimensions for the student last linear layer $\in \{ 1 2 8 , 2 5 6 \}$ , and teacher loss function parameters $\alpha$ and $\beta \in \{ 1 . 0 , 0 . 7 , 0 . 5 , 0 . 3 , 0 . 0 \}$ .
For RND, RIDE, Count, and ICM, we used learning rate $1 0 ^ { - 4 }$ , batch size 32, unroll length 100, RMSProp optimizer with $\epsilon = 0 . 0 1$ and momentum 0, which were the best values found for these methods on MiniGrid tasks by Raileanu & Rocktaschel (2020). We further searched over the ¨ entropy coefficient $\in \{ 0 . 0 0 0 5 , 0 . 0 0 1 , 0 . 0 0 0 1 \}$ and the intrinsic reward coefficient $\in \{ 0 . 1 , 0 . 0 1 , 0 . 5 \}$ on KCmedium and OMmedium. The results reported in Tables 2, 3 and 4 use the best values found from these experiments, while the results reported in Table 5 use the best parameter values reported by Raileanu & Rocktaschel (2020). For ASP, we ran the authors’ implementation using ¨ its reverse mode. We used the defaults for most hyperparameters, grid searching only over sp steps $\in \{ 5 , 1 0 , 2 0 \}$ , sp test rate $\in \{ . 1 , . 5 \}$ , and sp alice entr $\in \{ . 0 0 3 , . 0 3 \}$ .
The best hyperparameters for AMIGO and each baseline are reported below:
AMIGO: a student batch size of 8, a teacher batch size of 150, a student learning rate of .001, a teacher learning rate of .001, an unroll length of 100, a student entropy cost of .0005, a teacher entropy cost of .01, and observation embedding dimension of 5, a student last layer embedding dimension of 256, and finally, $\alpha = 0 . 7$ and $\beta = 0 . 3$ .
RND: partially observed intrinsic reward, partially observed policy, entropy cost of .0005, intrinsic reward coefficient of .1
RIDE: for KCmedium, partially observed intrinsic reward, partially observed policy, entropy cost of .0005, intrinsic reward coefficient of .1; for OMmedium: fully observed intrinsic reward, partially observed policy, entropy cost of .0005, intrinsic reward coefficient of .1
COUNT: partially observed intrinsic reward, partially observed policy, entropy cost of .0005, intrinsic reward coefficient of .1
ICM: for KCmedium, partially observed intrinsic reward, fully observed policy, entropy cost of .0005, intrinsic reward coefficient of .1; for OMmedium: partially observed intrinsic reward, partially observed policy, entropy cost of .0005, intrinsic reward coefficient of .1
ASP: Best performing hyperparameters (in the easier environments) were 10 sp steps, a sp test rate of .5, and Alice entropy of .003. All other hyperparameters used the defaults in the codebase.
# C SAMPLE EFFICIENCY
We show, in Figure 4, the mean extrinsic reward over time during training for the best configuration of the various methods. The first row consists of intermediately difficult environments in which different forms of intrinsic motivation perform similarly, the first two evironments require less than 30 million steps while OMmedhard and the three more challenging environments of the bottom rows require in the order of hundreds of millions of frames. Any plot where a method’s line is not visible indicates that the method is consistently failing to reach reward states throughout its training.
 Figure 4: Reward curves over training time comparing AMIGO to competing methods and baselines. The y-axis shows the Mean Extrinsic Reward (performance) obtained in two medium and four harder different environments, shown for 30M and 500M frames respectively.
The important point of note here is that on the two easiest environments, KCmedium and OMmedium, agents need about 10 million steps to converge while on the other four more challenging environments, they need an order of 100 million steps to learn the tasks, showcasing AMIGO’s contributions not just to solving the exploration problem, but also to improving the sample complexity of agent training.
# D ABLATION STUDY
To further explore the effectiveness and robustness of our method, in this subsection we investigate the alternative criteria discussed in Section 3.4. We compare the FULL MODEL with its ablations and alternatives consisting of removing the extrinsic bonus (NOEXTRINSIC), removing the environment change bonus (NOENVCHANGE), adding a novelty bonus( WITHNOVELTY).
We also considered two alternative reward forms for the teacher to provide a more continuous and gradual reward than the previously introduced “all or nothing” threshold. We consider a Gaussian $\bar { p } \sim \mathrm { N o r m a l } ( t ^ { * } , \sigma )$ reward around the target threshold $t ^ { * }$ :
$$r ^ { T } = { \left\{ \begin{array} { l l } { - 1 } & { { \mathrm { i f } } \quad t ^ { + } = 0 } \\ { 1 + \log _ { p } ( t ^ { + } ) - \log _ { p } ( t ^ { * } ) } & { { \mathrm { o t h e r w i s e } } } \end{array} \right. }$$
and a Linear-Exponential reward which grows linearly towards the threshold and then decays exponentially as the goal proposed becomes too hard (as measured according to the number of steps):
$$r ^ { T } = \left\{ \begin{array} { l l } { e ^ { - ( t ^ { + } - t ^ { * } ) / c } } & { \mathrm { i f } \quad t ^ { + } \geq t ^ { * } } \\ { t ^ { + } / t ^ { * } } & { \mathrm { i f } \quad t ^ { + } < t ^ { * } } \end{array} \right.$$
We report these two alternative forms of reward as (GAUSSIAN and LINEAR-EXPONENTIAL) in the study below.
Table 6: Ablations and Alternatives. Number of steps (in millions) for models to learn to reach its final level of reward in the different environments (0 means the model did not learn to get any extrinsic reward). FULL MODEL is the main algorithm described above. NOEXTRINSIC does not provide any extrinsic reward to the teacher. NOENVCHANGE removes the reward for selecting goals that change as a result of episode resets. WITHNOVELTY adds a novelty bonus that decreases depending on the number of times an object has been successfully proposed. GAUSSIAN and LINEAR-EXPONENTIAL explore alternative reward functions for the teacher.
<table><tr><td rowspan="2">Model</td><td colspan="3">Medium Difficulty Environments</td><td colspan="3">Hard Environments</td></tr><tr><td>KCmedium</td><td>OMmedium</td><td>OMmedhard</td><td>KChard</td><td>KCharder</td><td>OMhard</td></tr><tr><td>FULL MODEL</td><td>7M</td><td>8M</td><td>320M</td><td>140M</td><td>300M</td><td>370M</td></tr><tr><td>NOEXTRINSIC</td><td>240M</td><td>50M</td><td>0</td><td>0</td><td>0</td><td>0</td></tr><tr><td>NoENVCHANGE</td><td>400M</td><td>37M</td><td>0</td><td>0</td><td>0</td><td>0</td></tr><tr><td>WITHNOVELTY</td><td>15M</td><td>20M</td><td>350M</td><td>100M</td><td>370M</td><td>0</td></tr><tr><td>GAUSSIAN</td><td>320M</td><td>60M</td><td>0</td><td>0</td><td>0</td><td>0</td></tr><tr><td>LINEAR-EXP</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td></tr></table>
Performance is shown in Table 6 where the number of steps needed to converge (to the final extrinsic reward) is reported. A positive number means the model learned to solve the task, while 0 means the model did not manage to get any extrinsic reward. For all models we encourage goal diversity on the teacher with a high entropy coefficient of .05 (as compared to .0005 of the student).
As the table shows, removing the extrinsic reward or the environment change bonus severely hurts the model, making it unable to solve the harder environments. The novelty bonus was minimally beneficial in one of the environments (namely KChard) but slightly ineffective on the others. The more gradual reward forms considered are not robust to the learning dynamics and often result in the system going into rabbit holes where the algorithm learns to propose goals which provide sub-optimal rewards, thus not helping to solve the actual task. Best results across all environments in our Full Model were obtained using the simple threshold reward function along with entropy regularization and in combination with the extrinsic reward and changing bonuses, but without the novelty bonus.
# E QUALITATIVE ANALYSIS
To better understand the learning dynamics of AMIGO, Figure 5 shows the intrinsic reward throughout training received by the student (top panel) as well as the teacher (middle panel). The bottom panel shows the difficulty of the proposed goals as measured by the target threshold $t ^ { * }$ used by the teacher (described in Section 3). The trajectories reflect interesting and complex learning dynamics.
For visualization purposes we divide this learning period into five phases: Phase 1: The student slowly becomes able to reach intrinsic goals with minimal difficulty. The teacher first learns to propose easy nearby goals. Phase 2: Once the student learns how to reach nearby goals, the adversarial dynamics cause a drop in the teacher reward which is then forced to explore and propose harder goals. Phase 3: An equilibrium is found in which the student is forced to learn to reach more challenging goals.
 Figure 5: An example of a learning trajectory on OMhard, one of the most challenging environments. Despite the lack of extrinsic reward, the panels show the dynamics of the intrinsic rewards for the student (top panel), for the teacher (middle panel), and the difficulty of the goals captured as $t ^ { * }$ (bottom panel).
Phase 4: The student becomes too capable again and the teacher is forced to increase the difficulty of the proposed goals. Phase 5: The difficulty reaches a state where it induces a new equilibrium in which the student is unable to reach the goals and forced to improve its student.
AMIGO generates diverse and complex learning dynamics that lead to constant improvements of the agent’s policy. In some phases, both components benefit from learning in the environment (as is the case during the first phase), while some phases are completely adversarial (fourth phase), and some phases require more exploration from both components (i.e. third and fifth phases).
Figure 3, presented in Section 4.4, further exemplifies a typical curriculum in which the teacher learns to propose increasingly harder goals. The examples show some of the typical goals proposed at different learning phases. First, the teacher proposes nearby goals. After some training, it learns to propose goals that involve traversing rooms and opening doors. Eventually, the teacher proposes goals which involve interacting with different objects. Despite the increasing capacity of the agent to interact with the environment, OMhard remains a challenging task and AMIGO learns to solve it in only one of the five runs.
# F GOAL EXAMPLES
Figure 6 shows examples of goals proposed by the agent during different stages of learning. Typically, in early stages the teacher learns to propose easy nearby goals. As learning progresses it is incentivized to proposed farther away goals that often involve traversing rooms and opening doors. Finally, in later stages the agent often learns to propose goals that involve removing obstacles and interacting with objects. We often observe this before the policy achieves any extrinsic reward.
 Figure 6: Some examples of goals during early, mid, and late stages of learning (examples for KCmedium, OMhard and OMmedium are first, second, and third rows respectively). The red triangle is the agent, the red square is the goal proposed by the teacher, and the blue ball is the extrinsic goal.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379# LEARNING AND POLICY SEARCH IN STOCHASTIC DYNAMICAL SYSTEMS WITH BAYESIAN NEURAL NETWORKS
Stefan Depeweg Siemens AG and Technical University of Munich stefan.depeweg@siemens.com
José Miguel Hernández-Lobato University of Cambridge jmh233@cam.ac.uk
Finale Doshi-Velez Harvard University finale@seas.harvard.edu Steffen Udluft Siemens AG steffen.udluft@siemens.com
# ABSTRACT
We present an algorithm for policy search in stochastic dynamical systems using model-based reinforcement learning. The system dynamics are described with Bayesian neural networks (BNNs) that include stochastic input variables. These input variables allow us to capture complex statistical patterns in the transition dynamics (e.g. multi-modality and heteroskedasticity), which are usually missed by alternative modeling approaches. After learning the dynamics, our BNNs are then fed into an algorithm that performs random roll-outs and uses stochastic optimization for policy learning. We train our BNNs by minimizing $\alpha$ -divergences with $\alpha = 0 . 5$ , which usually produces better results than other techniques such as variational Bayes. We illustrate the performance of our method by solving a challenging problem where model-based approaches usually fail and by obtaining promising results in real-world scenarios including the control of a gas turbine and an industrial benchmark.
# 1 INTRODUCTION
In model-based reinforcement learning, an agent uses its experience to first learn a model of the environment and then uses that model to reason about what action to take next. We consider the case in which the agent observes the current state $\mathbf { s } _ { t }$ , takes some action a, and then observes the next state $\mathbf { s } _ { t + 1 }$ . The problem of learning the model corresponds then to learning a stochastic transition function $p ( \mathbf { s } _ { t + 1 } | \mathbf { s } _ { t } , \mathbf { a } )$ specifying the conditional distribution of $\mathbf { s } _ { t + 1 }$ given $\mathbf { s } _ { t }$ and a. Most classic control theory texts, e.g. Bertsekas (2002), will start with the most general model of dynamical systems:
$$\mathbf { s } _ { t + 1 } = f ( \mathbf { s } _ { t } , \mathbf { a } , z , \mathcal { W } )$$
where $f$ is some deterministic function parameterized by weights $\mathcal { W }$ that takes as input the current state $\mathbf { s } _ { t }$ , the control signal a, and some stochastic disturbance $z$ .
However, to date, we have not been able to robustly learn dynamical system models to such a level of generality. Popular modes for transition functions include Gaussian processes (Rasmussen et al., 2003; Ko et al., 2007; Deisenroth & Rasmussen, 2011), fixed bases such as Laguerre functions (Wahlberg, 1991), and adaptive basis functions or neural networks (Draeger et al., 1995). All of these methods assume deterministic transition functions, perhaps with some addition of Gaussian observation noise. Thus, they are severely limited in the kinds of stochasticity—or transition noise—they can express. In many real-world scenarios stochasticity may often arise due to some unobserved environmental feature that can affect the dynamics in complex ways (such as unmeasured gusts of wind on a boat).
In this work we use Bayesian neural networks (BNNs) in conjunction with a random input noise source $z$ to express stochastic dynamics. We take advantage of a very recent inference advance based on $\alpha$ -divergence minimization (Hernández-Lobato et al., 2016), with $\alpha = 0 . 5$ , to learn with high accuracy BNN transition functions that are both scalable and expressive in terms of stochastic patterns. Previous work achieved one but not both of these two characteristics.
We focus our evaluation on the off-policy batch reinforcement learning scenario, in which we are given an initial batch of data from an already-running system and are asked to find a better (ideally near-optimal) policy. Such scenarios are common in real-world industry settings such as turbine control, where exploration is restricted to avoid possible damage to the system. We propose an algorithm that uses random roll-outs and stochastic optimization for learning an optimal policy from the predictions of BNNs. This method produces (to our knowledge) the first model-based solution of a 20-year-old benchmark problem: the Wet-Chicken (Tresp, 1994). We also obtain very promising results on a real-world application on controlling gas turbines and on an industrial benchmark.
# 2 BACKGROUND
# 2.1 MODEL-BASED REINFORCEMENT LEARNING
We consider reinforcement learning problems in which an agent acts in a stochastic environment by sequentially choosing actions over a sequence of time steps, in order to minimize a cumulative cost. We assume that our environment has some true dynamics $T _ { \mathrm { t r u e } } ( \mathbf { s } _ { t + 1 } | \mathbf { s } , \mathbf { a } )$ , and we are given a cost function $c ( \mathbf { s } _ { t } )$ . In the model-based reinforcement learning setting, our goal is to learn an approximation $T _ { \mathrm { a p p r o x } } ( \mathbf { s } _ { t + 1 } | \mathbf { s } , \mathbf { a } )$ for the true dynamics based on collected samples $( \mathbf { s } _ { t } , \mathbf { a } , \mathbf { s } _ { t + 1 } )$ . The agent then tries to solve the control problem in which $T _ { \mathrm { a p p r o x } }$ is assumed to be the true dynamics.
# 2.2 BAYESIAN NEURAL NETWORKS WITH STOCHASTIC INPUTS
Given data $\mathcal { D } = \{ \mathbf { x } _ { n } , \mathbf { y } _ { n } \} _ { n = 1 } ^ { N }$ , formed by feature vectors $\mathbf { x } _ { n } \in \mathbb { R } ^ { D }$ and targets $\mathbf { y } _ { n } \in \mathbb { R } ^ { K }$ , we assume that ${ \bf y } _ { n } = f ( { \bf x } _ { n } , z _ { n } ; \mathcal { W } ) + \epsilon _ { n }$ , where $f ( \cdot , \cdot ; \mathcal W )$ is the output of a neural network with weights The network receives as input the feature vector ${ \bf x } _ { n }$ and the random disturbance $z _ { n } \sim \mathcal { N } ( 0 , \gamma )$ . The activation functions for the hidden layers are rectifiers: $\varphi ( x ) = \operatorname* { m a x } ( x , 0 )$ . The activation functions for the output layers are the identity function: $\varphi ( x ) = x$ . The network output is corrupted by the additive noise variable $\epsilon _ { n } \sim \mathcal { N } ( \mathbf { 0 } , \mathbf { \tilde { \Sigma } } )$ with diagonal covariance matrix $\pmb { \Sigma }$ . The role of the noise disturbance $z _ { n }$ is to capture unobserved stochastic features that can affect the network’s output in complex ways. Without $z _ { n }$ , randomness is only given by the additive Gaussian observation noise $\epsilon _ { n }$ , which can only describe limited stochastic patterns. The network has $L$ layers, with $V _ { l }$ hidden units in layer $l$ , and $\mathcal { W } = \{ \mathbf { W } _ { l } \} _ { l = 1 } ^ { L }$ is the collection of $V _ { l } \times ( V _ { l - 1 } + 1 )$ weight matrices. The $+ 1$ is introduced here to account for the additional per-layer biases.
One could argue why $\epsilon _ { n }$ is needed at all when we are already using the more flexible stochastic model based on $z _ { n }$ . The reason for this is that, in practice, we make predictions with the above model by averaging over a finite number of samples of $z _ { n }$ and $\mathcal { W }$ . By using $\epsilon _ { n }$ , we obtain a predictive distribution whose density is well defined and given by a mixture of Gaussians. If we eliminate $\epsilon _ { n }$ , the predictive density is degenerate and given by a mixture of delta functions.
Let $\mathbf { Y }$ be an $N \times K$ matrix with the targets ${ \bf y } _ { n }$ and $\mathbf { X }$ be an $N \times D$ matrix of feature vectors ${ \bf x } _ { n }$ We denote by $\mathbf { z }$ the $N$ -dimensional vector with the values of the random disturbances $z _ { 1 } , \dots , z _ { N }$ that were used to generate the data. The likelihood function is
$$p ( \mathbf { Y } \mid \mathcal { W } , \mathbf { z } , \mathbf { X } ) = \prod _ { n = 1 } ^ { N } p ( \mathbf { y } _ { n } \mid \mathcal { W } , \mathbf { z } , \mathbf { x } _ { n } ) = \prod _ { n = 1 } ^ { N } \prod _ { k = 1 } ^ { K } \mathcal { N } \big ( y _ { n , k } \mid f ( \mathbf { x } _ { n } , z _ { n } ; \mathcal { W } ) , \pmb { \Sigma } \big ) .$$
The prior for each entry in $\mathbf { z }$ is $\mathcal { N } ( 0 , \gamma )$ . We also specify a Gaussian prior distribution for each entry in each of the weight matrices in $\mathcal { W }$ . That is,
$$p ( \mathbf { z } ) = \prod _ { n = 1 } ^ { N } \mathcal { N } ( z _ { n } | 0 , \gamma ) , \qquad p ( \mathcal { W } ) = \prod _ { l = 1 } ^ { L } \prod _ { i = 1 } ^ { V _ { l } } \prod _ { j = 1 } ^ { V _ { l - 1 } + 1 } \mathcal { N } ( w _ { i j , l } | 0 , \lambda ) ,$$
where $w _ { i j , l }$ is the entry in the $i$ -th row and $j$ -th column of $\mathbf { W } _ { l }$ and $\gamma$ and $\lambda$ are a prior variances. The posterior distribution for the weights $\mathcal { W }$ and the random disturbances $\mathbf { z }$ is given by Bayes’ rule:
$$p ( \mathcal { W } , \mathbf { z } \mid \mathcal { D } ) = \frac { p ( \mathbf { Y } \mid \mathcal { W } , \mathbf { z } , \mathbf { X } ) p ( \mathcal { W } ) p ( \mathbf { z } ) } { p ( \mathbf { Y } \mid \mathbf { X } ) } .$$
 Figure 1: Solution for the minimization of the $\alpha$ -divergence between the posterior $p$ (in blue) and the Gaussian approximation $q$ (in red and unnormalized). Figure source Minka (2005).
Given a new input vector $\mathbf { x } _ { \star }$ , we can then make predictions for $\mathbf { y } _ { \star }$ using the predictive distribution
$$p ( \mathbf { y } _ { \star } | \mathbf { x } _ { \star } , \mathcal { D } ) = \int \left[ \int \mathcal { N } ( y _ { \star } | f ( \mathbf { x } _ { \star } , z _ { \star } ; \mathcal { W } ) , \pm ) \mathcal { N } ( z _ { \star } | 0 , 1 ) d z _ { \star } \right] p ( \mathcal { W } , \mathbf { z } | \mathcal { D } ) d \mathcal { W } d \mathbf { z } .$$
Unfortunately, the exact computation of (4) is intractable and we have to use approximations.
# 2.3 $_ { \pmb { \alpha } }$ -DIVERGENCE MINIMIZATION
We approximate the exact posterior distribution $p ( \mathcal { W } , \mathbf { z } \mid \mathcal { D } )$ with the factorized Gaussian distribution
$$q ( \mathcal W , \mathbf z ) = \left[ \prod _ { l = 1 } ^ { L } \prod _ { i = 1 } ^ { V _ { l } } \prod _ { j = 1 } ^ { V _ { l - 1 } + 1 } \mathcal N ( w _ { i j , l } | m _ { i j , l } ^ { w } , v _ { i j , l } ^ { w } ) \right] \left[ \prod _ { n = 1 } ^ { N } \mathcal N ( z _ { n } | m _ { n } ^ { z } , v _ { n } ^ { z } ) \right] .$$
The parameters mwij,l, $v _ { i j , l } ^ { w }$ and $m _ { n } ^ { z } , \ v _ { n } ^ { z }$ are determined by minimizing a divergence between $p ( \mathcal { W } , \mathbf { z } \vert \mathcal { D } )$ and the approximation $q$ . After fitting $q$ , we make predictions by replacing $p ( \mathcal { W } , \mathbf { z } \mid \mathcal { D } )$ with $q$ in (4) and approximating the integrals in (4) with empirical averages over samples of $\mathcal { W } \sim q$ .
We aim to adjust the parameters of (5) by minimizing the $\alpha$ -divergence between $p ( \mathcal { W } , \mathbf { z } \vert \mathcal { D } )$ and $q ( \boldsymbol { \mathcal { W } } , { \mathbf z } )$ (Minka, 2005):
$$\mathrm { D } _ { \alpha } [ p ( \mathcal { W } , \mathbf { z } | \mathcal { D } ) | | q ( \mathcal { W } , \mathbf { z } ) ] = \frac { 1 } { \alpha ( \alpha - 1 ) } \left( 1 - \int p ( \mathcal { W } , \mathbf { z } | \mathcal { D } ) ^ { \alpha } q ( \mathcal { W } , \mathbf { z } ) ^ { ( 1 - \alpha ) } \right) d \mathcal { W } d \mathbf { z } ,$$
which includes a parameter $\alpha \in \mathbb { R }$ that controls the properties of the optimal $q$ . Figure 1 illustrates these properties for the one-dimensional case. When $\alpha \geq 1$ , $q$ tends to cover the whole posterior distribution $p$ . When $\alpha \leq 0$ , $q$ tends to fit a local mode in $p$ . The value $\alpha = 0 . 5$ is expected to achieve a balance between these two tendencies. Importantly, when $\alpha 0$ , the solution obtained is the same as with variational Bayes (VB) (Wainwright & Jordan, 2008).
The direct minimization of (6) is infeasible in practice for arbitrary $\alpha$ . Instead, we follow HernándezLobato et al. (2016) and optimize an energy function whose minimizer corresponds to a local minimization of $\alpha$ -divergences, with one $\alpha$ -divergence for each of the $N$ likelihood factors in (1). Since $q$ is Gaussian and the priors $p ( \mathcal { W } )$ and $p ( \mathbf { z } )$ are also Gaussian, we represent $q$ as
$$q ( \mathcal { W } , { \mathbf z } ) \propto \left[ \prod _ { n = 1 } ^ { N } f ( \mathcal { W } ) f _ { n } ( z _ { n } ) \right] p ( \mathcal { W } ) p ( { \mathbf z } ) ,$$
where $f ( \mathcal W )$ is a Gaussian factor that approximates the geometric mean of the $N$ likelihood factors in (1) as a function of $\mathcal { W }$ . Each $f _ { n } ( z _ { n } )$ is also a Gaussian factor that approximates the $n$ -th likelihood factor in (1) as a function of $z _ { n }$ . We adjust $f ( \mathcal W )$ and the $f _ { n } ( z _ { n } )$ by minimizing local $\alpha$ -divergences. In particular, we minimize the energy function
$$E _ { \alpha } ( q ) = - \log Z _ { q } - \frac { 1 } { \alpha } \sum _ { n = 1 } ^ { N } \log \mathbf { E } _ { \mathcal { W } , z _ { n } \sim q } \left[ \left( \frac { p ( \mathbf { y } _ { n } \mid \mathcal { W } , \mathbf { x } _ { n } , z _ { n } , \pmb { \Sigma } ) } { f ( \mathcal { W } ) f _ { n } ( z _ { n } ) } \right) ^ { \alpha } \right] ,$$
(Hernández-Lobato et al., 2016), where $f ( \mathcal W )$ and $f _ { n } ( z _ { n } )$ are in exponential Gaussian form and parameterized in terms of the parameters of $q$ and the priors $p ( \mathcal { W } )$ and $p ( z _ { n } )$ , that is,
$$\begin{array} { l } { { \displaystyle f ( \mathcal { W } ) = \exp \left\{ \sum _ { l = 1 } ^ { L } \sum _ { i = 1 } ^ { V _ { l } } \sum _ { j = 1 } ^ { V _ { l - 1 } + 1 } \frac { 1 } { N } \left( \frac { \lambda v _ { i , j , l } ^ { w } } { \lambda - v _ { i , j , l } ^ { w } } w _ { i , j , l } ^ { 2 } + \frac { m _ { i , j , l } ^ { w } } { v _ { i , j , l } ^ { w } } w _ { i , j , l } \right) \right\} \propto \left[ \frac { q ( \mathcal { W } ) } { p ( \mathcal { W } ) } \right] ^ { \frac { 1 } { N } } , } } \\ { { \displaystyle f _ { n } ( z _ { n } ) = \exp \left\{ \frac { \gamma v _ { n } ^ { z } } { \gamma - v _ { n } ^ { z } } z _ { n } ^ { 2 } + \frac { m _ { n } ^ { z } } { v _ { n } ^ { z } } z _ { n } \right\} \propto \frac { q ( z _ { n } ) } { p ( z _ { n } ) } } , } \end{array}$$
and $\log Z _ { q }$ is the logarithm of the normalization constant of the exponential Gaussian form of $q$ :
$$\log Z _ { q } = \sum _ { l = 1 } ^ { L } \sum _ { i = 1 } ^ { V _ { l } } \sum _ { j = 1 } ^ { V _ { l - 1 } + 1 } \left[ \frac { 1 } { 2 } \log \left( 2 \pi v _ { i , j , l } ^ { w } \right) + \frac { \left( m _ { i , j , l } ^ { w } \right) ^ { 2 } } { v _ { i , j , l } ^ { w } } \right] + \sum _ { n = 1 } ^ { N } \left[ \frac { 1 } { 2 } \log \left( 2 \pi v _ { n } ^ { z } \right) + \frac { \left( m _ { n } ^ { z } \right) ^ { 2 } } { v _ { n } ^ { z } } \right] .$$
The scalable optimization of (8) is done in practice by using stochastic gradient descent. For this, we subsample the sums for $n = 1 , \ldots , N$ in (8) and (11) using mini-batches and approximate the expectations over $q$ in (8) with an average over $K$ samples drawn from $q$ . We can then use the reparametrization trick (Kingma et al., 2015) to obtain gradients from the resulting stochastic approximator to (8). The hyper-parameters $\pmb { \Sigma }$ , $\lambda$ and $\gamma$ can also be tuned by minimizing (8). In practice we only tune $\pmb { \Sigma }$ and keep $\lambda = 1$ and $\gamma = d$ . The latter means that the prior scale of each $z _ { n }$ grows with the data dimensionality. This guarantees that, a priori, the effect of each $z _ { n }$ in the neural network’s output does not diminish when more and more features are available.
Minimizing (8) when $\alpha 0$ is equivalent to running the method VB (Hernández-Lobato et al., 2016), which has recently been used to train Bayesian neural networks in reinforcement learning problems (Blundell et al., 2015; Houthooft et al., 2016; Gal et al., 2016). However, we propose to minimize (8) using $\alpha = 0 . 5$ , which often results in better test log-likelihood values.
We have also observed $\alpha = 0 . 5$ to be more robust than VB when $q ( \mathbf { z } )$ is not fully optimized. In particular, $\alpha = 0 . 5$ can still capture complex stochastic patterns even when we do not learn $q ( \mathbf { z } )$ and instead keep it fixed to the prior $p ( \mathbf { z } )$ . By contrast, VB fails completely in this case (see Appendix A).
# 3 POLICY SEARCH USING BNNS WITH STOCHASTIC INPUTS
We now describe a gradient-based policy search algorithm that uses the BNNs with stochastic disturbances from the previous section. The motivation for our approach lies in its applicability to industrial systems: we wish to estimate a policy in parametric form, using only an available batch of state transitions obtained from an already-running system. We assume that the true dynamics present stochastic patterns that arise due to some unobserved process affecting the system in complex ways.
Model-based policy search methods include two key parts (Deisenroth et al., 2013). The first part consists in learning a dynamics model from data in the form of state transitions $\left( \mathbf { s } _ { t } , \mathbf { a } _ { t } , \mathbf { s } _ { t + 1 } \right)$ , where $\mathbf { s } _ { t }$ denotes the current state, $\mathbf { a } _ { t }$ is the action applied and $\mathbf { s } _ { t + 1 }$ is the resulting state. The second part consists in learning the parameters $\mathcal { W } _ { \pi }$ of a deterministic policy function $\pi$ that returns the optimal action $\mathbf { a } _ { t } = \pi ( \mathbf { s } _ { t } ; \mathcal { W } _ { \pi } )$ as function of the current state $\mathbf { s } _ { t }$ . The policy function can be a neural network with deterministic weights given by $\mathcal { W } _ { \pi }$ .
The first part in the aforementioned procedure is a standard regression task, which we solve by using the modeling approach from the previous section. We assume the dynamics to be stochastic with the following true transition model:
$$\begin{array} { r } { \mathbf { s } _ { t } = f _ { \mathrm { t r u e } } \left( \mathbf { s } _ { t - 1 } , \mathbf { a } _ { t - 1 } , z _ { t } ; \mathcal { W } _ { \mathrm { t r u e } } \right) , \quad z _ { t } \sim \mathcal { N } ( 0 , \gamma ) . } \end{array}$$
where the input disturbances $z _ { t } \sim \mathcal { N } ( 0 , \gamma )$ account for the stochasticity in the dynamics. When the Markov state $\mathbf { s } _ { t }$ is hidden and we are given only observations $\mathbf { o } _ { t }$ , we can use the time embedding theorem using a suitable window of length $n$ and approximate:
$$\hat { \mathbf { s } } ( t ) = \left[ \mathbf { o } _ { t - n } , \cdot \cdot \cdot \mathbf { \sigma } , \mathbf { o } _ { t } \right] .$$
The transition model in equation 12 specifies a probability distribution $p ( \mathbf { s } _ { t } | \mathbf { s } _ { t - 1 } , \mathbf { a } _ { t - 1 } )$ that we approximate using a BNN with stochastic inputs:
$$p ( \mathbf { s } _ { t } | \mathbf { s } _ { t - 1 } , \mathbf { a } _ { t - 1 } ) \approx \int \mathcal { N } ( \mathbf { s } _ { t } | f ( \mathbf { s } _ { t - 1 } , \mathbf { a } _ { t - 1 } , z _ { t } ; \mathcal { W } ) , \pmb { \Sigma } ) q ( \mathcal { W } ) \mathcal { N } ( z _ { t } | 0 , \gamma ) d \mathcal { W } d z _ { t } ,$$
Algorithm 1 Model-based policy search using Bayesian neural networks with stochastic inputs.
<table><tr><td>1: Input: D= {Sn,an,△n} for n ∈1..N 2: Fit q(W) and ∑ by optimizing (8). 3: function UNFOLD(So) 4: sample{W1,.,WK} from q(W) 5: C↑0 6: fork=1:Kdo 7: fort=O :Tdo 2+1~N(0,2) 8: 9: △t←f(st,π(st;Wπ),2t+1;Wk) e+1~N(0,∑) 10: 11:</td></tr></table>
 Figure 2: Predictive distribution of $y _ { t }$ given by different methods in four different scenarios. Ground truth (red) is obtained by sampling from the real dynamics.
where the feature vectors in our BNN are now $\mathbf { s } _ { t - 1 }$ and $\mathbf { a } _ { t - 1 }$ and the targets are given by $\mathbf { s } _ { t }$ . In this expression, the integration with respect to $\mathcal { W }$ accounts for stochasticity arising from lack of knowledge of the model parameters, while the integration with respect to $z _ { t }$ accounts for stochasticity arising from unobserved processes that cannot be modeled. In practice, these integrals are approximated by an average over samples of $z _ { t } \sim \mathcal { N } ( 0 , \gamma )$ and $\mathcal { W } \sim q$ .
In the second part of our model-based policy search algorithm, we optimize the parameters $\mathcal { W } _ { \pi }$ of a policy that minimizes the sum of expected cost over a finite horizon $T$ with respect to our belief $q ( \mathcal { W } )$ . This expected cost is obtained by averaging over multiple virtual roll-outs. For each roll-out we sample $w _ { i } \sim q$ and then simulate state trajectories using the model $\mathbf { s } _ { t + 1 } = f ( \mathbf { s } _ { t } , \mathbf { a } _ { t } , z _ { t } ; \mathcal { W } _ { i } ) + \boldsymbol { \epsilon } _ { t + 1 }$ with policy $\mathbf { a } _ { t } = \pi ( \mathbf { s } _ { t } ; \mathcal { W } _ { \pi } )$ , input noise $z _ { t } \sim \mathcal { N } ( 0 , \gamma )$ and additive noise $\epsilon _ { t + 1 } \sim \mathcal { N } ( \mathbf { 0 } , \Sigma )$ . This procedure allows us to obtain estimates of the policy’s expected cost for any particular cost function. If model, policy and cost function are differentiable, we are then able to tune $\mathcal { W } _ { \pi }$ by stochastic gradient descent over the roll-out average.
Given a cost function $c ( \mathbf { s } _ { t } )$ , the objective to be optimized by our policy search algorithm is
$$\begin{array} { r } { J ( \mathcal { W } _ { \pi } ) = \mathbf { E } \left[ \sum _ { t = 1 } ^ { T } c ( \mathbf { s } _ { t } ) \right] . } \end{array}$$
We approximate (15) by using (14), replacing $\mathbf { a } _ { t }$ with $\pi ( \mathbf { s } _ { t } ; \mathcal { W } _ { \pi } )$ and using sampling to approximate the expectations:
$$\begin{array} { l } { { \displaystyle { \cal J } ( \mathcal { W } _ { \pi } ) = \int \left[ \displaystyle { \sum _ { t = 1 } ^ { T } c ( { \bf s } _ { t } ) } \right] \left[ \displaystyle { \prod _ { t = 1 } ^ { T } \int } \mathcal { N } ( { \bf s } _ { t } | f ( { \bf s } _ { t - 1 } , \pi ( { \bf s } _ { t - 1 } ; \mathcal { W } _ { \pi } ) , z _ { t } ; \mathcal { W } ) , { \bf \Sigma } ) q ( \mathcal { W } ) \mathcal { N } ( z _ { t } | 0 , \gamma ) d \mathcal { W } d z _ { t } \right] } } \\ { { \displaystyle p ( { \bf s } _ { 0 } ) d { \bf s } _ { 0 } \cdot \cdot \cdot \cdot d { \bf s } _ { T } } } \\ { \displaystyle ~ = \int \left[ \displaystyle { \sum _ { t = 1 } ^ { T } c ( { \bf s } _ { t } ^ { \mathcal { W } , \{ z _ { 1 } , \dots , z _ { t } \} , \{ { \bf s } _ { t } \} , \dots , { \bf s } _ { t } \} , \mathcal { W } _ { \pi } ) } q ( \mathcal { W } ) d \mathcal { W } \left[ \displaystyle { \prod _ { t = 1 } ^ { T } \mathcal { N } ( \epsilon _ { t } | { \bf 0 } , { \bf \Sigma } ) \mathcal { N } ( z _ { t } | { \bf 0 } , \gamma ) d \epsilon _ { t } d z _ { t } } \right] p ( { \bf s } _ { 0 } ) d { \bf s } _ { 0 } } } \\ {\right] \displaystyle \approx \displaystyle \frac { 1 } { K } \sum _ { k = 1 } ^ { K } \left[ \displaystyle { \sum _ { t = 1 } ^ { T } c ( { \bf s } _ { t } ^ { \mathcal { W } ^ { k } , \{ z _ { 1 } ^ { k } , \dots , z _ { t } ^ { k } \} , \{ { \bf s } _ { t } ^ { k } , \dots , { \bf s } _ { t } ^ { k } \} , \mathcal { W } _ { \pi } ) } . } } \end{\right]array} \end{array}$$
The first line in (16) is obtained by using the assumption that the dynamics are Markovian with respect to the current state and the current action and by replacing $p ( \mathbf { s } _ { t } | \mathbf { s } _ { t - 1 } , \mathbf { a } _ { t - 1 } )$ with the right-hand side of (14). In the second line, sW,{z1,...,zt},{1,...,t},Wπt is the state that is obtained at time t in a roll-out generated by using a policy with parameters $\mathcal { W } _ { \pi }$ , a transition function parameterized by $\mathcal { W }$ and input noise $z _ { 1 } , \dots , z _ { t }$ , with additive noise values $\epsilon _ { 1 } , \ldots , \epsilon _ { t }$ . In the last line we have approximated the integration with respect to $\mathcal { W } , z _ { 1 } , \ldots , z _ { T } , \epsilon _ { 1 } , \ldots , \epsilon _ { T }$ and $\mathbf { s } _ { 0 }$ by averaging over $K$ samples of these variables. To sample $\mathbf { s } _ { 0 }$ , we draw this variable uniformly from the available transitions $\left( \mathbf { s } _ { t } , \mathbf { a } _ { t } , \mathbf { s } _ { t + 1 } \right)$ .
The expected cost (15) can then be optimized by stochastic gradient descent using the gradients of the Monte Carlo approximation given by the last line of (16). Algorithm 1 computes this Monte
 Figure 3: Visualization of three policies in state space. Waterfall is indicated by top black bar. Left: policy $\pi _ { V B }$ obtained with a BNN trained with VB. Avg. reward is $- 2 . 5 3$ . Middle: policy $\pi _ { \alpha = 0 . 5 }$ obtained with a BNN trained with $\alpha = 0 . 5$ . Avg. reward is $- 2 . 3 1$ . Right: policy $\pi _ { G P }$ obtained by using a Gaussian process model. Avg. reward is $- 2 . 9 4$ . Color and arrow indicate direction of paddling of policy when in state $\mathbf { s } _ { t }$ , arrow length indicates action magnitude. Best viewed in color.
<table><tr><td>Dataset</td><td>MLP</td><td>VB</td><td>α=0.5</td><td>α=1.0</td><td>GP</td><td>PSO-P</td></tr><tr><td>Wetchicken</td><td>-2.71±0.09</td><td>-2.67±0.10</td><td>-2.37±0.01</td><td>-2.42±0.01</td><td>-3.05±0.06</td><td>-2.34</td></tr><tr><td>Turbine</td><td>-0.65±0.14</td><td>-0.45±0.02</td><td>-0.41±0.03</td><td>-0.55±0.08</td><td>-0.64±0.18</td><td>NA</td></tr><tr><td>Industrial</td><td>-183.5±4.1</td><td>-180.2±0.6</td><td>-174.2±1.1</td><td>-171.1±2.1</td><td>-285.2±20.5</td><td>-145.5</td></tr><tr><td>Avg. Rank</td><td>3.6±0.3</td><td>3.1±0.2</td><td>1.5±0.2</td><td>2.3±0.3</td><td>4.5±0.3</td><td></td></tr></table>
Table 1: Policy performances over different benchmarks. Printed are average values over 5 runs with respective standard errors. Bottom row is the average rank over all $5 \times 3$ runs.
Carlo approximation. The gradients can then be obtained using automatic differentiation tools such as Theano (Theano Development Team). Note that Algorithm 1 uses the BNNs to make predictions for the change in the state $\Delta _ { t } = { \bf s } _ { t + 1 } - { \bf s } _ { t }$ instead of for the next state $\mathbf { s } _ { t + 1 }$ since this approach often performs better in practice (Deisenroth & Rasmussen, 2011).
# 4 EXPERIMENTS
We now evaluate the performance of our algorithm for policy search in different benchmark problems. These problems are chosen based on two reasons. First, they contain complex stochastic dynamics and second, they represent real-world applications common in industrial settings. A theano implementation of algorithm 1 is available online1. See the appendix B for a short introduction to all methods we compare to and appendix C for the hyper-parameters used.
# 4.1 WET-CHICKEN BENCHMARK
The Wet-Chicken benchmark (Tresp, 1994) is a challenging problem for model-based policy search that presents both bi-modal and heteroskedastic transition dynamics. We use the two-dimensional version of the problem (Hans & Udluft, 2009) and extend it to the continuous case.
In this problem, a canoeist is paddling on a two-dimensional river. The canoeist’s position at time $t$ is $( x _ { t } , y _ { t } )$ . The river has width $w = 5$ and length $l = 5$ with a waterfall at the end, that is, at $y _ { t } = l$ . The canoeist wants to move as close to the waterfall as possible because at time $t$ he gets reward $r _ { t } = - ( l - y _ { t } )$ . However, going beyond the waterfall boundary makes the canoeist fall down, having to start back again at the origin $( 0 , 0 )$ . At time $t$ the canoeist can choose an action $( a _ { t , x } , a _ { t , y } ) \in [ - 1 , 1 ] ^ { 2 }$ that represents the direction and magnitude of his paddling. The river dynamics have stochastic turbulences $s _ { t }$ and drift $v _ { t }$ that depend on the canoeist’s position on the $x$ axis. The larger $x _ { t }$ , the larger the drift and the smaller $x _ { t }$ , the larger the turbulences. The underlying dynamics are given by the following system of equations. The drift and the turbulence magnitude are given by $v _ { t } \stackrel { - } { = } 3 x _ { t } w ^ { - 1 }$ and $s _ { t } = 3 . 5 - v _ { t }$ , respectively. The new location $( x _ { t + 1 } , y _ { t + 1 } )$ is given by the current
<table><tr><td>Dataset</td><td>MLP</td><td>VB</td><td>α=0.5</td><td>α=1.0</td><td>GP</td></tr><tr><td colspan="6">MSE</td></tr><tr><td>WetChicken</td><td>1.289±0.013</td><td>1.347±0.015</td><td>1.347±0.008</td><td>1.359±0.017</td><td>1.359±0.017</td></tr><tr><td>Turbine</td><td>0.16±0.001</td><td>0.21±0.003</td><td>0.192±0.002</td><td>0.237±0.004</td><td>0.492±0.026</td></tr><tr><td>Industrial</td><td>0.0186±0.0052</td><td>0.0182±0.0052</td><td>0.017±0.0046</td><td>0.0171±0.0047</td><td>0.0233±0.0049</td></tr><tr><td>Avg. Rank</td><td>2.0±0.34</td><td>3.1±0.24</td><td>2.4±0.23</td><td>2.9±0.36</td><td>4.6±0.23</td></tr><tr><td colspan="6">Log-Likelihood</td></tr><tr><td>WetChicken</td><td>-1.755±0.003</td><td>-1.140±0.033</td><td>-1.057±0.014</td><td>-1.070±0.011</td><td>-1.722±0.011</td></tr><tr><td>Turbine</td><td>-0.868±0.007</td><td>-0.775±0.004</td><td>-0.746±0.013</td><td>-0.774±0.015</td><td>-2.663±0.131</td></tr><tr><td>Industrial</td><td>0.767±0.047</td><td>1.132±0.064</td><td>1.328±0.108</td><td>1.326±0.098</td><td>0.724±0.04</td></tr><tr><td>Avg. Rank</td><td>4.3±0.12</td><td>2.6±0.16</td><td>1.3±0.15</td><td>2.1±0.18</td><td>4.7±0.12</td></tr></table>
Table 2: Model test error and test log-likelihood for different benchmarks. Printed are average values over 5 runs with respective standard errors. Bottom row is the average rank over all $5 \times 3$ runs.
location $( x _ { t } , y _ { t } )$ and current action $( a _ { t , x } , a _ { t , y } )$ using
$$x _ { t + 1 } = \left\{ \begin{array} { l l } { 0 } & { \mathrm { i f } \quad x _ { t } + a _ { t , x } < 0 } \\ { 0 } & { \mathrm { i f } \quad \hat { y } _ { t + 1 } > l } \\ { w } & { \mathrm { i f } \quad x _ { t } + a _ { t , x } > w } \\ { x _ { t } + a _ { t , x } } & { \mathrm { o t h e r w i s e } } \end{array} \right. , \qquad y _ { t + 1 } = \left\{ \begin{array} { l l } { 0 } & { \mathrm { i f } \quad \hat { y } _ { t + 1 } < 0 } \\ { 0 } & { \mathrm { i f } \quad \hat { y } _ { t + 1 } > l } \\ { \hat { y } _ { t + 1 } } & { \mathrm { o t h e r w i s e } } \end{array} \right. ,$$
where $\hat { y } _ { t + 1 } = y _ { t } + \left( a _ { t , y } - 1 \right) + v _ { t } + s _ { t } \tau _ { t }$ and $\tau _ { t } \sim \mathrm { U n i f } ( [ - 1 , 1 ] )$ is a random variable that represents the current turbulence. These dynamics result in rich transition distributions depending on the position as illustrated by the plots in Figure 2. As the canoeist moves closer to the waterfall, the distribution for the next state becomes increasingly bi-modal (see Figure 1c) because when he is close to the waterfall, the change in the current location can be large if the canoeist falls down the waterfall and starts again at $( 0 , 0 )$ . The distribution may also be truncated uniform for states close to the borders (see Figure 1d). Furthermore the system has heteroskedastic noise, the smaller the value of $x _ { t }$ the higher the noise variance (compare Figure 1a with 1b). Because of these properties, the Wet-Chicken problem is especially difficult for model-based reinforcement learning methods. To our knowledge it has only been solved using model-free approaches after a discretization of the state and action sets (Hans & Udluft, 2009). For model training we use a batch 2500 random state transitions.
The predictive distributions of different models for $y _ { t + 1 }$ are shown in Figure 2 for specific choices of $( x _ { t } , y _ { t } )$ and $( a _ { x , t } , a _ { y , t } )$ . These plots show that BNNs with $\alpha = 0 . 5$ are very close to the ground-truth. While it is expected that Gaussian processes fail to model multi-modalities in Figure 1c, the FTIC approximation allows them to model the heteroskedasticity to an extent. VB captures the stochastic patterns on a global level, but often under or over-estimates the true probability density in specific regions. The test-loglikelihood and test MSE in $y$ -dimension are reported in Table 2 for all methods. (the transitions for $x$ are deterministic given $y$ ).
After fitting the models, we train policies using Algorithm 1 with a horizon of size $T = 5$ . Table 1 shows the average reward obtained by each method. BNNs with $\alpha = 0 . 5$ perform best and produce policies that are very close to the optimal upper bound, as indicated by the performance of the particle swarm optimization policy (PSO-P). In this problem VB seems to lack robustness and has much larger empirical variance across experiment repetitions than $\alpha = 0 . 5$ or $\alpha = 1 . 0$ .
Figure 3 shows three example policies, πVB , $\pi _ { \alpha = 0 . 5 }$ and $\pi _ { \mathrm { G P } }$ (Figure 3a,3b and 3c, respectively). The policies obtained by BNNs with random inputs (VB and $\alpha = 0 . 5$ ) show a richer selection of actions. The biggest differences are in the middle-right regions of the plots, where the drift towards the waterfall is large and the bi-modal transition for $y$ (missed by the GP) is more important.
# 4.2 INDUSTRIAL APPLICATIONS
We now present results on two industrial cases. First, we focus on data generated by a real gas turbine and second, we consider a recently introduced simulator called the "industrial benchmark", with code publicly available2 (Hein et al., 2016b). According to the authors: "The "industrial benchmark" aims at being realistic in the sense, that it includes a variety of aspects that we found to be vital in industrial applications."
 Figure 4: Roll-outs of algorithm 1 for two starting states $\mathbf { s } _ { 0 }$ (top/bottom) using different types of BNNs (left to right) with $K = 7 5$ samples for $T = 7 5$ steps. Action sequence $A _ { 0 } , \cdots , A _ { T = 7 5 }$ given by dataset for each $\mathbf { s } _ { 0 }$ . From left to right: model trained using VB, $\alpha = 0 . 5$ and $\alpha = 1 . 0$ respectively. Red: trajectory observed in dataset, blue: sample average, light blue: individual samples.
# 4.2.1 GAS TURBINE DATA
For the experiment with gas turbine data we simulate a task with partial observability. To that end we use 40,000 observations of a 30 dimensional time-series of sensor recordings from a real gas turbine. We are also given a cost function that evaluates the performance of the current state of the turbine. The features in the time-series are grouped into three different sets: a set of environmental variables $E _ { t }$ (e.g. temperature and measurements from sensors in the turbine) that cannot be influenced by the agent, a set of variables relevant for the cost function $N _ { t }$ (e.g. the turbines current pollutant emission) and a set of steering variables $A _ { t }$ that can be manipulated to control the turbine.
We first train a world model as a reflection of the real turbine dynamics. To that end we define the world model’s transitions for $N _ { t }$ to have the functional form $N _ { t } = f ( E _ { t - 5 } , . . , E _ { t } , A _ { t - 5 } , . . A _ { t } ) .$ . The world model assumes constant transitions for the environmental variables: $E _ { t + 1 } = E _ { t }$ . To make fair comparisons, our world model is given by a non-Bayesian neural network with deterministic weights and with additive Gaussian output noise.
We then use the world model to generate an artificial batch of data for training the different methods. The inputs in this batch are still the same as in the original turbine data, but the outputs are now sampled from the world model. After generating the artificial data, we only keep a small subset of the original inputs to the world model. The aim of this experiment is to learn policies that are robust to noise in the dynamics. This noise would originate from latent factors that cannot be controlled, such as the missing features that were originally used to generate the outputs by the world model but which are no longer available. After training the models for the dynamics, we use algorithm 1 for policy optimization. The resulting policies are then finally evaluated in the world model.
Tables 2 and 1 show the respective model and policy performances for each method. The experiment was repeated 5 times and we report average results. We observe that $\alpha = 0 . 5$ performs best in this scenario, having the highest test log-likelihood and best policy performance.
# 4.2.2 INDUSTRIAL BENCHMARK
In this benchmark the hidden Markov state space $\mathbf { s } _ { t }$ consists of 27 variables, whereas the observable state $\mathbf { o } _ { t }$ is only 5 dimensional. This observable state consists of 3 adjustable steering variables $A _ { t }$ : the velocity $v ( t )$ , the gain $g ( t )$ and the shift $s ( t )$ . We also observe the fatigue $f ( t )$ and consumption $c ( t )$ that together form the reward signal $R ( t ) = - ( 3 f ( t ) + c ( t ) )$ . Also visible is the setpoint $S$ , a constant hyper-parameter of the benchmark that indicates the complexity of the dynamics.
For each setpoint $S \in \{ 1 0 , 2 0 , \cdots , 1 0 0 \}$ we generate 7 trajectories of length 1000 using random exploration. This batch with $7 0 , 0 0 0$ state transitions forms the training set. We use 30, 000 state transitions, consisting of 3 trajectories for each setpoint, as test set.
For data preprocessing, in addition to the standard normalization process, we apply a log transformation to the reward variable. Because the reward is bounded in the interval $[ 0 , R _ { m a x } ]$ , we use a logit transformation to map this interval into the real line. We define the functional form for the dynamics as $R _ { t } = f ( A _ { t - 1 5 } , \cdot \cdot \cdot , A _ { t } , R _ { t - 1 5 } , \cdot \cdot \cdot , R _ { t - 1 } )$ .
The test errors and log-likelihood are given in Table 2. We see that BNNs with $\alpha = 0 . 5$ and $\alpha = 1 . 0$ perform best here, whereas Gaussian processes or the MLP obtain rather poor results.
Each row in Figure 4 visualizes long term predictions of the MLP and BNNs trained with VB and $\alpha = 0 . 5$ in two specific cases. In the top row we see that while all three methods produce wrong predictions in expectation (compare dark blue curve to red curve). However, BNNs trained with $V B$ and with $\alpha = 0 . 5$ exhibit a bi-modal distribution of predicted trajectories, with one mode following the ground-truth very closely. By contrast, the MLP misses the upper mode completely. The bottom row shows that the VB and $\alpha = 0 . 5$ also produce more tight confident bands in other settings.
Next, we learn policies using the trained models. Here we use a relatively long horizon of $T = 7 5$ steps. Table 1 shows average rewards obtained when applying the policies to the real dynamics. Because both benchmark and models have an autoregressive component, we do an initial warm-up phase using random exploration before we apply the policies to the system and start to measure rewards.
We observe that GPs perform very poorly in this benchmark. We believe the reason for this is the long search horizon, which makes the uncertainties in the predictive distributions of the GPs become very large. Tighter confidence bands, as illustrated in Figure 4 seem to be key for learning good policies. Overall, $\alpha = 1 . 0$ performs best with $\alpha = 0 . 5$ being very close.
# 5 RELATED WORK
There has been relatively little attention to using Bayesian neural networks for reinforcement learning. In Blundell et al. (2015) a Thompson sampling approach is used for a contextual bandits problem; the focus is tackling the exploration-exploitation trade-off, while the work in Watter et al. (2015) combines variational auto-encoder with stochastic optimal control for visual data. Compared to our approach the first of these contributions focusses on the exploration/exploitation dilemma, while the second one uses a stochastic optimal control approach to solve the learning problem. By contrast, our work seeks to find an optimal parameterized policy.
Policy gradient techniques are a prominent class of policy search algorithms (Peters & Schaal, 2008). While model-based approaches were often used in discrete spaces (Wang & Dietterich, 2003), model-free approaches tended to be more popular in continuous spaces (e.g. Peters & Schaal (2006)).
Our work can be seen as a Monte-Carlo model-based policy gradient technique in continuous stochastic systems. Similar work was done using Gaussian processes (Deisenroth & Rasmussen, 2011) and with recurrent neural networks (Schaefer et al., 2007) . The Gaussian process approach, while restricted to a Gaussian state distribution, allows propagating beliefs over the roll-out procedure. More recently Gu et al. (2016) augment a model-free learning procedure with data generated from model-based roll-outs.
# 6 CONCLUSION AND FUTURE WORK
We have extended the standard Bayesian neural network (BNN) model with the addition of a random input noise source $z$ . This enables principled Bayesian inference over complex stochastic functions. We have shown that our BNNs with random inputs can be trained with high accuracy by minimizing $\alpha$ -divergences, with $\alpha = 0 . 5$ , which often produces better results than variational Bayes. We have also presented an algorithm that uses random roll-outs and stochastic optimization for learning a parameterized policy in a batch scenario. This algorithm particular suited for industry domains.
Our BNNs with random inputs have allowed us to solve a challenging benchmark problem where model-based approaches usually fail. They have also shown promising results on industry benchmarks including real-world data from a gas turbine. In particular, our experiments indicate that a BNN trained with $\alpha = 0 . 5$ as divergence measure in conjunction with the presented algorithm for policy optimization is a powerful black-box tool for policy search.
As future work we will consider safety and exploration. For safety, we believe having uncertainty over the underlaying stochastic functions will allows us to optimize policies by focusing on worst case results instead of on average performance. For exploration, having uncertainty on the stochastic functions will be useful for efficient data collection.
# ACKNOWLEDGEMENTS
José Miguel Hernández-Lobato acknowledges support from the Rafael del Pino Foundation. The authors would like to thank Ryan P. Adams, Hans-Georg Zimmermann, Matthew J. Johnson, David Duvenaud and Justin Bayer for helpful discussions.
# REFERENCES
D.P. Bertsekas. Dynamic Programming and Optimal Control. Athena Scientific optimization and computation series. 2002. ISBN 9781886529083.
Charles Blundell, Julien Cornebise, Koray Kavukcuoglu, and Daan Wierstra. Weight uncertainty in neural networks. In ICML, pp. 1613–1622, 2015.
Thang D Bui, Daniel Hernández-Lobato, Yingzhen Li, José Miguel Hernández-Lobato, and Richard E Turner. Deep Gaussian processes for regression using approximate expectation propagation. In ICML, pp. 1472–1481, 2016.
Marc Deisenroth and Carl E Rasmussen. PILCO: A model-based and data-efficient approach to policy search. In ICML, pp. 465–472, 2011.
Marc Peter Deisenroth, Gerhard Neumann, and Jan Peters. A survey on policy search for robotics. Foundations and Trends in Robotics, 2:1–142, 2013.
A. Draeger, S. Engell, and H. Ranke. Model predictive control using neural networks. IEEE Control Systems, 15:61–66, 1995.
Yarin Gal, Rowan Mcallister, and Carl Rasmussen. Improving PILCO with Bayesian neural networks dynamics models. In Data-Efficient Machine Learning workshop, ICML, 2016.
Shixiang Gu, Timothy Lillicrap, Ilya Sutskever, and Sergey Levine. Continuous deep q-learning with model-based acceleration. arXiv preprint arXiv:1603.00748, 2016.
Alexander Hans and Steffen Udluft. Efficient uncertainty propagation for reinforcement learning with limited data. In ICANN, pp. 70–79. Springer, 2009.
Daniel Hein, Alexander Hentschel, Thomas A Runkler, and Steffen Udluft. Reinforcement learning with particle swarm optimization policy (PSO-P) in continuous state and action spaces. IJSIR, 7: 23–42, 2016a.
Daniel Hein, Alexander Hentschel, Volkmar Sterzing, Michel Tokic, and Steffen Udluft. Introduction to the" industrial benchmark". arXiv preprint arXiv:1610.03793, 2016b.
José Miguel Hernández-Lobato, Matthew W Hoffman, and Zoubin Ghahramani. Predictive entropy search for efficient global optimization of black-box functions. In NIPS, pp. 918–926, 2014.
José Miguel Hernández-Lobato, Yingzhen Li, Mark Rowland, Daniel Hernández-Lobato, Thang Bui, and Richard E Turner. Black-box $\alpha$ -divergence minimization. In ICML, pp. 1511–1520, 2016.
Rein Houthooft, Xi Chen, Yan Duan, John Schulman, Filip De Turck, and Pieter Abbeel. VIME: Variational information maximizing exploration. In NIPS, pp. 1109–1117, 2016.
Diederik P Kingma, Tim Salimans, and Max Welling. Variational dropout and the local reparameterization trick. In NIPS, pp. 2575–2583, 2015.
Jonathan Ko, Daniel J Klein, Dieter Fox, and Dirk Haehnel. Gaussian processes and reinforcement learning for identification and control of an autonomous blimp. In IEEE Robotics and Automation, pp. 742–747, 2007.
Tom Minka. Divergence measures and message passing. Technical report, Microsoft Research, 2005.
Jan Peters and Stefan Schaal. Policy gradient methods for robotics. In IROS, pp. 2219–2225, 2006.
Jan Peters and Stefan Schaal. Reinforcement learning of motor skills with policy gradients. Neural networks, 21:682–697, 2008.
Carl Edward Rasmussen, Malte Kuss, et al. Gaussian processes in reinforcement learning. In NIPS, pp. 751–758, 2003.
Anton Maximilian Schaefer, Steffen Udluft, and Hans-Georg Zimmermann. The recurrent control neural network. In ESANN, pp. 319–324, 2007.
Edward Snelson and Zoubin Ghahramani. Sparse Gaussian processes using pseudo-inputs. In NIPS, pp. 1257–1264, 2005.
Theano Development Team. Theano: A Python framework for fast computation of mathematical expressions. arXiv e-print abs/1605.02688.
V. Tresp. The wet game of chicken. Technical report, 1994.
Bo Wahlberg. System identification using Laguerre models. IEEE Transactions on Automatic Control, 36:551–562, 1991.
M. J. Wainwright and M. I. Jordan. Graphical models, exponential families, and variational inference. Foundations and Trends in Machine Learning, 1:1–305, 2008.
Xin Wang and Thomas G Dietterich. Model-based policy gradient reinforcement learning. In ICML, pp. 776–783, 2003.
Manuel Watter, Jost Springenberg, Joschka Boedecker, and Martin Riedmiller. Embed to control: A locally linear latent dynamics model for control from raw images. In NIPS, pp. 2728–2736, 2015.
 Figure 5: Ground truth and predictive distributions for two toy problems introduced in main text. Top: bi-modal prediction problem, Bottom: heteroskedastic prediction problem. Left column: Training data (blue points) and ground truth functions (red). Columns 2-4: predictions generated with VB, $\alpha = 0 . 5$ and $\alpha = 1 . 0$ , respectively.
# A ROBUSTNESS OF $\alpha = 0 . 5$ AND $\alpha = 1 . 0$ WHEN $q ( \mathbf { z } )$ IS NOT LEARNED
We evaluate the accuracy of the predictive distributions generated by BNNs with stochastic inputs trained by minimizing (8) for different BNNs parameterized by $\alpha$ in two simple regression problems. The first one is characterized by a bimodal predictive distribution. The second is characterized by a heteroskedastic predictive distribution. In the latter case the magnitude of the noise in the targets changes as a function of the input features.
In the first problem $x \in [ - 2 , 2 ]$ and $y$ is obtained as $y = 1 0 \sin ( x ) + \epsilon$ with probability 0.5 and $y = 1 0 \cos ( x ) + \epsilon$ , otherwise, where $\epsilon \sim \mathcal { N } ( 0 , 1 )$ and $\epsilon$ is independent of $x$ . The plot in the top of the 1st column in Figure 5 shows a training dataset obtained by sampling 2500 values of $x$ uniformly at random. The plot clearly shows that the distribution of $y$ for a particular $x$ is bimodal. In the second problem $x \in [ - 4 , 4 ]$ and $y$ is obtained as $y = 7 \sin ( x ) + 3 | \cos ( x / 2 ) | \epsilon$ . The plot in the bottom of the 1st column in Figure 5 shows a training dataset obtained with 1000 values of $x$ uniformly at random. The plot clearly shows that the distribution of $y$ is heteroskedastic, with a noise variance that is a function of $x$ .
We evaluated the predictive performance obtained by minimizing (8) using $\alpha = 0 . 5$ and $\alpha = 1 . 0$ and also by running VB. However, we do not learn $q ( \mathbf { z } )$ and keeping it instead fixed to the prior $p ( \mathbf { z } )$ .
We fitted a neural network with 2 hidden layers and 50 hidden units per layer using Adam with its default parameter values, with a learning rate of 0.01 in the first problem and 0.002 in the second problem. We used mini-batches of size 250 and 1000 training epochs. To approximate the expectations in 8, we draw $K = 5 0$ samples from $q$ .
The plots in the 3rd and 4th columns of Figure 5 show the predictions obtained with $\alpha = 0 . 5$ and $\alpha = 1 . 0$ , respectively. In these cases, the predictive distribution is able to capture the bimodality in the first problem and the heteroskedasticity pattern in the second problem in both cases The plots in the 2nd column of Figure 5 show the predictions obtained with VB, which converges to suboptimal solutions in which the predictive distribution has a single mode (in the first problem) or is homoskedastic (in the second problem). Tables 3 and 4 show the average test RMSE and log-likelihood obtained by each method on each problem.
These results show that Bayesian neural networks trained with $\alpha = 0 . 5$ or $\alpha = 1 . 0$ are more robust than VB and can still model complex predictive distributions, which may be multimodal and heteroskedastic, even when $q ( \mathbf { z } )$ is not learned and is instead kept fixed to the prior $p ( \mathbf { z } )$ . By contrast, VB fails to capture complex stochastic patterns in this setting.
Table 3: Test error and log-likelihood for the bi-modal prediction problem.
<table><tr><td>Method</td><td>RMSE</td><td>Log-likelihood</td></tr><tr><td>VB</td><td>5.12</td><td>-3.05</td></tr><tr><td>α = 0.5</td><td>5.14</td><td>-2.10</td></tr><tr><td>α = 1.0</td><td>5.15</td><td>-2.11</td></tr></table>
Table 4: Test error and log-likelihood for the heteroskedastic prediction problem.
<table><tr><td>Method</td><td>RMSE</td><td>Log-likelihood</td></tr><tr><td>VB</td><td>1.88</td><td>-2.05</td></tr><tr><td>α = 0.5</td><td>1.89</td><td>-1.78</td></tr><tr><td>α =1.0</td><td>1.94</td><td>-1.98</td></tr></table>
# B METHODS
In the experiments we compare to the following methods:
Standard MLP. The standard multi-layer preceptron (MLP) is equivalent to our BNNs, but does not have uncertainty over the weight $\mathcal { W }$ and does not include any stochastic inputs. We train this method using early stopping on a subset of the training data. When we perform roll-outs using algorithm 1, the predictions of the MLP are made stochastic by adding Gaussian noise to its output. The noise variance is fixed by maximum likelihood on some validation data after model training.
Variational Bayes (VB). The most prominent approach in training modern BNNs is to optimize the variational lower bound (Blundell et al., 2015; Houthooft et al., 2016; Gal et al., 2016). This is in practice equivalent to $\alpha$ -divergence minimization when $\alpha 0$ (Hernández-Lobato et al., 2016). In our experiments we use $\alpha$ -divergence minimization with $\alpha = 1 0 ^ { - 6 }$ to implement this method.
Gaussian Processes (GPs). Gaussian Processes have recently been used for policy search under the name of PILCO (Deisenroth & Rasmussen, 2011). For each dimension of the target variables, we fit a different sparse GP using the FITC approximation (Snelson & Ghahramani, 2005). In particular, each sparse GP is trained using 150 inducing inputs by using the method stochastic expectation propagation (Bui et al., 2016). After this training process we approximate the sparse GP by using a feature expansion with random basis functions (see supplementary material of Hernández-Lobato et al. 2014). This allows us to draw samples from the GP posterior distribution over functions, enabling the use of Algorithm 1 for policy training. Note that PILCO will instead moment-match at every roll-out step as it works by propagating Gaussian distributions. However, in our experiments we obtained better performance by avoiding the moment matching step with the aforementioned approximation based on random basis functions.
Particle Swarm Optimization Policy(PSO-P). We use this method to estimate an upper bound for reward performance. PSO-P is a model predictive control (MPC) method that uses the true dynamics when applicable (Hein et al., 2016a). For a given state $\mathbf { s } _ { t }$ , the best action is selected using the standard receding horizon approach on the real environment. Note that this is not a benchmark method to compare to, we use it instead as an indicator of what the best possible reward can be achieved for a fixed planning horizon $T$ .
# C MODEL PARAMETERS
For all tasks we will use a standard MLP with two hidden layer with 20 hidden units each as policy representation. The activation functions for the hidden units are rectifiers: $\varphi ( x ) = \operatorname* { m a x } ( x , 0 )$ . If present, bounding of the actions is realized using the tanh activation function on the outputs of the policy. All models based on neural network will share the same hyperparameter. We use ADAM as learning algorithm in all tasks.
WetChicken The neural network models are set to 2 hidden layers and 20 hidden units per layer. We use 2500 random state transitions for training. We found that assuming no observation noise by setting $\Gamma$ to a constant of $1 0 ^ { - 5 }$ helped the models converge to lower energy values.
For policy training we use a horizon of size $T = 5$ and optimize the policy network for 100 epochs, averaging over $K = 2 0$ samples in each gradient update, with mini-batches of size 10 and learning rate set to 10−5.
Turbine The world model and the BNNs have two hidden layers with 50 hidden units each. For policy training and world-model evaluation we perform a roll-out with horizon $T = 2 0$ . For learning the policy we use minibaches of size 10 and draw $K = 1 0$ samples from $q$ .
Industrial Benchmark For the neural network models we use two hidden layers with 75 hidden units.We use a horizon of $T = 7 5$ , training for 500 epochs with batches of size 50 and $K = 2 5$ samples for each rollout.
# D COMPUTATIONAL COMPLEXITY
MODEL TRAINING
All models were trained using theano and a single GPU. Training the standard neural network is fast, the training time for this method was between 5 - 20 minutes, depending on data set size and dimensionality of the benchmark. In theano, the computational graph of the BNNs is similar to that of an ensemble of standard neural networks. The training time for the BNNs varied between 30 minutes to 5 hours depending on data size and dimensionality of benchmark. The sparse Gaussian Process was optimized using an expectation propagation algorithm and after training, it was approximated with a Bayesian linear model with fixed basis functions whose weights are initialized randomly (see Appendix B). We choose the inducing points in the GPs and the number of training epochs for these models so that the resulting training time was comparable to that of the BNNs.
# POLICY SEARCH
For policy training we used a single CPU. All methods are of similar complexity as they are all trained using Algorithm 1. Depending on the horizon, data set size and network topology, training took between 20 minutes (Wet-Chicken, $T = 5$ ), 3-4 hours (Turbine, $T = 2 0$ ) and 14-16 hours (industrial benchmark, $T = 7 5$ ).123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514# BENCHMARKING MODEL-BASED REINFORCEMENT LEARNING
Anonymous authors Paper under double-blind review
# ABSTRACT
Model-based reinforcement learning (MBRL) is widely seen as having the potential to be significantly more sample efficient than model-free RL. However, research in model-based RL has not been very standardized. It is fairly common for authors to experiment with self-designed environments, and there are several separate lines of research, which are sometimes closed-sourced or not reproducible. Accordingly, it is an open question how these various existing algorithms perform relative to each other. To facilitate research in MBRL, in this paper we gather a wide collection of MBRL algorithms and propose over 18 benchmarking environments specially designed for MBRL. We benchmark these algorithms with unified problem settings, including noisy environments. Beyond cataloguing performance, we explore and unify the underlying algorithmic differences across MBRL algorithms. We characterize three key research challenges for future MBRL research: the dynamics bottleneck, the planning horizon dilemma, and the early-termination dilemma. Finally, to facilitate future research on MBRL, we open-source our benchmark1.
# 1 INTRODUCTION
Reinforcement learning (RL) algorithms are most commonly classified in two categories: model-free RL (MFRL), which directly learns a value function or a policy by interacting with the environment, and model-based RL (MBRL), which uses interactions with the environment to learn a model of it. While model-free algorithms have achieved success in areas including robotics (Lillicrap et al., 2015; Schulman et al., 2017; Heess et al., 2017; Andrychowicz et al., 2018), video-games (Mnih et al., 2013; 2016), and character animation (Peng et al., 2018), their high sample complexity limits largely their application to simulated domains. By learning a model of the environment, model-based methods learn with significantly lower sample complexity. However, learning an accurate model of the environment has proven to be a challenging problem in certain domains. Modelling errors cripple the effectiveness of these algorithms, resulting in policies that exploit the deficiencies of the models, which is known as model-bias (Deisenroth & Rasmussen, 2011). Recent approaches have been able to alleviate the model-bias problem by characterizing the uncertainty of the learned models by the means of probabilistic models and ensembles. This has enabled model-based methods to match model-free asymptotic performance in challenging domains while using much fewer samples (Kurutach et al., 2018; Chua et al., 2018; Clavera et al., 2018).
These recent advances have led to a great excitement in the field of model-based reinforcement learning. Despite the impressive results achieved, how these methods compare against each other and against standard baselines remains unclear. Reproducibility and lack of open-source code are persistent problems in RL (Henderson et al., 2018; Islam et al., 2017), which makes it difficult to compare novel algorithms against prior lines of research. In MBRL, this problem is exacerbated by the modifications made to the environments: pre-processing of the observations, modification of the reward functions, or using different episode horizons. Such lack of standardized implementations and environments in MBRL makes it difficult to quantify scientific progress.
Systematic evaluation and comparison will not only further our understanding of the strengths and weaknesses of existing algorithms, but also reveal their limitations and suggest directions for future research. Benchmarks play a crucial role in other fields of research. For instance, MFRL has benefited greatly from the introduction of benchmarking code bases and environments such as rllab (Duan et al., 2016), OpenAI Gym (Brockman et al., 2016), and DM Control Suite (Tassa et al., 2018); where the latter two have been the de facto benchmarking platforms. Besides RL, benchmarking platforms have also accelerated areas such as computer vision (Deng et al., 2009; Lin et al., 2014), machine translation (Koehn et al., 2007) and speech recognition (Panayotov et al., 2015).
In this paper, we benchmark 11 MBRL algorithms and 4 MFRL algorithms across 18 environments based on the standard OpenAI Gym (Brockman et al., 2016). The environments, designed to hold the common assumptions in model-based methods, range from simple 2D tasks, such as Cart-Pole, to complex domains that are usually not evaluated on, such as Humanoid. The benchmark is further extended by characterizing the robustness of the different methods when stochasticity in the observations and actions is introduced. Based on the empirical evaluation, we propose three main causes that stagnate the performance of model-based methods: 1) Dynamics bottleneck: algorithms with learned dynamics are stuck at performance local minima significantly worse than using groundtruth dynamics, i.e. the performance does not increase when more data is collected. 2) Planning horizon dilemma: while increasing the planning horizon provides more accurate reward estimation, it can result in performance drops due to the curse of dimensionality and modelling errors. 3) Early termination dilemma: early termination is commonly used in MFRL for more directed exploration, to achieve faster learning. However, similar performance gain are not yet observed in MBRL algorithms, which limits their effectiveness in complex environments.
# 2 PRELIMINARIES
We formulate all of our tasks as a discrete-time finite-horizon Markov decision process (MDP), which is defined by the tuple $( \mathcal S , \mathcal A , p , r , \rho _ { 0 } , \gamma , H )$ . Here, $s$ denotes the state space, $\mathcal { A }$ denotes the action space, $p ( s ^ { \prime } | { a } , { s } ) : \mathcal { S } \times \mathcal { A } \times \mathcal { S } [ 0 , 1 ]$ is transition dynamics density function, $r ( s , a , s ^ { \prime } ) :$ $S \times \mathcal { A } \times \mathcal { S } \mathbb { R }$ defines the reward function, $\rho _ { 0 }$ is the initial state distribution, $\gamma$ is the discount factor, and $H$ is the horizon of the problem. Contrary to standard model-free RL, we assume access to an analytic differentiable reward function. The aim of RL is to learn an optimal policy maximizes the expected total reward $\begin{array} { r } { J ( \pi ) = \mathbb { E } _ { a _ { t } \sim \pi } [ \sum _ { t = 1 } ^ { H } \gamma ^ { t } r ( s _ { t } , a _ { t } ) ] } \end{array}$ . $\pi$ that
Dynamics Learning: MBRL algorithms are characterized by learning a model of the environment. After repeated interactions with the environment, the experienced transitions are stored in a dataset $\mathcal { D } = \{ ( s _ { t } , a _ { t } , s _ { t + 1 } ) \}$ which is then used to learn a dynamics function $\tilde { f } _ { \phi }$ . In the case where ground-truth dynamics are deterministic, the learned dynamics function $\tilde { f } _ { \phi }$ predicts the next state. In stochastic settings, it is common to represent the dynamics with a Gaussian distribution, i.e., $p ( \boldsymbol { s } _ { t + 1 } | \boldsymbol { a } _ { t } , \boldsymbol { s } _ { t } ) \sim \mathcal { N } ( \mu ( \boldsymbol { s } _ { t } , \boldsymbol { a } _ { t } ) , \Sigma ( \boldsymbol { s } _ { t } , \boldsymbol { a } _ { t } ) )$ and the learned dynamics model corresponds to $\tilde { f } _ { \phi } =$ $( \tilde { \mu } _ { \phi } ( s _ { t } , a _ { t } ) , \tilde { \Sigma } _ { \phi } ( s _ { t } , a _ { t } ) )$ .
# 3 ALGORITHMS
In this section, we introduce the benchmarked MBRL algorithms, which are divided into: 1) Dynastyle Algorithms, 2) Policy Search with Backpropagation through Time, and 3) Shooting Algorithms.
# 3.1 DYNA-STYLE ALGORITHMS
In the Dyna algorithm (Sutton, 1990; 1991a;b), training iterates between two steps. First, using the current policy, data is gathered from interaction with the environment and then used to learn the dynamics model. Second, the policy is improved with imagined data generated by the learned model. Dyna algorithms learn policies using model-free algorithms with rich imaginary experience without interaction with the real environment. Dyna can also be applied to tasks with image input as in world models (Ha & Schmidhuber, 2018a;b).
Model-Ensemble Trust-Region Policy Optimization (ME-TRPO) (Kurutach et al., 2018): Instead of using a single model, ME-TRPO uses an ensemble of neural networks to model the dynamics, which effectively combats model-bias. The ensemble $\tilde { f } _ { \phi } = \{ \tilde { f } _ { \phi _ { 1 } } , . . . , \tilde { f } _ { \phi _ { K } } \}$ is trained using standard squared L2 loss. In the policy improvement step, the policy is updated using Trust-Region Policy
Optimization (TRPO) (Schulman et al., 2015), on experience generated by the learned dynamics models.
Stochastic Lower Bound Optimization (SLBO) (Luo et al., 2019): SLBO is a variant of ME-TRPO with theoretical guarantees of monotonic improvement. In practice, instead of using single-step squared L2 loss, SLBO uses a multi-step L2-norm loss to train the dynamics.
Model-Based Meta-Policy-Optimzation (MB-MPO) (Clavera et al., 2018): MB-MPO forgoes the reliance on accurate models by meta-learning a policy that is able to adapt to different dynamics. Similar to ME-TRPO, MB-MPO learns an ensemble of neural networks. However, each model in the ensemble is considered as a different task to meta-train (Finn et al., 2017) on. MB-MPO meta-trains a policy that quickly adapts to any of the different dynamics of the ensemble, which is more robust against model-bias.
# 3.2 POLICY SEARCH WITH BACKPROPAGATION THROUGH TIME
Contrary to Dyna-style algorithms, where the learned dynamics models are used to provide imagined data, policy search with backpropagation through time exploits the model derivatives. Consequently, these algorithms are able to compute the analytic gradient of the RL objective with respect to the policy, and improve the policy accordingly.
Probabilistic Inference for Learning Control (PILCO) (Deisenroth & Rasmussen, 2011; Deisenroth et al., 2015; Kamthe & Deisenroth, 2017): In PILCO, Gaussian processes (GPs) are used to model the dynamics of the environment. The dynamics model $f _ { \mathcal { D } } ( s _ { t } , a _ { t } )$ is a probabilistic and nonparametric function of the collected data $\mathcal { D }$ . The policy $\pi _ { \theta }$ is trained to maximize the RL objective by computing the analytic derivatives of the objective with respect to the policy parameters $\theta$ . The training process iterates between collecting data using the current policy and improving the policy. Inference in GPs does not scale in high dimensional environments, limiting its application to simpler domains.
Iterative Linear Quadratic-Gaussian (iLQG) (Tassa et al., 2012): In iLQG, the ground-truth dynamics are assumed to be known by the agent. The algorithm uses a quadratic approximation on the RL reward function and a linear approximation on the dynamics, converting the problem solvable by linear-quadratic regulator (LQR) (Bemporad et al., 2002). By using dynamic programming, the optimal controller for the approximated problem is a linear time-varying controller. iLQG is a model predictive control (MPC) algorithm, where re-planning is performed at each time-step.
Guided Policy Search (GPS) (Levine & Abbeel, 2014; Levine et al., 2015; Zhang et al., 2016; Finn et al., 2016b; Montgomery & Levine, 2016; Chebotar et al., 2017): Guided policy search essentially distills the iLQG controllers $\pi _ { \mathcal { G } }$ into a neural network policy $\pi _ { \theta }$ by behavioural cloning, which minimizes $\mathbb { E } [ D _ { \mathrm { K L } } ( \pi _ { \mathcal { G } } ( \cdot | s _ { t } ) \| \pi _ { \theta } ) ]$ . The dynamics are modelled to be Gaussian-linear time-varying. To prevent over-confident policy improvement that deviates from the last real-world trajectory, the reward function is augmented as $\tilde { r } ( s _ { t } , a _ { t } ) = r ( s _ { t } , a _ { t } ) - \eta D _ { \mathrm { K L } } ( \pi _ { \mathcal { G } } ( \cdot | s _ { t } ) | | p ( \cdot | s _ { t } ) )$ , where $p ( \cdot | s _ { t } )$ is the passive dynamics distribution from last trajectories. In this paper, we use the MD-GPS variant (Montgomery & Levine, 2016).
Stochastic Value Gradients (SVG) (Heess et al., 2015): SVG tackles the problem of compounding model errors by using observations from the real environment, instead of the imagined one. To accommodate mismatch between model predictions and real transitions, the dynamics models in SVG are probabilistic. The policy is improved by computing the analytic gradient of the real trajectories with respect to the policy. Re-parametrization trick is used to permit back-propagation through the stochastic sampling.
# 3.3 SHOOTING ALGORITHMS
This class of algorithms provide a way to approximately solve the receding horizon problem posed in model predictive control (MPC) when dealing with non-linear dynamics and non-convex reward functions. Their popularity has increased with the use of neural networks for modelling dynamics.
Random Shooting (RS) (Richards, 2005; Rao, 2009): RS optimizes the action sequence $\mathbf { } _ { \mathbf { } } \mathbf { } \mathbf { } a _ { t : t + \tau }$ d planning reward under the l. In particular, the agent generates ned dynamics model, i.e.,candidate random sequences $\begin{array} { r } { \operatorname* { m a x } _ { a _ { t : t + \tau } } \mathbb { E } _ { s _ { t } ^ { \prime } \sim \tilde { f } _ { \phi } } [ \sum _ { t ^ { \prime } = t } ^ { t + \tau } r ( s _ { t } ^ { \prime } , a _ { t } ^ { \prime } ) ] } \end{array}$ $K$
of actions from a uniform distribution, and evaluates each candidate using the learned dynamics. The optimal action sequence is approximated as the one with the highest return. A RS agent only applies the first action from the optimal sequence and re-plans at every time-step.
Mode-Free Model-Based (MB-MF) (Nagabandi et al., 2017): Generally, random shooting has worse asymptotic performance when compared with model-free algorithms. In MB-MF, the authors first train a RS controller $\pi _ { R S }$ , and then distill the controller into a neural network policy $\pi _ { \theta }$ using DAgger (Ross et al., 2011), which minimizes $D _ { \mathrm { K L } } ( \pi _ { \theta } ( s _ { t } ) , \pi _ { R S } )$ . After the policy distillation step, the policy is fine-tuned using standard model-free algorithms. In particular the authors use TRPO (Schulman et al., 2015).
Probabilistic Ensembles with Trajectory Sampling (PETS-RS and PETS-CEM) (Chua et al., 2018): In the PETS algorithm, the dynamics are modelled by an ensemble of probabilistic neural networks models, which captures both epistemic uncertainty from limited data and network capacity, and aleatoric uncertainty from the stochasticity of the ground-truth dynamics. PETS-RS is the same as RS except for different modeling of the dynamics. In PETS-CEM, the online optimization problem is solved using cross-entropy method (CEM) (De Boer et al., 2005; Botev et al., 2013) to obtain a better solution. PETS-CEM can also plan in latent space of image observations (Hafner et al., 2018).
# 3.4 MODEL-FREE BASELINES
In our benchmark, we include MFRL baselines to quantify the sample complexity and asymptotic performance gap between MFRL and MBRL. Specifically, we compare against representative MFRL algorithms including Trust-Region Policy Optimization (TRPO) (Schulman et al., 2015), Proximal-Policy Optimization (PPO) (Schulman et al., 2017; Heess et al., 2017), Twin Delayed Deep Deterministic Policy Gradient (TD3) (Fujimoto et al., 2018), and Soft Actor-Critic (SAC) (Haarnoja et al., 2018). The former two are state-of-the-art on-policy MFRL algorithms, and the latter two are considered the state-of-the-art off-policy MFRL algorithms.
# 4 EXPERIMENTS
In this section, we present the results of our benchmarking and examine the causes that stagnate the performance of MBRL methods. Specifically, we designed the benchmark to answer the following questions: 1) How do existing MBRL approaches compare against each other and against MFRL methods across environments with different complexity (Section 4.3)? 2) Are MBRL algorithms robust against observation and action noise (Section 4.4)? and 3) What are the main bottlenecks in the MBRL methods?
Aiming to answer the last question, we present three phenomena inherent of MBRL methods, which we refer to as dynamics bottleneck (Section 4.5), planning horizon dilemma (Section 4.6), and early termination dilemma (Section 4.7).
# 4.1 BENCHMARKING ENVIRONMENTS
Our benchmark consists of 18 environments with continuous state and action space based on OpenAI Gym (Brockman et al., 2016). We include a full spectrum of environments with different difficulty and episode length, from CartPole to Humanoid. More specifically, we have the following modifications:
To accommodate traditional MBRL algorithms such as iLQG and GPS, we modify the reward function so that the gradient with respect to observation always exists or can be approximated. • We note that early termination has not been applied in MBRL, and we specifically have both the raw environments and the variants with early termination, indicated by the suffix ET. • The original Swimmer-v0 in OpenAI Gym was unsolvable for all algorithms. Therefore, we modified the position of the velocity sensor so that it’s easier to solve. We name this easier version as Swimmer while still keep the original one as a reference, named as Swimmer-v0.
For a detailed description of the environments and the reward functions used, we refer readers to Appendix A. We also provide open-sourced version of the tasks based on Roboschool or Pybullet (AMD, 2014; Ellenberger, 2018; Klimov & Schulman, 2017), which we refer to Appendix H.
 Figure 1: A subset of all 18 performance curve figures of the bench-marked algorithms. All the algorithms are run for 200k time-steps and with 4 random seeds. The remaining figures are in appendix C.
# 4.2 EXPERIMENT SETUP
Performance Metric and Hyper-parameter Search: Each algorithm is run with 4 random seeds. In the learning curves, the performance is averaged with a sliding window of 5 algorithm iterations. The error bars were plotted by the default Seaborn (Waskom, 2010) smoothing scheme from the mean and standard deviation of the results. Similarly, in the tables, we show the performance averaged across different random seeds with a window size of 5000 time-steps. We perform a grid search for each algorithm separately, which is summarized in appendix B. For each algorithm, We show the results using the hyper-parameters producing the best average performance.
Training Time: In MFRL, 1 million time-step training is common, but for many environments, MBRL algorithms converge much earlier than $2 0 0 \mathrm { k }$ time-steps and it takes an impractically long time to train for 1 million time-steps for some of the MBRL algorithms. We therefore show both the performance of $2 0 0 \mathrm { k }$ time-step training for all algorithms and show the performance of 1M time-step training for algorithms where computation is not a major bottleneck.
# 4.3 BENCHMARKING PERFORMANCE
In Table 1, we summarize the performance of each algorithm trained with 200,000 time-steps. We also include some representative performance curves in Figure 1. The learning curves for all the environments can be seen in appendix C. The engineering statistics shown in Table 2 include the computational resources, the estimated wall-clock time, and whether the algorithm is fast enough to run at real-time at test time, namely, if the action selection can be done faster than the default time-step of the environment. In Table 5, we summarize the performance ranking.
Shooting Algorithms: RS is very effective on simple tasks such as InvertedPendulum, CartPole and Acrobot, but as task difficulty increases RS gradually gets surpassed by PETS-RS and PETS-CEM, which indicates that modelling uncertainty aware dynamics is crucial for the performance. At the same time, PETS-CEM is better than PETS-RS in most of the environments, showing the importance of an effective planning module. However, PETS-CEM search is not as effective as PETS-RS in Ant, Walker2D and SlimHumanoid, indicating that we need more expressive and general planning module for more complex environments. MB-MF does not have obvious gains compared to other shooting algorithms, but like other model-free controllers, MB-MF can jump out of performance local-minima in MountainCar. Shooting algorithms are effective and robust across different environments.
Dyna-Style Algorithms: MB-MPO surpasses the performance of ME-TRPO in most of the environments and achieves the best performance in domains like HalfCheetah. Both algorithms seems to perform the best when the horizon is short. SLBO can solve MountainCar and Reacher very efficiently, but more interestingly in complex environment it achieves better performance than ME-TRPO and MB-MPO, except for in SlimHumanoid. This category of algorithms is not efficient to solve long horizon complex domains due to the compounding error effect.
SVG: For the majority of the tasks, SVG does not have the best sample efficiency. But for Humanoid environments, SVG is very effective compared with other MBRL algorithms. Complex environments exacerbate compounding errors; SVG which uses real observations and a value function to look into future returns, is able to surpass other MBRL algorithms in these high-dimensional domains.
Table 1: Final performance for 18 environments of the bench-marked algorithms. All the algorithms are run for $2 0 0 \mathrm { k }$ time-steps. Blue refers to the best methods using ground truth dynamics, red to the best MBRL algorithms, and green to the best MFRL algorithms. The results show the mean and standard deviation averaged over 4 random seeds and a window size of 5000 times-steps. "GT" indicates the model is using the ground-truth dynamics.
<table><tr><td></td><td>Pendulum</td><td>InvertedPendulum</td><td>Acrobot</td><td>CartPole</td><td>Mountain Car</td><td>Reacher</td></tr><tr><td>Random</td><td>-202.6 ± 249.3</td><td>-205.1 ± 13.6</td><td>-374.5 ± 17.1</td><td>38.4±32.5</td><td>-105.1 ± 1.8</td><td>-45.7 ± 4.8</td></tr><tr><td>ILQG</td><td>160.8 ± 29.8</td><td>-0.0±0.0</td><td>-195.5± 28.7</td><td>199.3 ± 0.6</td><td>-55.9 ± 8.3</td><td>-6.0± 2.6</td></tr><tr><td>GT-CEM</td><td>170.5 ± 35.2</td><td>-0.2 ± 0.1</td><td>13.9 ± 40.5</td><td>199.9 ± 0.1</td><td>-58.0 ± 2.9</td><td>-3.6 ± 1.2</td></tr><tr><td>GT-RS</td><td>171.5 ± 31.8</td><td>-0.0 ± 0.0</td><td>2.5 ± 39.4</td><td>200.0 ±0.0</td><td>-68.5 ± 2.2</td><td>-25.7 ± 3.5</td></tr><tr><td>RS</td><td>164.4 ± 9.1</td><td>-0.0± 0.0*</td><td>-4.9 ± 5.4</td><td>200.0 ± 0.0*</td><td>-71.3± 0.5</td><td>-27.1± 0.6</td></tr><tr><td>MB-MF</td><td>157.5 ± 13.2</td><td>-182.3 ± 24.4</td><td>-92.5 ± 15.8</td><td>199.7 ± 1.2</td><td>4.2 ± 18.5</td><td>-15.1 ± 1.7</td></tr><tr><td></td><td>167.4 ± 53.0</td><td>-20.5± 28.9</td><td>12.5 ± 29.0*</td><td>199.5 ± 3.0</td><td>-57.9± 3.6</td><td>-12.3± 5.2</td></tr><tr><td>PETS-CEM</td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>PETS-RS</td><td>167.9 ± 35.8</td><td>-12.1 ± 25.1</td><td>-71.5 ± 44.6</td><td>195.0 ± 28.0</td><td>-78.5 ± 2.1</td><td>-40.1± 6.9</td></tr><tr><td>ME-TRPO</td><td>177.3 ± 1.9*</td><td>-126.2 ± 86.6</td><td>-68.1 ±6.7</td><td>160.1 ± 69.1</td><td>-42.5 ± 26.6</td><td>-13.4 ±0.2</td></tr><tr><td>GPS</td><td>162.7 ± 7.6</td><td>-74.6 ± 97.8</td><td>-193.3 ± 11.7</td><td>14.4 ±18.6</td><td>-10.6 ± 32.1</td><td>-19.8 ± 0.9</td></tr><tr><td>PILCO</td><td>166.1 ± 23.0</td><td>-1.5 ± 1.6</td><td>-394.4 ± 1.4 -79.7± 6.6</td><td>196.1 ± 13.3</td><td>-59.0 ± 4.6 -27.6± 32.6</td><td>-13.2 ± 5.9</td></tr><tr><td>SVG</td><td>141.4 ± 62.4 171.2 ± 26.9</td><td>-183.1 ± 9.0 -0.0 ± 0.0*</td><td>-87.8 ± 12.9</td><td>82.1± 31.9 199.3 ± 2.3</td><td>-30.6± 34.8</td><td>-11.0 ± 1.0 -5.6 ± 0.8</td></tr><tr><td>MB-MPO SLBO</td><td>173.5 ± 2.5</td><td>-240.4 ± 7.2</td><td>-75.6±8.8</td><td>78.0 ± 166.6</td><td>44.1 ± 6.8</td><td>-4.1 ± 0.1*</td></tr><tr><td></td><td>163.4 ± 8.0</td><td>-40.8±21.0</td><td>-95.3±8.9</td><td>86.5±7.8</td><td>21.7± 13.1</td><td></td></tr><tr><td>PPO TRPO</td><td>166.7 ± 7.3</td><td>-27.6 ± 15.8</td><td>-147.5 ± 12.3</td><td>47.3 ± 15.7</td><td>-37.2 ± 16.4</td><td>-17.2 ± 0.9 -10.1± 0.6</td></tr><tr><td>TD3</td><td>161.4 ± 14.4</td><td>-224.5± 0.4</td><td>-64.3± 6.9</td><td>196.0 ± 3.1</td><td>-60.0 ± 1.2</td><td>-14.0 ±0.9</td></tr><tr><td>SAC</td><td>168.2 ± 9.5</td><td>-0.2 ± 0.1</td><td>-52.9 ± 2.0</td><td>199.4 ± 0.4</td><td>52.6 ± 0.6*</td><td>-6.4 ± 0.5</td></tr><tr><td></td><td>HalfCheetah</td><td>Swimmer-v0</td><td>Swimmer</td><td>Ant</td><td>Ant-ET</td><td>Walker2D</td></tr><tr><td>Random</td><td>-288.3± 65.8</td><td>1.2 ± 11.2</td><td>-9.5± 11.6</td><td>473.8± 40.8</td><td>124.6 ± 145.0</td><td></td></tr><tr><td>iLQG</td><td>2142.6 ± 137.7</td><td>47.8 ± 2.4</td><td>306.7±0.8</td><td>9739.8 ± 745.0</td><td>1506.2 ± 459.4</td><td>-2456.9± 345.3</td></tr><tr><td>GT-CEM</td><td>14777.2 ± 13964.2</td><td>111.0 ± 4.6</td><td>335.9 ± 1.1</td><td>12115.3 ± 209.7</td><td>226.0± 178.6</td><td>-1186.2 ± 126.3 7719.7 ± 486.7</td></tr><tr><td>GT-RS</td><td>815.7 ± 38.5</td><td>35.8±3.0</td><td>42.2 ±5.3</td><td>2709.1 ± 631.1</td><td>2519.0 ± 469.8</td><td>-1641.4 ± 137.6</td></tr><tr><td>RS</td><td>421.0 ± 55.2</td><td>31.1 ± 2.0</td><td>92.8±8.1</td><td>535.5± 37.0</td><td>239.9 ± 81.7</td><td></td></tr><tr><td>MB-MF</td><td>126.9 ± 72.7</td><td>51.8±30.9</td><td>284.9 ± 25.1</td><td>134.2 ± 50.4</td><td>85.7± 27.7</td><td>-2060.3 ± 228.0 -2218.1 ± 437.7</td></tr><tr><td>PETS-CEM</td><td>2795.3 ± 879.9</td><td>22.1 ± 25.2</td><td>306.3 ± 37.3</td><td>1165.5 ± 226.9</td><td>81.6 ± 145.8</td><td>260.2 ± 536.9</td></tr><tr><td>PETS-RS</td><td>966.9 ± 471.6</td><td>42.1 ± 20.2</td><td>170.1 ± 8.1</td><td>1852.1 ± 141.0*</td><td>130.0± 148.1</td><td>312.5 ± 493.4*</td></tr><tr><td>ME-TRPO</td><td>2283.7 ± 900.4</td><td>30.1± 9.7</td><td>336.3 ± 15.8*</td><td>282.2 ± 18.0</td><td>42.6± 21.1</td><td>-1609.3 ± 657.5</td></tr><tr><td>GPS</td><td>52.3 ± 41.7</td><td>14.5 ± 5.6</td><td>-35.3±8.4</td><td>445.5± 212.9</td><td>275.4 ± 309.1</td><td>-1730.8 ± 441.7</td></tr><tr><td>PILCO</td><td>-41.9 ± 267.0</td><td>-13.8 ± 16.1</td><td>-18.7±10.3</td><td>770.7 ± 153.0</td><td>N.A.</td><td>-2693.8 ± 484.4</td></tr><tr><td>SVG</td><td>336.6 ± 387.6</td><td>77.2 ± 99.0</td><td>75.2 ±85.3</td><td>377.9 ± 33.6</td><td>185.0 ± 141.6</td><td>-1430.9 ± 230.1</td></tr><tr><td>MB-MPO</td><td>3639.0 ± 1185.8</td><td>85.0 ± 98.9*</td><td>268.5 ± 125.4</td><td>705.8± 147.2</td><td>30.3± 22.3</td><td>-1545.9 ± 216.5</td></tr><tr><td>SLBO</td><td>1097.7 ± 166.4</td><td>41.6 ± 18.4</td><td>125.2± 93.2</td><td>718.1 ± 123.3</td><td>200.0 ± 40.1</td><td>-1277.7 ± 427.5</td></tr><tr><td>PPO</td><td>17.2 ± 84.4</td><td>38.0 ± 1.5</td><td>306.8±4.2</td><td>321.0 ±51.2</td><td>80.1 ± 17.3</td><td>-1893.6 ± 234.1</td></tr><tr><td>TRPO</td><td>-12.0 ± 85.5</td><td>37.9 ± 2.0</td><td>215.7± 10.4</td><td>323.3 ± 24.9</td><td>116.8 ± 47.3</td><td>-2286.3 ± 373.3</td></tr><tr><td>TD3</td><td>3614.3 ± 82.1</td><td>40.4 ± 8.3</td><td>331.1 ± 0.9</td><td>956.1 ± 66.9</td><td>259.7 ± 1.0</td><td>-73.8 ± 769.0</td></tr><tr><td>SAC</td><td>4000.7 ± 202.1*</td><td>41.2 ± 4.6</td><td>309.8 ± 4.2</td><td>506.7 ± 165.2</td><td>2012.7 ± 571.3*</td><td>-415.9 ± 588.1</td></tr><tr><td></td><td>Walker2D-ET</td><td>Hopper</td><td>Hopper-ET</td><td>SlimHumanoid</td><td>SlimHumanoid-ET</td><td>Humanoid-ET</td></tr><tr><td>Random</td><td>-2.8±4.3</td><td>-2572.7± 631.3</td><td>12.7 ± 7.8</td><td>-1172.9 ± 757.0</td><td>41.8± 47.3</td><td>50.5± 57.1</td></tr><tr><td>iLQG</td><td>229.0 ± 74.7</td><td>1157.6 ± 224.7</td><td>83.4± 21.7</td><td>13225.2 ± 1344.9</td><td>520.0 ± 240.9</td><td>255.0 ± 94.6</td></tr><tr><td>GT-CEM</td><td>254.8 ± 233.4</td><td>3232.3 ± 192.3</td><td>256.8 ± 16.3</td><td>45979.8 ± 1654.9</td><td>1242.7 ± 676.0</td><td>1236.2 ± 668.0</td></tr><tr><td>GT-RS</td><td>207.9 ± 27.2</td><td>-2467.2 ± 55.4</td><td>209.5 ± 46.8</td><td>8074.4 ± 441.1</td><td>361.5 ± 103.8</td><td>312.9 ± 167.8</td></tr><tr><td>RS</td><td>201.1 ± 10.5</td><td>-2491.5 ± 35.1</td><td>247.1 ± 6.1</td><td>-99.2 ± 388.5</td><td>332.8±13.4</td><td>295.5 ± 10.9</td></tr><tr><td>MB-MF</td><td>350.0 ± 107.6</td><td>-1047.4 ± 1098.7</td><td>926.9 ± 154.1</td><td>-1320.2 ± 735.3</td><td>809.7 ± 57.5</td><td>776.8 ± 62.9</td></tr><tr><td>PETS-CEM</td><td>-2.5 ± 6.8</td><td>1125.0 ± 679.6</td><td>129.3 ± 36.0</td><td>1472.4 ± 738.3</td><td>355.1 ± 157.1</td><td>110.8 ± 91.0</td></tr><tr><td>PETS-RS</td><td>-0.8±3.2</td><td>-1469.8 ± 224.1</td><td>205.8 ± 36.5</td><td>2055.1 ± 771.5*</td><td>320.7 ± 182.2</td><td>106.9 ± 102.6</td></tr><tr><td>ME-TRPO</td><td>-9.5± 4.6</td><td>1272.5 ± 500.9</td><td>4.9± 4.0</td><td>-154.9 ± 534.3</td><td>76.1 ±8.8</td><td>72.9 ±8.9</td></tr><tr><td>GPS</td><td>-2400.6 ± 610.8</td><td>-768.5 ± 200.9</td><td>-2303.9 ± 338.1</td><td>-592.6 ± 214.1</td><td>N.A.</td><td>N. A.</td></tr><tr><td>PILCO</td><td>N.A.</td><td>-1729.9 ± 1611.1</td><td>N.A</td><td>N.A</td><td>N.A</td><td>N.A.</td></tr><tr><td>SVG</td><td>252.4 ± 48.4</td><td>-877.9 ± 427.9</td><td>435.2 ± 163.8</td><td>1096.8 ± 791.0</td><td>1084.3 ± 77.0*</td><td>811.8 ± 241.5</td></tr><tr><td>MB-MPO</td><td>-10.3 ± 1.4</td><td>333.2 ± 1189.7</td><td>8.3±3.6</td><td>674.4± 982.2</td><td>115.5 ± 31.9</td><td>73.1 ± 23.1</td></tr><tr><td>SLBO</td><td>207.8 ± 108.7</td><td>-741.7 ± 734.1</td><td>805.7 ± 142.4</td><td>-588.9 ± 332.1</td><td>776.1 ± 252.5</td><td>1377.0 ± 150.4</td></tr><tr><td>PPO</td><td>306.1 ± 17.2</td><td>-103.8 ± 1028.0</td><td>758.0 ± 62.0</td><td>-1466.7 ± 278.5</td><td>454.3 ± 36.7</td><td>451.4 ± 39.1</td></tr><tr><td>TRPO</td><td>229.5 ± 27.1</td><td>-2100.1 ± 640.6</td><td>237.4 ± 33.5</td><td>-1140.9 ± 241.8</td><td>281.3 ± 10.9 1070.0 ± 168.3</td><td>289.8 ±5.2 147.7 ± 0.7</td></tr><tr><td>TD3 SAC</td><td>3299.7 ± 1951.5* 2216.4 ± 678.7</td><td>2245.3 ± 232.4* 726.4 ± 675.5</td><td>1057.1 ± 29.5 1815.5 ± 655.1*</td><td>1319.1 ± 1246.1 1328.4 ± 468.2</td></table>
PILCO: PILCO achieves one of the best sample efficiency in low dimentional environments such as Cartpole, Pendulum and InvertedPendulum. But it fails in most other environments with bigger episode length and observation size, being unstable across random seeds and time-consuming to train.
GPS: GPS has the best performance in Ant-ET, but cannot match the best algorithms in other environments. In the original GPS, the environment is usually 100 time-step long, while most of our environments are 200 or 1000 time-step. Also GPS assumes several separate constant initial states, while our environments sample the initial state from a distribution. The deviation of trajectories between iterations can be the reason of GPS’s performance drop.
<table><tr><td></td><td>RS</td><td>MBMF</td><td>PETS</td><td>PETS-RS</td><td>METRPO</td><td>GPS</td><td>PILCO</td><td>SVG</td><td>MB-MPO</td><td>SLBO</td><td>PPO</td><td>TRPO</td><td>TD3</td><td>SAC</td></tr><tr><td>Reacher2D</td><td>9.23</td><td>4.03</td><td>4.64</td><td>2.68</td><td>4.76</td><td>1.1</td><td>120</td><td>1.61</td><td>30.9</td><td>2.38</td><td>0.02</td><td>0.02</td><td>2.9</td><td>2.38</td></tr><tr><td>Cheetah</td><td>8.83</td><td>4.05</td><td>15.3</td><td>6.76</td><td>5.23</td><td>3.3</td><td>N.A.</td><td>1.41</td><td>57.5</td><td>4.96</td><td>0.04</td><td>0.02</td><td>4.3</td><td>2.21</td></tr><tr><td>Ant</td><td>8.2</td><td>5.25</td><td>6.5</td><td>5.01</td><td>3.46</td><td>5.1</td><td>N.A</td><td>1.49</td><td>55.2</td><td>5.46</td><td>0.07</td><td>0.05</td><td>3.6</td><td>3.15</td></tr><tr><td>Humanoid-ET</td><td>13.9</td><td>5.05</td><td>7.03</td><td>5.1</td><td>5.68</td><td>N.A.</td><td>N.A</td><td>1.92</td><td>41.4</td><td>5.5</td><td>0.05</td><td>0.04</td><td>5.37</td><td>3.35</td></tr><tr><td>Slimhumanoid-ET</td><td>9.5</td><td>3.3</td><td>4.76</td><td>3.35</td><td>2.58</td><td>N.A</td><td>N.A.</td><td>1.06</td><td>41.5</td><td>6.86</td><td>0.03</td><td>0.03</td><td>3.13</td><td>4.05</td></tr><tr><td>Slimhumanoid</td><td>11.73</td><td>4.8</td><td>6.6</td><td>5.06</td><td>2.36</td><td>17.24</td><td>N.A</td><td>1.05</td><td>41.6</td><td>6.8</td><td>0.04</td><td>0.03</td><td>3.95</td><td>3.15</td></tr><tr><td>Real-time testing</td><td>X</td><td>√</td><td>X</td><td>X</td><td>√</td><td>√</td><td>√</td><td>√</td><td>√</td><td>√</td><td>√</td><td>√</td><td>√</td><td>√</td></tr><tr><td>CPU/GPU used</td><td>20/0</td><td>20/0</td><td>4/1</td><td>4/1</td><td>4/1</td><td>5/0</td><td>4/1</td><td>2/0</td><td>8/0</td><td>12/0</td><td>5/0</td><td>5/0</td><td>12/0</td><td>12/0</td></tr></table>
Table 2: Wall-clock time in hours for each algorithm trained for 200k time-steps.
MF baselines: SAC and TD3 are two very powerful baselines with very stable performance across different environments. In general model-free and model-based methods are two almost evenly matched rivals when trained for 200,000 time-steps.
MB with Ground-truth Dynamics: Algorithms with ground-truth dynamics can solve the majority of the tasks, except for some of the tasks such as MountainCar. With the increasing complexity of the environments, shooting methods gradually have much better performance than the policy search methods such as iLQG, whose linear quadratic assumption is not a good approximation anymore. Early termination cause a lot of troubles for model-based algorithms, both with and without ground-truth dynamics, which is further studied in section 4.7.
# 4.4 NOISY ENVIRONMENTS
In this section, we study the robustness of each algorithm with respect to the noise added to the observation and actions. Specifically, we added Gaussian white noise to the observations and actions with standard deviation $\sigma _ { o }$ and $\sigma _ { a }$ , respectively. In Table 3 we show the results for the HalfCheetah environment, for the full results we refer the reader to appendix D.
<table><tr><td>HalfCheetah</td><td>iLQG</td><td>GT-PETS</td><td>RS</td><td>PETS</td><td>ME-TRPO</td><td>SVG</td><td>MB-MPO</td><td>SLBO</td><td>GT-RS</td><td>PETS-RS</td><td>SAC</td><td>TD3</td></tr><tr><td>Original Performance</td><td>2142.6</td><td>14777.2</td><td>421</td><td>2795.3</td><td>2283.7</td><td>336.6</td><td>3639.0</td><td>1097.7</td><td>815.7</td><td>966.9</td><td>4000.7</td><td>3614.3</td></tr><tr><td>Change/σ=0.1</td><td>-2167.9</td><td>-13138.7</td><td>-274.8</td><td>-915.8</td><td>-1874.3</td><td>-336.5</td><td>-1282.6</td><td>-885.2</td><td>-809.1</td><td>-749.9</td><td>-2854</td><td>-2718.6</td></tr><tr><td>Change/σo=0.01</td><td>-1955.4</td><td>-5550.7</td><td>+2.1</td><td>-385</td><td>-886.8</td><td>-95.8</td><td>-3.5</td><td>+147.1</td><td>-322.4</td><td>-152</td><td>-131.5</td><td>-2797</td></tr><tr><td>Change/σa=0.1</td><td>-1881.4</td><td>-3292.7</td><td>+24.8</td><td>-367.8</td><td>-963.9</td><td>-173.1</td><td>-266.1</td><td>+495.5</td><td>-210.9</td><td>161.7</td><td>-470.2</td><td>642.2</td></tr><tr><td>Change/σa=0.03</td><td>-1832.5</td><td>-1616.6</td><td>+21.3</td><td>-368.1</td><td>-160.8</td><td>-314.7</td><td>+79.7</td><td>-366.6</td><td>-170</td><td>50.6</td><td>-292.6</td><td>327.5</td></tr></table>
Table 3: The relative changes of performance of each algorithm in noisy HalfCheetah environments. We use bold text to indicates a decrease of performance ${ > } 1 0 \%$ of the performance without noise.
As expected, adding noise is in general detrimental to the performance of the MBRL algorithms. ME-TRPO and SLBO are more likely to suffer from a catastrophic performance drop when compared to shooting methods such as PETS and RS, suggesting that re-planning successfully compensates for the uncertainty. On the other hand, the Dyna-style method MB-MPO presents to be very robust against noise. Due to the limited exploration in baseline, the performance is sometimes increased after adding noise that encourages exploration.
# 4.5 DYNAMICS BOTTLENECK
We further run MBRL algorithms for 1M time-steps on HalfCheetah, Walker2D, Hopper, and Ant environments to capture the asymptotic performance, as are shown in Table 4 and Figure 2. The results show that MBRL algorithms plateau at a performance level well below their model-free counterparts and themselves with ground-truth dynamics. This points out that when learning models, more data does not result in better performance. For instance, PETS’s performance plateaus after 400k time-steps at a value much lower than the performance when using the ground-truth dynamics. We also study the performance with different network capacity, as well as using linear of RBF parameterization, as summarized in Appendix G.
The following assumptions can potentially explain the dynamics bottleneck. 1) The prediction error accumulates with time, and MBRL inevitably involves prediction on unseen states. While techniques such as probabilistic ensemble were proposed to capture uncertainty, it can be seen empirically in our paper as well as in Chua et al. (2018), that prediction becomes unstable and inaccurate with time. 2) The policy and the learning of dynamics is coupled, which makes the agents more prone to performance local-minima. While exploration and off-policy learning have been studied in Bellemare et al. (2016); Dearden et al. (1999); Wiering & Schmidhuber (1998); Houthooft et al. (2016); Schaul et al. (2019); Fujimoto et al. (2018), it has been barely addressed on current model-based approaches.

Figure 2: Performance curve for each algorithm trained for 1 million time-steps.
<table><tr><td></td><td>GT-CEM</td><td>PETS-CEM</td><td>ME-TRPO</td><td>MB-MPO</td><td>SLBO</td><td>TD3</td><td>SAC</td></tr><tr><td>HalfCheetah</td><td>14777.2 ± 13964.2</td><td>2875.9 ± 1132.2</td><td>2672.7 ± 1481.6</td><td>4513.1 ± 1045.4</td><td>2041.4 ± 932.7</td><td>5072.9 ± 815.8</td><td>6095.5 ± 936.1</td></tr><tr><td>Walker2D</td><td>7719.7 ± 486.7</td><td>1931.7 ± 667.3</td><td>-2947.1 ± 640.0</td><td>-1793.7 ± 80.6</td><td>1371.7 ± 2761.7</td><td>3293.6 ± 644.4</td><td>3941.0 ± 985.3</td></tr><tr><td>Hopper</td><td>3232.3± 192.3</td><td>288.4 ± 988.2</td><td>948.0± 854.3</td><td>-495.2 ± 265.0</td><td>2963.1 ± 323.4</td><td>2745.7 ± 546.7</td><td>3020.3 ± 134.6</td></tr><tr><td>Ant</td><td>12115.3 ± 209.7</td><td>1675.0 ± 108.6</td><td>262.7 ± 36.5</td><td>810.8± 240.6</td><td>513.6 ± 182.0</td><td>3073.8 ± 773.8</td><td>2989.9 ± 1182.8</td></tr></table>
Table 4: Bench-marking performance for 1 million time-steps.
# 4.6 PLANNING HORIZON DILEMMA
One of the critical choices in shooting methods is the planning horizon. In Figure 3, we show the performance of iLQG, CEM and RS, using the same number of candidate planning sequences, but with different planning horizon. We notice that increasing the planning horizon does not necessarily increase the performance, and more often instead decreases the performance. This happens both when using ground-truth dynamics and using learned dynamics. We argue that this is result of insufficient planning in a search space which increases exponentially with planning depth, i. e., the curse of dimensionality, as is also observed in Vemula et al. (2019); Hafner et al. (2018).
 Figure 3: The relative performance with different planning horizon.
However, in more complex environments such as the ones with early terminations, short planning horizon can lead to catastrophic performance drop, which we discuss in appendix I. We further experiment with the imaginary environment length in Dyna algorithms. We have similar results that increasing horizon does not necessarily help the performance, which is summarized in appendix F.
# 4.7 EARLY TERMINATION DILEMMA
Early termination, when the episode is finalized before the horizon has been reached, is a standard technique used in MFRL algorithms to prevent the agent from visiting unpromising states or damaging states for real robots (Peng et al., 2018; 2016; Merel et al., 2017; Heess et al., 2016; Brockman et al., 2016). When early termination is applied to the real environments, MBRL can correspondingly also apply early termination in the planned trajectories, or generate early terminated imaginary data. However, we find this technique hard to integrate into the existing MB algorithms. The results, shown in Table 1, indicates that early termination does in fact decrease the performance for MBRL algorithms of different types. We further experiment with addition schemes to incorporate early termination, summarized in appendix I. However none of them were successful. We argue that to perform efficient learning in complex environments, such as Humanoid, early termination is almost necessary. We leave it as an important request for research.
<table><tr><td></td><td>RS</td><td>MB-MF</td><td>PETS-CEM</td><td>PETS-RS</td><td>ME-TRPO</td><td>GPS</td><td>PILCO</td><td>SVG</td><td>MB-MPO</td><td>SLBO</td></tr><tr><td>Mean rank Median rank</td><td>5.3/10 5.5/10</td><td>5.6/10 7/10</td><td>4.1/10 4/10</td><td>5/10 5/10</td><td>5.8/10 6.5 /10</td><td>7.9/10 8.5/10</td><td>8.5/10 10/10</td><td>5.0/10 4/10</td><td>4.7 /10 4.5/10</td><td>4.1/10 3.5/10</td></tr></table>
Table 5: The ranking of the MBRL algorithms in the 18 benchmarking environments
# 5 CONCLUSIONS
In this paper, we benchmark the performance of a wide collection of existing MBRL algorithms, evaluating their sample efficiency, asymptotic performance and robustness. Through systematic evaluation and comparison, we characterize three key research challenges for future MBRL research. Across this very substantial benchmarking, there is no clear consistent best MBRL algorithm, suggesting lots of opportunities for future work bringing together the strengths of different approaches.
# REFERENCES
Yunfei Bai Steve Baker Gino van den Bergen Jeff Bingham Nicola Candussi Erin Catto Lawrence Chai Erwin Coumans Disney Animation Benjamin Ellenberger Christer Ericson Google Dirk Gregorius Marcus Hennix Jasmine Hsu MBSim Development Team Takahiro Harada Simon Hobbs John Hsu Ole Kniemeyer Jay Lee Francisco Leon lunkhound Vsevolod Klementjev Phil Knight John McCutchan Steven Peters Roman Ponomarev Nathanael Presson Gabor PUHR Arthur Shek Russel Smith Sony Jakub Stephien Marten Svanfeldt Jie Tan Pierre Terdiman Steven Thompson Tamas Umenhoffer AMD, Apple. Bullet physics sdk. https://github.com/ bulletphysics/bullet3, 2014.
Marcin Andrychowicz, Bowen Baker, Maciek Chociej, Rafal Jozefowicz, Bob McGrew, Jakub Pachocki, Arthur Petron, Matthias Plappert, Glenn Powell, Alex Ray, et al. Learning dexterous in-hand manipulation. arXiv preprint arXiv:1808.00177, 2018.
Marc Bellemare, Sriram Srinivasan, Georg Ostrovski, Tom Schaul, David Saxton, and Remi Munos. Unifying count-based exploration and intrinsic motivation. In D. D. Lee, M. Sugiyama, U. V. Luxburg, I. Guyon, and R. Garnett (eds.), Advances in Neural Information Processing Systems 29, pp. 1471–1479. Curran Associates, Inc., 2016. URL http://papers.nips.cc/paper/ 6383-unifying-count-based-exploration-and-intrinsic-motivation. pdf.
Alberto Bemporad, Manfred Morari, Vivek Dua, and Efstratios N Pistikopoulos. The explicit linear quadratic regulator for constrained systems. Automatica, 38(1):3–20, 2002.
Zdravko I Botev, Dirk P Kroese, Reuven Y Rubinstein, and Pierre L’Ecuyer. The cross-entropy method for optimization. In Handbook of statistics, volume 31, pp. 35–59. Elsevier, 2013.
Greg Brockman, Vicki Cheung, Ludwig Pettersson, Jonas Schneider, John Schulman, Jie Tang, and Wojciech Zaremba. Openai gym. arXiv preprint arXiv:1606.01540, 2016.
Yevgen Chebotar, Mrinal Kalakrishnan, Ali Yahya, Adrian Li, Stefan Schaal, and Sergey Levine. Path integral guided policy search. In 2017 IEEE international conference on robotics and automation (ICRA), pp. 3381–3388. IEEE, 2017.
Kurtland Chua, Roberto Calandra, Rowan McAllister, and Sergey Levine. Deep reinforcement learning in a handful of trials using probabilistic dynamics models. arXiv preprint arXiv:1805.12114, 2018.
Ignasi Clavera, Jonas Rothfuss, John Schulman, Yasuhiro Fujita, Tamim Asfour, and Pieter Abbeel. Model-based reinforcement learning via meta-policy optimization. CoRR, abs/1809.05214, 2018. URL http://arxiv.org/abs/1809.05214.
Pieter-Tjerk De Boer, Dirk P Kroese, Shie Mannor, and Reuven Y Rubinstein. A tutorial on the cross-entropy method. Annals of operations research, 134(1):19–67, 2005.
Richard Dearden, Nir Friedman, and David Andre. Model based bayesian exploration. In Proceedings of the Fifteenth Conference on Uncertainty in Artificial Intelligence, UAI’99, pp. 150–159, San Francisco, CA, USA, 1999. Morgan Kaufmann Publishers Inc. ISBN 1-55860-614-9. URL http://dl.acm.org/citation.cfm?id=2073796.2073814.
Marc Deisenroth and Carl E Rasmussen. Pilco: A model-based and data-efficient approach to policy search. In Proceedings of the 28th International Conference on machine learning (ICML-11), pp. 465–472, 2011.
Marc Peter Deisenroth, Dieter Fox, and Carl Edward Rasmussen. Gaussian processes for dataefficient learning in robotics and control. IEEE transactions on pattern analysis and machine intelligence, 37(2):408–423, 2015.
Jia Deng, Wei Dong, Richard Socher, Li-Jia Li, Kai Li, and Li Fei-Fei. Imagenet: A large-scale hierarchical image database. In 2009 IEEE conference on computer vision and pattern recognition, pp. 248–255. Ieee, 2009.
Yan Duan, Xi Chen, Rein Houthooft, John Schulman, and Pieter Abbeel. Benchmarking deep reinforcement learning for continuous control. In International Conference on Machine Learning, pp. 1329–1338, 2016.
Benjamin Ellenberger. Pybullet gymperium. https://github.com/benelot/ pybullet-gym, 2018.
C. Finn, M. Zhang, J. Fu, X. Tan, Z. McCarthy, E. Scharff, and S. Levine. Guided policy search code implementation, 2016a. URL http://rll.berkeley.edu/gps. Software available from rll.berkeley.edu/gps.
Chelsea Finn, Sergey Levine, and Pieter Abbeel. Guided cost learning: Deep inverse optimal control via policy optimization. In International Conference on Machine Learning, pp. 49–58, 2016b.
Chelsea Finn, Pieter Abbeel, and Sergey Levine. Model-agnostic meta-learning for fast adaptation of deep networks. CoRR, abs/1703.03400, 2017. URL http://arxiv.org/abs/1703. 03400.
Scott Fujimoto, Herke van Hoof, and David Meger. Addressing function approximation error in actor-critic methods. arXiv preprint arXiv:1802.09477, 2018.
David Ha and Jürgen Schmidhuber. Recurrent world models facilitate policy evolution. In Advances in Neural Information Processing Systems, pp. 2450–2462, 2018a.
David Ha and Jürgen Schmidhuber. World models. arXiv preprint arXiv:1803.10122, 2018b.
Tuomas Haarnoja, Aurick Zhou, Pieter Abbeel, and Sergey Levine. Soft actor-critic: Off-policy maximum entropy deep reinforcement learning with a stochastic actor. arXiv preprint arXiv:1801.01290, 2018.
Danijar Hafner, Timothy Lillicrap, Ian Fischer, Ruben Villegas, David Ha, Honglak Lee, and James Davidson. Learning latent dynamics for planning from pixels. arXiv preprint arXiv:1811.04551, 2018.
Nicolas Heess, Gregory Wayne, David Silver, Timothy Lillicrap, Tom Erez, and Yuval Tassa. Learning continuous control policies by stochastic value gradients. In Advances in Neural Information Processing Systems, pp. 2944–2952, 2015.
Nicolas Heess, Greg Wayne, Yuval Tassa, Timothy Lillicrap, Martin Riedmiller, and David Silver. Learning and transfer of modulated locomotor controllers. arXiv preprint arXiv:1610.05182, 2016.
Nicolas Heess, Srinivasan Sriram, Jay Lemmon, Josh Merel, Greg Wayne, Yuval Tassa, Tom Erez, Ziyu Wang, Ali Eslami, Martin Riedmiller, et al. Emergence of locomotion behaviours in rich environments. arXiv preprint arXiv:1707.02286, 2017.
Peter Henderson, Riashat Islam, Philip Bachman, Joelle Pineau, Doina Precup, and David Meger. Deep reinforcement learning that matters. In Thirty-Second AAAI Conference on Artificial Intelligence, 2018.
Rein Houthooft, Xi Chen, Xi Chen, Yan Duan, John Schulman, Filip De Turck, and Pieter Abbeel. Vime: Variational information maximizing exploration. In D. D. Lee, M. Sugiyama, U. V. Luxburg, I. Guyon, and R. Garnett (eds.), Advances in Neural Information Processing Systems 29, pp. 1109–1117. Curran Associates, Inc., 2016. URL http://papers.nips.cc/paper/ 6591-vime-variational-information-maximizing-exploration.pdf.
Riashat Islam, Peter Henderson, Maziar Gomrokchi, and Doina Precup. Reproducibility of benchmarked deep reinforcement learning tasks for continuous control. arXiv preprint arXiv:1708.04133, 2017.
Sanket Kamthe and Marc Peter Deisenroth. Data-efficient reinforcement learning with probabilistic model predictive control. arXiv preprint arXiv:1706.06491, 2017.
Oleg Klimov and J Schulman. Roboschool, 2017.
Philipp Koehn, Hieu Hoang, Alexandra Birch, Chris Callison-Burch, Marcello Federico, Nicola Bertoldi, Brooke Cowan, Wade Shen, Christine Moran, Richard Zens, et al. Moses: Open source toolkit for statistical machine translation. In Proceedings of the 45th annual meeting of the association for computational linguistics companion volume proceedings of the demo and poster sessions, pp. 177–180, 2007.
Thanard Kurutach, Ignasi Clavera, Yan Duan, Aviv Tamar, and Pieter Abbeel. Model-ensemble trust-region policy optimization. arXiv preprint arXiv:1802.10592, 2018.
Sergey Levine and Pieter Abbeel. Learning neural network policies with guided policy search under unknown dynamics. In Advances in Neural Information Processing Systems, pp. 1071–1079, 2014.
Sergey Levine, Nolan Wagener, and Pieter Abbeel. Learning contact-rich manipulation skills with guided policy search. In 2015 IEEE international conference on robotics and automation (ICRA), pp. 156–163. IEEE, 2015.
Timothy P Lillicrap, Jonathan J Hunt, Alexander Pritzel, Nicolas Heess, Tom Erez, Yuval Tassa, David Silver, and Daan Wierstra. Continuous control with deep reinforcement learning. arXiv preprint arXiv:1509.02971, 2015. Tsung-Yi Lin, Michael Maire, Serge Belongie, James Hays, Pietro Perona, Deva Ramanan, Piotr Dollár, and C Lawrence Zitnick. Microsoft coco: Common objects in context. In European conference on computer vision, pp. 740–755. Springer, 2014. Yuping Luo, Huazhe Xu, Yuanzhi Li, Yuandong Tian, Trevor Darrell, and Tengyu Ma. Algorithmic framework for model-based deep reinforcement learning with theoretical guarantees. ICLR, 2019. Josh Merel, Yuval Tassa, Sriram Srinivasan, Jay Lemmon, Ziyu Wang, Greg Wayne, and Nicolas Heess. Learning human behaviors from motion capture by adversarial imitation. arXiv preprint arXiv:1707.02201, 2017. Volodymyr Mnih, Koray Kavukcuoglu, David Silver, Alex Graves, Ioannis Antonoglou, Daan Wierstra, and Martin Riedmiller. Playing atari with deep reinforcement learning. arXiv preprint arXiv:1312.5602, 2013. Volodymyr Mnih, Adria Puigdomenech Badia, Mehdi Mirza, Alex Graves, Timothy Lillicrap, Tim Harley, David Silver, and Koray Kavukcuoglu. Asynchronous methods for deep reinforcement learning. In International Conference on Machine Learning, pp. 1928–1937, 2016. William H Montgomery and Sergey Levine. Guided policy search via approximate mirror descent. In Advances in Neural Information Processing Systems, pp. 4008–4016, 2016. Anusha Nagabandi, Gregory Kahn, Ronald S Fearing, and Sergey Levine. Neural network dynamics for model-based deep reinforcement learning with model-free fine-tuning. arXiv preprint arXiv:1708.02596, 2017. Vassil Panayotov, Guoguo Chen, Daniel Povey, and Sanjeev Khudanpur. Librispeech: an asr corpus based on public domain audio books. In 2015 IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP), pp. 5206–5210. IEEE, 2015. Xue Bin Peng, Glen Berseth, and Michiel Van de Panne. Terrain-adaptive locomotion skills using deep reinforcement learning. ACM Transactions on Graphics (TOG), 35(4):81, 2016. Xue Bin Peng, Pieter Abbeel, Sergey Levine, and Michiel van de Panne. Deepmimic: Example-guided deep reinforcement learning of physics-based character skills. ACM Transactions on Graphics (TOG), 37(4):143, 2018. Aravind Rajeswaran, Kendall Lowrey, Emanuel V Todorov, and Sham M Kakade. Towards generalization and simplicity in continuous control. In Advances in Neural Information Processing Systems, pp. 6553–6564, 2017. Anil V Rao. A survey of numerical methods for optimal control. Advances in the Astronautical Sciences, 135(1):497–528, 2009. Arthur George Richards. Robust constrained model predictive control. PhD thesis, Massachusetts Institute of Technology, 2005. Stéphane Ross, Geoffrey Gordon, and Drew Bagnell. A reduction of imitation learning and structured prediction to no-regret online learning. In Proceedings of the fourteenth international conference on artificial intelligence and statistics, pp. 627–635, 2011. Tom Schaul, Diana Borsa, Joseph Modayil, and Razvan Pascanu. Ray interference: a source of plateaus in deep reinforcement learning. arXiv preprint arXiv:1904.11455, 2019. John Schulman, Sergey Levine, Pieter Abbeel, Michael Jordan, and Philipp Moritz. Trust region policy optimization. In Proceedings of the 32nd International Conference on Machine Learning (ICML-15), pp. 1889–1897, 2015. John Schulman, Filip Wolski, Prafulla Dhariwal, Alec Radford, and Oleg Klimov. Proximal policy optimization algorithms. arXiv preprint arXiv:1707.06347, 2017. Richard S Sutton. Integrated architectures for learning, planning, and reacting based on approximating dynamic programming. In Machine Learning Proceedings 1990, pp. 216–224. Elsevier, 1990. Richard S Sutton. Dyna, an integrated architecture for learning, planning, and reacting. ACM SIGART Bulletin, 2(4):160–163, 1991a. Richard S Sutton. Planning by incremental dynamic programming. In Machine Learning Proceedings 1991, pp. 353–357. Elsevier, 1991b. Yuval Tassa, Tom Erez, and Emanuel Todorov. Synthesis and stabilization of complex behaviors through online trajectory optimization. In Intelligent Robots and Systems (IROS), 2012 IEEE/RSJ International Conference on, pp. 4906–4913. IEEE, 2012. Yuval Tassa, Yotam Doron, Alistair Muldal, Tom Erez, Yazhe Li, Diego de Las Casas, David Budden, Abbas Abdolmaleki, Josh Merel, Andrew Lefrancq, et al. Deepmind control suite. arXiv preprint arXiv:1801.00690, 2018. Anirudh Vemula, Wen Sun, and J Andrew Bagnell. Contrasting exploration in parameter and action space: A zeroth-order optimization perspective. arXiv preprint arXiv:1901.11503, 2019. Michael Waskom. Seaborn: statistical data visualization. http://seaborn.pydata.org/, 2010. Accessed: 2010-09-30. Marco Wiering and Jürgen Schmidhuber. Efficient model-based exploration. In PROCEEDINGS OF THE SIXTH INTERNATIONAL CONFERENCE ON SIMULATION OF ADAPTIVE BEHAVIOR: FROM ANIMALS TO ANIMATS 6, pp. 223–228. MIT Press/Bradford Books, 1998. Tianhao Zhang, Gregory Kahn, Sergey Levine, and Pieter Abbeel. Learning deep control policies for autonomous aerial vehicles with mpc-guided policy search. In 2016 IEEE international conference on robotics and automation (ICRA), pp. 528–535. IEEE, 2016.
# A ENVIRONMENT OVERVIEW
We provide an overview of the environments in this section. Table 6 shows the dimensionality and horizon lengths of those environments, and Table 7 specifies their reward functions.
<table><tr><td>Environment Name</td><td>Observation Space Dimension</td><td>Action Space Dimension</td><td>Horizon</td></tr><tr><td>Acrobot</td><td>6</td><td>1</td><td>200</td></tr><tr><td>Pendulum</td><td>3</td><td>1</td><td>200</td></tr><tr><td>InvertedPendulum</td><td>4</td><td>1</td><td>100</td></tr><tr><td>CartPole</td><td>4</td><td>1</td><td>200</td></tr><tr><td>MountainCar</td><td>2</td><td>1</td><td>200</td></tr><tr><td>Reacher2D (Reacher)</td><td>11</td><td>2</td><td>50</td></tr><tr><td>HalfCheetah</td><td>17</td><td>6</td><td>1000</td></tr><tr><td>Swimmer-v0</td><td>8</td><td>2</td><td>1000</td></tr><tr><td>Swimmer</td><td>8</td><td>2</td><td>1000</td></tr><tr><td>Hopper</td><td>11</td><td>3</td><td>1000</td></tr><tr><td>Ant</td><td>28</td><td>8</td><td>1000</td></tr><tr><td>Walker 2D</td><td>17</td><td>6</td><td>1000</td></tr><tr><td>Humanoid</td><td>376</td><td>17</td><td>1000</td></tr><tr><td>SlimHumanoid</td><td>45</td><td>17</td><td>1000</td></tr></table>
Table 6: Dimensions of observation and action space, and horizon length for most of the environments used in the experiments.
<table><tr><td>Environment Name</td><td>Reward Function Rt</td></tr><tr><td>Acrobot</td><td>- cOs01,t -COs (01,t +02,t)</td></tr><tr><td>Pendulum</td><td>-cos0t -0.1sin0t -0.10²-0.001a²</td></tr><tr><td>InvertedPendulum</td><td>-0</td></tr><tr><td>CartPole</td><td>cos 0t-0.01x²</td></tr><tr><td>MountainCar</td><td>positiont</td></tr><tr><td>Reacher2D (Reacher)</td><td>-distancet - |latll2</td></tr><tr><td>HalfCheetah</td><td>xt-0.1/|atll2</td></tr><tr><td>Swimmer-v0</td><td>xt -0.0001||atll2</td></tr><tr><td>Swimmer</td><td>xt-0.0001||atll2</td></tr><tr><td>Hopper</td><td>xt-0.1|/atl²-3.0 × (zt -1.3)²</td></tr><tr><td>Ant</td><td>xt-0.1/|atll2-3.0 × (zt -0.57)2</td></tr><tr><td>Walker2D</td><td>xt-0.1//atll²-3.0 × (zt -1.3)²</td></tr><tr><td>Humanoid</td><td>50/3 × xt-0.1|latll²- 5e-6 ×impact + 5 × bool(1.0 <= zt <= 2.0</td></tr><tr><td>SlimHumanoid</td><td>50/3 × 𝑥t -0.1||atl/²+ 5 × bool(1.0<= zt <= 2.0)</td></tr></table>
Table 7: Reward function for most of the environments used in the experiments. The tasks specified by the reward functions are discussed in further detail in Section A.1.
# A.1 ENVIRONMENT-SPECIFIC DESCRIPTIONS
In this section, we provide details about environment-specific dynamics and goals.
Acrobot The dynamical system consists of a pendulum with two links. The joint between the two links is actuated. Initially, both links point downwards. The goal is to swing up the pendulum, such that the tip of the pendulum reaches a given height. Let $\theta _ { 1 , t }$ , $\theta _ { 2 , t }$ be the joint angles of the first (with one end fixed to a hinge) and second link at time $t$ . The 6-dimensional observation at time $t$ is the tuple: $( \cos \theta _ { 1 , t } , \sin \theta _ { 1 , t } , \cos \theta _ { 2 , t } , \sin \theta _ { 2 , t } , \dot { \theta } _ { 1 , t } , \dot { \theta } _ { 2 , t } )$ . The reward is the height of the tip of the pendulum: $R _ { t } = - \cos \theta _ { 1 , t } - \cos \left( \theta _ { 1 , t } + \theta _ { 2 , t } \right)$ .
Pendulum A single-linked pendulum is fixed on the one end, with an actuator located on the joint. The goal is to keep the pendulum at the upright position. Let $\theta _ { t }$ be the joint angle at time $t$ The 3-dimensional observation at time $t$ is $( \cos \theta _ { t } , \sin \theta _ { t } , \dot { \theta } _ { t } )$ The reward penalizes the position and velocity deviation from the upright equilibrium, as well as the magnitude of the control input.
InvertedPendulum The dynamical system consists of a cart that slides on a rail, and a pole connected through an unactuated joint to the cart. The only actuator applies force on the cart along the rail. The actuator force is a real number. Let $\theta _ { t }$ be the angle of the pole away from the upright vertical position, and $x _ { t }$ be the position of the cart away from the centre of the rail at time $t$ . The 4-dimensional observation at time $t$ is $( x _ { t } , \theta _ { t } , \dot { x } _ { t } , \dot { \theta } _ { t } )$ . The reward $- \theta _ { t } ^ { 2 }$ penalizes the angular deviation from the upright position.
CartPole The dynamical system of Cart-Pole is very similar to that of the Inverted Pendulum environment. The differences are: 1) the real-valued actuator input is discretized to $- 1 , 1$ , with a threshold at zero; 2) the reward $\cos \theta _ { t } - 0 . 0 1 x _ { t } ^ { 2 }$ indicates that the goal is to make the pole stay upright, and the cart stay at the centre of the rail.
MountainCar A car is initially positioned between two “mountains", and can drive on a onedimensional track. The goal is to reach the top of the “mountain" on the right. However, the engine of the car is not strong enough for it to drive up the valley in one go, so the solution is to drive back and forth to accumulate momentum. The observation at time $t$ is the tuple $( p o s i t i o n _ { t } , v e l o c i t y _ { t } )$ , where both the position and velocity are one-dimensional, with respect to the track. The reward at time $t$ is simply positiont. Note that we use a fixed horizon, so that the agent is encouraged to reach the goal as soon as possible.
Reacher2D (or Reacher) An arm with two links is fixed at one end, and is free to move on the horizontal 2D plane. There are two actuators, located at the two joints respectively. At each episode, a target is randomly placed on the 2D plane within reach of the arm. The goal is to make the tip of the arm reach the target as fast as possible, and with the smallest possible control input. Let $\theta _ { t }$ be the two joint positions, $\pmb { x } _ { t a r g e t , t }$ be the position of the target, and ${ \mathbf { \boldsymbol { x } } } _ { t i p , t }$ be the position of the tip of the arm at time $t$ , respectively.The observation is $( \cos \theta _ { t } , \sin \theta _ { t } , { x _ { t a r g e t , t } } , \dot { \theta } _ { t } , { x _ { t i p , t } } - { x _ { t a r g e t , t } } )$ . The reward at time $t$ is $| | { \pmb x } _ { t i p , t } - { \pmb x } _ { t a r g e t , t } | | _ { 2 } ^ { 2 } - | | { \pmb a } _ { t } | | _ { 2 } ^ { 2 }$ , where the first term is the Euclidean distance between the tip and the target.
HalfCheetah Half Cheetah is a 2D robot with 7 rigid links, including 2 legs and a torso. There are 6 actuators located at 6 joints respectively. The goal is to run forward as fast as possible, while keeping control inputs small. The observation include the (angular) position and velocity of all the joints (including the root joint, whose position specifies the robot’s position in the world coordinate), except for the $x$ position of the root joint. The reward is the $x$ direction velocity plus penalty for control inputs.
Swimmer-v0 Swimmer-v0 is a 2D robot with 3 rigid links, sliding on a 2D plane. There are 2 actuators, located on the 2 joints between the links. The root joint is located at the centre of the middle link. The observation include the (angular) position and velocity of all the joints, except for the position of the two slider joints (indicating the $x$ and $y$ positions). The reward is the $x$ direction velocity plus penalty for control inputs.
Swimmer The dynamical system of Swimmer is similar to that of Swimmer-v0, except that the root joint is located at the tip of the first link (i.e. the “head" of the swimmer).
Hopper Hopper is a 2D “robot leg" with 4 rigid links, including the torso, thigh, leg and foot. There are 3 actuators, located at the three joints connecting the links. The observation include the (angular) position and velocity of all the joints, except for the $x$ position of the root joint. The reward is the $x$ direction velocity plus penalty for the distance to a target height and control input. The intended goal is to hop forward as fast as possible, while approximately maintaining the standing height, and with the smallest control input possible. We also add an alive bonus of 1 to the agents at every time-step, which is also applied to Ant, Walker2D.
Ant Ant is a 3D robot with 13 rigid links, including a torso 4 legs. There are 8 actuators, 2 for each leg, located at the joints. The observation include the (angular) position and velocity of all the joints, except for the $x$ and $y$ positions of the root joint. The reward is the $x$ direction velocity plus penalty for the distance to a target height and control input. The intended goal is to go forward, while approximately maintaining the normal standing height, and with the smallest control input possible.
Walker2D Walker 2D is a planar robot, consisting of 7 rigid links, including a torso and 2 legs. There are 6 actuators, 3 for each leg. The observation include the (angular) position and velocity of all the joints, except for the $x$ position of the root joint. The reward is the $x$ direction velocity plus penalty for the distance to a target height and control input. The intended goal is to walk forward as fast as possible, while approximately maintaining the standing height, and with the smallest control input possible.
Humanoid Humanoid is a 3D human shaped robot consisting of 13 rigid links. There are 17 actuators, located at the humanoid’s abdomen, hips, knees, shoulders and elbows. The observation space include the joint (angular) positions and velocities, centre of mass based inertia, velocity, external force, and actuator force. The reward is the scaled $x$ direction velocity, plus penalty for control input, impact (external force) and undesired height.
SlimHumanoid The dynamical system of Slim Humanoid is similar to that of Humanoid, except that the observation is simply the joint positions and velocities, without the center of mass based quantities, external force and actuator force. Also, the reward no longer penalizes the impact (external force).
# B HYPER-PARAMETER SEARCH AND ENGINEERING DETAILS
In this section, we provide a more detailed description of the hyper-parameters we search for each algorithm. Note that we select the best hyper-parameter combination for each algorithm, but we still provide a reference hyper-parameter combination that is generally good for all environments.
# B.1 ILQG
For iLQG algorithm, the hyper-parameters searched are summarized in 8. While the recommended hyper-parameters usually have the best performance, they can result in more computation resources needed. In the following sections, number of planning trajectory is also refereed as search population size.
<table><tr><td>Hyper-parameter</td><td>Value Tried</td><td>Recommended Value</td></tr><tr><td>planning horizon</td><td>10,20,30,50,100</td><td>20</td></tr><tr><td>maxlinesearch backtrack</td><td>1,5,10, 15,20</td><td>10</td></tr><tr><td>number iLQG update per time-step</td><td>1,5,10,20</td><td>10</td></tr><tr><td>number of planning trajectory</td><td>1, 2,..., 10, 20</td><td>10</td></tr></table>
Table 8: Hyper-parameter grid search options for iLQG.
# B.2 GROUND-TRUTH CEM AND GROUND-TRUTH RS
For the CEM and RS with ground-truth dynamics, we search only with different planning horizon, search population size. which include 10, 20, 30, 40, 50, 60, 70, 80, 90, 100. As also mentioned in planning horizon dilemma in section 4.6, the best planning horizon is usually 20 to 30.
# B.3 RS, PETS AND PETS-RS
We mention that in Nagabandi et al. (2017), RS has very different hyper-parameter sets from the RS studied in PETS-RS Chua et al. (2018). The search of hyper-parameters for RS is the same for note that for the dynamics-propagation combination, we choose PE-E not because of having the best performance. PE-E is among the best models, with comparable performance to other combinations such as PE-DS, PE-TS1, PE-TSinf. However PE-E is very computation efficient compared to other variants. For example, PE-DS on PETS-CEM costs 68 hours for one random seed for HalfCheetah with planning horizon of 30 to train for 200,000 time-steps. While PE-E usually only takes about 5 hours, and is suitable for research. The best models for HalfCheetah uses planning horizon of 100, and takes about 15 hours.
<table><tr><td>Hyper-parameter</td><td>Value Tried</td><td>Recommended Value</td></tr><tr><td>planning horizon</td><td>10,20.,30,...,90,100</td><td>30</td></tr><tr><td>search population size</td><td>500,1000,2000</td><td>1000</td></tr></table>
Table 9: Hyper-parameter grid search options for RS, CEM using ground-truth dynamics.
RS using ground-truth dynamics as illustrated in the Table 9. The PETS and PETS is searched with the hyper-parameters in Table 10. For simpler environments, it is usually better to use a planning horizon of 30. For environments such as Walker2D and Hopper, 100 is the best planning horizon. We
<table><tr><td>Hyper-parameter</td><td>Value Tried</td><td>Recommended Value</td></tr><tr><td>planning horizon</td><td>10,30,50,60,70,80,90,100</td><td>30/100</td></tr><tr><td rowspan="2">search population size elite size</td><td>50,100,500,1000,2000</td><td>500</td></tr><tr><td>50,100,150</td><td>50</td></tr><tr><td>PETS combination</td><td>D-E,DE-E,PE-E,PE-TSinf,PE-TS1,PE-DS</td><td>PE-E</td></tr></table>
Table 10: Hyper-parameter grid search options for RS.
We also note that with some trivial pre-processing of the observation function, such as using sin and cos functions to the angle observation, the performance can be much better for PETS. We include the performance on the pre-processed task provided in the original PETS paper Chua et al. (2018), and compare it with the performance on the provided task in the benchmark in Figure 4. We note that for the modified environments in Chua et al. (2018), the performance can reach more than 10000 for 200k time-steps.
 Figure 4: The performance of HalfCheetah from our benchmark, and the HalfCheetah from the PETS paper Chua et al. (2018), which we refer to as "Modified". We also include the performance of PETS-CEM and PETS-RS using different dynamics-propagation combination on the modified HalfCheetah from Chua et al. (2018).
In the benchmark results in the main paper, PETS-RS uses the search scheme in Table 10, except for it does not have hyper-parameters of elite size.
# B.4 MBMF
Originally MBMF was designed to run for 1 million time-steps Nagabandi et al. (2017). Therefore, to accommodate the algorithm with 200,000 time-steps, we perform the search in Table 11.
<table><tr><td>Hyper-parameter</td><td>Value Tried</td><td>Recommended Value</td></tr><tr><td rowspan="3">trust region method search population size planning horizon</td><td>TRPO,PPO</td><td>PPO</td></tr><tr><td>1000,5000,2000</td><td>5000</td></tr><tr><td>10,20,30</td><td>20</td></tr><tr><td rowspan="3">time-steps per iteration model based time-steps</td><td>1000,2000, 5000</td><td>1000</td></tr><tr><td>5000,7000,10000</td><td>7000</td></tr><tr><td>100,300, 500</td><td>300</td></tr></table>
Table 11: Hyper-parameter grid search options for MBMF.
# B.5 METRPO AND SLBO
For METRPO and SLBO, we search for the following hyper-parameters. We note that for environments with episode length of 100 or 200, we always use the same length for imaginary episodes. We also refer to Appendix F for more details.
<table><tr><td>Hyper-parameter</td><td>Value Tried</td><td>Recommended Value</td></tr><tr><td>imaginary episode length</td><td>1000,500,200,100</td><td>1000</td></tr><tr><td>TRPO iterations</td><td>1,10, 20,30, 40</td><td>20/40</td></tr><tr><td>network ensembles</td><td>1,5,10, 20</td><td>5</td></tr><tr><td>Terminate imaginary episode</td><td>True,False</td><td>False</td></tr></table>
Table 12: Hyper-parameter grid search options for METRPO and SLBO.
# B.6 GPS
The GPS is based on the code-base Finn et al. (2016a). We note that in the original code-base, the agent samples the initial state from several separate conditions. For each condition, there is not randomness of the initial state. However, in our bench-marking environments, the initial state is sample from a Gaussian distribution, which is essentially making the environments harder to solve.
<table><tr><td>Hyper-parameter</td><td>Value Tried</td><td>Recommended Value</td></tr><tr><td>time-step per iteration</td><td>1000,5000,10000</td><td>5000</td></tr><tr><td>kl step</td><td>0.5, 1.0, 2.0, 0.5</td><td>1.0</td></tr><tr><td>dynamics Gaussian mixture model clusters</td><td>5,10,20,30</td><td>20</td></tr><tr><td>policy Gaussian mixture model clusters</td><td>10,20</td><td>20</td></tr></table>
Table 13: Hyper-parameter grid search options for GPS.
# B.7 PILCO
For PILCO, we search for the following hyper-parameter in Table 14. We note that PILCO is very unstable across random seeds. Also, it is quite common for PILCO algorithms to add additional penalty in existing code-bases using human priors. We argue that it is unfair to other algorithms and we remove any additional reward functions. Also, for PILCO to train for 200,000 time-steps, we have to use a data-set to increase training efficiency.
# B.8 SVG
For SVG, we reproduce the variant of SVG-1 with experience replay, which is claimed in Heess et al. (2015).
Table 14: Hyper-parameter grid search options for PILCO.
<table><tr><td>Hyper-parameter</td><td>Value Tried</td><td>Recommended Value</td></tr><tr><td rowspan="2">Optimizing Horizon episode per iteration data-set size</td><td>30,100,200,adaptive</td><td>100 or 30</td></tr><tr><td>1,2,4 200,1000,2000,20000,40000,10000</td><td>1 200 or 1000</td></tr></table>
<table><tr><td>Hyper-parameter</td><td>Value Tried</td><td>Recommended Value</td></tr><tr><td>SVG learning rate</td><td>0.00003,0.0001, 0.0003,0.001</td><td>0.0001</td></tr><tr><td rowspan="3">data buffer size KL penalty</td><td>25000</td><td>25000</td></tr><tr><td>0.0003, 0.001, 0.003</td><td>0.001</td></tr><tr><td></td><td></td></tr></table>
Table 15: Hyper-parameter grid search options for SVG.
# B.9 MB-MPO
In this algorithm, we use most the hyper-parameters in the original paper Clavera et al. (2018), except in the ones the algorithm is more sensitive to.
<table><tr><td>Hyper-parameter</td><td>Value Tried</td><td>Recommended Value</td></tr><tr><td>inner learning rate</td><td>0.0005, 0.001, 0.01</td><td>0.0005</td></tr><tr><td>rollouts per task</td><td>10,20,30</td><td>20</td></tr><tr><td>MAML iterations</td><td>30,50,75</td><td>50</td></tr></table>
Table 16: Hyper-parameter grid search options for MB-MPO.
# B.10 MODEL-FREE BASELINES
For PPO and TRPO, we search for different time-steps samples in one iteration. For SAC and TD3, we use the default values from Haarnoja et al. (2018) and Fujimoto et al. (2018) respectively.
<table><tr><td>Hyper-parameter</td><td>Value Tried</td><td>|Recommended Value</td></tr><tr><td></td><td>time-steps per iteration丨1000,2000,5000,20000</td><td>2000</td></tr></table>
Table 17: Hyper-parameter grid search options for model-free algorithms.
 Figure 5: Performance curve for MBRL algorithms. There are still 3 more figures in a continued Figure 6.
In this appendix section, we include all the curves of every algorithms in Figure 5 and Figure 6. Some of the GPS curves and PILCO curves are not shown in the figures. We note that this is because their reward scale is sometimes very different from other algorithms.
 Figure 6: (Continued) Performance curve for MBRL algorithms.
<table><tr><td></td><td>RS</td><td>MBMF</td><td>PETS</td><td>PETS-RS</td><td>METRPO</td><td>GPS</td><td>PILCO</td><td>SVG</td><td>MB-MPO</td><td>SLBO</td><td></td><td>PPO</td><td>TRPO</td><td>TD3</td><td>SAC</td></tr><tr><td>Average</td><td>10.23</td><td></td><td>4.41</td><td>7.47</td><td>4.66</td><td>4.01</td><td>6.68</td><td>120</td><td>1.42</td><td>44.68</td><td>5.32</td><td>0.04</td><td>0.031</td><td>3.87</td><td>3.04</td></tr><tr><td>Standard deviation</td><td>2.16</td><td>0.74</td><td>3.96</td><td>1.45</td><td></td><td>1.40</td><td>7.22</td><td>N.A.</td><td>0.33</td><td>9.95</td><td>1.63</td><td>0.0172</td><td>0.0116</td><td>0.89</td><td>0.67</td></tr></table>
Table 18: Wall-clock time in hours averaged for each algorithm trained for 200k time-steps from the original Table 2.
In addition to Table 4, we also have the performance of SVG trained for 1 million time-steps. For the environments of HalfCheetah, Ant, Walker2D and Hopper, the performance is respectively 578.7 239.1, 472.0 48.1, -1168.2 537.2 and $- 7 5 3 . 4 { \pm } 5 8 0 . 8 $ .
# D NOISY ENVIRONMENTS
In this appendix section, we provide more details of the performance with noise for each algorithm. In Figure 7 and Figure 8, we show the curves of different algorithms, and in Table 19 and Table 20 we show the performance numbers at the end the of training. The pink color indicates a decrease of performance, while the green color indicates a increase of performance, and black color indicates a almost the same performance.
<table><tr><td></td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>Cheetah</td><td rowspan=1 colspan=1>Cheetah,σ。= 0.1</td><td rowspan=1 colspan=1>Cheetah,σ。= 0.01</td><td rowspan=1 colspan=1>Cheetah,σ= 0.1</td><td rowspan=1 colspan=1>Cheetah,σa= 0.03</td></tr><tr><td></td><td rowspan=2 colspan=1>iLQRGT-PETS</td><td rowspan=1 colspan=1>2142.6 ± 137.7</td><td rowspan=1 colspan=1>-25.3 ± 127.5</td><td rowspan=1 colspan=1>187.2 ± 102.9</td><td rowspan=1 colspan=1>261.2 ± 106.8</td><td rowspan=1 colspan=1>310.1 ± 112.6</td></tr><tr><td></td><td rowspan=1 colspan=1>14777.2 ± 13964.2</td><td rowspan=1 colspan=1>1638.5 ± 188.5</td><td rowspan=1 colspan=1>9226.5 ± 8893.4</td><td rowspan=1 colspan=1>11484.5 ± 12264.7</td><td rowspan=1 colspan=1>13160.6 ± 13642.6</td></tr><tr><td></td><td rowspan=1 colspan=1>GT-RS</td><td rowspan=1 colspan=1>815.7 ± 38.5</td><td rowspan=1 colspan=1>6.6 ± 52.5</td><td rowspan=1 colspan=1>493.3 ± 38.3</td><td rowspan=1 colspan=1>604.8 ± 42.7</td><td rowspan=1 colspan=1>645.7 ± 39.6</td></tr><tr><td></td><td rowspan=1 colspan=1>RS</td><td rowspan=1 colspan=1>421.0 ± 55.2</td><td rowspan=1 colspan=1>146.2 ± 19.9</td><td rowspan=1 colspan=1>423.1 ± 28.7</td><td rowspan=1 colspan=1>445.8 ± 19.2</td><td rowspan=1 colspan=1>442.3 ± 26.0</td></tr><tr><td></td><td rowspan=1 colspan=1>MB-MF</td><td rowspan=1 colspan=1>126.9 ± 72.7</td><td rowspan=1 colspan=1>146.1 ± 87.8</td><td rowspan=1 colspan=1>232.1 ± 122.0</td><td rowspan=1 colspan=1>184.0 ± 148.9</td><td rowspan=1 colspan=1>257.0 ± 96.6</td></tr><tr><td></td><td rowspan=1 colspan=1>PETS</td><td rowspan=1 colspan=1>2795.3 ± 879.9</td><td rowspan=1 colspan=1>1879.5 ± 801.5</td><td rowspan=1 colspan=1>2410.3 ± 844.0</td><td rowspan=1 colspan=1>2427.5 ± 674.1</td><td rowspan=1 colspan=1>2427.2 ± 1118.6</td></tr><tr><td></td><td rowspan=1 colspan=1>PETS-RS</td><td rowspan=1 colspan=1>966.9 ± 471.6</td><td rowspan=1 colspan=1>217.0 ± 193.4</td><td rowspan=1 colspan=1>814.9 ± 678.6</td><td rowspan=1 colspan=1>1128.6 ± 674.2</td><td rowspan=1 colspan=1>1017.5 ± 734.9</td></tr><tr><td></td><td rowspan=1 colspan=1>ME-TRPO</td><td rowspan=1 colspan=1>2283.7 ± 900.4</td><td rowspan=1 colspan=1>409.4 ± 834.2</td><td rowspan=1 colspan=1>1396.9 ± 834.8</td><td rowspan=1 colspan=1>1319.8 ± 698.0</td><td rowspan=1 colspan=1>2122.9 ± 889.1</td></tr><tr><td></td><td rowspan=2 colspan=1>GPSPILCO</td><td rowspan=2 colspan=1>52.3 ± 41.7-41.9 ± 267.0</td><td rowspan=1 colspan=1>-6.8 ± 13.6</td><td rowspan=1 colspan=1>175.2 ± 169.4</td><td rowspan=1 colspan=1>41.6 ± 45.7</td><td rowspan=1 colspan=1>94.0 ± 57.0</td></tr><tr><td></td><td rowspan=1 colspan=1>-282.0 ± 258.4</td><td rowspan=1 colspan=1>-275.4 ± 164.6</td><td rowspan=1 colspan=1>-175.6 ± 284.1</td><td rowspan=1 colspan=1>-260.8 ± 290.3</td></tr><tr><td></td><td rowspan=1 colspan=1>SVG</td><td rowspan=1 colspan=1>336.6 ± 387.6</td><td rowspan=1 colspan=1>0.1 ± 271.3</td><td rowspan=1 colspan=1>240.8 ± 236.6</td><td rowspan=1 colspan=1>163.5 ± 338.6</td><td rowspan=1 colspan=1>21.9 ± 81.0</td></tr><tr><td></td><td rowspan=1 colspan=1>MB-MPO</td><td rowspan=1 colspan=1>3639.0±1185.8</td><td rowspan=1 colspan=1>2356.4 ± 734.4</td><td rowspan=1 colspan=1>3635.5 ± 1486.8</td><td rowspan=1 colspan=1>3372.9 ± 1373</td><td rowspan=1 colspan=1>3718.7 ± 922.3</td></tr><tr><td></td><td rowspan=1 colspan=1>SLBO</td><td rowspan=1 colspan=1>1097.7 ± 166.4</td><td rowspan=1 colspan=1>212.5 ± 279.6</td><td rowspan=1 colspan=1>1244.8 ± 604.0</td><td rowspan=1 colspan=1>1593.2 ± 265.0</td><td rowspan=1 colspan=1>731.1 ± 215.8</td></tr><tr><td></td><td rowspan=1 colspan=1>PPO</td><td rowspan=1 colspan=1>17.2 ± 84.4</td><td rowspan=1 colspan=1>-113.3 ± 92.8</td><td rowspan=1 colspan=1>-83.1 ± 117.7</td><td rowspan=1 colspan=1>-28.0 ± 54.1</td><td rowspan=1 colspan=1>-35.5 ± 87.8</td></tr><tr><td rowspan=3 colspan=2>TRPOTD3SAC</td><td rowspan=1 colspan=1>TRPO</td><td rowspan=1 colspan=1>-12.0 ± 85.5</td><td rowspan=1 colspan=1>-146.0 ± 67.4</td><td rowspan=1 colspan=1>9.4 ± 57.6</td><td rowspan=1 colspan=1>-32.7 ± 110.9</td></tr><tr><td rowspan=1 colspan=1>3614.3 ± 82.1</td><td rowspan=1 colspan=1>895.7 ± 61.6</td><td rowspan=1 colspan=1>817.3 ± 11.0</td><td rowspan=1 colspan=1>4256.5 ± 117.4</td><td rowspan=1 colspan=1>3941.8 ± 61.3</td></tr><tr><td rowspan=1 colspan=1>4000.7 ± 202.1</td><td rowspan=1 colspan=1>1146.7 ± 67.9</td><td rowspan=1 colspan=1>3869.2 ± 88.2</td><td rowspan=1 colspan=1>3530.5 ± 67.8</td><td rowspan=1 colspan=1>3708.1 ± 96.2</td></tr></table>
Table 19: The performance of each algorithm in noisy HalfCheetah (referred to in short hand as “Cheetah") environments. The green and red colors indicate increase and decrease in performance, respectively.
# E PLANNING HORIZON DILEMMA GRID SEARCH
We note that we also perform the dilemma search with different population size with learnt PETSCEM. We experiment both with the HalfCheetah in our benchmarking environments, as well as the environments from Chua et al. (2018), whose observation is further pre-processed. It can be seen from the figure that, planning horizon dilemma exists with different population size. We also show that observation pre-processing can affect the performance by a large margin.
 Figure 7: The performance curve for algorithms with noise. We represent the noise standard deviation with "O" and "A" respectively for the noise added to the observation and action space.
# F PLANNING HORIZON DILEMMA IN DYNA ALGORITHMS
In this section, we study how the environment length and imaginary environment length (or planning horizon) affect the performance. More specifically, we test with HalfCheetah and Ant, using different environment length form [100, 200, 500, 1000]. For the planning horizon, besides the matching
 Figure 8: (Continued) The performance curve for algorithms with noise. We represent the noise standard deviation with "O" and "A" respectively for the noise added to the observation and action space.
length, we also test all the length from [100, 200, 500, 800, 1000]. The figures are shown in Figure 10, and the tables are shown in Table 21.
Note that we also include planning horizon longer than the actual environment length for reference. For example, for the Ant with 100 environment length, we also include results using 200, 500, 800,
<table><tr><td></td><td>Pendulum</td><td>Pendulum,σ= 0.1</td><td>Pendulum,σ。= 0.01</td><td>Cart-Pole</td><td>Cart-Pole,σ= 0.1</td><td>Cart-Pole,σ= 0.01</td></tr><tr><td>iLQR</td><td>160.8 ± 29.8</td><td>-357.9 ± 251.9</td><td>-2.2 ± 166.5</td><td>200.3± 0.6</td><td>197.8 ± 2.9</td><td>200.4 ± 0.7</td></tr><tr><td>GT-PETS</td><td>170.5 ± 35.2</td><td>171.4 ± 26.2</td><td>157.3 ± 66.3</td><td>200.9 ±0.1</td><td>199.5 ± 1.2</td><td>200.9 ± 0.1</td></tr><tr><td>GT-RS</td><td>171.5 ± 31.8</td><td>125.2 ± 40.3</td><td>157.8 ± 39.1</td><td>201.0 ± 0.0</td><td>200.2 ± 0.3</td><td>201.0±0.0</td></tr><tr><td>RS</td><td>164.4 ± 9.1</td><td>154.5 ± 12.9</td><td>160.1 ± 6.7</td><td>201.0 ± 0.0</td><td>197.7 ± 4.5</td><td>200.9 ±0.0</td></tr><tr><td>MB-MF</td><td>157.5 ± 13.2</td><td>162.8 ± 14.7</td><td>165.9 ± 8.5</td><td>199.7 ± 1.2</td><td>152.3 ± 48.3</td><td>137.9 ± 48.5</td></tr><tr><td>PETS</td><td>167.4 ± 53.0</td><td>174.7 ± 27.8</td><td>166.7 ± 52.0</td><td>199.5 ± 3.0</td><td>156.6 ± 50.3</td><td>196.1 ± 5.1</td></tr><tr><td>PETS-RS</td><td>167.9 ± 35.8</td><td>148.0 ± 58.6</td><td>113.6 ± 124.1</td><td>195.0 ± 28.0</td><td>192.3 ± 20.6</td><td>200.8 ± 0.2</td></tr><tr><td>ME-TRPO</td><td>177.3 ± 1.9</td><td>173.3 ± 3.2</td><td>173.7 ± 4.8</td><td>160.1 ± 69.1</td><td>174.9 ± 21.9</td><td>165.9 ± 58.5</td></tr><tr><td>GPS</td><td>162.7 ± 7.6</td><td>162.2 ± 4.5</td><td>168.9 ± 6.8</td><td>14.4 ± 18.6</td><td>-479.8 ± 859.7</td><td>-22.7 ± 53.8</td></tr><tr><td>PILCO</td><td>-132.6 ± 410.1</td><td>-211.6 ± 272.1</td><td>168.9 ± 30.5</td><td>-1.9 ± 155.9</td><td>139.9 ± 54.8</td><td>-2060.1 ± 14.9</td></tr><tr><td>SVG</td><td>141.4 ± 62.4</td><td>86.7 ± 34.6</td><td>78.8 ± 73.2</td><td>82.1± 31.9</td><td>119.2 ± 46.3</td><td>106.6 ± 42.0</td></tr><tr><td>MB-MPO</td><td>171.2 ± 26.9</td><td>178.4 ± 22.2</td><td>183.8 ± 19.9</td><td>199.3 ± 2.3</td><td>-65.1 ± 542.6</td><td>198.2 ± 1.8</td></tr><tr><td>SLBO</td><td>173.5± 2.5</td><td>171.1 ± 1.5</td><td>173.6 ± 2.4</td><td>78.0 ± 166.6</td><td>-691.7 ± 801.0</td><td>-141.8 ± 167.5</td></tr><tr><td>PPO</td><td>163.4 ± 8.0</td><td>165.9 ± 15.4</td><td>157.3 ± 12.6</td><td>86.5± 7.8</td><td>120.5 ± 42.9</td><td>120.3 ± 46.7</td></tr><tr><td>TRPO</td><td>166.7 ± 7.3</td><td>167.5 ± 6.7</td><td>161.1 ± 13.0</td><td>47.3 ± 15.7</td><td>-572.3 ± 368.0</td><td>-818.0 ± 288.1</td></tr><tr><td>TD3</td><td>161.4 ± 14.4</td><td>169.2 ± 13.1</td><td>170.2 ± 7.2</td><td>196.0 ± 3.1</td><td>190.4 ± 4.7</td><td>180.9 ± 8.2</td></tr><tr><td>SAC</td><td>168.2 ± 9.5</td><td>169.3 ± 5.6</td><td>169.1 ± 12.6</td><td>199.4 ± 0.4</td><td>60.9 ± 23.4</td><td>70.7 ± 11.4</td></tr></table>
Table 20: The performance of each algorithm in noisy Pendulum and Cart-Pole environments. The green and red colors indicate increase and decrease in performance, respectively. Numbers in black indicate no significant change compared to the default performance.
 Figure 9: The performance grid using different planning horizon and depth.
<table><tr><td>Environment</td><td>Original Length</td><td>Horizon=100</td><td>Horizon=200</td><td>Horizon=500</td><td>Horizon=800</td><td>Horizon=1000</td></tr><tr><td>HalfCheetah</td><td>Env-100</td><td>250.7 ± 32.1</td><td>290.3 ± 44.5</td><td>222.0 ± 34.1</td><td>253.0 ± 22.3</td><td>243.7 ± 41.7</td></tr><tr><td>HalfCheetah</td><td>Env-200</td><td>422.7 ± 143.7</td><td>675.4 ± 139.6</td><td>529.0 ± 50.0</td><td>451.4 ± 124.5</td><td>528.1 ± 74.7</td></tr><tr><td>HalfCheetah</td><td>Env-500</td><td>816.6 ± 466.0</td><td>583.4 ± 392.7</td><td>399.2 ± 250.5</td><td>986.9 ± 501.9</td><td>1062.7 ± 182.0</td></tr><tr><td>HalfCheetah</td><td>Env-1000</td><td>1312.1 ± 656.1</td><td>1514.2 ± 1001.5</td><td>1522.6 ± 456.3</td><td>1544.2 ± 1349.0</td><td>2027.5 ± 1125.5</td></tr><tr><td>Ant</td><td>Env-100</td><td>1207.8 ± 41.6</td><td>1142.2 ± 25.7</td><td>1111.9 ± 35.3</td><td>1103.7 ± 70.9</td><td>1085.5 ± 22.9</td></tr><tr><td>Ant</td><td>Env-200</td><td>1249.9 ± 127.7</td><td>1172.7 ± 36.4</td><td>1136.9 ± 32.6</td><td>1079.7 ± 37.3</td><td>1096.8 ± 18.6</td></tr><tr><td>Ant</td><td>Env-500</td><td>1397.6 ± 49.9</td><td>1319.1 ± 50.1</td><td>1423.6 ± 46.2</td><td>1287.3 ± 118.7</td><td>1331.5 ± 92.9</td></tr><tr><td>Ant</td><td>Env-1000</td><td>1666.2 ± 201.9</td><td>1646.0 ± 151.8</td><td>1680.7 ± 255.3</td><td>1530.7 ± 48.0</td><td>1647.2 ± 118.5</td></tr></table>
Table 21: The performance for different environment length and planning horizon in SLBO summarized in to a table. HalfCheetah and Ant were used in the experiments.
1000 planning horizon. As we can see, for the HalfCheetah environment, increasing planning horizon does not have obvious affects on the performance. In the Ant environments with different environment lengths, a planning horizon of 100 usually produces the best performance, instead of the longer ones.
 Figure 10: The performance curve for different environment length and planning horizon in SLBO. HalfCheetah and Ant were used in the experiments.
# G DYNAMICS NETWORK STRUCTURE AND CAPACITY
We also study how the structure or the capacity of the dynamics network affect the performance. In Figure 11, we show the performance of PETS-CEM on HalfCheetah using different networks to learn the dynamics. In Rajeswaran et al. (2017), the authors show that two simple networks, linear network and RBF network, can be used as the policy network, which obtains similar performance compared with using multi-layer perceptron (MLP) in model-free reinforcement learning. Therefore, we use linear network and RBF network to learn the dynamics in model-based reinforcement learning. We also test the performance using wider and deeper networks.
As we can see from Figure 11, in model-based RL, linear network and RBF network lead to catastrophic performance drop, indicating multi-layer neural network (MLP) is needed to learn the features to model forward dynamics. On the other hand, increasing the capacity of the MLP by making it much deeper and wider does not seem to increase the performance either.
# H NON-MUJOCO ENVIRONMENTS
To facilitate research, we also provide simulated agents that uses free physics engines other than MuJoCo. Some of the results can be shown in Figure 12. We note that these environments have different reward and observation functions from the environments benchmarked in the main paper. Therefore the results can not be used to compare with the results of the environments based on MuJoCo.
 Figure 11: The performance of PETS-CEM on HalfCheetah using different network structures.
 Figure 12: The performance curve for some of the tasks based on Roboschool or Pybullet Klimov & Schulman (2017); AMD (2014); Ellenberger (2018).
We use the best hyper-parameters for the corresponding MuJoCo environments, which indicates potential performance gain can be obtained with more careful hyper-parameter search.
# I EARLY TERMINATION
<table><tr><td></td><td>GT-CEM</td><td>GT-CEM-ET</td><td>GT-CEM-ET,T= 100</td><td>learned-CEM</td><td>learned-CEM-ET</td></tr><tr><td>Ant</td><td>12115.3 ± 209.7</td><td>8074.2 ± 210.2</td><td>4339.8±87.8</td><td>1165.5 ± 226.9</td><td>162.6 ± 142.1</td></tr><tr><td>Hopper</td><td>3232.3 ± 192.3</td><td>260.5 ± 12.2</td><td>817.8 ± 217.6</td><td>1125.0 ± 679.6</td><td>801.9 ± 194.9</td></tr><tr><td>Walker2D</td><td>7719.7 ± 486.7</td><td>105.3 ± 36.6</td><td>6310.3 ± 55.0</td><td>-493.0± 583.7</td><td>290.6 ± 113.4</td></tr></table>
Table 22: The performance of PETS algorithm with and without early termination.
In this appendix section, we include the results of several schemes we experiment with early termination. The early termination dilemma is universal in all MBRL algorithms we tested, including Dynaalgorithms, shooting algorithms, and algorithm that performs policy search with back-propagation through time. To study the problem, we majorly start with exploring shooting algorithms including RS, PETS-RS and PETS-CEM, which only relates to early termination during planning. In Table 23 and Table 24, we also include the results that the agent does not consider being terminated in planning, even if it will be terminated, which we represent as "Unaware".
<table><tr><td></td><td>GT-CEM</td><td>GT-CEM+ET-Unaware</td><td>GT-CEM-ET</td><td>GT-CEM-ET,T= 100</td></tr><tr><td>Ant</td><td>12115.3 ± 209.7</td><td>226.0 ± 178.6</td><td>8074.2 ± 210.2</td><td>4339.8± 87.8</td></tr><tr><td>Hopper</td><td>3232.3 ± 192.3</td><td>256.8 ± 16.3</td><td>260.5 ± 12.2</td><td>817.8 ± 217.6</td></tr><tr><td>Walker2D</td><td>7719.7 ± 486.7</td><td>254.8 ± 233.4</td><td>105.3 ± 36.6</td><td>6310.3 ± 55.0</td></tr></table>
Table 23: The performance using ground-truth dynamics for CEM.
For the algorithms with unknown dynamics, we specifically study PETS. We design the following schemes.
Scheme A: The episode will not be terminated and the agent does not consider being terminated during planning.
<table><tr><td></td><td>GT-RS</td><td>GT-RS-ET-Unaware</td><td>GT-RS-ET</td><td>GT-RS-ET, T = 100</td></tr><tr><td>Ant</td><td>2709.1 ± 631.1</td><td>2519.0 ± 469.8</td><td>2083.8 ± 537.2</td><td>2083.8 ± 537.2</td></tr><tr><td>Hopper</td><td>-2467.2 ± 55.4</td><td>209.5 ± 46.8</td><td>220.4 ± 54.9</td><td>289.8 ± 30.5</td></tr><tr><td>Walker2D</td><td>-1641.4 ± 137.6</td><td>207.9 ± 27.2</td><td>231.0 ± 32.4</td><td>258.3 ± 51.5</td></tr></table>
Table 24: The performance using ground-truth dynamics for RS.
<table><tr><td></td><td>Scheme A</td><td>Scheme B</td><td>Scheme D</td><td>Scheme C</td><td>Scheme E</td></tr><tr><td>Ant</td><td>1165.5 ± 226.9</td><td>81.6 ± 145.8</td><td>171.0 ± 177.3</td><td>110.8 ± 171.8</td><td>162.6 ± 142.1</td></tr><tr><td>Hopper</td><td>1125.0 ± 679.6</td><td>129.3 ± 36.0</td><td>701.7 ± 173.6</td><td>801.9 ± 194.9</td><td>684.1 ± 157.2</td></tr><tr><td>Walker2D</td><td>-493.0 ± 583.7</td><td>-2.5± 6.8</td><td>-79.1 ± 172.4</td><td>290.6 ± 113.4</td><td>142.8 ± 150.6</td></tr></table>
Table 25: The performance of PETS-CEM using learned dynamics at 200k time-steps.
<table><tr><td></td><td>Ant-ET-Unaware</td><td>Ant-ET</td><td>Ant-ET-2xPenalty</td><td>Ant-ET-5xPenalty</td><td>Ant-ET-10xPenalty</td><td>Ant-ET-20xPenalty</td><td>Ant-ET-30Penalty</td></tr><tr><td>GT-CEM</td><td>226.0± 178.6</td><td>8074.2± 210.2</td><td>1940.9 ± 2051.9</td><td>8092.3 ± 183.1</td><td>7968.8± 179.6</td><td>7969.9 ± 181.5</td><td>7601.5 ± 1140.8</td></tr><tr><td>GT-RS</td><td>2519.0 ± 469.8</td><td>2083.8 ± 537.2</td><td>2474.3 ± 636.4</td><td>2591.1 ± 447.5</td><td>2541.1 ± 827.9</td><td>2715.6± 763.2</td><td>2728.8± 855.5</td></tr><tr><td>Learnt-PETS</td><td>1165.5 ± 226.9</td><td>81.6 ± 145.8</td><td>196.4 ± 176.7</td><td>181.0± 142.8</td><td>205.5 ± 186.0</td><td>204.6 ± 202.6</td><td>188.3 ± 130.7</td></tr></table>
Table 26: The performance of agents using different alive bonus or depth penalty during planning.
Scheme B: The episode will be terminated early and the agent adds penalty in planning to avoid being terminated.
Scheme C: The episode will be terminated, and the agent pads zero rewards after the episode is terminated during planning.
Scheme D: The same as Scheme A except for that the episode will be terminated.
Scheme E: The same as Scheme C except for that agent is allow to interact with the environment for extra time-steps (100 time-steps for example) to learn dynamics around termination boundary.
The results are summarized in Table 25. We also study adding more alive bonus, i. e. more death penalty during planning, whose results are shown in Table 26.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224# INCORPORATING LONG-RANGE CONSISTENCY I NCNN-BASED TEXTURE GENERATION
Guillaume Berger & Roland Memisevic
Department of Computer Science and Operations Research University of Montreal guillaume.berger@umontreal.ca, memisevr@iro.umontreal.ca
# ABSTRACT
Gatys et al. (2015a) showed that pair-wise products of features in a convolutional network are a very effective representation of image textures. We propose a simple modification to that representation which makes it possible to incorporate longrange structure into image generation, and to render images that satisfy various symmetry constraints. We show how this can greatly improve rendering of regular textures and of images that contain other kinds of symmetric structure. We also present applications to inpainting and season transfer.
# 1 INTRODUCTION
There are currently two dominant approaches to texture synthesis: non-parametric techniques, which synthesize a texture by extracting pixels (or patches) from a reference image that are resampled for rendering (Efros & Leung, 1999; Kwatra et al., 2003), and parametric statistical models, which optimize reconstructions to match certain statistics computed on filter responses (Heeger & Bergen, 1995; Portilla & Simoncelli, 2000). Recently, the second approach has seen a significant advancement, after Gatys et al. (2015a) showed that a CNN pre-trained on an object classification task, such as ImageNet (Russakovsky et al., 2015), can be very effective at generating textures. Gatys et al. (2015a) propose to minimize with respect to the input image a loss function, that measures how well certain high-level features of a reference image are preserved. The reference image constitutes an example of the texture to be generated. The high-level features to be preserved are pair-wise products of feature responses, averaged over the whole image, referred to as the “Gramian” in that work. In Gatys et al. (2015b), the same authors show that by adding a second term to the cost, which matches the content of another image, one can render that other image in the “style” (texture) of the first. Numerous follow-up works have since then analysed and extended this approach (Ulyanov et al., 2016; Johnson et al., 2016; Ustyuzhaninov et al., 2016).
As shown in Figure 1, this method produces impressive results. However, it fails to take into account non-local structure, and consequently cannot generate results that exhibit long-range correlations in images. An example of the importance of long-range structure is the regular brick wall texture in the middle of the figure. Another example is the task of inpainting, where the goal is to fill in a missing part of an image, such that it is faithful to the non-missing pixels. Our main contribution is to introduce a way to deal with long-range structure using a simple modification to the product-based texture features. Our approach is based on imposing a “Markov-structure” on high-level features, allowing us to establish feature constraints that range across sites instead of being local. Unlike classical approaches to preserving spatial structure in image generation, such as Markov Random Fields and learning-based extensions (Roth & Black, 2005), our approach does not impose any explicit local constraints on pixels themselves. Rather, inspired by Gatys et al. (2015a), it encourages consistency to be satisfied on high-level features and on average across the whole image. We present applications to texture generation, inpainting and season transfer.
# 2 THE ARTISTIC STYLE ALGORITHM
# 2.1 SYNTHESIS PROCEDURE
Given a reference texture, $x$ , the algorithm described in Gatys et al. (2015a) permits to synthesize by optimization a new texture $\hat { x }$ similar to $x$ . To achieve this, the algorithm exploits an ImageNet
 Figure 1: Reference image (left) and generated texture (right) using the procedure described in Gatys et al. (2015a).
 Figure 2: Summary of the texture synthesis procedure described in Gatys et al. (2015a). We use a VGG-19 network Simonyan & Zisserman (2014) as the pre-trained CNN.
pre-trained model to define metrics suitable for describing textures: “Gram” matrices of feature maps, computed on top of $L$ selected layers. Formally, let $\hat { N } ^ { l }$ be the number of maps in layer $l$ of a pre-trained CNN. The corresponding Gram matrix $G ^ { \bar { l } }$ is a $N ^ { l } \times N ^ { l }$ matrix defined as:
$$G _ { i j } ^ { l } = \frac { 1 } { M ^ { l } } \sum _ { k = 1 } ^ { M ^ { l } } F _ { i k } ^ { l } F _ { j k } ^ { l } = \frac { 1 } { M ^ { l } } \langle F _ { i : } ^ { l } , F _ { j : } ^ { l } \rangle$$
where $F _ { i : } ^ { l }$ is the $i ^ { t h }$ vectorized feature map of layer $l$ , $M ^ { l }$ is the number of elements in each map of this layer, and where $\langle \cdot , \cdot \rangle$ denotes the inner product. Equation 1 makes it clear that $G ^ { l }$ captures how feature maps from layer $l$ are correlated to each other. Diagonal terms, $G _ { i i } ^ { l }$ are the squared Frobenius norm of the $i ^ { t h }$ map $\left\| F _ { i : } ^ { l } \right\| _ { F } ^ { 2 }$ , so they represent its spatially averaged energy. We will discuss the Gramians in more detail in the next paragraph. Once the Gram matrices $\{ G ^ { l } \} _ { l \in [ 1 , L ] }$ of the reference texture are computed, the synthesis procedure by Gatys et al. (2015a) amounts to constructing an image that produces Gram matrices $\{ \hat { G } ^ { l } \} _ { l \in [ 1 , L ] }$ that match the ones of the reference texture. More precisely, the following loss function is minimized with respect to the image being constructed:
$$\mathcal { L } _ { s t y l e } = \sum _ { l = 1 } ^ { L } w _ { l } \left. \hat { \boldsymbol { G } } ^ { l } - \boldsymbol { G } ^ { l } \right. _ { F } ^ { 2 } = \sum _ { l = 1 } ^ { L } w _ { l } \mathcal { L } _ { s t y l e } ^ { l }$$
where $w _ { l }$ is a normalizing constant similar to Gatys et al. (2015a).
The overall process is summarized in Figure 2. While the procedure can be computationally expensive, there have been successful attempts reported recently which reduce the generation time (Ulyanov et al., 2016; Johnson et al., 2016).
# 2.2 WHY GRAM MATRICES WORK
Feature Gram matrices are effective at representing texture, because they capture global statistics across the image due to spatial averaging. Since textures are static, averaging over positions is required and makes Gram matrices fully blind to the global arrangement of objects inside the reference image. This property permits to generate very diverse textures by just changing the starting point of the optimization. Despite averaging over positions, coherence across multiple features needs to be preserved (locally) to model visually sensible textures. This requirement is taken care of by the off-diagonal terms in the Gram matrix, which capture the co-occurence of different features at a single spatial location. Indeed, Figure 3 shows that restricting the texture representation to the squared Frobenius norm of feature maps (i.e. diagonal terms) makes distinct object-parts from the reference texture encroach on each other in the reconstruction, as local coherence is not captured by the model. Exploiting off-diagonal terms improves the quality of the reconstruction as consistency across feature maps is enforced (on average across the image).
 Figure 3: Exploiting Gram matrices of feature maps as in Gatys et al. (2015a) $( 1 ^ { s t } r o w )$ or only the squared Frobenius norm of feature maps $( 2 ^ { n d } r o w )$ for increasingly deep layers (from left to right).
The importance of local coherence can be intuitively understood in the case of linear features (or in the lowest layer of a convolutional network): when decomposing an image using Gabor-like features, local structure can be expressed as the relative offsets in the Fourier phase angles between multiple different filter responses. A sharp step-edge, for example, requires the phases of local Fourier components at different frequencies to align in a different way than a blurry edge or a ridge (Morrone & Burr, 1988; Kovesi, 1999). Also, natural images exhibit very specific phaserelationships across frequency components in general, and destroying these makes the image look unnatural (Wang & Simoncelli, 2003). The same is not true of Fourier amplitudes (represented on the diagonals of the Gramian), which play a much less important role in the visual appearance (Oppenheim & Lim, 1981). In the case of deeper representations, the situation is more complex, but it is still local co-occurrence averaged over the whole image that captures texture.
Unfortunately, average local coherence falls short of capturing long-range structure in images. Spatial consistency is hard to capture within a single filter bank, because of combinatorial effects. Indeed, since Gram matrices capture coherence at a single spatial location, every feature would have to be matched to multiple transformed versions of itself. A corollary is that every feature would have to appear in the form of multiple transformed copies of itself in order to capture spatial consistency. However, this requirement clashes with the limited number of features available in each CNN layer. One way to address this is to use higher-layer features, whose receptive fields are larger. Unfortunately, as illustrated in Figure 3, even if using layers up to pool5 whose input receptive field covers the whole image1 (first row, last column), the reconstruction remains mainly unstructured and the method fails to produce spatial regularities.
# 3 MODELING SPATIAL CO-OCCURENCES
To account for spatial structure in images, we propose encoding this structure in the feature selfsimilarity matrices themselves. To this end, we suggest that, instead of computing co-occurences between multiple features within a map, we compute co-occurences between feature maps $F ^ { l }$ and spatially transformed feature maps $T ( F ^ { l } )$ , where $T$ denotes a spatial transformation. In the simplest case, $T$ represents local translation, which amounts to measuring similarities between local features and other neighbouring features. We denote by $T _ { x , + \delta }$ the operation consisting in horizontally translating feature maps by $\delta$ pixels and define the transformed Gramian:
$$G _ { x , \delta , i j } ^ { l } = \frac { 1 } { M ^ { l } } \langle T _ { x , + \delta } \left( F _ { i : } ^ { l } \right) , T _ { x , - \delta } \left( F _ { j : } ^ { l } \right) \rangle$$
 Figure 4: Computing the shifted Gram matrix for a given layer with feature maps of width $X$ .
where $T _ { x , - \delta }$ performs a translation in the opposite direction. As illustrated in Figure 4, the transformation in practice simply amounts to removing the $\delta$ first or last columns from the raw feature maps. Therefore, the inner product now captures how features at position $( i , j )$ are correlated with features located at position $( i , j + \delta )$ in average. While Figure 4 illustrates the case where feature maps are horizontally shifted, one would typically use translations along both the $x$ -axis and the $y$ -axis. Our transformed Gramians are related to Gray-Level Co-occurrence Matrices (GLCM) (Haralick et al., 1973) which compute the unnormalized frequencies of pixel values for a given offset in an image. While GLCMs have been mainly used for analysis, some work tried to use these features for texture synthesis (Lohmann, 1995). Usually, GLCMs are defined along 4 directions: $0 ^ { \circ }$ and $9 0 °$ (i.e. horizontal and vertical offsets), as well as $4 5 ^ { \circ }$ and $1 3 5 ^ { \circ }$ (i.e. diagonal offsets). In comparison, our method does not consider diagonal offsets and captures spatial coherence on high-level features, making use of a pre-trained CNN, instead of working directly in the pixel domain.
With this definition for transformed Gram matrices, we propose defining the loss as: $\begin{array} { r l } { \mathcal { L } } & { { } = } \end{array}$ $\mathcal { L } _ { s t y l e } + \mathcal { L } _ { c c }$ , where $c c$ stands for cross-correlation. Like $\mathcal { L } _ { s t y l e }$ , $\mathcal { L } _ { c c }$ is a weighted sum of multiple losses $\mathcal { L } _ { c c , \delta } ^ { l }$ defined for several selected layers as the mean squared error between transformed Gram matrices of the reference texture and the one being constructed:
$$\mathcal { L } _ { c c , \delta } ^ { l } = \frac { 1 } { 2 } \left( \mathcal { L } _ { c c , x , \delta } ^ { l } + \mathcal { L } _ { c c , y , \delta } ^ { l } \right) = \frac { 1 } { 2 } \left( \left. \hat { G } _ { x , \delta } ^ { l } - G _ { x , \delta } ^ { l } \right. _ { F } ^ { 2 } + \left. \hat { G } _ { y , \delta } ^ { l } - G _ { y , \delta } ^ { l } \right. _ { F } ^ { 2 } \right)$$
Although this amounts to adding more terms to a representation that was already high-dimensional and overparametrized, we found that these additional terms do not hurt the diversity of generated textures. Indeed, the new loss remains blind to the global arrangement of objects. In fact, there exists a specific situation where our approach is strictly equivalent to computing Gram matrices of deeper layers: with linear activations and “one-hot” convolution kernels2, deeper layers would simply contain translated versions of lower feature maps. In that case, computing Gram matrices of deeper layers would permit to directly capture cross-correlation statistics in lower ones. Nevertheless, this situation is very unlikely when using a pretrained CNN, as the network probably learned operations more useful than simple translations during its supervised training.
While we focus on translation for most of our results, we shall discuss other types of transformation in the experiments Section.
# 4 EXPERIMENTS
In our experiments, we exploit the same normalized version of the VGG-19 network3 (Simonyan & Zisserman, 2014) as in Gatys et al. (2015a;b) and layers conv1 1, pool1, pool2, pool3, and pool4 are always used to define the standard Gram matrices. In our method, we did not use conv1 1 to define cross-correlation terms, as the large number of neurons at this stage makes the computation of Gram matrices costly. Corresponding $\delta$ values for each layer are discussed in the next paragraph.
 Figure 5: P ool2 reconstruction using different values for $\delta$ in $\mathcal { L } _ { c c , \delta } ^ { p o o l 2 }$ . $\boldsymbol { \cdot } \boldsymbol { 1 } ^ { s t }$ column): Without crosscorrelation terms. (Other columns): Using a single cross-correlation term with a fixed value $( 1 ^ { s t }$ row) or using multiple cross-correlation terms with distinct $\delta$ values $( 2 ^ { n d } r o w )$ .
Finally, our implementation4 uses Lasagne (Dieleman et al., 2015). Each image is of size $3 8 4 \times 3 8 4$ Most textures used as references in this paper were taken from textures.com and pixabay.com.
# 4.1 EXPERIMENTS WITH TRANSLATION-GRAMIANS
The $\delta$ parameter is of central importance as it dictates the range of the spatial constraints. We observed that the optimal value depends on both the considered layer in the pre-trained CNN and the reference texture, making it difficult to choose a value automatically.
For instance, Figure 5 shows generated images from the brick wall texture using only the pool2 layer with different $\delta$ configurations. The first row depicts the results when considering single values of $\delta$ only. While $\delta = 4$ or $\delta = 8$ are good choices, considering extreme long-range correlations does not help for this particular texture: a brick depends mostly on its neighbouring bricks and not the far-away ones. More precisely, a translation of more than 16 pixels in the pool2 layer makes the input receptive field move more than 64 pixels. Therefore $\delta = 1 6$ or $\delta = 3 2$ do not capture any information about neighbouring bricks. Unfortunately, this is not true for all textures, and $\delta = 1 6$ or $\delta = 3 2$ might be good choices for another image that exhibits longer structures.
Searching systematically for a $\delta$ configuration that works well with the reference texture being considered would be a tedious task: even for a very regular texture with a periodic horizontal (or vertical) pattern, it is hard to guess the optimal $\delta$ values for each layer (for deeper ones in particular). Instead, we propose to use a fixed but wide set of $\delta$ values per layer, by defining the cost to be: $\mathcal { L } _ { c c } ^ { l } = \sum _ { k } \mathcal { L } _ { c c , \delta _ { k } } ^ { l }$ . A potential concern is that combining many loss terms can hurt the reconstruction or the diversity of generated textures. Figure 5 (second row) shows contrarily that there is no visual effect from using $\delta$ values that are not specifically useful for the reference texture being considered: the rendering benefits from using $\bar { \delta } \in \{ 2 , \dot { 4 } , 8 \}$ while considering bigger values $( \delta \in \{ 2 , 4 , 8 , 1 6 , 3 2 \}$ , e.g.) does not help, but does not hurt the reconstruction either. We found the same to be true for other textures as well, and our results (shown in the next Section) show that combining the loss terms is able to generate very diverse textures. A drawback from using multiple cross-correlation terms per layers, however, is computational. We found that in our experimental setups, adding cross-correlation terms increases the generation time by roughly $8 0 \%$ .
As a guide-line, for image sizes of roughly $3 8 4 \times 3 8 4$ pixels, we recommend the following $\delta$ values per layer (which we used in all our following experiments): $\{ 2 , 4 , 8 , 1 6 , 3 2 , 6 4 \}$ for pool1, $\{ 2 , 4 , 8 , 1 6 , 3 2 \}$ for pool2, $\{ 2 , 4 , 8 , 1 6 \}$ for pool3, and $\{ 2 , 4 , 8 \}$ for pool4. The number and the range of $\delta$ values decrease with depth because feature maps are getting smaller due to $2 \times 2$ pooling layers. This configuration should be sufficient to account for spatial structure in any $3 8 4 \times 3 8 4$ image.
 Figure 6: Some results of our approach compared with Gatys et al. (2015a). Only the initialization differs in the last two columns. Further results are shown in the supplementary material.
# 4.2 SYNTHESIS OF STRUCTURED TEXTURE EXAMPLES
Figure 6 shows the result of our approach applied to various structured and unstructured textures. It demonstrates that the method is effective at capturing long-range correlations without simply copying the content of the original texture. For instance, note how our model captures the depth aspect of the reference image in the third and fourth rows.
 Figure 7: Texture generation applied to in-painting. More in-painted images can be found in the supplementary material.
 Figure 8: Season transfer examples.
The problem of synthesizing near-regular structures is challenging because stochasticity and regularity are adversarial properties (Lin et al., 2006). Non-parametric patch-based techniques, such as Efros & Freeman (2001), are better suited for this task because they can $t i l e ^ { 5 }$ the reference image. On the other hand, regular structures are usually more problematic for parametric statistical models. Nevertheless, the two first rows of Figure 6 demonstrate that our approach can produce good visual results and can reduce the gap to patch-based methods on these kinds of texture.
Even if the reference image is not a texture, the generated images in the last row (Leonardo Dicaprio’s face) provide a good visual illustration of the effect of translation terms. In contrast to Gatys et al., our approach preserves longer-range structure, such as the alignment and similar appearance of the eyes, hair on top of the forehead, the chin below the mouth, etc. Finally, when the reference texture is unstructured (fifth row), our solution does not necessarily provide a benefit, but it also does not hurt the visual quality or the diversity of the generated textures.
# 4.3 INPAINTING APPLICATION
Modelling long-range correlations can make it possible to apply texture generation to inpainting, because it allows us to impose consistency constraints between the newly rendered region and the unmodified parts of the original image.
To apply our approach to texture inpainting, we extracted two patches from the original image: one that covers the whole area to inpaint, and another one that serves as the reference texture. Then, approximately the same process as for texture generation is used, with the following two modifications: First, instead of random noise, the optimization starts from the masked content patch (the one to inpaint) showing a grey area and its non-missing surrounding. Second, we encourage the borders of the output to not change much with respect to the original image using an $L _ { 2 }$ penalty. We apply the penalty both in the Gatys et al. rendering and in ours. Some inpainted images are shown in Figure 7. As seen in the figure, our solution significantly outperforms Gatys et al. in terms of visual quality. Further results are shown in the supplementary material.
 Figure 9: Generation of abstract symmetric textures.
# 4.4 SEASON TRANSFER
Figure 8 shows the result of applying our approach to a style transfer task, as in Gatys et al. (2015b): transferring the “season” of a landscape image to another one. On this task, the results from our approach are similar to those from Gatys et al. (2015b). Nevertheless, in contrast to the Gatys et al. results, our approach seems to better capture global information, such as sky color and leaves (bottom row), or the appearance of branches in the winter image (top row).
# 4.5 INCORPORATING OTHER TYPES OF STRUCTURE
While we focused on feature map translations in most of our experiments, other transformations can be applied as well. To illustrate this point, we explored a way to generate symmetric textures using another simple transformation. To this end, we propose flipping one of the two feature maps before computing the Gram matrices: $G _ { l r , i j } ^ { l } = \langle F _ { i : } ^ { l } , T _ { l r } \ ' ( F _ { j : } ^ { l } ) \rangle$ . Here $T _ { l r }$ corresponds to the left-right flipping operation, but we also considered up-down flipping of feature maps: $\mathcal { L } ^ { l } = \mathcal { L } _ { s t y l e } ^ { l } + \mathcal { L } _ { l r } ^ { l } +$ L lud .
As can be seen in Figure 9, in contrast to Gatys et al., the additional loss terms capture which objects are symmetric in the reference texture, and enforce these same objects to be symmetric in the reconstruction as well. Other kinds of transformation could be used, depending on the type of property in the source texture one desires to preserve.
# 5 CONCLUSION
We presented an approach to satisfying long-range consistency constraints in the generation of images. It is based on a variation of the method by Gatys et al., and considers spatial co-occurences of local features (instead of only co-occurences across features). We showed that the approach permits to generate textures with various global symmetry properties and that it makes it possible to apply texture generation to in-painting. Since it preserves correlations across sites, the approach is reminiscent of an MRF, but in contrast to an MRF or other graphical models, it defines correlationconstraints on high-level features of a (pre-trained) CNN rather than on pixels.
# REFERENCES
Sander Dieleman, Jan Schlter, Colin Raffel, et al. Lasagne: First release., August 2015. URL http://dx. doi.org/10.5281/zenodo.27878. A. A. Efros and T. K. Leung. Texture synthesis by non-parametric sampling. In Proceedings of the International Conference on Computer Vision-Volume 2, ICCV ’99, pp. 1033–, 1999. Alexei A. Efros and William T. Freeman. Image Quilting for Texture Synthesis and Transfer. Proceedings of SIGGRAPH 2001, pp. 341–346, August 2001. L. A. Gatys, A. S. Ecker, and M. Bethge. Texture synthesis using convolutional neural networks. In Advances in Neural Information Processing Systems 28, 2015a. URL http://arxiv.org/abs/1505.07376. L. A. Gatys, A. S. Ecker, and M. Bethge. A neural algorithm of artistic style. CoRR, abs/1508.06576, 2015b. URL http://arxiv.org/abs/1508.06576. R. Haralick, K. Shanmugam, and I. Dinstein. Texture features for image classification. IEEE Transactions on Systems, Man, and Cybernetics 3 (6), 1973. David J. Heeger and James R. Bergen. Pyramid-based texture analysis/synthesis. In Proceedings of the 22nd Conference on Computer Graphics and Interactive Techniques, SIGGRAPH 1995, pp. 229–238, 1995. J. Johnson, A. Alahi, and L. Fei-Fei. Perceptual losses for real-time style transfer and super-resolution. CoRR, abs/1603.08155, 2016. URL http://arxiv.org/abs/1603.08155. P. Kovesi. Image features from phase congruency. Videre, 1(3):2–27, 1999. V. Kwatra, A. Schdl, I. Essa, G. Turk, and A. Bobick. Graphcut textures: Image and video synthesis using graph cuts. ACM Transactions on Graphics, SIGGRAPH 2003, 22(3):277–286, 2003. Wen-Chieh Lin, James Hays, Chenyu Wu, V. Kwatra, and Yanxi Liu. Quantitative evaluation on near regular texture synthesis. In CVPR ’06, volume 1, pp. 427 – 434, June 2006. G. Lohmann. Analysis and synthesis of textures: A co-occurrence-based approach. Computers and Graphics, 19(1), pp. 29–36, 1995. M. C. Morrone and D. C. Burr. Feature detection in human vision: A phase-dependent energy model. Proceedings of the Royal Society of London B: Biological Sciences, 235(1280):221–245, 1988. A. V. Oppenheim and J. S. Lim. The importance of phase in signals. Proceedings of the IEEE, 69(5):529–541, 1981. ISSN 0018-9219. J. Portilla and E. P. Simoncelli. A parametric texture model based on joint statistics of complex wavelet coefficients. Int. J. Comput. Vision, 40(1):49–70, 2000. S. Roth and M. J. Black. Fields of experts: A framework for learning image priors. In IEEE Conf. on Computer Vision and Pattern Recognition, volume 2, pp. 860–867, June 2005. O. Russakovsky, J. Deng, H. Su, J. Krause, S. Satheesh, S. Ma, Z. Huang, A. Karpathy, A. Khosla, M. Bernstein, A. C. Berg, and L. Fei-Fei. ImageNet Large Scale Visual Recognition Challenge. International Journal of Computer Vision (IJCV), 115(3):211–252, 2015. K. Simonyan and A. Zisserman. Very deep convolutional networks for large-scale image recognition. CoRR, abs/1409.1556, 2014. D. Ulyanov, V. Lebedev, A. Vedaldi, and V. Lempitsky. Texture networks: Feed-forward synthesis of textures and stylized images. In International Conference on Machine Learning (ICML), 2016. I. Ustyuzhaninov, W. Brendel, L. A. Gatys, and M. Bethge. Texture synthesis using shallow convolutional networks with random filters. CoRR, abs/1606.00021, 2016. URL http://arxiv.org/abs/1606. 00021. Z. Wang and E. P. Simoncelli. Local phase coherence and the perception of blur. In Advances in Neural Information Processing Systems 16 [NIPS 2003], pp. 1435–1442, 2003. Ciyou Zhu, Richard H. Byrd, Peihuang Lu, and Jorge Nocedal. L-bfgs-b - fortran subroutines for large-scale bound constrained optimization. Technical report, ACM Trans. Math. Software, 1994.
# Supplementary material
A TEXTURE GENERATION


# B INPAINTING



 Gatys et al.
 Inpainted image
 Gatys et al.


Table 1: Final Gatys et al. loss for all inpainted textures (by order of appearance).
<table><tr><td rowspan=1 colspan=1></td><td rowspan=1 colspan=2>Gatys et al. loss</td></tr><tr><td rowspan=1 colspan=1>Texture</td><td rowspan=1 colspan=1>Gatys et al.</td><td rowspan=1 colspan=1>Ours</td></tr><tr><td rowspan=1 colspan=1>"red_leaves”</td><td rowspan=1 colspan=1>3.38e-4</td><td rowspan=1 colspan=1>4.72e-4</td></tr><tr><td rowspan=1 colspan=1>“floor”</td><td rowspan=1 colspan=1>3.68e-4</td><td rowspan=1 colspan=1>4.73e-4</td></tr><tr><td rowspan=1 colspan=1>Supplementa</td><td rowspan=1 colspan=1>rymaterialtex</td><td rowspan=1 colspan=1>tures</td></tr><tr><td rowspan=1 colspan=1>"leaves"</td><td rowspan=1 colspan=1>4.08e-4</td><td rowspan=1 colspan=1>5.14e-4</td></tr><tr><td rowspan=1 colspan=1>“cargo”</td><td rowspan=1 colspan=1>3.39e-4</td><td rowspan=1 colspan=1>4.73e-4</td></tr><tr><td rowspan=1 colspan=1>"building”</td><td rowspan=1 colspan=1>8.90e-4</td><td rowspan=1 colspan=1>6.67e-4</td></tr><tr><td rowspan=1 colspan=1>"building2"</td><td rowspan=1 colspan=1>7.19e-4</td><td rowspan=1 colspan=1>7.78e-4</td></tr><tr><td rowspan=1 colspan=1>"cargo2"</td><td rowspan=1 colspan=1>1.05e-3</td><td rowspan=1 colspan=1>1.18e-3</td></tr><tr><td rowspan=1 colspan=1>"small_bricks"</td><td rowspan=1 colspan=1>1.21e-3</td><td rowspan=1 colspan=1>6.82e-4</td></tr><tr><td rowspan=1 colspan=1>"football_team"</td><td rowspan=1 colspan=1>4.56e-3</td><td rowspan=1 colspan=1>5.68e-3</td></tr></table>
Table 1 reports the final Gatys et al. losses obtained by both approaches for all inpainted textures showed previously. In most cases, the Gatys et al. (2015a) approach converges to a smaller value, which is not surprising since our method optimizes a modified version of the loss. Table 1, combined with the visual aspect of Gatys et al. inpainted renderings, illustrates that only imposing local coherence is not enough to obtain good inpainted textures. Our texture representation seems to be better suited for this task.


 Style
 Content (&init)
 Ours
 Gatys



# C SYMMETRIC TEXTURES
md/train/0IOX0YcCdTn/0IOX0YcCdTn.mdAdded+513
md/train/0cmMMy8J5q/0cmMMy8J5q.mdAdded+357
md/train/1XwPDFrJObw/1XwPDFrJObw.mdAdded+361
md/train/8twKpG5s8Qh/8twKpG5s8Qh.mdAdded+330
md/train/A5VV3UyIQz/A5VV3UyIQz.mdAdded+391
md/train/B1ZZTfZAW/B1ZZTfZAW.mdAdded+344
md/train/BJxwPJHFwS/BJxwPJHFwS.mdAdded
md/train/BkxUvnEYDH/BkxUvnEYDH.mdAdded+522
md/train/BkxnKkrtvS/BkxnKkrtvS.mdAdded+499
md/train/ByJDAIe0b/ByJDAIe0b.mdAdded+487
md/train/CZ8Y3NzuVzO/CZ8Y3NzuVzO.mdAdded+251
md/train/DNl5s5BXeBn/DNl5s5BXeBn.mdAdded+446
md/train/ETBc_MIMgoX/ETBc_MIMgoX.mdAdded+357
md/train/H1fl8S9ee/H1fl8S9ee.mdAdded+379
md/train/H1lefTEKDS/H1lefTEKDS.mdAdded+514
md/train/HyGTuv9eg/HyGTuv9eg.mdAdded+224
md/train/Ja-hVQrfeGZ/Ja-hVQrfeGZ.mdAdded
md/train/MRQJmsNPp8E/MRQJmsNPp8E.mdAdded
md/train/OdklztJBBYH/OdklztJBBYH.mdAdded
md/train/Rd138pWXMvG/Rd138pWXMvG.mdAdded
md/train/S191YzbRZ/S191YzbRZ.mdAdded
md/train/SJxzFySKwH/SJxzFySKwH.mdAdded
md/train/Syg-YfWCW/Syg-YfWCW.mdAdded
md/train/SygXPaEYvH/SygXPaEYvH.mdAdded
md/train/SyhRVm-Rb/SyhRVm-Rb.mdAdded
md/train/Syx5eT4KDS/Syx5eT4KDS.mdAdded
md/train/WZnVnlFBKFj/WZnVnlFBKFj.mdAdded
md/train/bM4Iqfg8M2k/bM4Iqfg8M2k.mdAdded
md/train/dmCL033_YwO/dmCL033_YwO.mdAdded
md/train/gwnoVHIES05/gwnoVHIES05.mdAdded
md/train/kcI3T5qe1jr/kcI3T5qe1jr.mdAdded
md/train/mQPBmvyAuk/mQPBmvyAuk.mdAdded
md/train/nMefdZyJ7ie/nMefdZyJ7ie.mdAdded
md/train/oSrM_jG_Ng/oSrM_jG_Ng.mdAdded
md/train/r1Ue8Hcxg/r1Ue8Hcxg.mdAdded
md/train/r1Usiwcex/r1Usiwcex.mdAdded
md/train/r1lUl6NFDH/r1lUl6NFDH.mdAdded
md/train/r1xapAEKwS/r1xapAEKwS.mdAdded
md/train/r1xjgxBFPB/r1xjgxBFPB.mdAdded
md/train/rJzLciCqKm/rJzLciCqKm.mdAdded
md/train/rkeYUsRqKQ/rkeYUsRqKQ.mdAdded
md/train/rkgvXlrKwH/rkgvXlrKwH.mdAdded
md/train/rkxmPgrKwB/rkxmPgrKwB.mdAdded
md/train/ryewE3R5YX/ryewE3R5YX.mdAdded
md/train/rylb3eBtwr/rylb3eBtwr.mdAdded
md/train/ryxWIgBFPS/ryxWIgBFPS.mdAdded
md/train/s-NI4H4e3Rf/s-NI4H4e3Rf.mdAdded
md/train/ssohLcmn4-r/ssohLcmn4-r.mdAdded
md/train/tc5qisoB-C/tc5qisoB-C.mdAdded
md/train/wg_kD_nyAF/wg_kD_nyAF.mdAdded