diff --git a/askyourhumansusinghumaninstructionstoimprovegeneralizationinreinforcementlearning/02332191-3640-4bf2-b0ec-5ad2e22699ee_content_list.json b/askyourhumansusinghumaninstructionstoimprovegeneralizationinreinforcementlearning/02332191-3640-4bf2-b0ec-5ad2e22699ee_content_list.json new file mode 100644 index 0000000000000000000000000000000000000000..e35e13ce6ea41a2947268c9566f541ee9cfed8c6 --- /dev/null +++ b/askyourhumansusinghumaninstructionstoimprovegeneralizationinreinforcementlearning/02332191-3640-4bf2-b0ec-5ad2e22699ee_content_list.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c7474035f114460dfd4b5becd9cabff4c6f6f1649fea4ee8fc765fec5ebe4cf7 +size 126266 diff --git a/askyourhumansusinghumaninstructionstoimprovegeneralizationinreinforcementlearning/02332191-3640-4bf2-b0ec-5ad2e22699ee_model.json b/askyourhumansusinghumaninstructionstoimprovegeneralizationinreinforcementlearning/02332191-3640-4bf2-b0ec-5ad2e22699ee_model.json new file mode 100644 index 0000000000000000000000000000000000000000..5cb7b439d129dbf982e6f7a641f3fbfc62c165e6 --- /dev/null +++ b/askyourhumansusinghumaninstructionstoimprovegeneralizationinreinforcementlearning/02332191-3640-4bf2-b0ec-5ad2e22699ee_model.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f6afd9d34b73c9f50e3abd491feb8dfb6907ff0a8b9378ffd4406f390a361e88 +size 145618 diff --git a/askyourhumansusinghumaninstructionstoimprovegeneralizationinreinforcementlearning/02332191-3640-4bf2-b0ec-5ad2e22699ee_origin.pdf b/askyourhumansusinghumaninstructionstoimprovegeneralizationinreinforcementlearning/02332191-3640-4bf2-b0ec-5ad2e22699ee_origin.pdf new file mode 100644 index 0000000000000000000000000000000000000000..3b44c236ba2248abf553f1bfba222b2df4dbeef5 --- /dev/null +++ b/askyourhumansusinghumaninstructionstoimprovegeneralizationinreinforcementlearning/02332191-3640-4bf2-b0ec-5ad2e22699ee_origin.pdf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e8bc5817f0348c06c11867ec616ca1ccd860bc0ddf6f2d6b00c319373f4fef81 +size 3521633 diff --git a/askyourhumansusinghumaninstructionstoimprovegeneralizationinreinforcementlearning/full.md b/askyourhumansusinghumaninstructionstoimprovegeneralizationinreinforcementlearning/full.md new file mode 100644 index 0000000000000000000000000000000000000000..d226f9a8c7ef821f49100db7bd7760c6695d94a3 --- /dev/null +++ b/askyourhumansusinghumaninstructionstoimprovegeneralizationinreinforcementlearning/full.md @@ -0,0 +1,668 @@ +# ASK YOUR HUMANS: USING HUMAN INSTRUCTIONS TO IMPROVE GENERALIZATION IN REINFORCEMENT LEARNING + +Valerie Chen, Abhinav Gupta, & Kenneth Marino + +Carnegie Mellon University + +{vchen2, abhinavg, kdmarino}@cs.cmu.edu + +# ABSTRACT + +Complex, multi-task problems have proven to be difficult to solve efficiently in a sparse-reward reinforcement learning setting. In order to be sample efficient, multi-task learning requires reuse and sharing of low-level policies. To facilitate the automatic decomposition of hierarchical tasks, we propose the use of step-by-step human demonstrations in the form of natural language instructions and action trajectories. We introduce a dataset of such demonstrations in a crafting-based grid world. Our model consists of a high-level language generator and low-level policy, conditioned on language. We find that human demonstrations help solve the most complex tasks. We also find that incorporating natural language allows the model to generalize to unseen tasks in a zero-shot setting and to learn quickly from a few demonstrations. Generalization is not only reflected in the actions of the agent, but also in the generated natural language instructions in unseen tasks. Our approach also gives our trained agent interpretable behaviors because it is able to generate a sequence of high-level descriptions of its actions. + +# 1 INTRODUCTION + +One of the most remarkable aspects of human intelligence is the ability to quickly adapt to new tasks and environments. From a young age, children are able to acquire new skills and solve new tasks through imitation and instruction (Council et al., 2000; Meltzoff, 1988; Hunt, 1965). The key is our ability to use language to learn abstract concepts and then reapply them in new settings. Inspired by this, one of the long term goals in AI is to build agents that can learn to accomplish new tasks and goals in an open-world setting using just a few examples or few instructions from humans. For example, if we had a health-care assistant robot, we might want to teach it how to bring us our favorite drink or make us a meal in just the way we like it, perhaps by showing it how to do this a few times and explaining the steps involved. However, the ability to adapt to new environments and tasks remains a distant dream. + +Previous work have considered using language as a high-level representation for RL (Andreas et al., 2017; Jiang et al., 2019). However, these approaches typically use language generated from templates that are hard-coded into the simulators the agents are tested in, allowing the agents to receive virtually unlimited training data to learn language abstractions. But both ideally and practically, instructions are a limited resource. If we want to build agents that can quickly adapt in open-world settings, they need to be able to learn from limited, real instruction data (Luketina et al., 2019). And unlike the clean ontologies generated in these previous approaches, human language is noisy and diverse; there are many ways to say the same thing. Approaches that aim to learn new tasks from humans must be able to use human-generated instructions. + +In this work, we take a step towards agents that can learn from limited human instruction and demonstration by collecting a new dataset with natural language annotated tasks and corresponding gameplay. The environment and dataset is designed to directly test multi-task and sub-task learning, as it consists of nearly 50 diverse crafting tasks.1 Crafts are designed to share similar features and + +![](images/77751fd6b8aca8b0068067792822fa7ee8fc934a71bee7565bb614b6bb9337d0.jpg) +Figure 1: From state observation at time step $t$ , the agent generates a natural language instruction "go to key and press grab," which guides the agent to grab the key. After the instruction is fulfilled and the agent grabs the key, the agent generates a new instruction at $t + 1$ . + +sub-steps so we would be able to test whether the method is able to learn these shared features and reuse existing knowledge to solve new, but related tasks more efficiently. Our dataset is collected in a crafting-based environment and contains over 6,000 game traces on 14 unique crafting tasks which serve as the training set. The other 35 crafting tasks will act as zero-shot tasks. The goal is for an agent to be able to learn one policy that is able to solve both tasks it was trained on as well as a variety of unseen tasks which contain similar sub-tasks as the training tasks. + +To do this, we train a neural network system to generate natural language instructions as a high-level representation of the sub-task, and then a policy to achieve the goal condition given these instructions. Figure 1 shows how our agent takes in the given state of the environment and a goal (Iron Ore), generates a language representation of the next instruction, and then uses the policy to select an action conditioned on the language representation - in this case to grab the key. We incorporate both imitation learning (IL) using both the language and human demonstrations and Reinforcement Learning (RL) rewards to train our agent to solve complicated multi-step tasks. + +Our approach which learns from human demonstrations and language outperforms or matches baseline methods in the standard RL setting. We demonstrate that language can be used to better generalize to new tasks without reward signals and outperforms baselines on average over 35 zero-shot crafting tasks. Our method uses language as a high-level task to help decompose a larger, complex task into sub-tasks and identify correct sub-tasks to utilize in a zero-shot task setting. We also show that the agent can learn few-shot tasks with only a few additional demos and instructions. Finally, training with human-generated instructions gives us an interpretable explanation of the agent's behavior in cases of success and failure. Generalization is further demonstrated in the agent's ability to explain how the task is decomposed in both train and evaluation settings, in a way that reflects the actual recipes that describe the crafting task. With our dataset collection procedure and language-conditioned method, we demonstrate that using natural human language can be practically applied to solving difficult RL problems and begin solving the generalization problem in RL. We hope that this will inspire future work that incorporates human annotation, specifically language annotation, to solve more difficult and diverse tasks. + +# 2 RELATED WORK + +Previous works on language descriptions of tasks and sub-tasks have generally relied on what Andreas et al. (2017) calls "sketches." A sketch specifies the necessary sub-tasks for a final task and is manually constructed for every task. The agent then relies on reward signals from the sketches in order to learn these predefined sub-tasks. However, in our setup, we want to infer such "sketches" from a limited number of instructions given by human demonstrations. This setting is not only more difficult but also more realistic for practical applications of RL where we might not have a predefined ontology and simulator, just a limited number of human-generated instructions. In addition, at test time, their true zero-shot task requires the sketch, whereas our method is able to generate the "sketches" in the form of high-level language with no additional training and supervision. + +Similarly, other works have used synthetically generated sub-goals and descriptions to train their methods and suffer from similar problems of impracticality. Shu et al. (2018) introduces a Stochastic Temporal Grammar to enable interpretable multi-task RL in the Minecraft environment. Similarly, the BabyAI platform Chevalier-Boisvert et al. (2019a) presents a synthetic language which models commands inside a grid-based environment. They utilize curriculum training to approach learning complex skills and demonstrate through experimentation in their environment that existing approaches of pure IL or pure RL are extremely sample inefficient. Cideron et al. (2019) extend Hindsight Experience Replay (HER) to language goals in the BabyAI platform to solve a single instruction generated from a hand-crafted language. The BabyAI environment is extended by Cao et al. (2020) to include descriptive texts of the environment to improve the generalization of RL agents. Jiang et al. (2019) also uses procedural generated language using the MuJoCo physics engine and the CLEVR engine to learn a hierarchical representation for multi-task RL. Oh et al. (2017) also tackles zero-shot generalizations, but like the others considers only procedurally-generated instructions, learning to use analogies to learn correspondences between similar sub-tasks. + +The main work that also investigates using a limited number of human-generated instructions in RL environments is Hu et al. (2019). This paper also uses natural language instructions in hierarchical decision making to play a real-time strategy game involving moving troop units across long time scales. This work uses only behavioral cloning with natural language instructions, whereas we use a mixture of RL and imitation learning. They also do not investigate the benefits of language in zero-shot or few-shot settings and do not demonstrate cross-task generalization as we do. + +Hierarchical approaches as a way of learning abstractions is well studied in the Hierarchical Reinforcement Learning (HRL) literature (Dayan & Hinton, 1993; Parr & Russell, 1998; Stolle & Precup, 2002). This is typically done by predefining the low-level policies by hand, by using some proxy reward to learn a diverse set of useful low-level policies (Heess et al., 2016; Florensa et al., 2017; Eysenbach et al., 2018; Hausman et al., 2018; Marino et al., 2019), or more generally learning options (Sutton et al., 1999). Our approach differs in that unlike in options and other frameworks, we generate language as a high-level state which conditions the agent's policy rather than handing control over to low-level policies directly. + +Other works have shown the effectiveness of using a combination of reinforcement learning and imitation learning. Le et al. (2018) presents a hybrid hierarchical reinforcement learning and imitation learning algorithm for the game Montezuma's revenge by leveraging IL for the high-level controller and RL for the low-level controller demonstrating the potential for combining IL and RL to achieve the benefits of both algorithms. By learning meta-actions, the agent is able to learn to solve the complex game. However, their meta-actions were also hand specified. + +Others have utilized natural language for other tasks, including Williams et al. (2018), Co-Reyes et al. (2018), and Andreas et al. (2018) but not focused on the multi-task learning setting. Matthews et al. (2019) demonstrates the use of word embeddings to inform robotic motor control as evidence of particular promise for exploiting the relationship between language and control. Narasimhan et al. (2018) uses language descriptions of the environment to aid domain transfer. The sub-field of language and vision navigation specifically has investigated how to train agents to navigate to a particular location in an environment given templated or natural language (Chaplot et al., 2018; Anderson et al., 2018; TELex et al., 2011; Mei et al., 2016; Chen & Mooney, 2011; Yu et al., 2018) or to navigate to a particular location to answer a question Das et al. (2018). Similarly to this work, Nguyen et al. (2019) uses human-generated language to find objects in a simulated environment, Zhong et al. (2020) and Branavan et al. (2012) reads a document (i.e. a players manual) to play a variety of games, and Lynch & Sermanet (2020) trains agents to follow both image and language-based goals. All of these works require the agent to read some text at both train and test time and follow those instructions to achieve some goal. In contrast, at test time, our agent only receives a high-level goal, which is what item to craft. Our agent must take the high-level goal as input and generates its own instructions to solve the task. In other words, our task is both instruction following and instruction generation. Related to instruction generation, some work have explored more generally intrinsic motivation for goal generation (Florensa et al., 2018; Forestier et al., 2017). In our work, however, we learn the goals via the human language instructions. + +# 3 HUMAN ANNOTATION COLLECTION + +The first step of our approach requires human demonstrations and instructions. To that requirement, we built an interface to collect human-annotated data to guide the learning model. + +![](images/13e257927cf37a619a52ea10f6c52ae40a52810a4fedd4b4b2f58c3b68480d2a.jpg) +Figure 2: (Left) Example view of game interface that the worker would see on AMT. On the left the worker is given the goal and recipes; the board is in the middle; the worker provides annotations on the right. (Right) Example sequence of instructions provided by the Turker for the given task of Stone Pickaxe. + +Crafting Environment: As shown in Figure 2, our environment is a Minecraft-inspired 5-by-5 gridworld. The Crafting Agent navigates the grid by moving up, down, left, and right. The agent can grab certain objects, like tools, if it is next to them and use the tools to mine resources. The agent must also use a key or switch to open doors blocking its path. Finally, the agent can also go to a crafting table to build final items. The agent can choose from 8 actions to execute: up, down, left, right, toggle, grab, mine, and craft. The environment is fully observable. Our crafting environment extends the crafting environment of Andreas et al. (2017) to include obstacles and crafts that are specified by material, introducing compositionally complex tasks (i.e. instead of 'Make Axe', we have 'Make Iron Axe' etc). In total, we consider about 50 crafting tasks, 14 of which we collect annotations for and 35 of which are used for test time. At the start of each game, all object/resource locations are fully randomized in the environment. + +Crafting Task: The goal of the agent in our world is to complete crafts. By design, a crafting-based world allows for complexity and hierarchy in how the agent interacts with items in the gridworld. To craft an item, the agent must generally first pick up a tool, go to a resource, mine the resource, and then go to a table to craft the item. To make an iron ore, the agent must use the pickaxe at the Iron Ore Vein to mine Iron Ore to complete the task. The Iron Ore recipe is an example of a 1-step task because it creates one item. A 5-step task, like Diamond Pickaxe, involves the mining and/or crafting of 5 items. We capped the tasks at a maximum length of 5 recipe steps to limit the amount of time a worker would have to spend on the task. Note that each recipe step requires multiple time-steps to complete. Crafts are designed to share similar features and sub-steps to test whether the agent is able to learn these shared features and reuse existing knowledge to solve new, but related tasks more efficiently (these relations between tasks are detailed in Table 3 and in Figure 10). While the task may seem simple to human annotators to solve, such compositional tasks still pose difficulties for sparse-reward RL. We further increase the difficulty of this task by restricting the agent to a limited number of steps (100) to complete the task, leaving little room to make unrecoverable mistakes such as spending time collecting or using unnecessary resources. + +Data Collection Process: Figure 2 shows our interface. Given the goal craft, relevant recipes, and the initial board configuration, the worker provides step-by-step instructions accompanied by execution on the actual game board of each instruction. The workflow would be to type one instruction, execute the instruction, then type the next instruction, and execute until the goal was completed. The data collection interface and a corresponding example set of natural language instructions provided by a Turker is illustrated on the rightmost side of Figure 2. This is but one way that a Turker might choose to break down the 5-step crafting task. The appendix has more details on the collection process in Section A.1. We will release the environment and dataset. + +Dataset Analysis: Between the 14 crafts, we collected 6,322 games on AMT. In total, this dataset contains 195,405 state-action pairs and 35,901 total instructions. In the supplementary material we present relevant summary statistics about the data, including the number of instructions provided for each $n$ -step task. The number of instructions, and consequently, actions required increases with the number steps as shown in Table 4. + +# 4 METHODS + +Our proposed approach to solving these multi-step crafting tasks is to learn from human-generated natural language instructions and demonstrations. The model is first pre-trained using imitation learning (IL) and then fine-tuned using sparse-reward in reinforcement learning (RL). The goal of the agent is to learn one policy that is able to solve a variety of tasks (around 50) in the environment including ones it has not seen when only trained on a subset of the total tasks. + +![](images/ff36cbee2082abb80dff772efb8069c25b17e02a8ab29440a2b912b3e2256a90.jpg) +Figure 3: (Left) High-level language generator. (Right) Low-level policy conditioned on language. + +Architecture: As outlined in Figure 3, we factor the agent into a hierarchical set-up with a language generator at the high-level and policy conditioned on the language at the low-level. At each time step, the state encoder produces a vector representation that is then used as input to both the language generator and language-conditioned policy. Relevant information about the state, including the grid, inventory, and goal are encoded. Items which are relevant for crafting are embedded using a 300-dimension GloVe embedding, summing the embeddings for multiple word items (i.e. Iron Ore Vein). Non-crafting items, such as door, wall, or key, are represented using a one-hot vector. Further details are provided in Section B. + +Imitation Learning Pre-training: We warm-start the model using the human demonstrations. Language is generated at the high-level with an encoder-decoder framework. The encoding from the state encoder is decoded by an LSTM which generates a natural language instruction. The target language instruction is the AMT worker's provided instruction. In our dataset, the vocabulary size was 212, after filtering for words that appeared at least 5 times. At test time, we do not have access to the ground truth instructions, so instead the LSTM decoder feeds back the previously generated word as the next input and terminates when the stop token is generated. From the language generator module, we extract the last hidden state of the generated instruction. The hidden state is concatenated with the encoded state and passed through a series of fully connected layers. The final layer outputs the action. In the supervised training phase, the full model is trained by backpropagating through a language and action loss (cross entropy loss). + +Reinforcement Learning Fine-tuning: We use the proximal policy optimization (PPO) algorithm Schulman et al. (2017) in RL with the reward defined below to learn an optimal policy to map from state encoding to output action. The maximum number of steps in an episode is set to 100. We utilize a training set-up which samples from all tasks (1-step through 5-step tasks). In preliminary experiments, we observe that sampling from 3-step tasks alone, for example, poses too complex of an exploration problem for the model to receive any reward. We define a sparse reward, where the agent only receives a reward when it has completed the full craft. In RL fine-tuning, we freeze the language generator component because there is no more language supervision provided in the simulated environment. We also find that empirically backpropagating the loss through language distorts the output language as there is no constraint for it to continue to be similar to human language. All training hyperparameters and details are provided in supplementary materials. + +# 5 EXPERIMENTS + +We compare our method against five baselines (1-5) which are reduced forms of our method to evaluate the necessity of each component. We also consider two baselines (6-7), which swap out the language generator for alternative high-level tasks, to evaluate the usefulness of language as a selected high-level task. These baselines have the additional training that our method received, as well as the implicit compositionality, but without language. In both baselines (6-7), we perform the same training steps as with our method. Implementation details are presented in Section B. + +1. IL: The IL baseline uses the same low-level architecture as our method, without a high-level hidden state. The model learns to map state encoding to an output action. + +2. IL w/ Generative Language: IL w/ Generative Language is the supervised baseline of our method, which does not include RL reward. This baseline allows us to observe and compare the benefit of having a reward to train in simulation when the model has access to both actions and language instructions. + +3. IL w/ Discriminative Language: We compare our method to a closely adapted version of the method proposed in Hu et al. (2019) which similarly uses language in the high-level. Rather than generate language, their high-level language is selected from a set of instructions from the collected user annotation. We discuss this adaptation in the Appendix. They consider instruction sets of sizes $N = \{50, 250, 500\}$ and find the best performance on the largest instruction set $N = 500$ which is the size we use in our implementation. + +4. RL: Another baseline we consider is the reinforcement learning (RL) setting where the agent is provided no demonstrations but has access to sparse-reward in RL. The architecture we use here is the same as the IL architecture. This baseline demonstrates the capacity to learn the crafting tasks without any human demonstrations and allows us to see whether human demonstrations are useful. + +5. IL + RL: We also consider a baseline that does not incorporate language which is IL+RL. In IL+RL, we pretrain the same IL architecture using the human demonstrations as a warm-start to RL. It is important to note that this baseline does not include the natural language instructions as a part of training. We extract all of the state-action pairs at train a supervised model on the data as in the IL model and then we utilize the RL sparse-reward to fine-tune. + +6. State Reconstruction (SR): We train an autoencoder to perform state reconstruction. The autoencoder reconstructs the state encoding and the vector at the bottleneck of the autoencoder is used as the hidden layer for the policy. SR as a baseline allows us to consider latent representations in the state encoding as a signal for the policy. + +7. State Prediction (SP): We train a recurrent network, with the same architecture as our language generator, to perform state prediction. The model stores the past 3 states from time $T$ to predict the $T + 1$ state. So at time $T$ , the states $T - 2$ , $T - 1$ , and $T$ are used to predict state $T + 1$ . From the LSTM, the hidden state is extracted in the same manner as our IL + RL w/ Lang model. SP as a baseline allows us to compare against another recurrent high-level method with the additional computation power. + +# 5.1 RESULTS + +Standard setting: We evaluate the various methods on crafts which we have collected human demonstrations for to benchmark comparative performance in our environment. An initial analysis is to first consider how much the IL model is able to learn from human demonstrations alone, so we consider IL, IL with Generative Language, and IL with Discriminative Language (results are in Section C). None of these approaches are able to solve the most difficult 5-step tasks or the simpler tasks consistently, with an average of about $18 - 19\%$ success rate for 1-step tasks. We believe the 3 and 5-step tasks are difficult enough such that annotations alone were not able to capture the diversity of board configurations for the variety of crafts given that the board is randomly initialized each time. However, based on an analysis of the language selected (see Tables 11 vs. Table 12), the generated language is more interpretable and made more sense in a zero shot setting. Given the language is fixed after this point, all remaining experiments moving forward use generative language. + +As shown in Figure 4, our method performs well against baselines. We find that human demonstrations are necessary to guide learning because the learned behavior for RL is essential to arbitrarily + +![](images/7ae12346aa097c3edc96eee12858834f58b4a89e5f82652ba5daff6a5883d9f7.jpg) +Figure 4: Comparing baselines with our method on accuracy. Human demonstrations are necessary to complete tasks with 3 or more steps. Averaged over 3 runs. + +![](images/59675af4dbbfba4a56c60950ab9cb93c0bbb5d1b11266a190eb32c381a75da32.jpg) + +![](images/c852613d7a7d75faccdd5e873e8c496769c48f8a1298b4a9746bb685ceeff3a5.jpg) + +![](images/6144cce5572cb644c5cb6a14c340995cb8b253e5d83404b43fbdb5f3aa22a95c.jpg) + +walk around the grid and interact with items. For simple 1 and 2 step tasks, this is a feasible strategy for the allotted steps for an episode. However, there is little room for error in the most difficult 5-step tasks, as even human demonstrations take on average 40 steps to solve. We also find that for the standard setting, incorporating a high-level network allows the model to achieve good results when comparing our method to SP and SR. + +In Figure 5 we show the result of our method when we ablate the number of demonstrations we use. This lets us see how many demonstrations we would feasibly need for the model to learn how to solve the crafting tasks. As we decrease the amount of data provided, we find that there is greater variance in the policy's ability to complete the task, but the performance only significantly degrades when we start using only $25\%$ of the data on the hardest tasks. + +![](images/b0abf0cad390604c9fb62ac3bba5fef1fb257cd974c252aaf86fbc73e10f22fe.jpg) +Figure 5: Ablation of our method with varying amounts of human annotations (25%, 50%, 75% and 100%). For each fraction, we sample that number of demonstrations from the dataset for each type of task. Averaged over 3 runs. + +![](images/c2abab82513a6560808143b4a0df29258f73e79a5c2cb335ae98dbb63b4ad29d.jpg) + +![](images/27569ea7ffa3de62b0e2122969419e2130d64b2d4e2cb2f3e8aa43a2c2818cbd.jpg) + +![](images/0fbbd2c7741c8a536b944ee16cff0afb2ad798149b8fbdd11777f24a52003e00.jpg) + +Zero Shot: Our method is able to use natural language instructions to improve performance on difficult tasks in the standard setting. But how well is our method able to do on completely new tasks not seen during training? We investigate our performance on zero-shot tasks, where the agent receives no human demonstrations or instructions, and no rewards on these tasks. The agent has to try to complete these tasks that it has never seen before and cannot train on at all. These unseen tasks do share sub-task structure with tasks which were seen in the training process, so the desired behavior is for the model to reuse subpolicies seen in other contexts for this new context. For example, in training the agent might have seen demonstrations or received rewards for a task like "Cobblestone Stairs" and "Iron Ingot." At test time, we can evaluate the agent on an item like "Cobblestone Ingot", which has never been seen by the agent. The agent should be able to infer the sub-task breakdown given prior knowledge of similar tasks. + +We present 35 examples of unseen tasks in Table 1. We find that overall our method outperforms all other baselines. While SR and SP were able to match our method's performance in standard setting, they are not able to generalize. SR and SP are viable solutions to learn complex tasks in the standard RL setting, but the representations these models learned do not aid in generalizing to unseen tasks. Here, we believe, using language is key because it creates a representation that better abstracts to new tasks. In the supplementary material, we show that in the cases of unseen tasks, the model indeed is able to generate language that properly corresponds to these new combinations of materials and items, particularly decomposing the complex item into sub-tasks that were previously seen in the training phase. + +**Demonstration Only and Few-Shot:** In the demonstration only, we assume that we have access to only human demonstrations for some subset of tasks. From the entire pool of 14 tasks we collected demonstrations for, we withhold 3 tasks (around $20\%$ of total tasks) for testing. These 3 tasks consist of a one, two, and three step task. We run results on 3 permutations of withholding 3 + +Table 1: Accuracy evaluated on 100 games for 35 unseen crafts. Our method outperforms baselines. We do not list IL or IL w/ Language results which are $0\%$ for all tasks. + +
Steps22222222222222222222
RL9391959092929181000000130722846
IL+RL92988594918395972196371897829793949181
SP02003337269290098089178174233
SR9664006770609907988746937169870055
Ours99991001009399100100979899999910097100999798
Overall, M/G
Steps333333333333355555-
RL10000000000000000023
IL+RL908700000085298687390000055
SP89012041004701260160000022
SR1020120000386050000030
Ours9798231804009639959849360001469
+ +tasks. For each of the 3 withheld tasks, we include these demonstrations in the supervised training phase but do not provide reward in RL fine-tuning. We vary the amount of demonstrations that are provided: $5\%$ , $10\%$ , and $100\%$ . The most generous case is to assume that the model has access to all demonstrations that were collected in the dataset. Per task, the total number of demonstrations was about 300-500. Additionally we considered a more strict few-shot case where we reduce the number of demonstrations to 20-40 which is about $5 - 10\%$ of the original number of demonstrations. We do not include 5-step tasks because we only collected demonstrations for two 5-step tasks. From the results in Table 2, we can see that our method outperforms baselines in its ability to utilize the few demonstrations to improve performance. + +Table 2: Evaluation of few-shot tasks for our method against baseline comparisons. We consider three settings for how many demonstrations are given to the model: $5\%$ (20 demos), $10\%$ (40 demos), $100\%$ . Variance results are included in supplementary material. Results are averaged across 3 seeds. + +
ILIL w/LangIL+RLSPSROurs
Steps5%10%100%5%10%100%5%10%100%5%10%100%5%10%100%5%10%100%
1-step16%18%18%17%19%19%96%91%98%96%98%97%53%84%94%97%90%95%
2-step4%3%0%5%5%9%66%64%66%53%64%71%10%40%63%87%73%82%
3-step1%2%0%1%3%4%1%23%22%10%27%46%0%31%50%5%47%74%
+ +Interpretability: One key benefit of incorporating natural language into the model is the ability for humans to interpret how the model is making decisions. We observe that the generated instructions closely match those of the recipes that we provide to the annotators in the data collection phase in both train (Table 12) and test (Table 13, 14) settings. However, the discriminative language didn't break down the task into steps that made sense (Table 11). Figure 6 presents example instructions generated by our model. + +# 6 CONCLUSION + +In this paper, we present a dataset of human demonstrations and natural language instructions to solve hierarchical tasks in a crafting-based world. We also describe a hierarchical model to enable efficient learning from this data through a combined supervised and reinforcement learning approach. In general, we find that leveraging human demonstrations allows the model to drastically outperform RL baselines. Additionally, our results demonstrate that natural language not only allows the model to explain its decisions but it also improves the model's performance on the most difficult crafting tasks and further allows generalization to unseen tasks. We also demonstrate the model's ability to expand its skillset through few additional human demonstrations. While we demonstrate our approach's success in a grid-based crafting environment, we believe that our method is able to be adapted towards generalizable, multi-task learning in a variety of other environments. + +![](images/87ff9a2a88bd944e461a1c51a02de2db918d3672f573dd75d63f99f9487762c2.jpg) +Figure 6: Generated language at test time for a 2-step craft. We only display key frames of the trajectory which led to changes in the language. These key frames match changes in the inventory to the object mentioned in the generated instruction. Qualitatively, the generated instructions are consistent during what we would describe as a sub-task. Quantitatively, the network will spend on average 4.8 steps in the environment for the same generated language output. + +# REFERENCES + +Peter Anderson, Qi Wu, Damien Teney, Jake Bruce, Mark Johnson, Niko Sunderhauf, Ian Reid, Stephen Gould, and Anton van den Hengel. Vision-and-language navigation: Interpreting visually-grounded navigation instructions in real environments. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 3674-3683, 2018. +Jacob Andreas, Dan Klein, and Sergey Levine. Modular multitask reinforcement learning with policy sketches. In Proceedings of the 34th International Conference on Machine Learning-Volume 70, pp. 166-175. JMLR.org, 2017. +Jacob Andreas, Dan Klein, and Sergey Levine. Learning with latent language. In Proceedings of the 2018 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, Volume 1 (Long Papers), pp. 2166-2179, 2018. +SRK Branavan, David Silver, and Regina Barzilay. Learning to win by reading manuals in a montecarlo framework. Journal of Artificial Intelligence Research, 43:661-704, 2012. +Tianshi Cao, Jingkang Wang, Yining Zhang, and Sivabalan Manivasagam. Babyai++: Towards grounded-language learning beyond memorization. arXiv preprint arXiv:2004.07200, 2020. +Devendra Singh Chaplot, Kanhashree Mysore Sathyendra, Rama Kumar Pasumarthi, Dheeraj Rajagopal, and Ruslan Salakhutdinov. Gated-attention architectures for task-oriented language grounding. In Thirty-Second AAAI Conference on Artificial Intelligence, 2018. +David L Chen and Raymond J Mooney. Learning to interpret natural language navigation instructions from observations. In Twenty-Fifth AAAI Conference on Artificial Intelligence, 2011. +Maxime Chevalier-Boisvert, Dzmitry Bahdanau, Salem Lahlou, Lucas Willems, Chitwan Saharia, Thien Huu Nguyen, and Yoshua Bengio. BabyAI: First steps towards grounded language learning with a human in the loop. In International Conference on Learning Representations, 2019a. URL https://openreview.net/forum?id=rJeXCo0cYX. +Maxime Chevalier-Boisvert, Dzmitry Bahdanau, Salem Lahlou, Lucas Willems, Chitwan Saharia, Thien Huu Nguyen, and Yoshua Bengio. BabyAI: First steps towards grounded language learning with a human in the loop. In International Conference on Learning Representations, 2019b. URL https://openreview.net/forum?id=rJeXCo0cYX. +Geoffrey Cideron, Mathieu Seurin, Florian Strub, and Olivier Pietquin. Self-educated language agent with hindsight experience replay for instruction following. arXiv preprint arXiv:1910.09451, 2019. +John D Co-Reyes, Abhishek Gupta, Suvansh Sanjeev, Nick Altieri, Jacob Andreas, John DeNero, Pieter Abbeel, and Sergey Levine. Guiding policies with language via meta-learning. In International Conference on Learning Representations, 2018. + +National Research Council et al. How people learn: Brain, mind, experience, and school: Expanded edition. National Academies Press, 2000. +Abhishek Das, Samyak Datta, Georgia Gkioxari, Stefan Lee, Devi Parikh, and Dhruv Batra. Embodied Question Answering. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition (CVPR), 2018. +Peter Dayan and Geoffrey E Hinton. Feudal reinforcement learning. In Advances in neural information processing systems, pp. 271-278, 1993. +Benjamin Eysenbach, Abhishek Gupta, Julian Ibarz, and Sergey Levine. Diversity is all you need: Learning skills without a reward function. In International Conference on Learning Representations, 2018. +Carlos Florensa, Yan Duan, and Pieter Abbeel. Stochastic neural networks for hierarchical reinforcement learning. In International Conference on Learning Representations, 2017. +Carlos Florensa, David Held, Xinyang Geng, and Pieter Abbeel. Automatic goal generation for reinforcement learning agents. In International conference on machine learning, pp. 1515-1528, 2018. +Sebastien Forestier, Rémy Portelas, Yoan Mollard, and Pierre-Yves Oudeyer. Intrinsically motivated goal exploration processes with automatic curriculum learning. arXiv preprint arXiv:1708.02190, 2017. +Karol Hausman, Jost Tobias Springenberg, Ziyu Wang, Nicolas Heess, and Martin Riedmiller. Learning an embedding space for transferable robot skills. 2018. +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. +Hengyuan Hu, Denis Yarats, Qucheng Gong, Yuandong Tian, and Mike Lewis. Hierarchical decision making by generating and following natural language instructions. In Advances in neural information processing systems, pp. 10025-10034, 2019. +JMcVLevine Hunt. Intrinsic motivation and its role in psychological development. In Nebraska symposium on motivation, volume 13, pp. 189-282. University of Nebraska Press, 1965. +Yiding Jiang, Shixiang Shane Gu, Kevin P Murphy, and Chelsea Finn. Language as an abstraction for hierarchical deep reinforcement learning. In Advances in Neural Information Processing Systems, pp. 9414-9426, 2019. +Hoang Le, Nan Jiang, Alekh Agarwal, Miroslav Dudik, Yisong Yue, and Hal Daumé. Hierarchical imitation and reinforcement learning. In International Conference on Machine Learning, pp. 2917-2926, 2018. +Jelena Luketina, Nantas Nardelli, Gregory Farquhar, Jakob Foerster, Jacob Andreas, Edward Grefenstette, Shimon Whiteson, and Tim Rocktäschel. A survey of reinforcement learning informed by natural language. In Proceedings of the Twenty-Eighth International Joint Conference on Artificial Intelligence, IJCAI-19, pp. 6309-6317. International Joint Conferences on Artificial Intelligence Organization, 7 2019. doi: 10.24963/ijcai.2019/880. URL https://doi.org/10.24963/ijcai.2019/880. +Corey Lynch and Pierre Sermanet. Grounding language in play. arXiv preprint arXiv:2005.07648, 2020. +Kenneth Marino, Abhinav Gupta, Rob Fergus, and Arthur Szlam. Hierarchical rl using an ensemble of proprioceptive periodic policies. ICLR, 2019. +David Matthews, Sam Kriegman, Collin Cappelle, and Josh Bongard. Word2vec to behavior: morphology facilitates the grounding of language in machines. 2019. + +Hongyuan Mei, Mohit Bansal, and Matthew R Walter. Listen, attend, and walk: Neural mapping of navigational instructions to action sequences. In Thirtieth AAAI Conference on Artificial Intelligence, 2016. +Andrew N Meltzoff. Imitation, objects, tools, and the rudiments of language in human ontogeny. Human evolution, 3(1-2):45-64, 1988. +Karthik Narasimhan, Regina Barzilay, and Tommi Jaakkola. Grounding language for transfer in deep reinforcement learning. Journal of Artificial Intelligence Research, 63:849-874, 2018. +Khanh Nguyen, Debadeepta Dey, Chris Brockett, and Bill Dolan. Vision-based navigation with language-based assistance via imitation learning with indirect intervention. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 12527-12537, 2019. +Junhyuk Oh, Satinder Singh, Honglak Lee, and Pushmeet Kohli. Zero-shot task generalization with multi-task deep reinforcement learning. In Proceedings of the 34th International Conference on Machine Learning-Volume 70, pp. 2661-2670. JMLR.org, 2017. +Ronald Parr and Stuart J Russell. Reinforcement learning with hierarchies of machines. In Advances in neural information processing systems, pp. 1043-1049, 1998. +John Schulman, Filip Wolski, Prafulla Dhariwal, Alec Radford, and Oleg Klimov. Proximal policy optimization algorithms. arXiv preprint arXiv:1707.06347, 2017. +Tianmin Shu, Caiming Xiong, and Richard Socher. Hierarchical and interpretable skill acquisition in multi-task reinforcement learning. In International Conference on Learning Representations, 2018. +Martin Stolle and Doina Precup. Learning options in reinforcement learning. In International Symposium on abstraction, reformulation, and approximation, pp. 212-223. Springer, 2002. +Richard S Sutton, Doina Precup, and Satinder Singh. Between mdps and semi-mdps: A framework for temporal abstraction in reinforcement learning. Artificial intelligence, 112(1-2):181-211, 1999. +Stefanie TELlex, Thomas Kollar, Steven Dickerson, Matthew R Walter, Ashis Gopal Banerjee, Seth Teller, and Nicholas Roy. Understanding natural language commands for robotic navigation and mobile manipulation. In Twenty-Fifth AAAI Conference on Artificial Intelligence, 2011. +Edward C Williams, Nakul Gopalan, Mine Rhee, and Stefanie TELlex. Learning to parse natural language to grounded reward functions with weak supervision. In 2018 IEEE International Conference on Robotics and Automation (ICRA), pp. 1-7. IEEE, 2018. +Haonan Yu, Haichao Zhang, and Wei Xu. Interactive grounded language acquisition and generalization in a 2d world. In International Conference on Learning Representations, 2018. URL https://openreview.net/forum?id=H1UOm4gA-. +Victor Zhong, Tim Roktaschel, and Edward Grefenstette. Rtfm: Generalising to new environment dynamics via reading. In International Conference on Learning Representations, 2020. URL https://openreview.net/forum?id=SJgob6NKvH. + +# A DATASET + +# A.1 COLLECTION PROCESS + +In this section, we provide additional details for our data collection process on Amazon Mechanical Turk (AMT). Firstly, we filter workers by the following criteria: a) HIT Approval % of greater than 95, b) Location is in an English speaking country, c) soft block has not been granted. These criteria help to ensure the quality of collected data, particularly in terms of natural language. + +![](images/a0e36752b224b6caa3da5327ad4366461e85bdbfd0e7bdb1d5f39e98030f00a1.jpg) +Figure 7: Workflow to collect human demonstrations for our dataset. + +We collected the dataset over the course of a few weeks. For each HIT, we paid the Turker $0.65. On average the task took about 3-4 minutes. For each HIT, we generate a unique entrance code that is provided to the Turker on the AMT website. The Turker is also provided with a unique exit code once the HIT is complete. Given the entrance and exit code we are able to pay workers accordingly for their demonstrations. + +Workers were provided with an entrance code at the beginning of the task to enter the website and an exit code when they completed the task to be able to submit the HIT. This enforces that we do not have workers doing extra HITs that we are unable to pay for and to ensure that worker who submit HITs have indeed completed our task. Then we also wrote a parsing script to be able to quickly verify all submitted HITs to the task before payment. Specifically, we used this script to manually review the list of instructions generated for each task to ensure that the instructions provided were indeed pertinent to the task at hand. + +We had many returning workers who completed our task. A few even wrote emails to our requesting email to let us know that they really enjoyed the HIT and thought it was quite interesting to work on. This suggests that collecting demonstrations of this kind is relatively interesting for humans to provide. + +# A.2 HIT INSTRUCTIONS + +Prior to starting the task, each worker was provided with this instructions page which gives an analogy for cooking stir-fry as an analogy for the types of instructions that we believe they would provide. The demo page is shown in Figure 8. + +Invoking users to provide a particular level of specificity was difficult to convey without explicitly providing example instructions. We deliberately chose not to provide examples as to not prime the worker to a particular format to follow. New workers were given two short games to complete to familiarize themselves with the environment. Returning workers were given one longer game to complete as they already had experience with the task. Workers who completed the task as previously described were fully compensated. + +Originally, some workers provided not enough instructions, meaning that they wanted to finish the task as quickly as possible, and other workers provided instructions that were too granular, meaning that they did not abstract the task into sub-tasks and rather wrote "press left" or "go up 1" as their instruction. Prior to approving the HIT, checked prior to the worker submitting the HIT and built in precautions so that they had to redo a level if they did not comply with such instructions clearly delineated in the demo. + +# Demo + +Welcome to the HIT! Read instructions carefully. If you do not follow the instructions below, we reserve the right to not pay for the HIT. + +Below is a snippet of a demo from Wikihow of the type of annotation we will be looking for, but in our game setting. + +These are their steps to make vegetable stir-fry. + +Notice how the tutorial gives you a one sentence description of each high level step, but it is not too specific about each action. + +1. Select vegetables to use. + +![](images/875ad7fde3db90898d71b1e3913598ffb044c89edd1e783796d1ec518ee8cd41.jpg) + +2. Wash and dry the vegetables... + +![](images/012cddfb6b7d460cd18b8ca61f3c3d10ef914afcf6560b5f72050696c5242dac.jpg) + +3. Slice the vegetables into thin pieces. + +![](images/e8e69f5e0acdcc545caed64c87eaea2633a09b116b9f9d51dfe27a4cce24245d.jpg) + +Credits to https://m.wikihow.com/Stir-Fry-Vegetables. + +Similarly, in our task, you will be given a goal for the agent to accomplish. + +![](images/044f6b4322283ef8000e4fe9bb5157bf4b0ff7757a150d8236fc54ccf76f1e94.jpg) + +And we want you to write the instruction steps to achieve this goal. + +1. Keep it high level and break the task down, just like Wikihow. +2. Do not write just the specific action (e.g. up, down, left, craft, mine, etc) or something like "press up" or "press left 2 times" which are not meaningful steps as your instruction. +3. Since we want high level steps, this means you will execute more than 1 action per instruction. + +![](images/a29dfa313ea3ee3ca4b369a0a9890ebb94e6cde704ccf4c39bc36e11049c7d00.jpg) + +Then, demonstrate how to do this step by executing the step using the UP, LEFT, DOWN, RIGHT (or arrow keys). + +Use the other buttons (or keys denoted in the parentheses), explained below to complete the task. + +![](images/6137288e00e61d9cdbbe02af39d0ec7f3c1a0cda5709ceac34f85b37767532be.jpg) +Figure 8: Demo instructions for AMT workers. + +After you have completed the first instruction, press the "DONE" button (or hit enter). + +![](images/1924ae6563336b0e0d13605c2a8dea6ef42d2039ac61c6d4ceb07647550bf499.jpg) + +Then return to write the next instruction, then execute, and do this step-by-step until goal is completed. + +![](images/08314b79893dd44c95a1860a41d37e9922d007a9f21220181532f23c91b63998.jpg) + +By the end of this game, you should have typed MULTIPLE instructions, each followed by a sequence of button/ key presses. + +You should be writing meaningful high level instructions which are not "up", "press up", or "go left 2 times". + +If you do not follow these instructions, you will not be paid. + +# A.3 ADDITIONAL ENVIRONMENT AND CRAFTING TASK DETAILS + +Figure 9 gives an example of the type of task (Make Iron Ore) that would be presented to the worker, which includes the goal, recipes, and the current board. Table 3 shows how the tasks are related in terms of sub-tasks. This might be because of a similar material (i.e. Iron) or a similar craft (i.e. Stairs). + +GOAL: + +Make Iron Ore (Iron Ore=1) + +RECIPES: + +![](images/e8306904a92fd5b27370bde02d2f228a355814ba9be167d8935e4b9fb5ebb2ce.jpg) +Ore Vein + +![](images/610d86987b9fc7eac81200c8ef3d330b7eb0812b569adc6dee773e043b45c10e.jpg) +Pickaxe + +![](images/e7ec9be7496475b4896a5c8b3798f23705785a7e960f051259b5254d4434d676.jpg) + +![](images/2f32dc912be2e65b691d4307aa769ddaac89b498a6b1965c174b2029076b6121.jpg) +Iron Ore + +![](images/ace0580c51a466955a62ac3a00da778d896240851040f5876b1df17d0234a6ef.jpg) +Figure 9: Example board and goal configuration where the goal is to make an iron ore. The worker uses the recipes provided to give appropriate instructions and execute accordingly. + +Table 3: List of recipes for which we have collected annotations, labeled by the number of steps needed to complete it and other recipes which may share sub-tasks of underlying structure. + +
IDRecipe NameStepsRelated Crafts by ID
1Gold Ore12
2Iron Ore11,8
3Diamond Boots212,14
4Brick Stairs25,7
5Cobblestone Stairs24,7,13
6Wooden Door37
7Wood Stairs34,5,6
8Iron Ingot32
9Leather Leggings310,11,12
10Leather Chestplate39,11,12
11Leather Helmet39,10,12
12Leather Boots33,9,10,11
13Stone Pickaxe55,14
14Diamond Pickaxe53,13
+ +![](images/b6faff0c2c639eb99b1237678a0eb3bc36ded58807b384e62d7612238cde3ea2.jpg) +Figure 10: A more in-depth example of 3 out of the 14 training tasks to show how the subtasks are related (red boxes = final craft, blue boxes = raw material). + +![](images/eb75e244be4270a0a6c02bf36c2077fe9a0aaa92ea2a1945eb390580721117a1.jpg) + +![](images/055e84bce56fb1abdd9b796f465264529f8cb09733a4690295653f25d1a6134c.jpg) + +Table 4: Summary statistics for tasks of varying difficulty. + +
StepsAverage # of InstructionsAverage # of Actions
1-step3.715.4
2-step4.921.5
3-step6.127.6
5-step8.840.1
+ +# A.4 EXAMPLE DATA COLLECTED + +Table 5 gives examples of instructions randomly sampled from our dataset. Even with a limited number of crafts, we were able to collect language instructions with diversity in sentence construction. There are inconsistencies in capitalization and spelling which we handled in the preprocessing of the data. Table 6 shows the most frequently used instructions. Figure 11 gives summary statistics of the instruction side of the dataset. + +![](images/cb38ba98165aa1b01eaf94ab244c41ba420bbb93ff815261d2dd4872b5182240.jpg) +Figure 11: (Left) Instruction frequency (Middle) Word frequency (Right) Histogram of instruction lengths. + +![](images/7dc872b53a8585d0306ea531d15f9606cc3133ac1cfb8b4583fa084155f7f528.jpg) + +![](images/2e0ae962d10c5ddfc0073cc4854be861618e1cb0b9fe5fe7f94c884fc608315e.jpg) + +Table 5: Examples of randomly sampled instructions. + +
Grab the pickaxe. +Make a stone pickaxe from stick and cobblestone. +Go to leather boots bench and Craft Leather Boots. +Move to Tree. +Craft at the leather helmet bench +Make a leather chestplate from the leather. +Unlock the door. +Move up two squares and grab the key. +Go to switich and open door with Toggle Switch. +Chop down the tree to get its wood. +Go to the stone pickaxe crafting bench. +Mine diamond ore. +Go to stock and click Mine to harvest Cobblestone. +Toggle the switch to open the door. +Grab the pickaxe. +Go back through door and mine gold ore vein. +Walk to brick factory and acquire bricks. +Go to wood bench and Craft Wood Plank. +Craft Diamond Pickaxe. +Move to ingot. +Next step, use axe on tree to get wood. +Go to iron ore vein and mine for iron ore. +Unlock the door with the key and enter the room. +Pick up axe and put into inventory. +Craft at the stick bench. +Open the door to your right. +Mine the cobblestone stash. +Get eht pickaxe. +Go to tools and click Grab to take each one.Craft diamond axe with its bench, stick, diamond. +Pick up key using "GRAB". +Grab the key; this may be useful. +Collect Tool and Pass Through Door. +Go to brick stairs bench and craft. +Move up to the axe and pick it up. +Use Mine on Iron Ore Vein to collect Iron. +Use pickaxe to mine diamond ore vein. +Move to Stick bench and Craft Stick. +Craft Wood Plank. +Harvest wood from tree using "MINE". +2. "Open Door", then move to Pickax and "grab". +Craft brick stairs with its bench and brick. +Go "Mine" both the iron ore vein and the coal vein. +Mine the wood. +Mine Diamond Ore Vein. +Chop down the tree to get its wood. +Move to Rabbit. +Go to tools and click Grab to take each one. +Grab key. +Go to stick workbench and press craft. +Go to TOOL (Pickaxe). +Go to the stone pickaxe table. +Move to Wood Plank bench and Craft. +Mine cobblestone stash, then go to tree. +Craft Wooden Door. +Craft diamond boots. +Use pickaxe to mine iron ore vein. +Flip the switch.
+ +# B METHODS DETAILS + +Given the dataset of human demonstrations, we convert traces of each game into state-action pairs for training. In the subsequent sections are additional details of training parameters for both the supervised IL training and RL fine-tuning. The computing infrastructure for each experiment was on 1 GeForce GTX 1080 Ti GPU. Each experiment took between a few hours to a few days to run. + +# B.1 DATA PREPROCESSING + +From the dataset, which had 6,322 game traces, we extracted 195,405 state-action pairs and 35,901 total instructions. This is done by matching an action to the corresponding state within a trace as well as the high-level natural language instruction. Each instruction was edited using a spell checker package to reduce the size of the final vocabulary. In the link above, we provide the cleaned version of the dataset. + +# B.2 IL PARAMETERS + +Both language generation and language-conditioned policy networks use Cross Entropy Loss and Adam optimizer (learning rate 0.001). In addition, the language loss also includes the addition of doubly stochastic regularization, based on the attention mechanism, and clipping of the gradient norm to a max norm of 3. We train for 15-20 epochs. The batch size used during supervised training was 64. By evaluating after each epoch on 100 randomly spawned games, we find that performance plateaus after that number of epochs. As in the RL reward, we only consider a game to be complete if the final craft is completed within the given number of steps. We use the entire dataset for training, since validation/testing were performed on randomly generated new games. + +Table 6: Instruction sorted by usage frequency. + +
Grab pickaxe. +Grab the pickaxe. +Open the door. +Open door. +Grab axe. +Craft wood plank. +Toggle the switch. +Grab the key. +Mine tree. +Grab key. +Craft stick. +Toggle switch to open door. +Grab the axe. +Toggle switch. +Go to pickaxe. +Go to wood bench and craft wood plank. +Grab key to open door. +Get the pickaxe. +Go to tools and click grab to take each one. +Craft leather. +Go to key grab it go to door and open door. +Go to switch and open door with toggle switch. +Go to tree. +Grab the sword. +Go to stick bench and craft stick. +Mine the tree. +Grab sword. +Pick up pickaxe using grab. +Mine rabbit.Mine cobblestones stash. +Pick up the pickaxe. +Go to switch. +Go to pickaxe and click grab to take it. +Go to wood plank and press craft. +Go to axe. +Get the key. +Mine diamond ore vein. +Mine cobblestones. +Go to stick and press craft. +Go to pickaxe and select "grab". +Make planks. +Use key to open door. +Craft diamond pickaxe. +Go to pickaxe and press grab. +Craft stone pickaxe. +Unlock the door. +Make sticks. +Go to stone bench and craft stone pickaxe. +Mine the diamond ore vein. +Go to key. +Go to door. +Mine cobblestone stash. +Grab axe to mine tree. +Pick up axe using grab. +Get the axe. +Go to stocks click mine to harvest wood/stone. +Craft wood plank with its bench and wood. +Use the switch to open the door.
+ +Table 7: We compare to some related datasets/environments (Chevalier-Boisvert et al., 2019b; Jiang et al., 2019; Hu et al., 2019; Anderson et al., 2018). We don't report dataset size for an environment that generates synthetic language. Note that $\sim$ means limited evaluation, they demonstrate unseen evaluation on one setting only). Most notably, our work focuses on developing a method that performs well on unseen tasks. We want to clarify that unseen means tasks/environments which the agent has never received supervised reward for. This is not the same as generating a new configuration of a task that the agent received reward for in training. + +
DatasetLanguageDataset SizeTaskUnseen Tasks
BabyAISynthetic-Navigation/object placementNo
HAL/CLEVRSynthetic-Object sorting/arrangement~
R2RNatural10,800 ViewsVision+language navigationYes
MiniRTSNatural5,392 GamesReal-time strategy gameNo
OursNatural6,322 GamesCompositional crafting tasksYes
+ +# B.3 RL PARAMETERS + +To fine-tune with RL, we first created a gym environment for the Maze game, which at reset time will spawn a new Mazebase game in the backend. In the parameters of the environment, we define the maximum episode steps to be 100. The action space of the environment is Discrete space of size 8 (up, down, left, right, toggle switch, grab, craft, mine) and the observation space is a flat vector that concatenates all state observations. For the PPO algorithm, we use a learning rate of 2.5e4, clip parameter of 0.1, value loss coefficient of 0.5, 8 processes, 128 steps, size 4 mini-batch, linear learning rate decay, 0.01 entropy coefficient, and 100000000 environment steps. + +# B.4 ARCHITECTURE DETAILS + +# B.4.1 STATE ENCODING + +As shown in Figure 12, the relevant information about the state that is encoded includes the $5 \times 5$ grid, inventory, and goal. We have two representations of the $5 \times 5$ grid: one with items relevant for crafting and another with a one-hot representation of non-crafting-related items, such as a door, wall, or key. All crafting-related items on the board, inventory, and goal are embedded using a 300-dimension GloVe embedding, summing the embeddings for multiple word items (i.e. Iron Ore Vein). The intuition for this distinction is that for generalization, crafting items should be associated in terms of compositionality, whereas non-crafting items are standalone. + +To compute the state encoding, we first passed the two grids, inventory, and goal through separate fully connected layers to reduce to the same dimension and concatenated along the vectors. The final size of the state encoding tensor is (27, 128), where 25 are for the grid, 1 for inventory, and 1 for goal. + +![](images/1b624554d1593f350b24eedb99ccfd22d78fb17aae26fe549df1e895c5fcc448.jpg) +Figure 12: At each time step we encode state relevant observations including the goal, inventory, and grid. This encoding is utilized by both the language generator and the language-conditioned policy. The boxes in green, denote the observations that were encoded using the GloVe embedding. + +# B.4.2 IL W/ DISCRIMINATIVE LANGUAGE + +Since Hu et al. (2019) is a closely related work to ours, we wanted to compare our method against theirs. Their method only uses behavioral cloning, which is our IL w/ Generative Language but instead with discriminative language. We modify our high-level language generator to discriminate amongst the most frequent $N = 500$ instructions by adapting code released from Hu et al. (2019) of their LSTM-based language model here). We plugged in our own state encoding instead of theirs, which is anyways tailored to their environment. In summary, the high-level language module is largely the same as our model, both LSTMs, except for the modification of the output layer, which predicts over the set of possible instructions. We similarly extract the hidden state to condition the low-level policy on. The low-level policy is kept the same as our IL w/ Generative Language model for fair comparison. The training parameters are the same as other baselines. + +# B.4.3 OUR METHOD + +The state encoder, which is used in the high- and low-level model is covered in the section above. The size of the hidden layer in the language generator LSTM takes input size 128 and has a hidden size of 32. The size of layers in the policy network is 48 and 8, and uses ReLU activations. + +# B.4.4 STATE RECONSTRUCTION + +The state reconstruction architecture was instantiated using an autoencoder with 4 hidden layers, taking as input the state encoding tensor. The low-dimensional representation after 2 hidden layers is used as the hidden state for the policy. The autoencoder is trained with MSE loss on the state encoding. This model trained for a total of 25 epochs in the IL phase. + +# B.4.5 STATE PREDICTION + +The state prediction architecture largely resembled the language generator. However, we removed the GloVe weight embedding layer. In IL training, the dataset was modified to include the past $T$ states. In RL training, the environment was modified to record the previous $T$ states. If there were $< T$ states in the current trajectory, the same state is used as input and subsequently replaced. The recurrent network is trained with MSE loss on the state encoding. This model trained for a total of 20 epochs in the IL phase. + +# B.4.6 UNI-MODAL INPUT + +A baseline we considered, but did not included in the main text, is to evaluate the necessity of the state encoding in multi-modal datasets. In other works, language instructions are sufficient to solve the task without a state encoding or some representation of the current state. This ablation helps verify that the generated instructions are sufficiently high level that they do not provide the agent with all the information necessary to complete the task in addition to the simulator itself. We considered a baseline where the agent only sees language instructions without the state encoding, so the state encoding is used to generate language, but is not provided as additional input to the policy network. This performs poorly and is not able to solve even the simplest 1-step task. We believe this is because a representation of the current state is critical to completing the task completion, and is not captured by the high-level instructions. + +# C SUPPLEMENTARY RESULTS + +# C.1 IL RESULTS IN STANDARD SETTING + +As shown in Table 8, having access to natural language instructions is only marginally beneficial. While the two environments capture different tasks, we found empirically that the model proposed by Hu et al. [14], which is most similar to our IL+Lang baseline, was able to solve their miniRTS environment using a similarly sized dataset to ours, whereas IL+Lang is not sufficient to complete the most difficult tasks in our environment. + +Table 8: Accuracy of IL (with and without language) evaluated over 100 games with 3 different seeds. + +
StepsIL no languageIL Gen. LanguageIL Disc. Language
1-step18.00%± 3.55%19.33% ± 1.89%20.00% ± 1.35%
2-step0.00%± 0.00%9.33% ± 2.05%8.33%± 0.98%
3-step0.00%± 0.00%4.33% ± 0.47%0.00%± 0.00%
5-step0.00%± 0.00%0.00%± 0.00%0.00%± 0.00%
+ +# C.2 DEMONSTRATION ONLY AND FEW-SHOT + +As shown in Table 9, we find low deviation in our multiple variance runs. However, we do observe in some cases such as IL+RL $10\%$ and $100\%$ higher variance because in some trials the model was not able to solve any of the 3-step tasks and in others it was. In the cases of low variance, either the model was able to consistently or not solve the tasks. + +Table 9: Variance results from Table 3 in the main paper, which presents accuracy. + +
ILIL w/LangIL+RLSPSROurs
Steps5%10%100%5%10%100%5%10%100%5%10%100%5%10%100%5%10%100%
1-step2%1%3%5%3%2%2%5%8%3%1%2%4%3%1%1%2%2%
2-step1%1%0%1%1%1%9%10%17%19%9%13%8%40%15%1%3%7%
3-step1%2%0%0%0%0%1%33%31%14%24%18%0%7%15%4%27%10%
+ +# C.3 REWARD ONLY + +Finally, for completeness, we consider the scenario where the agent receives a reward but no demonstrations. The tasks which we select for this setting are sampled from the unseen tasks list. We + +choose 3 2-5 step crafts. We evaluate this scenario on our method against other baselines which train using a reward signal. In Table 10, we evaluate on tasks for which we do not have demonstrations and fine-tune a trained model with the reward signal for these tasks. This setting is not very interesting from a generalization perspective, since rewards are a far more expensive resource compared to demonstrations and instructions. We don't include 1-step tasks since that is able to be solved easily by RL alone (see 1-step results in Figure 4). IL and IL w/ Language is not included because this reduces to the zero shot setting. + +Table 10: Comparison of 2-5 step tasks where only reward is provided to the agent. We believe IL+RL is not able to adapt to these new tasks, given reward only, since it has overfit to the original training tasks. We find that our method outperforms baselines in this setting. + +
StepsRLIL+RLOurs
2-step92.00%±0.81%0%95.33%±0.94%
3-step71.67%±0.47%0%88.00%±1.41%
5-step0.00%±0.00%0%65.00%±5.67%
+ +# C.4 INTERPRETABILITY + +Table 11: Step-by-step discriminated high-level instructions for seen crafts. + +
Goal: Iron Ore +grab the pickaxe +mine iron ore +mine the iron ore vein +unknownGoal: Gold Ore +unknown +go to the key +unknown +go to gold ore vein and mine
Goal: Brick Stairs +grab key and open door +mine bricks +unknownGoal: Cobblestone Stairs +take the pickaxe +go to cobblestone stash and mine +use pickaxe to mine cobblestone stash +go to cobblestone stash and mine +got to stock and click mine to harvest cobblestones +unknown +craft cobblestone stairs
Goal: Diamond Boots +unknown +go to pickaxe +unknownGoal: Iron Ore +toggle switch to open door +take the pickaxe +toggle switch to open door +unknown
+ +We present more examples of generated language for both seen and unseen tasks (Table 12 and Table 13). The tables show a complete set of instructions for tasks which were successfully completed. We observe that if the task was not complete then the language generator would be stuck on a particular instruction. The language generated for tasks where the model received supervised data is, as expected, more consistent in using the correct language when generating instructions. However, the language generated for tasks which are new to the model also generated instructions which indicated the use of the correct items. We can observe some mistakes such as generating "leather boots" instead of "leather stairs" or generating an unknown token. Particularly for the Gold/Brick Pickaxe examples, the model is able to generate fairly consistent language for a challenging, new 5-step task. Note that in the Gold Pickaxe example, the model was not able to predict the use of item gold so it uses the word stocks. In the Brick Pickaxe example the model correctly inferred the use of brick. These inconsistencies perhaps can be explained by the amount of training examples where brick and gold appeared, with the former being much more frequent than the latter. + +Natural language allows us to understand why a model fails to complete a task from simply looking at the generated instructions, which can facilitate future model development and refinement. We identify two failure cases: (1) failure of language generation and (2) failure of policy. In (1), we + +Table 12: Step-by-step generated high-level instructions for seen crafts. + +
Goal: Gold Ore +go to key and press grab. +go to pickaxe and grab. +go to gold ore vein and mine.Goal: Brick Stairs +go to pickaxe and press grab. +go to the brick factor and mine brick. +go to brick stairs and press craft.
Goal: Diamond Pickaxe +go to axe and press grab. +go to key grab it go to door and open door. +go to tools and click grab to take each one. +go to tree and press mine. +go to stocks click mine to harvest. +go to tree and mine. +go to wood plank and press craft. +go to stick bench and craft stick.Goal: Wooden Door +go to the axe and grab it. +go to the switch and open door. +go to the axe and grab it. +go to the tree. +go to the tree and press mine. +go to wood plank and press craft. +go to wood plank bench and craft wooden door.
Goal: Leather Helmet +go to sword and click grab to take it. +go to key and press grab. +go to sword and click grab to take it. +go to rabbit and press mine. +go to leather and press craft. +go to leather boots bench and craft leather.Goal: Diamond Boots +go to key and press grab. +go to pickaxe and press grab. +go to diamond ore vein and mine. +go to diamond boots and press craft. +go to diamond bench and craft diamond boots.
Goal: Iron Ore +go to key and press grab. +go to pickaxe and press grab. +go to iron ore vein and press mine.Goal: Cobblestone Stairs +go to key and press grab. +go to pickaxe and press grab. +go to cobblestone stash and press mine. +go to cobblestone stairs and press craft.
Goal: Wood Stairs +go to axe and press grab. +go to tree and mine. +go to wood plank and press craft. +go to wood stairs and press craft.Goal: Leather Chestplate +go to sword and press grab. +go to rabbit and mine. +go to leather and craft. +go to leather chestplate and craft.
Goal: Leather Leggings +go to sword and click grab to take it. +go to rabbit and press mine. +go to leather and press craft. +go to leather bench and craft leatherGoal: Iron Ingot +go to key and press grab. +go to pickaxe and press grab. +go to iron ore vein and mine. +go to iron ingot and craft.
+ +observe occasional instructions generated for unseen tasks which have incorrect crafting materials. For example, "Go to iron ingot and press craft" was generated as an instruction for Gold Ingot. In (2), while the generated language is sensical for the task, the policy failed to execute correctly. + +Table 13: Step-by-step generated high-level instructions for unseen crafts. + +
Goal: Cobblestone Boots +go to key and press grab. +go to pickaxe and press grab. +go to cobblestone stash and mine. +go to workbench and press craft.Goal: Diamond Leggings +go to pickaxe and press grab. +go to diamond ore vein and mine. +go to diamond boots and press craft.
Goal: Leather Stairs +go to sword and press grab. +go to rabbit and mine the rabbit. +go to leather and press craft.Goal: Stone Helmet +go to pickaxe and press grab. +go to the cobblestones stash and mine. +go to the workbench and craft.
Goal: Diamond Ingot +go to pickaxe and press grab. +go to diamond ore vein. +go to the workbench and craft.Goal: Brick Door +go to pickaxe and press grab. +go to the brick factory and mine the brick. +go to the brick stairs and craft.
Goal: Brick Pickaxe +go to the pickaxe and grab it +go to the axe and press grab. +go to the tree. +go to the tree and mine. +go to the brick factory and mine. +go to the wood plank and craft. +go to the stick bench and craft stick. +go to stick and craft.Goal: Gold Pickaxe +go to the pickaxe and press grab. +go to the axe and grab it. +go to the tree. +go to stocks and click mine to harvest <unk>. +go to the tree and mine the tree. +go to wood plank and press craft. +go to stick and press craft.
Goal: Diamond Stairs +go to key and press grab. +go to pickaxe and press grab. +go to the diamond ore vein and mine. +go to the bench and craft.Goal: Wood Chestplate +go to key and grab it. +go to axe and grab it. +go to the tree. +go to tree and mine. +go to wood plank and craft.
+ +Table 14: Example of instruction and inventory side-by-side for 3 unseen tasks. As in Figure 6 from the main paper, the inventory changes when a subtask, given by the instruction, is completed. + +
Goal: Leather Door
InstructionInventory
go to the sword and grab it{'Sword': 1}
go to the rabbit and mine{'Sword': 1, 'Rabbit Hide': 1}
go to the leather and press craft{'Sword': 1, 'Rabbit Hide': 0, 'Leather': 1}
go to the leather boots bench and craft leather{'Sword': 1, 'Rabbit Hide': 0, 'Leather': 0, 'Leather Door': 1}
+ +
Goal: Stone Boots
InstructionInventory
go to key and press grab{'key': 1}
go to pickaxe and press grab{'key': 1, 'Pickaxe': 1}
go to the cobblestone stash and mine the <unk>{'key': 1, 'Pickaxe': 1, 'Cobblestone': 1}
go to the bench and craft{'key': 1, 'Pickaxe': 1, 'Cobblestone': 0, 'Stone Boots': 1}
+ +
Goal: Diamond Stairs
InstructionInventory
go to key and press grab{'key': 1}
go to pickaxe and press grab{'key': 1, 'Pickaxe': 1}
go to the diamond ore vein{'key': 1, 'Pickaxe': 1}
go to diamond ore vein and mine{'key': 1, 'Pickaxe': 1, 'Diamond': 1}
go to the bench and craft{'key': 1, 'Pickaxe': 1, 'Diamond': 0, 'Diamond Stairs': 1}
\ No newline at end of file diff --git a/askyourhumansusinghumaninstructionstoimprovegeneralizationinreinforcementlearning/images.zip b/askyourhumansusinghumaninstructionstoimprovegeneralizationinreinforcementlearning/images.zip new file mode 100644 index 0000000000000000000000000000000000000000..786f387b13dde7e15375b9df29ddd9203290f3a4 --- /dev/null +++ b/askyourhumansusinghumaninstructionstoimprovegeneralizationinreinforcementlearning/images.zip @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e346401a13b901396384fdf729d03e89f02a8109c06806f3fde8783f0a5f7264 +size 1583792 diff --git a/askyourhumansusinghumaninstructionstoimprovegeneralizationinreinforcementlearning/layout.json b/askyourhumansusinghumaninstructionstoimprovegeneralizationinreinforcementlearning/layout.json new file mode 100644 index 0000000000000000000000000000000000000000..09c6a9676af22a919e21cb415f32ff76f04efc63 --- /dev/null +++ b/askyourhumansusinghumaninstructionstoimprovegeneralizationinreinforcementlearning/layout.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:760d2158e69ef233ffdc93d222134a58b2e14c9d7d2c229acab69b89fcc4c00f +size 494733 diff --git a/attentionalconstellationnetsforfewshotlearning/8d357406-6e29-47af-b7d2-458a8aaa9f4c_content_list.json b/attentionalconstellationnetsforfewshotlearning/8d357406-6e29-47af-b7d2-458a8aaa9f4c_content_list.json new file mode 100644 index 0000000000000000000000000000000000000000..4f541b9913dd3394338c992fbe69780b4c739ca7 --- /dev/null +++ b/attentionalconstellationnetsforfewshotlearning/8d357406-6e29-47af-b7d2-458a8aaa9f4c_content_list.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0e72f0dafe3d223eca9c522e8875088c6ea35662a823d42db4d4254d6a54d40d +size 110791 diff --git a/attentionalconstellationnetsforfewshotlearning/8d357406-6e29-47af-b7d2-458a8aaa9f4c_model.json b/attentionalconstellationnetsforfewshotlearning/8d357406-6e29-47af-b7d2-458a8aaa9f4c_model.json new file mode 100644 index 0000000000000000000000000000000000000000..6e6dff1c89d950ad1f31f17c0ea452486e3502b0 --- /dev/null +++ b/attentionalconstellationnetsforfewshotlearning/8d357406-6e29-47af-b7d2-458a8aaa9f4c_model.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9686f7134be3d15e24baa19d03be1d4cc25476c3167ad366c289d5eb5dc48036 +size 132853 diff --git a/attentionalconstellationnetsforfewshotlearning/8d357406-6e29-47af-b7d2-458a8aaa9f4c_origin.pdf b/attentionalconstellationnetsforfewshotlearning/8d357406-6e29-47af-b7d2-458a8aaa9f4c_origin.pdf new file mode 100644 index 0000000000000000000000000000000000000000..a830aa96fe21c279385287d78c33eeffe0d60297 --- /dev/null +++ b/attentionalconstellationnetsforfewshotlearning/8d357406-6e29-47af-b7d2-458a8aaa9f4c_origin.pdf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0decbce91088f71525fc77ad7c0d9b5e5c8ae8af5236dfda244ee286674cb01c +size 3961693 diff --git a/attentionalconstellationnetsforfewshotlearning/full.md b/attentionalconstellationnetsforfewshotlearning/full.md new file mode 100644 index 0000000000000000000000000000000000000000..cc33a909c78f0cdea7023be1b3a4e1d4235a0953 --- /dev/null +++ b/attentionalconstellationnetsforfewshotlearning/full.md @@ -0,0 +1,419 @@ +# ATTENTIONAL CONSTELLATION NETS FOR FEW-SHOT LEARNING + +Weijian $\mathbf{X}\mathbf{u}^{*1}$ , Yifan $\mathbf{X}\mathbf{u}^{*1}$ , Huajin Wang $^{*1}$ & Zhuowen $\mathbf{T}\mathbf{u}^{1,2}$ + +University of California San Diego1, Amazon Web Services2 + +{wex041,yix081,huw011,ztu}@ucsd.edu + +# ABSTRACT + +The success of deep convolutional neural networks builds on top of the learning of effective convolution operations, capturing a hierarchy of structured features via filtering, activation, and pooling. However, the explicit structured features, e.g. object parts, are not expressive in the existing CNN frameworks. In this paper, we tackle the few-shot learning problem and make an effort to enhance structured features by expanding CNNs with a constellation model, which performs cell feature clustering and encoding with a dense part representation; the relationships among the cell features are further modeled by an attention mechanism. With the additional constellation branch to increase the awareness of object parts, our method is able to attain the advantages of the CNNs while making the overall internal representations more robust in the few-shot learning setting. Our approach attains a significant improvement over the existing methods in few-shot learning on the CIFAR-FS, FC100, and mini-ImageNet benchmarks. + +# 1 INTRODUCTION + +Tremendous progress has been made in both the development and the applications of the deep convolutional neural networks (CNNs) (Krizhevsky et al., 2012; Simonyan & Zisserman, 2015; Szegedy et al., 2015; He et al., 2016; Xie et al., 2017). Visualization of the internal CNN structure trained on e.g. ImageNet (Deng et al., 2009) has revealed the increasing level of semantic relevance for the learned convolution kernels/filters to the semantics of the object classes, displaying bar/edge like patterns in the early layers, object parts in the middle layers, and face/object like patterns in the higher layers (Zeiler & Fergus, 2014). In general, we consider the learned convolution kernels being somewhat implicit about the underlying objects since they represent projections/mappings for the input but without the explicit knowledge about the parts in terms of their numbers, distributions, and spatial configurations. + +On the other hand, there has been a rich history about explicit object representations starting from deformable templates (Yuille et al., 1992), pictorial structure (Felzenszwalb & Huttenlocher, 2005), constellation models (Weber et al., 2000; Fergus et al., 2003; Sudderth et al., 2005; Fei-Fei et al., 2006), and grammar-based model (Zhu & Mumford, 2007). These part-based models (Weber et al., 2000; Felzenszwalb & Huttenlocher, 2005; Fergus et al., 2003; Sudderth et al., 2005; Zhu & Mumford, 2007) share three common properties in the algorithm design: (1) unsupervised learning, (2) explicit clustering to obtain the parts, and (3) modeling to characterize the spatial configuration of the parts. Compared to the CNN architectures, these methods are expressive with explicit part-based representation. They have pointed to a promising direction for object recognition, albeit a lack of strong practice performance on the modern datasets. Another line of object recognition system with the part concept but trained discriminatively includes the discriminative trained part-based model (DPM) (Felzenszwalb et al., 2009) and the spatial pyramid matching method (SPM) (Lazebnik et al., 2006). In the context of deep learning, efforts exist to bring the explicit part representation into deep hierarchical structures (Salakhutdinov et al., 2012). + +The implicit and explicit feature representations could share mutual benefits, especially in few-shot learning where training data is scarce: CNNs may face difficulty in learning a generalized representation due to lack of sufficient training data, whereas clustering and dictionary learning + +provide a direct means for data abstraction. In general, end-to-end learning of both the implicit and explicit part-based representations is a viable and valuable means in machine learning. We view convolutional features as an implicit part-based representation since they are learned through back-propagation via filtering processes. On the other hand, an explicit representation can be attained by introducing feature clustering that captures the data abstraction/distribution under a mixture model. + +In this paper, we develop an end-to-end framework to combine the implicit and explicit part-based representations for the few-shot classification task by seamlessly integrating constellation models with convolution operations. In addition to keeping a standard CNN architecture, we also employ a cell feature clustering module to encode the potential object parts. This procedure is similar to the clustering/codebook learning for appearance in the constellation model (Weber et al., 2000). The cell feature clustering process generates a dense distance map. We further model the relations for the cells using a self-attention mechanism, resembling the spatial configuration design in the constellation model (Weber et al., 2000). Thus, we name our method constellation networks (ConstellationNet). We demonstrate the effectiveness of our approach on standard few-shot benchmarks, including FC100 (Oreshkin et al., 2018), CIFAR-FS (Bertinetto et al., 2018) and mini-ImageNet (Vinyals et al., 2016) by showing a significant improvement over the existing methods. An ablation study also demonstrates the effectiveness of ConstellationNet is not achieved by simply increasing the model complexity using e.g. more convolution channels or deeper and wider convolution layers (WRN-28-10 (Zagoruyko & Komodakis, 2016)) (see ablation study in Table 3 and Figure 2 (e)). + +# 2 RELATED WORK + +Few-Shot Learning. Recently, few-shot learning attracts much attention in the deep learning community (Snell et al., 2017; Lee et al., 2019). Current few-shot learning is typically formulated as a meta-learning problem (Finn et al., 2017), in which an effective feature embedding is learned for generalization across novel tasks. We broadly divide the existing few-shot learning approaches into three categories: (1) Gradient-based methods optimize feature embedding with gradient descent during meta-test stage (Finn et al., 2017; Bertinetto et al., 2018; Lee et al., 2019). (2) Metric-based methods learn a fixed optimal embedding with a distance-based prediction rule (Vinyals et al., 2016; Snell et al., 2017). (3) Model-based methods obtains a conditional feature embedding via a weight predictor (Mishra et al., 2017; Munkhdalai et al., 2017). Here we adopt ProtoNet (Snell et al., 2017), a popular metric-based framework, in our approach and boost the generalization ability of the feature embeddings with explicit structured representations from the constellation model. Recently, Tokmakov et al. (2019) proposes a compositional regularization to the image with its attribute annotations, which is different from out unsupervised part-discovery strategy. + +Part-Based Constellation/Discriminative Models. The constellation model family (Weber et al., 2000; Felzenszwalb & Huttenlocher, 2005; Fergus et al., 2003; Sudderth et al., 2005; Fei-Fei et al., 2006; Zhu & Mumford, 2007) is mostly generative/expressive that shares two commonalities in the representation: (1) clustering/codebook learning in the appearance and (2) modeling of the spatial configurations. The key difference among these approaches lies in how the spatial configuration is modeled: Gaussian distributions (Weber et al., 2000); pictorial structure (Felzenszwalb & Huttenlocher, 2005); joint shape model (Fergus et al., 2003); hierarchical graphical model (Sudderth et al., 2005); grammar-based (Zhu & Mumford, 2007). These constellation models represent a promising direction for object recognition but are not practical competitive compared with deep learning based approaches. There are also discriminative models: The discriminatively trained part-based model (DPM) (Felzenszwalb et al., 2009) is a typical method in this vein where object parts (as HOG features (Dalal & Triggs, 2005)) and their configurations (a star model) are learned jointly in a discriminative way. The spatial pyramid matching method (SPM) (Lazebnik et al., 2006) has no explicit parts but instead builds on top of different levels of grids with codebook learned on top of the SIFT features (Lowe, 2004). DPM and SPM are of practical significance for object detection and recognition. In our approach, we implement the constellation model with cell feature clustering and attention-based cell relation modeling to demonstrate the appearance learning and spatial configuration respectively. + +Parts models are extensively studied in fine-grained image classifications and object detection to provide spatial guidance for filtering uninformative object proposals (Simon & Rodner, 2015; Peng et al., 2017; Zhu et al., 2017; Ge et al., 2019; Qi et al., 2019). Related to our work, Neural Activation Constellations (NAC) (Simon & Rodner, 2015) introduces the constellation model to perform unsupervised part model discovery with convolutional networks. Our work is different from NAC in three aspects: (1) The algorithmic mechanisms behind Simon & Rodner (2015) and ours are + +![](images/bb50089c3fb3cd1f0bfbacd530f2282b2e6453281e12bb124769864c57a1a3f4.jpg) +Figure 1: Illustration of our ConstellationNet pipeline where the bottom part is the network architecture based on Conv-4 backbone, and the top part shows the constellation model. Our proposed ConstellationNet consists of "Constell." modules that perform explicit cell feature clustering with self-attention for joint relation modeling. + +different. Simon & Rodner (2015) implements a traditional Gaussian-based constellation module to model the spatial configuration and part selection on top of a fixed pre-trained CNN. However, in our ConstellationNet, our part representation and spatial configuration are modeled by cell feature clustering and self-attention based cell relation module, which is general-purpose, modularized and recursive. (2) In Simon & Rodner (2015), the constellation module is optimized in an EM-like algorithm, which is separate from the CNN optimization. Our constellation modules are seamlessly integrated into the current CNNs and jointly optimized with them. (3) Our ConstellationNet uses the dense cell features from the CNN feature maps, which considers all positions from the images as potential parts and models their relation. However, (Simon et al. 2015) extracts sparse part representations (i.e. it uses at most one part proposal per channel and selects even less parts later), which may not fully utilize the rich information from the CNN feature maps. + +# 3 FEW-SHOT LEARNING + +In a standard classification problem, we aim to learn a model trained on the dataset $\mathcal{D}^{\mathrm{base}}$ that can generalize its classification ability to unseen test set $\mathcal{D}^{\mathrm{novel}}$ belonging to same categories. In few-shot classification problem, we encourage $\mathcal{D}^{\mathrm{base}}$ and $\mathcal{D}^{\mathrm{novel}}$ to be formed from different categories to emphasize model's generalization ability on novel categories, where we denote training categories as $\mathcal{C}_{\mathrm{base}}$ , test categories as $\mathcal{C}_{\mathrm{novel}}$ , and $\mathcal{C}_{\mathrm{base}} \cap \mathcal{C}_{\mathrm{novel}} = \emptyset$ to ensure the fairness. + +In the training stage (a.k.a. meta-train stage), metric-based few-shot learning approaches (Snell et al., 2017; Vinyals et al., 2016; Oreshkin et al., 2018) usually learn a feature extractor $\phi(\mathbf{x})$ on the dataset $\mathcal{D}^{\mathrm{base}}$ to obtain generic feature embedding by optimizing the loss $\mathcal{L}(\phi)$ : + +$$ +\mathcal {L} (\phi) = \mathbb {E} _ {\left\{\left(\mathbf {x}, y\right) \right\} \sim \mathcal {D} _ {\text {b a s e}}} \ell \left(\left\{\left(\phi (\mathbf {x}), y\right) \right\}\right) \tag {1} +$$ + +where $\{(\mathbf{x},y)\}$ is a sampled mini-batch of data points and $\ell (\cdot)$ is usually an episodic few-shot loss (Vinyals et al., 2016) or a standard cross-entropy loss (Chen et al., 2020). + +In the inference stage (a.k.a. meta-test stage), a typical few-shot benchmark evaluates the model on $K$ -way, $N$ -shot classification tasks $\mathcal{T}$ drawn from $\mathcal{D}^{\mathrm{novel}}$ , where each task has a support set and a query set, i.e. $\mathcal{T} = (\mathcal{T}^{\mathrm{supp}},\mathcal{T}^{\mathrm{query}})$ . The support set $\mathcal{T}^{\mathrm{supp}}$ contains $K$ classes and each class has $N$ images (e.g. $K = 5$ , $N\in \{1,5\}$ ). Following Snell et al. (2017), the prediction $\hat{y}^\prime$ of a query image $\mathbf{x}'\in \mathcal{T}^{\mathrm{query}}$ is given by the label of nearest prototype $\mathbf{c}_k$ from $\mathcal{T}^{\mathrm{supp}}$ under a cosine similarity $d(\cdot ,\cdot)$ : + +$$ +\hat {y} ^ {\prime} = \arg \max _ {k} d \left(\phi \left(\mathbf {x} ^ {\prime}\right), \mathbf {c} _ {k}\right), \quad \mathbf {c} _ {k} = \frac {1}{N} \sum_ {(\mathbf {x}, y) \in \mathcal {T} ^ {\text {s u p p}}, y = k} \phi (\mathbf {x}). \tag {2} +$$ + +An extended description of the few-shot learning framework can be found from Appendix A.1. The generalization ability of the feature extractor $\phi (\mathbf{x})$ is improved in terms of training scheme (e.g. + +episodic learning (Vinyals et al., 2016)), network design (e.g. task condition (Oreshkin et al., 2018)) or objective function (e.g. learnable distance (Sung et al., 2018)). In our method, we propose a novel network design by inserting constellation models into CNNs and strengthen the intermediate features. + +# 4 CONSTELLATION MODEL + +The concept of constellation has been introduced to the few-shot learning scenario in early years (Fei-Fei et al., 2006), in which the appearance and the shape are independently learned in a mixture model. In our work, we revisit the constellation model in an end-to-end learning framework: First, we define the a cell feature as the individual local feature at a position in the feature map (see Figure 1). We then employ cell feature clustering to model the underlying distribution of input cell features, implying a part discovery procedure. We further obtain the distance map of the cell features from clustering and then perform cell relation modeling to build spatial relationships. + +# 4.1 CELL FEATURE CLUSTERING + +In convolutional neural networks (CNNs), the convolutional filters are learned to detect the discriminative patterns from low-level to high-level through back-propagation (Zeiler & Fergus, 2014). In fact, the backward signal in the back-propagation is not necessarily needed to obtain a pattern detector. With the feature map in the forward step of the CNN, we are able to cluster the individual features at each location of the feature map (a.k.a. cell features) into multiple centers and employ the cluster centers as filters (Coates & Ng, 2012; Krähenbuhl et al., 2015). Assume we obtain a convolutional feature map $\mathbf{U}$ with batch size $B$ , spatial size $H\times W$ and channels $C$ . We disassemble the feature map $\mathbf{U}\in \mathbb{R}^{B\times H\times W\times C}$ into a cell features set $\mathcal{U} = \{\mathbf{u}_1,\mathbf{u}_2,\dots,\mathbf{u}_n\}$ where $n = BHW$ and $\mathbf{u}_i\in \mathbb{R}^C$ is a cell feature. Naively, we can conduct a $k$ -means algorithm on input cell features $\mathcal{U}$ to solve the clustering objective: + +$$ +\min \sum_ {i} \sum_ {k} m _ {i k} \| \mathbf {u} _ {i} - \mathbf {v} _ {k} \| _ {2} ^ {2} \quad \text {s . t .} \quad m _ {i k} \in \{0, 1 \}, \quad \sum_ {k} m _ {i k} = 1 \tag {3} +$$ + +where $\mathcal{V} = \{\mathbf{v}_1, \mathbf{v}_2, \dots, \mathbf{v}_K\}$ is a set of cluster centers and $m_{ik}$ indicates if the input cell feature $\mathbf{u}_i$ is assigned to cluster center $\mathbf{v}_k$ . The clustering-based filters $\mathcal{V}$ can model the underlying cell feature distributions and capture the most frequent features, which can be explicitly interpreted as meaningful part patterns/part types. The hard assignment map $\mathbf{m}_i = (m_{i1}, m_{i2}, \dots, m_{iK})$ of input cell feature $\mathbf{u}_i$ onto the cluster centers can be used as a part-based representation, providing alternative information to the next layer in the CNN. + +However, there are two issues remaining unsolved in the naive design: Firstly, CNNs are typically optimized in a stochastic gradient descent (SGD) manner. Thus, in each forward step, only a minibatch of images are proceeded to provide cell features, which implies that the cluster centers cannot extract the global feature distribution across the whole dataset. Secondly, the hard assignment map has limited information due to its discrete representation. Therefore, inspired by Sculley (2010), we design a mini-batch soft $k$ -means algorithm to cluster the cell features approximately: + +- Initialization. Randomly initialize global cluster centers $\mathcal{V} = \{\mathbf{v}_1, \mathbf{v}_2, \dots, \mathbf{v}_K\}$ and a counter $\mathbf{s} = (s_1, s_2, \dots, s_K) = \mathbf{0}$ . +- Cluster Assignment. In forward step, given input cell features $\mathcal{U} = \{\mathbf{u}_1,\mathbf{u}_2,\dots,\mathbf{u}_n\}$ , we compute the distance vector $\mathbf{d}_i = (d_{i1},d_{i2},\ldots d_{iK})$ between input cell feature $\mathbf{u}_i$ and all cluster centers $\nu$ . We then compute the soft assignment $m_{ik}\in \mathbb{R}$ and generate the current mini-batch centers $\mathbf{v}_k^{\prime}$ : + +$$ +d _ {i k} = \left\| \mathbf {u} _ {i} - \mathbf {v} _ {k} \right\| _ {2} ^ {2}, \quad m _ {i k} = \frac {e ^ {- \beta d _ {i k}}}{\sum_ {j} e ^ {- \beta d _ {i j}}}, \quad \mathbf {v} _ {k} ^ {\prime} = \frac {\sum_ {i} m _ {i k} \mathbf {u} _ {i}}{\sum_ {i} m _ {i k}} \tag {4} +$$ + +where $\beta > 0$ is an inverse temperature. + +- Centroid Movement. We formulate a count update $\Delta \mathbf{s} = \sum_{i}\mathbf{m}_{i}$ by summing all assignment maps $\mathbf{m}_i = (m_{i1},m_{i2},\dots m_{iK})$ . The current mini-batch centers $\mathbf{v}_k^{\prime}$ are then updated to the global centers $\mathbf{v}_k$ with a momentum coefficient $\eta$ : + +$$ +\mathbf {v} _ {k} \leftarrow (1 - \eta) \mathbf {v} _ {k} + \eta \mathbf {v} _ {k} ^ {\prime}, \quad \eta = \frac {\lambda}{s _ {k} + \Delta s _ {k}} \tag {5} +$$ + +- Counter Update. Counter s is updated and distance vectors $\{\mathbf{d}_i\}$ are reshaped and returned: + +$$ +\mathbf {s} \leftarrow \mathbf {s} + \Delta \mathbf {s} \tag {6} +$$ + +With gradually updating global cluster centers, the above algorithm is able to address the issue of limited data in a mini-batch. In addition, we reshape the distance vectors $\{\mathbf{d}_i\}$ of all input cell features to a distance map $\mathbf{D} \in \mathbb{R}^{B \times H \times W \times K}$ . Each distance vector $\mathbf{d}_i$ can be seen as a learned cell code in codebook (dictionary) learning, which encodes a soft assignment of the visual word (i.e. cell feature) onto the codewords (i.e. cluster centers) and implies a part representation. The distance map $\mathbf{D}$ then can be viewed as a cell code map that represents a spatial distribution of identified parts, which is passed to following layers. Empirically, it is observed that when $\mathbf{u}_i$ and $\mathbf{v}_k$ are $L_2$ normalized, the training procedure is more stable and the Euclidean distance $d_{ik}$ is equivalent to a cosine similarity up to an affine transformation. Details of the cell feature clustering can be found in Appendix A.9. + +# 4.2 CELL RELATION AND SPATIAL CONFIGURATION MODELING + +Before the deep learning era, traditional constellation models (Fei-Fei et al., 2006) decompose visual information into appearance and shape representation. The appearance of different parts in the image is treated independently while the shape of parts is assumed to have spatial connections. In our constellation model, we establish the spatial relationship among the individual part-based representations at a different location from the distance map as well. Specifically, we apply the self-attention mechanism (Vaswani et al., 2017) to build the spatial relationship and enhance the representation instead of using probabilistic graphical models in prior work (Fei-Fei et al., 2006). + +In cell relation modeling, we add a positional encoding $\mathbf{P} \in \mathbb{R}^{B \times H \times W \times C}$ following Carion et al. (2020) for spatial locations to the distance map $\mathbf{D}$ and obtain the input feature map $\mathbf{F}_{\mathrm{I}}$ for query and key layers. For value layer, we directly flatten the distance map $\mathbf{D}$ to another input feature map $\mathbf{F}_{\mathrm{I}}'$ : + +$$ +\mathbf {F} _ {\mathrm {I}} = \text {S p a t i a l F l a t t e n} (\mathbf {D} + \mathbf {P}) \in \mathbb {R} ^ {B \times H W \times K}, \quad \mathbf {F} _ {\mathrm {I}} ^ {\prime} = \text {S p a t i a l F l a t t e n} (\mathbf {D}) \in \mathbb {R} ^ {B \times H W \times K} \tag {7} +$$ + +The input feature maps $\mathbf{F}_I, \mathbf{F}_I'$ are transformed into query, key and value $\{\mathbf{F}^q, \mathbf{F}^k, \mathbf{F}^v\} \subset \mathbb{R}^{B \times HW \times K}$ by three linear layers $\{\mathbf{W}^q, \mathbf{W}^k, \mathbf{W}^v\} \subset \mathbb{R}^{K \times K}$ and further computes the output feature $\mathbf{F}_A$ : + +$$ +\left[ \mathbf {F} ^ {q}, \mathbf {F} ^ {k}, \mathbf {F} ^ {v} \right] = \left[ \mathbf {F} _ {\mathrm {I}} \mathbf {W} ^ {q}, \mathbf {F} _ {\mathrm {I}} \mathbf {W} ^ {k}, \mathbf {F} _ {\mathrm {I}} ^ {\prime} \mathbf {W} ^ {v} \right] \tag {8} +$$ + +$$ +\mathbf {F} _ {\mathrm {A}} = \operatorname {A t t} \left(\mathbf {F} ^ {q}, \mathbf {F} ^ {k}, \mathbf {F} ^ {v}\right) = \operatorname {s o f t m a x} \left(\frac {\mathbf {F} ^ {q} \left(\mathbf {F} ^ {k}\right) ^ {\top}}{\sqrt {K}}\right) \mathbf {F} ^ {v} \tag {9} +$$ + +The softmax of dot product between query and key matrix $\mathbf{F}^q (\mathbf{F}^k)^\top \in \mathbb{R}^{B\times HW\times HW}$ calculates the similarity scores in the embedding space among features across the spatial dimension. This encodes the spatial relationships of input features and leads to an enhanced output feature representation $\mathbf{F}_{\mathrm{A}}$ . Besides, $\sqrt{K}$ in the denominator is to stabilize the gradient. In practice, we adopt a multi-head attention to model the feature relation in the embedding subspaces: + +$$ +\mathbf {F} _ {\mathrm {M H A}} = \operatorname {M u l t i H e a d A t t} \left(\mathbf {F} ^ {q}, \mathbf {F} ^ {k}, \mathbf {F} ^ {v}\right) = \left[ \mathbf {F} _ {1}, \dots , \mathbf {F} _ {J} \right] \mathbf {W}, \quad \mathbf {F} _ {j} = \operatorname {A t t} \left(\mathbf {F} _ {j} ^ {q}, \mathbf {F} _ {j} ^ {k}, \mathbf {F} _ {j} ^ {v}\right) \tag {10} +$$ + +In a $J$ -head attention, the aforementioned similarity scores in the $K' = \frac{K}{J}$ dimensional embedding subspace are calculated using the query, key and value from $j$ -th head, i.e. $\{\mathbf{F}_j^q, \mathbf{F}_j^k, \mathbf{F}_j^v\} \subset \mathbb{R}^{B \times HW \times K'}$ . The output features $\mathbf{F}_j$ of each head are computed following Eq. 9. All the output features $\{\mathbf{F}_1, \dots, \mathbf{F}_J\}$ are concatenated back into $K$ dimension embedding and further processed with a linear layer $\mathbf{W} \in \mathbb{R}^{K \times K}$ to generate multi-head output features $\mathbf{F}_{\mathrm{MHA}}$ . Such multi-head attention settings could provide more diverse feature relation without introducing extra parameters. + +# 4.3 INTEGRATE CONSTELLATION MODEL WITH CNNS + +Our constellation model has the capability to capture explicit structured features and encodes spatial relations among the cell features. The output features yield informative visual cues which are able to strengthen the convolutional features. Thus, as shown in Figure 1, we place the constellation model after the convolution operation to extract its unique explicit features and concatenate them with the original convolutional feature map. A following $1 \times 1$ convolutional layer is used on the concatenated features to restore the channels of convolutional feature map. In Table 3, we provide evidence that merging features from constellation model to the CNN backbone can significantly improve the representation ability. In contrast, increasing channels in CNNs alone to double the parameters (second row in Table 3) can only improve the performance marginally. Optionally, we found it is useful to adopt auxiliary loss when training the constellation model in deeper networks (e.g. ResNet-12). On top of each constellation model, we conduct a standard classification to acquire additional regularization. + +# 4.4 WHY CLUSTERING AND SELF-ATTENTION (CLUSTERING MAP + POSITIONAL ENCODING)? + +As described in Section 1 and 2, classical constellation models (Fergus et al., 2003; Felzenszwalb & Huttenlocher, 2005) extract parts with their spatial relationships; they are expressive but do not produce competitive results on modern image benchmarks. CNN models (Krizhevsky et al., 2012; He et al., 2016) attain remarkable results on large-scale image benchmarks (Deng et al., 2009) but they are limited when training data is scarce. We take the inspiration from the traditional constellation models, but with a realization that overcomes their previous modeling limitations. + +The main contribution of our work is a constellation module/block that performs cell-wise clustering, followed by self-attention on the clustering distance map + positional encoding. This separates our work from previous attempts, e.g. non-local block work (Wang et al., 2018) in which long-range non-linear averaging is performed on the convolution features (no clustering, nor positional encoding for the spatial configuration). The main properties of our constellation block include: (1) Cell based dense representation as opposed to the sparse part representation in (Weber et al., 2000) to make the cells recursively modeled in the self-attention unit in a modularized and general-purpose way. (2) Clustering to generate the cell code after clustering (codebook learning) that attains abstraction and is not dependent on the CNN feature dimensions. (3) Positional encoding (as in Carion et al. (2020)) for cells to encode the spatial locations. (4) Tokenized representation as expressive parts (code/clustering distance map + positional encoding) for the cells. (5) Self-attention to jointly model the cell code and positional encoding to capture the relationships between the parts together with their spatial configurations. + +# 5 EXPERIMENT + +# 5.1 DATASETS + +We adopt three standard benchmark datasets that are widely used in few-shot learning, CIFAR-FS dataset (Bertinetto et al., 2018), FC100 dataset (Oreshkin et al., 2018), and mini-ImageNet dataset (Vinyals et al., 2016). Details about dataset settings in few-shot learning are in Appendix A.2. + +# 5.2 NETWORK WITH MULTI-BRANCH + +We build ConstellationNet on two ProtoNet variants, namely Conv-4 and ResNet-12, which are commonly used in few-shot learning. Details of networks and the optimization are in Appendix. + +We develop a new technique, Multi-Branch, to optimize standard classification loss and prototypical loss simultaneously. We find the two training schemes, standard classification scheme and prototypical scheme, can be a companion rather than a conflict. Details of these two schemes can be found from Appendix A.1. Different from standard network backbone used in prior works, our embedding $\phi (\mathbf{x})$ is separated into two branches after a shared stem (Y-shape). Details of our multi-branch design are elaborated in A.10. The detailed ablation study is described in Table 3. + +Feature Augmentation. During the meta-testing stage, we discover that concatenating features before average pooling to the final output can improve classification accuracy. The advantage of this technique is that no additional training and model parameters are introduced. + +# 5.3 RESULTS ON STANDARD BENCHMARKS + +Table 1 and 2 summarize the results of the few-shot classification tasks on CIFAR-FS, FC100, and mini-ImageNet, respectively. Our method shows a notable improvement over several strong baselines in various settings. ConstellationNet significantly improves the performance on shallow networks (Conv-4). In Table 2, our model outperforms SIB (Hu et al., 2020) 1-shot by $0.6\%$ and 5-shot by $5.6\%$ . In Table 1, our model outperforms MetaOptNet (Lee et al., 2019) by $5.95\%$ in 1-shot and $6.24\%$ in 5-shot. For deep networks with rich features, the constellation module still contributes to the performance, showing its complementary advantage to convolution. Our ResNet-12 model beats (Lee et al., 2019) 1-shot result by $2.7\%$ on FC100, $3.4\%$ on CIFAR-FS, and $1.72\%$ on mini-ImageNet. The consistent improvement over both shallow and deep networks across all three datasets shows the generality of our method. Our ConstellationNet is orthogonal to the margin loss based methods (Liu et al., 2020; Li et al., 2020), and we also do not use extra cross-modal information (Xing et al., 2019; Li et al., 2020). On the contrary, our model enhances the embedding generalization ability by incorporating its own part-based representation. Additionally, to verify the orthogonality of our method, we adapt the negative margin loss following Liu et al. (2020) to our Conv-4 models in + +Table 1: Comparison to prior work on mini-ImageNet. Average 5-way classification accuracies (%) on mini-ImageNet meta-test split are reported with $95\%$ confidence intervals. Results of prior works are adopted from Lee et al. (2019) and original papers. $\dagger$ used extra cross-modal information. + +
ModelBackbonemini-ImageNet 5-way
1-shot5-shot
Meta-Learning LSTM (Ravi & Larochelle, 2016)Conv-443.44 ± 0.7760.60 ± 0.71
Matching Networks (Vinyals et al., 2016)Conv-443.56 ± 0.8455.31 ± 0.73
Prototypical Networks (Snell et al., 2017)Conv-449.42 ± 0.7868.20 ± 0.66
Transductive Prop Nets (Liu et al., 2018)Conv-455.51 ± 0.8669.86 ± 0.65
MetaOptNet (Lee et al., 2019)Conv-452.87 ± 0.5768.76 ± 0.48
Negative Margin (Liu et al., 2020)Conv-452.84 ± 0.7670.41 ± 0.66
ConstellationNet (ours)Conv-458.82 ± 0.2375.00 ± 0.18
SNAIL (Mishra et al., 2018)ResNet-1255.71 ± 0.9968.88 ± 0.92
TADAM (Oreshkin et al., 2018)ResNet-1258.50 ± 0.3076.70 ± 0.30
TapNet (Yoon et al., 2019)ResNet-1261.65 ± 0.1576.36 ± 0.10
Variational FSL (Zhang et al., 2019)ResNet-1261.23 ± 0.2677.69 ± 0.17
MetaOptNet (Lee et al., 2019)ResNet-1262.64 ± 0.6178.63 ± 0.46
CAN (Hou et al., 2019)ResNet-1263.85 ± 0.4879.44 ± 0.34
SLA-AG (Lee et al., 2020)ResNet-1262.93 ± 0.6379.63 ± 0.47
Meta-Baseline (Chen et al., 2020)ResNet-1263.17 ± 0.2379.26 ± 0.17
AM3 (Xing et al., 2019)†ResNet-1265.21 ± 0.3075.20 ± 0.27
ProtoNets + TRAML (Li et al., 2020)ResNet-1260.31 ± 0.4877.94 ± 0.57
AM3 + TRAML (Li et al., 2020)†ResNet-1267.10 ± 0.5279.54 ± 0.60
Negative Margin (Liu et al., 2020)ResNet-1263.85 ± 0.8181.57 ± 0.56
ConstellationNet (ours)ResNet-1264.89 ± 0.2379.95 ± 0.17
+ +Table 2: Comparison to prior work on FC100 and CIFAR-FS. Average 5-way classification accuracies (%) on CIFAR-FS and FC100 meta-test split are reported with $95\%$ confidence intervals. Results of prior works are adopted from Lee et al. (2019) and original papers. + +
ModelBackboneCIFAR-FS 5-wayFC100 5-way
1-shot5-shot1-shot5-shot
MAML (Finn et al., 2017)Conv-458.9 ± 1.971.5 ± 1.0--
Prototypical Networks (Snell et al., 2017)Conv-455.5 ± 0.772.0 ± 0.6--
Relation Networks (Sung et al., 2018)Conv-455.0 ± 1.069.3 ± 0.8--
R2D2 (Bertinetto et al., 2018)Conv-465.3 ± 0.279.4 ± 0.1--
SIB (Hu et al., 2020)Conv-468.7 ± 0.677.1 ± 0.4--
ConstellationNet (ours)Conv-469.3 ± 0.382.7 ± 0.2--
Prototypical Networks (Snell et al., 2017)ResNet-1272.2 ± 0.783.5 ± 0.537.5 ± 0.652.5 ± 0.6
TADAM (Oreshkin et al., 2018)ResNet-12--40.1 ± 0.456.1 ± 0.4
MetaOptNet-RR (Lee et al., 2019)ResNet-1272.6 ± 0.784.3 ± 0.540.5 ± 0.655.3 ± 0.6
MetaOptNet-SVM (Lee et al., 2019)ResNet-1272.0 ± 0.784.2 ± 0.541.1 ± 0.655.5 ± 0.6
ConstellationNet (ours)ResNet-1275.4 ± 0.286.8 ± 0.243.8 ± 0.259.7 ± 0.2
+ +Appendix A.8. We observe ConstellationNet with negative margin brings $0.52\%$ improvement to ConstellationNet, and obtains $6.93\%$ gain compared with baseline on mini-ImageNet. + +# 6 MODEL ANALYSIS + +# 6.1 ARCHITECTURE ALTERNATIVES + +In Table 3, we first study the role of each module in ConstellationNet, where the number of parameters is controlled approximately equivalent to the baseline's size. Our constellation model brings $6.41\%$ and $2.59\%$ improvements over baseline on 1-shot Conv-4 and ResNet-12 results. Combined with our multi-branch training procedure, the model further improves additional $1.34\%$ and $1.26\%$ on 1-shot Conv-4 and ResNet-12, respectively. Finally, feature augmentation from penultimate layer to final output embedding brings additional $0.45\%$ and $0.27\%$ improvements on two variants. + +We also test the baseline model with extra channels in the Table 3. The new model only shows slight improvements over original baseline, and is outperformed by our ConstellationNet with a large margin. We also obtain WRN-28-10 baseline results to validate our improvement. While making ResNet baselines deeper and wider, our ConstellationNet still outperforms this strong baseline. In Figure 2 (e), we further study whether the performance gap between ConstellationNet and baseline can be reduced by simply altering the baseline's model complexity using e.g. more convolution channels. Although the trend of baseline accuracy increases when increasing the model parameter number gradually, the performance gap is still significant. This validates our concept that modeling hierarchical part structures can greatly benefit features learned from convolution operation, and obtain a more robust feature representation. In addition, applying self-attention on the distance map (6-th + +Table 3: Effectiveness of modules. Average classification accuracies $(\%)$ on mini-ImageNet meta-test split. We compare our ConstellationNet with alternative architectures including the baseline and the modified baseline with extra channels based on Conv-4 and ResNet-12. We also include a baseline with WideResNet-28-10 (Zagoruyko & Komodakis, 2016) backbone for comparison. + +
BaselineCell Feature ClusteringCell Relation ModelingMulti BranchFeature AugmentExtra Channels1x1 Convolution#Params Conv-4ResNet-12
Conv-4/Res-121-shot5-shot1-shot
117K/8.0M50.62 ± 0.2368.40 ± 0.1960.77 ± 0.22
222K/16M51.76 ± 0.2269.54 ± 0.1861.45 ± 0.22
146K/8.3M53.34 ± 0.2370.61 ± 0.1962.24 ± 0.23
184K/9.7M55.92 ± 0.2373.02 ± 0.1862.75 ± 0.23
192K/8.4M55.46 ± 0.2372.52 ± 0.1861.54 ± 0.24
200K/8.4M57.03 ± 0.2374.09 ± 0.1863.36 ± 0.23
200K/8.4M58.37 ± 0.2374.52 ± 0.1864.62 ± 0.23
200K/8.4M58.82 ± 0.2375.00 ± 0.1864.89 ± 0.23
WRNWideResNet-28-10
36.5M61.54 ± 0.25
79.41 ± 0.23
+ +row: $57.03\%$ on Conv-4, 1-shot) achieves better performance than directly applying it to the original cell features (i.e. convolutional feature map) (4-th row: $55.92\%$ on Conv-4, 1-shot). We also tried to replace the cell feature clustering module with a 1x1 convolution layer (output dimension is equal to the number of clusters) (5-th row: $55.46\%$ on Conv-4, 1-shot). It is worse than our results (6-th row) as well. We observe that the 1x1 convolution layer is less expressive than the cell feature clustering module, making it difficult to extract enough context information during cell relation modeling. + +# 6.2 MODULES ANALYSIS + +![](images/ad78f359d2515ef3db9fbb7fdaa038d66646c0d21fad2d86a37992337d223b84.jpg) +Figure 2: Modules analysis. (a, b, c, d) We study the effectiveness of changing the number of clusters, the number of heads in attention layer, and the layer indices with constellation based on Conv-4, (e) We demonstrate the performance gain of our ConstellationNet is unmatched by increasing the model complexity of our baselines. All experiments are done on mini-ImageNet. + +![](images/a47c331855f16a21436777bede62c69e7f744d27bbbee06119c8737972776314.jpg) + +![](images/2c80f1fa530e936f15cacb5f16a55bceadcff33915d0644f82519cbbba38fbad.jpg) + +![](images/4418c3770817ccda9a81c8d12b2f864043120d53c86e80381610128818c285ff.jpg) + +![](images/413ebd7b44b009a6a1ca2b59ec1c0fd2c62351026278ab67c207d68ded79749e.jpg) + +In Figure 2 (a), we vary the number of clusters adapted in all layers to observe the performance change. We found that increasing the number of clusters improves the accuracy in general, and set clusters to 64 is optimal in terms of both model size and classification performance. Figure 2 (b) shows the number of attention heads does not effect performance as much as the number of cluster, and 8-head attention obtains $1.80\%$ performance gain on the 1-shot setting compared to 1-head attention. In Figure 2 (c, d), we also study the effectiveness of clustering algorithm applied to different layers. The results show both early features and high-level features benefit from introducing clusters algorithm into the original CNN architecture. + +# 6.3 VISUALIZATION + +Figure 3 demonstrates the visualization of cluster centers in each layer of Conv-4 model on miniImageNet. In the upper part of the figure, each image shows patches corresponding to the nearest cell features to a cluster center (i.e. with lowest Euclidean distance). It is observed that clusters in early layers (e.g. layer 1,2) represent simple low-level patterns while the clusters in high layers (e.g. layer 3,4) indicate more complex structures and parts. In the lower part of the figure, we choose two cluster centers from layer 4 for further interpretation: The left one with green box could possibly represent legs since it consists of various types of legs from human, dog and other animals. The right one with the red box shows most nearest cell features to this cluster center are parts with bird's head or beetles, which share a dotted structure (i.e. black dots on beetles / eyes on bird's head). + +The left side of Figure 4 shows the visualization of cell features that are assigned to different clusters. For each image, we extract the assignment maps corresponding to three cluster centers generated in the last constellation module of Conv-4 and find multiple cell features with the highest assignments within each assignment map. The locations of cell features are projected back in the original image space, marked by three different colors of ". . ." in the raw image to show three different feature clusters. For a given class of images, the same cluster centers are selected for comparison across 6 samples. As shown in Figure 4, we observe part information of each class is explicitly discovered. For the bird + +![](images/17a7c705c801a7ce3c15407448e561d7ccf06a5f6c89f701ab3497e452b78705.jpg) +Layer 1 + +![](images/9106dec65b4720ea7f50649685dd7478780bacbfe93be59ff1b95121f546c0a8.jpg) +Layer 2 + +![](images/1b7dba4308bd7efa2dcd0b755ce1456bb13571d55f1d005c998d8b95ec638fde.jpg) +Layer 3 + +![](images/87f8281167fd36733d1dfead1f6b3c14559ec217a7c90d241a857447bb0ac268.jpg) +Layer 4 + +![](images/539c7fd3e34349c1c7e534251b5aedc6cf7d45bc21f34e117361ae5f7dc53d26.jpg) + +![](images/0ef917f863ab14db6d36c549e6da612b1c367cada978487fa4a801f4a118e4dd.jpg) +Unicycle wheels (w/ human legs) +Dog's legs +Other legs +Figure 3: Visualization of cluster centers. (Upper) We visualize four cluster centers in each layer by showing patches associated with cell features that have the nearest distance to the clustering center. (Lower) Identifying parts from two cluster centers in layer 4: Left one with green box represents various types of legs. Right one with red box mostly shows beetles and bird's head, sharing a dotted structure. + +![](images/37cbb5b41c3dce6138a07a2246c392ed014cc7fae968f133f4d06cc35a3d2d61.jpg) +Human legs + +![](images/cc090c17558d80f23231d1c3712fb46aafe9c7bf68574fc279a190cc291ee435.jpg) +Beetles + +![](images/b5081d614465b4b8b4d5179959178c10a886ad0169c8eadcb199379551fd116b.jpg) +Bird's head + +![](images/d782cf5575a504e109309c9d83ce6694b3c1e73fc94095635cc3311058ebbf52.jpg) +Figure 4: Visualization of the cells assignment and attention maps. (Left) Each color represents a cluster, and each point, marked as "·", represents a cell assigned to a cluster center. We demonstrate 6 samples for each class (bird, dog and tank). (Right) We visualize attention maps of one query feature (at the location of red point in left part) with all key features. The middle part shows the attention maps corresponding to 8 heads in the multi-head attention. The right part shows an overlapped map of all attention maps. + +![](images/485a20d87468828fce8fdd98fbda41024b0f1e71ad54562435d06f1d3cd0c449.jpg) + +![](images/ca29778f2a0229a0e5ecb930245b1e1676810e09eb02227aad80836ce9761037.jpg) + +![](images/66e920897ae28547b1a3ace73582d203624a70d7f2896bb94d520ae98dc20378.jpg) + +![](images/27f28e6923ad860ed1df9543595fcdaa39c91782e34c79aeefee33b8dd647998.jpg) + +![](images/d88bca04dfd767f631f5bfea02a9930b5a5fcdb97b0e85f962a1b5a7d22733ab.jpg) + +category, we can see different parts in each image, including head (cyan " $\cdot$ ", body (purple " $\cdot$ " and tail (yellow " $\cdot$ "). For the dog category, we see parts including heads (red " $\cdot$ ", legs (green " $\cdot$ " and body (blue " $\cdot$ ". For the tank category, we see parts like track (light blue " $\cdot$ " and turret (pink " $\cdot$ ". + +The right side of Figure 4 visualizes the attention maps in the cell relation model. We use the last constellation module in the ResNet-12 model for visualization since it captures high-level features that better represent parts. We choose one query feature at the center of the object and show its attention map to all key features. The middle part of the figure shows the attention maps corresponding to 8 heads in the multi-head attention. It is observed that some parts are identified such as head (second map in first row), legs (first two map in second row), buttock (first map in first row) and body (second map in the second row). A merged attention map by overlaying all 8 attention maps is presented at right part of the figure. It indicates that all the attention heads together can extract the features of the whole object, which would be useful for final classification. + +# 7 CONCLUSION + +In this paper, we present ConstellationNet by introducing an explicit feature clustering procedure with relation learning via self-attention. We implement a mini-batch soft $k$ -means algorithm to capture the cell feature distribution. With integrated implicit (standard CNN modules) and explicit (cell feature clustering + cell relation modeling) representations, our proposed ConstellationNet achieves significant improvement over the competing methods on few-shot classification benchmarks. + +# ACKNOWLEDGMENTS + +This work is funded by NSF IIS-1618477 and NSF IIS-1717431. We thank Qualcomm Inc. for an award support. We thank Kwonjoon Lee, Tiange Luo and Hao Su for valuable feedbacks. + +# REFERENCES + +Luca Bertinetto, Joao F Henriques, Philip HS Torr, and Andrea Vedaldi. Meta-learning with differentiable closed-form solvers. arXiv preprint arXiv:1805.08136, 2018. +Nicolas Carion, Francisco Massa, Gabriel Synnaeve, Nicolas Usunier, Alexander Kirillov, and Sergey Zagoruyko. End-to-end object detection with transformers. In ECCV, 2020. +Yinbo Chen, Xiaolong Wang, Zhuang Liu, Huijuan Xu, and Trevor Darrell. A new meta-baseline for few-shot learning. arXiv preprint arXiv:2003.04390, 2020. +Adam Coates and Andrew Y Ng. Learning feature representations with k-means. In Neural networks: Tricks of the trade, pp. 561-580. Springer, 2012. +Navneet Dalal and Bill Triggs. Histograms of oriented gradients for human detection. In CVPR, 2005. +Jia Deng, Wei Dong, Richard Socher, Li-Jia Li, Kai Li, and Li Fei-Fei. Imagenet: A large-scale hierarchical image database. In Computer Vision and Pattern Recognition, 2009. CVPR 2009. IEEE Conference on, pp. 248-255. IEEE, 2009. +Li Fei-Fei, Rob Fergus, and Pietro Perona. One-shot learning of object categories. IEEE transactions on pattern analysis and machine intelligence, 28(4):594-611, 2006. +Pedro F Felzenszwalb and Daniel P Huttenlocher. Pictorial structures for object recognition. International journal of computer vision, 61(1):55-79, 2005. +Pedro F Felzenszwalb, Ross B Girshick, David McAllester, and Deva Ramanan. Object detection with discriminatively trained part-based models. IEEE transactions on pattern analysis and machine intelligence, 32(9):1627-1645, 2009. +Robert Fergus, Pietro Perona, and Andrew Zisserman. Object class recognition by unsupervised scale-invariant learning. In CVPR, 2003. +Chelsea Finn, Pieter Abbeel, and Sergey Levine. Model-agnostic meta-learning for fast adaptation of deep networks. arXiv preprint arXiv:1703.03400, 2017. +Weifeng Ge, Xiangru Lin, and Yizhou Yu. Weakly supervised complementary parts models for fine-grained image classification from the bottom up. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 3034-3043, 2019. +Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Deep residual learning for image recognition. In CVPR, 2016. +Geoffrey E Hinton, Sara Sabour, and Nicholas Frosst. Matrix capsules with em routing. 2018. +Ruiming Hou, Hong Chang, MA Bingpeng, Shiguang Shan, and Xilin Chen. Cross attention network for few-shot classification. In Advances in Neural Information Processing Systems, pp. 4005-4016, 2019. +Shell Xu Hu, Pablo G Moreno, Yang Xiao, Xi Shen, Guillaume Obozinski, Neil D Lawrence, and Andreas Damianou. Empirical bayes transductive meta-learning with synthetic gradients. arXiv preprint arXiv:2004.12696, 2020. +Adam Kosiorek, Sara Sabour, Yee Whye Teh, and Geoffrey E Hinton. Stacked capsule autoencoders. In Advances in Neural Information Processing Systems, pp. 15486-15496, 2019. +Philipp Krahenbuhl, Carl Doersch, Jeff Donahue, and Trevor Darrell. Data-dependent initializations of convolutional neural networks. arXiv preprint arXiv:1511.06856, 2015. +Alex Krizhevsky, Geoffrey Hinton, et al. Learning multiple layers of features from tiny images. 2009. +Alex Krizhevsky, Ilya Sutskever, and Geoffrey E Hinton. Imagenet classification with deep convolutional neural networks. In Advances in neural information processing systems, 2012. + +Svetlana Lazebnik, Cordelia Schmid, and Jean Ponce. Beyond bags of features: Spatial pyramid matching for recognizing natural scene categories. In CVPR, 2006. +Hankook Lee, Sung Ju Hwang, and Jinwoo Shin. Self-supervised label augmentation via input transformations. 37th International Conference on Machine Learning, Vienna, Austria, PMLR 119, 2020, 2020. +Kwonjoon Lee, Subhransu Maji, Avinash Ravichandran, and Stefano Soatto. Meta-learning with differentiable convex optimization. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 10657-10665, 2019. +Aoxue Li, Weiran Huang, Xu Lan, Jiashi Feng, Zhenguo Li, and Liwei Wang. Boosting few-shot learning with adaptive margin loss. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 12576-12584, 2020. +Bin Liu, Yue Cao, Yutong Lin, Qi Li, Zheng Zhang, Mingsheng Long, and Han Hu. Negative margin matters: Understanding margin in few-shot classification. arXiv preprint arXiv:2003.12060, 2020. +Yanbin Liu, Juho Lee, Minseop Park, Saehoon Kim, Eunho Yang, Sung Ju Hwang, and Yi Yang. Learning to propagate labels: Transductive propagation network for few-shot learning. arXiv preprint arXiv:1805.10002, 2018. +David G Lowe. Distinctive image features from scale-invariant keypoints. International journal of computer vision, 60(2):91-110, 2004. +Nikhil Mishra, Mostafa Rohaninejad, Xi Chen, and Pieter Abbeel. A simple neural attentive metalearner. arXiv preprint arXiv:1707.03141, 2017. +Nikhil Mishra, Mostafa Rohaninejad, Xi Chen, and Pieter Abbeel. A simple neural attentive metalearner. 2018. +Tsendsuren Munkhdalai, Xingdi Yuan, Soroush Mehri, and Adam Trischler. Rapid adaptation with conditionally shifted neurons. arXiv preprint arXiv:1712.09926, 2017. +Boris N Oreshkin, Alexandre Lacoste, and Pau Rodriguez. Tadam: Task dependent adaptive metric for improved few-shot learning. arXiv preprint arXiv:1805.10123, 2018. +Yuxin Peng, Xiangteng He, and Junjie Zhao. Object-part attention model for fine-grained image classification. IEEE Transactions on Image Processing, 27(3):1487-1500, 2017. +Lei Qi, Xiaoqiang Lu, and Xuelong Li. Exploiting spatial relation for fine-grained image classification. Pattern Recognition, 91:47-55, 2019. +Sachin Ravi and Hugo Larochelle. Optimization as a model for few-shot learning. 2016. +Sara Sabour, Nicholas Frosst, and Geoffrey E Hinton. Dynamic routing between capsules. In Advances in neural information processing systems, pp. 3856-3866, 2017. +Ruslan Salakhutdinov, Joshua B Tenenbaum, and Antonio Torralba. Learning with hierarchical-deep models. IEEE transactions on pattern analysis and machine intelligence, 35(8):1958-1971, 2012. +David Sculley. Web-scale k-means clustering. In Proceedings of the 19th international conference on World wide web, pp. 1177-1178, 2010. +Marcel Simon and Erik Rodner. Neural activation constellations: Unsupervised part model discovery with convolutional networks. In Proceedings of the IEEE international conference on computer vision, pp. 1143-1151, 2015. +Karen Simonyan and Andrew Zisserman. Very deep convolutional networks for large-scale image recognition. In ICLR, 2015. +Jake Snell, Kevin Swersky, and Richard Zemel. Prototypical networks for few-shot learning. In Advances in Neural Information Processing Systems, pp. 4077-4087, 2017. + +Erik B Sudderth, Antonio Torralba, William T Freeman, and Alan S Willsky. Learning hierarchical models of scenes, objects, and parts. In ICCV, volume 2, 2005. +Flood Sung, Yongxin Yang, Li Zhang, Tao Xiang, Philip HS Torr, and Timothy M Hospedales. Learning to compare: Relation network for few-shot learning. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 1199-1208, 2018. +Christian Szegedy, Wei Liu, Yangqing Jia, Pierre Sermanet, Scott Reed, Dragomir Anguelov, Dumitru Erhan, Vincent Vanhoucke, and Andrew Rabinovich. Going deeper with convolutions. In CVPR, 2015. +Pavel Tokmakov, Yu-Xiong Wang, and Martial Hebert. Learning compositional representations for few-shot recognition. In Proceedings of the IEEE International Conference on Computer Vision, pp. 6372-6381, 2019. +Yao-Hung Hubert Tsai, Nitish Srivastava, Hanlin Goh, and Ruslan Salakhutdinov. Capsules with inverted dot-product attention routing. arXiv preprint arXiv:2002.04764, 2020. +Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N Gomez, Lukasz Kaiser, and Illia Polosukhin. Attention is all you need. In Advances in neural information processing systems, pp. 5998-6008, 2017. +Oriol Vinyals, Charles Blundell, Timothy Lillicrap, Daan Wierstra, et al. Matching networks for one shot learning. In Advances in neural information processing systems, pp. 3630-3638, 2016. +Xiaolong Wang, Ross Girshick, Abhinav Gupta, and Kaiming He. Non-local neural networks. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 7794-7803, 2018. +Markus Weber, Max Welling, and Pietro Perona. Unsupervised learning of models for recognition. In ECCV, 2000. +Saining Xie, Ross Girshick, Piotr Dólar, Zhuowen Tu, and Kaiming He. Aggregated residual transformations for deep neural networks. In CVPR, 2017. +Chen Xing, Negar Rostamzadeh, Boris Oreshkin, and Pedro O O Pinheiro. Adaptive cross-modal few-shot learning. Advances in Neural Information Processing Systems, 32:4847-4857, 2019. +Sung Whan Yoon, Jun Seo, and Jaekyun Moon. Tapnet: Neural network augmented with task-adaptive projection for few-shot learning. arXiv preprint arXiv:1905.06549, 2019. +Alan L Yuille, Peter W Hallinan, and David S Cohen. Feature extraction from faces using deformable templates. International journal of computer vision, 8(2):99-111, 1992. +Sergey Zagoruyko and Nikos Komodakis. Wide residual networks. arXiv preprint arXiv:1605.07146, 2016. +Matthew D Zeiler and Rob Fergus. Visualizing and understanding convolutional networks. In ECCV, 2014. +Jian Zhang, Chenglong Zhao, Bingbing Ni, Minghao Xu, and Xiaokang Yang. Variational few-shot learning. In Proceedings of the IEEE International Conference on Computer Vision, pp. 1685-1694, 2019. +Song-Chun Zhu and David Mumford. A stochastic grammar of images. Now Publishers Inc, 2007. +Yousong Zhu, Chaoyang Zhao, Jinqiao Wang, Xu Zhao, Yi Wu, and Hanqing Lu. Coupling global structure with local parts for object detection. In Proceedings of the IEEE international conference on computer vision, pp. 4126-4134, 2017. + +# A APPENDIX + +# A.1 FEW-SHOT LEARNING FRAMEWORK + +In this section, we introduce background concepts of meta-learning and elaborate the few-shot learning framework used in our ConstellationNet. + +Meta-Learning in Few-Shot Classification. Current few-shot learning is typically formulated as a meta-learning task (Finn et al., 2017), in which an dataset $\mathcal{D}^{\mathrm{base}}$ is used to provide commonsense knowledge and a dataset $\mathcal{D}^{\mathrm{novel}}$ for the few-shot classification. $\mathcal{D}^{\mathrm{base}}$ has the classes $\mathcal{C}_{\mathrm{base}}$ which are disjoint from the $\mathcal{C}_{\mathrm{novel}}$ in $\mathcal{D}^{\mathrm{novel}}$ to ensure fairness. There are two stages, meta-training and meta-test, in the meta-learning framework: In meta-training stage, we attempt to train a model to learn generic features from $\mathcal{D}^{\mathrm{base}}$ . In meta-test stage, we adapt the model on the limited training split from $\mathcal{D}^{\mathrm{novel}}$ and evaluate the performance of the model on the test split. + +ProtoNet-Based Framework. In our ConstellationNet, we adopt ProtoNet (Snell et al., 2017) as the base few-shot learning framework. In ProtoNet, the dataset $\mathcal{D}^{\mathrm{novel}}$ is represented by a series of $K$ -way $N$ -shot tasks $\{\mathcal{T}\}$ where each task consists of a support set and a query set, i.e. $\mathcal{T} = (\mathcal{T}^{\mathrm{supp}}, \mathcal{T}^{\mathrm{query}})$ . The support set $\mathcal{T}^{\mathrm{supp}}$ contains $K$ classes and each class has $N$ examples from the training split of $\mathcal{D}^{\mathrm{novel}}$ , which are used to adapt the model in meta-test stage. The query set $\mathcal{T}^{\mathrm{query}}$ from the test split of $\mathcal{D}^{\mathrm{novel}}$ is then used to evaluate the model. + +The ProtoNet attempts to learn a generic feature extractor $\phi(\mathbf{x})$ on image $\mathbf{x}$ , and represent a class $k$ by the prototype $\mathbf{c}_k$ , which is the average feature of examples from support set $\mathcal{T}^{\mathrm{supp}}$ with this class: + +$$ +\mathbf {c} _ {k} = \frac {1}{| N |} \sum_ {(\mathbf {x}, y) \in \mathcal {T} ^ {\text {s u p p}}, y = k} \phi (\mathbf {x}) \tag {11} +$$ + +During the meta-test stage, we use the prototypes to compute the probability $p_k$ of a query example $\mathbf{x}' \in \mathcal{T}^{\text{query}}$ on class $k$ and predict its label $y'$ : + +$$ +p _ {k} = p \left(y = k \mid \mathbf {x} ^ {\prime}, \mathcal {T} ^ {\text {s u p p}}\right) = \frac {\exp \left(d \left(\mathbf {x} ^ {\prime} , \mathbf {c} _ {k}\right)\right)}{\sum_ {k ^ {\prime}} \exp \left(d \left(\mathbf {x} ^ {\prime} , \mathbf {c} _ {k ^ {\prime}}\right)\right)}, \quad y ^ {\prime} = \arg \max _ {k} p _ {k}. \tag {12} +$$ + +where $d(\cdot, \cdot)$ is a cosine similarity function (different from the Euclidean distance in Snell et al. (2017)). + +During the meta-training stage, there are two different training schemes: The prototypical scheme from ProtoNet uses an episodic learning strategy that also formulates the dataset $\mathcal{D}^{\mathrm{base}}$ as a series of tasks $\{\mathcal{T}\}$ . The negative log-likelihood loss $\mathcal{L}(\phi)$ is optimized: + +$$ +\ell \left(\mathcal {T} ^ {\text {s u p p}}, \mathcal {T} ^ {\text {q u e r y}}\right) = \mathbb {E} _ {\left(\mathbf {x} ^ {\prime}, y ^ {\prime}\right) \in \mathcal {T} ^ {\text {q u e r y}}} - \log p \left(y = y ^ {\prime} \mid \mathbf {x} ^ {\prime}, \mathcal {T} ^ {\text {s u p p}}\right), \tag {13} +$$ + +$$ +\mathcal {L} (\phi) = \mathbb {E} _ {\mathcal {T} = \left(\mathcal {T} ^ {\text {s u p p}}, \mathcal {T} ^ {\text {q u e r y}}\right) \sim \mathcal {D} ^ {\text {b a s e}}} \ell \left(\mathcal {T} ^ {\text {s u p p}}, \mathcal {T} ^ {\text {q u e r y}}\right). \tag {14} +$$ + +Another way is the standard classification scheme (Chen et al., 2020): It simply uses $\mathcal{D}^{\mathrm{base}}$ as a standard classification dataset $\{(\mathbf{x},y)\}$ consisting of $Q$ classes in total. Thus, a cross-entropy loss $\mathcal{L}(\phi)$ is optimized: + +$$ +\mathcal {L} (\phi) = \mathbb {E} _ {(\mathbf {x}, y) \sim \mathcal {D} ^ {\text {b a s e}}} - \log \frac {\exp \left(\mathbf {w} _ {y} \cdot \phi (\mathbf {x})\right)}{\sum_ {q} \exp \left(\mathbf {w} _ {q} \cdot \phi (\mathbf {x})\right)} \tag {15} +$$ + +where $\mathbf{w}_q$ is the linear weight for class $q$ . In our ConstellationNet, we use the standard classification scheme at default. For the experiment with multi-branch network, we use the prototypical scheme and standard classification scheme for separate branches. + +# A.2 DATASETS + +The CIFAR-FS dataset (Bertinetto et al., 2018) is a few-shot classification benchmark containing 100 classes from CIFAR-100 (Krizhevsky et al., 2009). The classes are randomly split into 64, 16 and 20 classes as meta-training, meta-validation and meta-testing set respectively. For each class, it + +contains 600 images of size $32 \times 32$ . We adopt the split from Lee et al. (2019). The FC100 dataset (Oreshkin et al., 2018) is another benchmark based on CIFAR-100 where classes are grouped into 20 superclasses to void the overlap between the splits. The mini-ImageNet dataset (Vinyals et al., 2016) is a common benchmark for few-shot classification containing 100 classes from ILSVRC-2012 (Deng et al., 2009). The classes are randomly split into 64, 16 and 20 classes as meta-training, meta-validation and meta-testing set respectively. For each class, it contains 600 images of size $84 \times 84$ . We follow the commonly-used split in Ravi & Larochelle (2016), Lee et al. (2019) and Chen et al. (2020). In all experiments, we conduct data augmentation for the meta-training set of all datasets to match Lee et al. (2019)'s implementation. + +# A.3 NETWORK BACKBONE + +Conv-4. Following Lee et al. (2019), we adopt the same network with 4 convolutional blocks. Each of the 4 blocks has a $3 \times 3$ convolutional layer, a batch normalization layer, a ReLU activation and a $2 \times 2$ max-pooling layer sequentially. The numbers of filters are 64 for all 4 convolutional layers. + +ResNet-12. Following Chen et al. (2020), we construct the residual block with 3 consecutive convolutional blocks followed by an addition average pooling layer where each convolutional block has a $3 \times 3$ convolutional layer, a batch normalization layer, a leaky ReLU activation, and max-pooling layers. The ResNet-12 network has 4 residual blocks with each filter size set to 64, 128, 256, 512, respectively. + +WRN-28-10. WideResNet expands the residual blocks by increasing the convolutional channels and layers (Zagoruyko & Komodakis, 2016). WRN-28-10 uses 28 convolutional layers with a widening factor of 10. + +# A.4 CONSTELLATION MODULE CONFIGURATION + +To achieve the best performance with constellation modules, we do not always fully enable them after all the convolutional layers. For Conv-4, we use constellation modules after all four convolutional layers, but the cell relation modeling module is disabled in first two constellation modules due to the high memory consumption. For ResNet-12, we enable the constellation modules after the convolutional layer 1,7,8,9 and disable the relation modeling module in the first constellation module. We use the deep supervision in ResNet-12 to stabilize the training of constellation modules. + +# A.5 SELF-ATTENTION SETTINGS + +We follow the common practice in Vaswani et al. (2017) to set the attention layer with residual connections, dropout and layer normalization. The sine positional encoding follows settings in Carion et al. (2020). + +# A.6 TRAINING DETAILS + +Optimization Settings. We follow implementation in Lee et al. (2019), and use SGD optimizer with initial learning rate of 1, and set momentum to 0.9 and weight decay rate to $5 \times 10^{-4}$ . The learning rate reduces to 0.06, 0.012, and 0.0024 at epoch 20, 40 and 50. The inverse temperature $\beta$ is set to 100.0 in the cluster assignment step, and $\lambda$ is set to 1.0 in the centroid movement step. + +# A.7 ABLATION STUDY ON THE NUMBER OF CLUSTERS + +Table 4 studies the number of clusters needed for random and similar classes. The result shows the optimal number of clusters are less affected by the number of clusters but more affected by the similarity between classes. Less number of clusters are needed for dataset with classes of high similarity, which aligns with our intuition, limited number of patterns exist in this dataset so that small number of clusters are enough to represent its part-based information. + +FC100 training dataset consists of 60 classes that are grouped evenly into 12 superclasses. In the random classes group, the training dataset includes 6 randomly selected super-classes (i.e., 30 classes) and models are trained with 8, 16, 32, 64 and 128 number of clusters. The highest accuracy occurs at 16 clusters (1-shot: $39.12\%$ in ResNet-12). In the similar classes group, 30 classes are randomly + +Table 4: Ablation study on the number of clusters for random and similar classes. We investigate how similarities of images in the training dataset affect the optimal number of clusters. The first group of experiments use training dataset with 30 similar classes while the second group use 30 random classes from FC100 dataset, all of which performed on ResNet-12 with Constellation module. + +
# ClustersSimilar ClassesRandom Classes
1-shot5-shot1-shot5-shot
838.9 ± 0.252.8 ± 0.240.9 ± 0.254.5 ± 0.2
1639.1 ± 0.251.8 ± 0.240.9 ± 0.254.9 ± 0.2
3238.7 ± 0.252.3 ± 0.240.9 ± 0.254.7 ± 0.2
6438.8 ± 0.252.3 ± 0.241.2 ± 0.254.9 ± 0.2
12838.8 ± 0.252.1 ± 0.240.8 ± 0.254.7 ± 0.2
+ +sampled from the original training dataset and we repeat the same experiments as above. The highest accuracy occurs at 64 clusters (1-shot: $41.22\%$ in ResNet-12), which is much more than the 16 clusters used for images from similar classes. + +# A.8 ADDITIONAL EXPERIMENTS WITH NEGATIVE MARGIN + +Table 5: Additional experiments with the use of negative margin. Average classification accuracies (%) on mini-ImageNet meta-test split. We compare our ConstellationNet and baseline with and without the negative margin loss based on Conv-4. + +
BaselineCell Feature ClusteringCell Relation ModelingNegative MarginConv-4
1-shot5-shot
50.62 ± 0.2368.40 ± 0.19
51.42 ± 0.2368.84 ± 0.19
57.03 ± 0.2374.09 ± 0.18
57.55 ± 0.2374.49 ± 0.18
+ +Table 5 studies the use of negative margin loss (Liu et al., 2020) on our Conv-4 models. In the negative margin loss, we use the inner-product similarity, the temperature coefficient $\beta = 1.0$ and the negative margin $m = -0.5$ , which attains the best performance improvement on our models. Besides, we do not have the fine-tune step during meta-test. Our baseline with the negative margin loss obtains $0.80\%$ improvement on 1-shot and $0.44\%$ improvement on 5-shot compared with the baseline. Similarly, our ConstellationNet with the negative margin loss achieves $0.52\%$ improvement on 1-shot and $0.40\%$ improvement on 5-shot. The consistent improvement of negative margin loss on the baseline and our ConstellationNet indicates that our constellation module is orthogonal to the negative margin loss, and both modules can boost the performance on few-shot classification. + +# A.9 CLARIFICATION ON CLUSTERING PROCEDURE + +In this section, we add more clarification on our cell feature clustering procedure in Sec. 4.1: During the training stage, the global cluster centers $\mathcal{V} = \{\mathbf{v}_k\}$ are updated by the computed clustering centers $\{\mathbf{v}_k^{\prime}\}$ in current mini-batch. Each update to a cluster center $\mathbf{v}_k$ is weighted by a momentum coefficient $\eta$ determined by the value of an associated counter $s_k$ , since we would like to avoid large adjustment from the current mini-batch in order to stabilize the global cluster centers. Besides, the mini-batches of examples are randomly drawn from the dataset following Sculley (2010), without specialized design to optimize clustering learning. During the evaluation stage, we fix the global cluster centers $\mathcal{V}$ in the forward step of our model, avoiding the potential information leak or transduction from the test mini-batches. + +# A.10 MULTI-BRANCH DETAILS + +Our embedding $\phi(\mathbf{x})$ is separated into two branches after a shared stem (Y-shape), which is defined as $\phi(\mathbf{x}) = \{\phi^{\mathrm{cls}}(\mathbf{x}), \phi^{\mathrm{proto}}(\mathbf{x})\}$ and $\phi^{\mathrm{cls}}(\mathbf{x}) = g^{\mathrm{cls}}(f^{\mathrm{stem}}(\mathbf{x}))$ , $\phi^{\mathrm{proto}}(\mathbf{x}) = g^{\mathrm{proto}}(f^{\mathrm{stem}}(\mathbf{x}))$ . Two branches $\phi^{\mathrm{cls}}(\mathbf{x}), \phi^{\mathrm{proto}}(\mathbf{x})$ are trained by standard classification and prototypical schemes separately + +in a multi-task learning fashion. During the testing time, $\phi^{\mathrm{cls}}(\mathbf{x})$ and $\phi^{\mathrm{proto}}(\mathbf{x})$ are concatenated together to compute distance between support prototypes and query images. + +For our ConstellationNet, we split the network into two branches after the second convolutional blocks (Conv-4) or the second residual blocks (ResNet-12). We keep the shared stem identical to the network backbone and reduce the channels of two separate branches to match the parameter size of the model without multi-branch. + +# A.11 CONNECTION WITH CAPSULE NETWORKS + +A notable development to learning the explicit structured representation in an end-to-end framework is the capsule networks (CapsNets) (Sabour et al., 2017). The line of works on CapsNets (Sabour et al., 2017; Hinton et al., 2018; Kosiorek et al., 2019; Tsai et al., 2020) intends to parse a visual scene in an interpretable and hierarchical way. Sabour et al. (2017) represents parts and objects in vector-based capsules with a dynamic routing mechanism. Tsai et al. (2020) uses a stacked autoencoder architecture to model the hierarchical relation among parts, objects and scenes. Here our ConstellationNet maintains part modeling by enabling the joint learning of the convolution and constellation modules to simultaneously attain implicit and explicit representations. \ No newline at end of file diff --git a/attentionalconstellationnetsforfewshotlearning/images.zip b/attentionalconstellationnetsforfewshotlearning/images.zip new file mode 100644 index 0000000000000000000000000000000000000000..86be7a35805e607ac9dfd3148e56660c122978f2 --- /dev/null +++ b/attentionalconstellationnetsforfewshotlearning/images.zip @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6fc255e44791e375ec2afaf73db3f920975f7fc567daf497bd6aa0a9e0a2255c +size 645376 diff --git a/attentionalconstellationnetsforfewshotlearning/layout.json b/attentionalconstellationnetsforfewshotlearning/layout.json new file mode 100644 index 0000000000000000000000000000000000000000..38ee4f8551f0b5b9f2a1376c28bc359f540a0b2b --- /dev/null +++ b/attentionalconstellationnetsforfewshotlearning/layout.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2bcf0126fe772b8fe01599090a97e7ea523da1a63661032811403e1af44cca77 +size 586788 diff --git a/auctionlearningasatwoplayergame/c67499e2-b68c-4964-a190-4aa8387dbeeb_content_list.json b/auctionlearningasatwoplayergame/c67499e2-b68c-4964-a190-4aa8387dbeeb_content_list.json new file mode 100644 index 0000000000000000000000000000000000000000..069545f29d896264496e3bab62d9c4e96366cb94 --- /dev/null +++ b/auctionlearningasatwoplayergame/c67499e2-b68c-4964-a190-4aa8387dbeeb_content_list.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c113146f834c76558e9c99a9a0f1cd30819a278c1cfeae7faadff6277145ba8d +size 95095 diff --git a/auctionlearningasatwoplayergame/c67499e2-b68c-4964-a190-4aa8387dbeeb_model.json b/auctionlearningasatwoplayergame/c67499e2-b68c-4964-a190-4aa8387dbeeb_model.json new file mode 100644 index 0000000000000000000000000000000000000000..c2a69dc6b5e2f513ddf3f131137b74a24e5c68ba --- /dev/null +++ b/auctionlearningasatwoplayergame/c67499e2-b68c-4964-a190-4aa8387dbeeb_model.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:bb220d7670271b49cd7be4f5ba5f8435199ab5965aaafbd78794cd925446e684 +size 118710 diff --git a/auctionlearningasatwoplayergame/c67499e2-b68c-4964-a190-4aa8387dbeeb_origin.pdf b/auctionlearningasatwoplayergame/c67499e2-b68c-4964-a190-4aa8387dbeeb_origin.pdf new file mode 100644 index 0000000000000000000000000000000000000000..5d7f61f34ba07203bbe18c36acb83eecec333759 --- /dev/null +++ b/auctionlearningasatwoplayergame/c67499e2-b68c-4964-a190-4aa8387dbeeb_origin.pdf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6866ec8d18e8f36340e4553a488ecdb1463c85bf87114a55321dc158e2318eea +size 1086404 diff --git a/auctionlearningasatwoplayergame/full.md b/auctionlearningasatwoplayergame/full.md new file mode 100644 index 0000000000000000000000000000000000000000..9eff35a0d37616b79221a3aef4af6b3a2149bbf1 --- /dev/null +++ b/auctionlearningasatwoplayergame/full.md @@ -0,0 +1,446 @@ +# Auction Learning as a TWO-PLAYER GAME + +Jad Rahme*, Samy Jelassi, S. Matthew Weinberg + +Princeton University + +Princeton, NJ 08540, USA + +{jrahme, sjelassi, smweinberg}@princeton.edu + +# ABSTRACT + +Designing an incentive compatible auction that maximizes expected revenue is a central problem in Auction Design. While theoretical approaches to the problem have hit some limits, a recent research direction initiated by Duetting et al. (2019) consists in building neural network architectures to find optimal auctions. We propose two conceptual deviations from their approach which result in enhanced performance. First, we use recent results in theoretical auction design to introduce a time-independent Lagrangian. This not only circumvents the need for an expensive hyper-parameter search (as in prior work), but also provides a single metric to compare the performance of two auctions (absent from prior work). Second, the optimization procedure in previous work uses an inner maximization loop to compute optimal misreports. We amortize this process through the introduction of an additional neural network. We demonstrate the effectiveness of our approach by learning competitive or strictly improved auctions compared to prior work. Both results together further imply a novel formulation of Auction Design as a two-player game with stationary utility functions. + +# 1 INTRODUCTION + +Efficiently designing truthful auctions is a core problem in Mathematical Economics. Concrete examples include the sponsored search auctions conducted by companies as Google or auctions run on platforms as eBay. Following seminal work of Vickrey (Vickrey, 1961) and Myerson (Myerson, 1981), auctions are typically studied in the independent private valuations model: each bidder has a valuation function over items, and their payoff depends only on the items they receive. Moreover, the auctioneer knows aggregate information about the population that each bidder comes from, modeled as a distribution over valuation functions, but does not know precisely each bidder's valuation (outside of any information in this Bayesian prior). A major difficulty in designing auctions is that valuations are private and bidders need to be incentivized to report their valuations truthfully. The goal of the auctioneer is to design an incentive compatible auction which maximizes expected revenue. + +Auction Design has existed as a rigorous mathematical field for several decades and yet, complete characterizations of the optimal auction only exist for a few settings. While Myerson's Nobel prize-winning work provides a clean characterization of the single-item optimum (Myerson, 1981), optimal multi-item auctions provably suffer from numerous formal measures of intractability (including computational intractability, high description complexity, non-monotonicity, and others) (Daskalakis et al., 2014; Chen et al., 2014; 2015; 2018; Hart & Reny, 2015; Thanassoulis, 2004). + +An orthogonal line of work instead develops deep learning architectures to find the optimal auction. Duetting et al. (2019) initiated this direction by proposing RegretNet, a feed-forward architecture. They frame the auction design problem as a constrained learning problem and lift the constraints into the objective via the augmented Lagrangian method. Training RegretNet involves optimizing this Lagrangian-penalized objective, while simultaneously updating network parameters and the Lagrangian multipliers themselves. This architecture produces impressive results: recovering near-optimal auctions in several known multi-item settings, and discovering new mechanisms when a theoretical optimum is unknown. + +Yet, this approach presents several limitations. On the conceptual front, our main insight is a connection to an exciting line of recent works (Hartline & Lucier, 2010; Hartline et al., 2011; Bei & + +Huang, 2011; Daskalakis & Weinberg, 2012; Rubinstein & Weinberg, 2018; Dughmi et al., 2017; Cai et al., 2019) on $\varepsilon$ -truthful-to-truthful reductions. On the technical front, we identify three areas for improvement. First, their architecture is difficult to train in practice as the objective is nonstationary. Specifically, the Lagrangian multipliers are time-dependent and they increase following a pre-defined schedule, which requires careful hyperparameter tuning (see §3.1 for experiments illustrating this). Leveraging the aforementioned works in Auction Theory, we propose a stationary Lagrangian objective. Second, all prior work inevitably finds auctions which are not precisely incentive compatible, and does not provide a metric to compare, say, an auction with revenue 1.01 which is 0.002-truthful, or one with revenue 1 which is 0.001-truthful. We argue that our stationary Lagrangian objective serves as a good metric (and that the second auction of our short example is "better" for our metric). Finally, their training procedure requires an inner-loop optimization (essentially, this inner loop is the bidders trying to maximize utility in the current auction), which is itself computationally expensive. We use amortized optimization to make this process more efficient. + +# CONTRIBUTIONS + +This paper leverages recent work in Auction Theory to formulate the learning of revenue-optimal auctions as a two-player game. We develop a new algorithm ALGnet (Auction Learning Game network) that produces competitive or better results compared to Duetting et al. (2019)'s RegretNet. In addition to the conceptual contributions, our approach yields the following improvements (as RegretNet is already learning near-optimal auctions, our improvement over RegretNet is not due to significantly higher optimal revenues). + +- Easier hyper-parameter tuning: By constructing a time-independent loss function, we circumvent the need to search for an adequate parameter scheduling. Our formulation also involves less hyperparameters, which makes it more robust. +- A metric to compare auctions: We propose a metric to compare the quality of two auctions which are not incentive compatible. +- More efficient training: We replace the inner-loop optimization of prior work with a neural network, which makes training more efficient. +- Online auctions: Since the learning formulation is time-invariant, ALGnet is able to quickly adapt in auctions where the bidders' valuation distributions varies over time. Such setting appears for instance in the online posted pricing problem studied in Bubeck et al. (2017). + +Furthermore, these technical contributions together now imply a novel formulation of auction learning as a two-player game (not zero-sum) between an auctioneer and a misreporter. The auctioneer is trying to design an incentive compatible auction that maximizes revenue while the misreporter is trying to identify breaches in the truthfulness of these auctions. The paper decomposes as follows. Section 2 introduces the standard notions of auction design. Section 3 presents our game formulation for auction learning. Section 4 provides a description of ALGnet and its training procedure. Finally, Section 5 presents numerical evidence for the effectiveness of our approach. + +# RELATED WORK + +Auction design and machine learning. Machine learning and computational learning theory have been used in several ways to design auctions from samples of bidder valuations. Machine learning has been used to analyze the sample complexity of designing optimal revenue-maximizing auctions. This includes the framework of single-parameter settings (Morgenstern & Roughgarden, 2015; Huang et al., 2018; Hartline & Taggart, 2019; Roughgarden & Schrijvers, 2016; Gonczarowski & Nisan, 2017; Guo et al., 2019), multi-item auctions (Dughmi et al., 2014; Gonczarowski & Weinberg, 2018), combinatorial auctions (Balcan et al., 2016; Morgenstern & Roughgarden, 2016; Syrgkanis, 2017) and allocation mechanisms (Narasimhan & Parkes, 2016). Other works have leveraged machine learning to optimize different aspects of mechanisms (Lahaie, 2011; Dütting et al., 2015). Our approach is different as we build a deep learning architecture for auction design. + +Auction design and deep learning. While Duetting et al. (2019) is the first paper to design auctions through deep learning, several other papers followed-up this work. Feng et al. (2018) extended it to budget constrained bidders, Golowich et al. (2018) to the facility location problem. Tacchetti et al. (2019) built architectures based on the Vickrey-Clarke-Groves mechanism. Rahme et al. (2021) used permutation-equivariant networks to design symmetric auctions. Shen et al. (2019) and Duetting + +et al. (2019) proposed architectures that exactly satisfy incentive compatibility but are specific to single-bidder settings. While all the previously mentioned papers consider a non-stationary objective function, we formulate a time-invariant objective that is easier to train and that makes comparisons between mechanisms possible. + +# 2 AUCTION DESIGN AS A TIME-VARYING LEARNING PROBLEM + +We first review the framework of auction design and the problem of finding truthful mechanisms. We then recall the learning problem proposed by Duetting et al. (2019) to find optimal auctions. + +# 2.1 AUCTION DESIGN AND LINEAR PROGRAM + +Auction design. We consider an auction with $n$ bidders and $m$ items. We will denote by $N = \{1, \dots, n\}$ and $M = \{1, \dots, m\}$ the set of bidders and items. Each bidder $i$ values item $j$ at a valuation denoted $v_{ij}$ . We will focus on additive auctions. These are auctions where the value of a set $S$ of items is equal to the sum of the values of the elements in that set at $\sum_{j \in S} v_{ij}$ . Additive auctions are perhaps the most well-studied setting in multi-item auction design (Hart & Nisan, 2012; Li & Yao, 2013; Daskalakis et al., 2014; Cai et al., 2016; Daskalakis et al., 2017). + +The auctioneer does not know the exact valuation profile $V = (v_{ij})_{i \in N, j \in M}$ of the bidders in advance but he does know the distribution from which they are drawn: the valuation vector of bidder $i$ , $\vec{v}_i = (v_{i1}, \ldots, v_{im})$ is drawn from a distribution $D_i$ over $\mathbb{R}^m$ . We will further assume that all bidders are independent and that $D_1 = \dots = D_n$ . As a result $V$ is drawn from $D := \otimes_{i=1}^{n} D_i = D_1^{\otimes^n}$ . + +Definition 1. An auction is defined by a randomized allocation rule $g = (g_{1},\ldots ,g_{n})$ and a payment rule $p = (p_{1},\dots ,p_{n})$ where $g_{i}\colon \mathbb{R}^{n\times m}\to [0,1]^{m}$ and $p_i\colon \mathbb{R}^{n\times m}\to \mathbb{R}_{\geqslant 0}$ . Additionally for all items $j$ and valuation profiles $V$ , the $g_{i}$ must satisfy $\sum_{i}[g_{i}(V)]_{j}\leqslant 1$ . + +Given a bid matrix $B = (b_{ij})_{i \in N, j \in M}$ , $[g_i(B)]_j$ is the probability that bidder $i$ receives object $j$ and $p_i(B)$ is the price bidder $i$ has to pay to the auction. The condition $\sum_i [g_i(V)]_j \leqslant 1$ allows the possibility for an item to be not allocated. + +Definition 2. The utility of bidder $i$ is defined by $u_{i}(\vec{v}_{i},B) = \sum_{j = 1}^{m}[g_{i}(B)]_{j}v_{ij} - p_{i}(B)$ . + +Bidders seek to maximize their utility and may report bids that are different from their true valuations. In the following, we will denote by $B_{-i}$ the $(n - 1) \times m$ bid matrix without bidder $i$ , and by $(\vec{b}_i', B_{-i})$ the $n \times m$ bid matrix that inserts $\vec{b}_i'$ into row $i$ of $B_{-i}$ (for example: $B := (\vec{b}_i, B_{-i})$ ). We aim at auctions that incentivize bidders to bid their true valuations. + +Definition 3. An auction $(g, p)$ is dominant strategy incentive compatible (DSIC) if each bidder's utility is maximized by reporting truthfully no matter what the other bidders report. For every bidder $i$ , valuation $\vec{v}_i \in D_i$ , bid $\vec{b}_i'\in D_i$ and bids $B_{-i} \in D_{-i}$ , $u_i(\vec{v}_i, (\vec{v}_i, B_{-i})) \geqslant u_i(\vec{v}_i, (\vec{b}_i', B_{-i}))$ . + +Definition 4. An auction is individually rational (IR) if for all $i \in N$ , $\vec{v}_i \in D_i$ and $B_{-i} \in D_{-i}$ , + +$$ +u _ {i} \left(\vec {v} _ {i}, \left(\vec {v} _ {i}, B _ {- i}\right)\right) \geqslant 0. \tag {IR} +$$ + +In a DSIC auction, the bidders have the incentive to truthfully report their valuations and therefore, the revenue on valuation profile $V$ is $\sum_{i=1}^{n} p_i(V)$ . Optimal auction design aims at finding a DSIC and IR auction that maximizes the expected revenue $\text{rev} \coloneqq \mathbb{E}_{V \sim D}[\sum_{i=1}^{n} p_i(V)]$ . Since there is no known characterization of DSIC mechanisms in the multi-item setting, we resort to the relaxed notion of ex-post regret. It measures the extent to which an auction violates DSIC. + +Definition 5. The ex-post regret for a bidder $i$ is the maximum increase in his utility when considering all his possible bids and fixing the bids of others. For a valuation profile $V$ , it is given by $r_i(V) = \max_{\vec{b}_i' \in \mathbb{R}^m} u_i(\vec{v}_i, (\vec{b}_i', V_{-i})) - u_i(\vec{v}_i, (\vec{v}_i, V_{-i}))$ . In particular, DSIC is equivalent to + +$$ +r _ {i} (V) = 0, \forall i \in N, \forall V \in D. \tag {IC} +$$ + +The bid $\vec{b}_i^\prime$ that achieves $r_i(V)$ is called the optimal misreport of bidder $i$ for valuation profile $V$ . Therefore, finding an optimal auction is equivalent to the following linear program: + +$$ +\min _ {(g, p) \in \mathcal {M}} - \mathbb {E} _ {V \sim D} \left[ \sum_ {i = 1} ^ {n} p _ {i} (V) \right] \quad \text {s . t .} \quad r _ {i} (V) = 0, \quad \forall i \in N, \forall V \in D, \tag {LP} +$$ + +# 2.2 AUCTION DESIGN AS A LEARNING PROBLEM + +As the space of auctions $\mathcal{M}$ may be large, we will set a parametric model. In what follows, we consider the class of auctions $(g^w,p^w)$ encoded by a neural network of parameter $w\in \mathbb{R}^d$ . The corresponding utility and regret function will be denoted by $u_{i}^{w}$ and $r_i^w$ + +Following Duetting et al. (2019), the formulation (LP) is relaxed: the IC constraint for all $V \in D$ is replaced by the expected constraint $\mathbb{E}_{V \sim D} [r_i^w(V)] = 0$ for all $i \in N$ . The justification for this relaxation can be found in Duetting et al. (2019). By replacing expectations with empirical averages, the learning problem becomes: + +$$ +\min _ {w \in \mathbb {R} ^ {d}} - \frac {1}{L} \sum_ {\ell = 1} ^ {L} \sum_ {i = 1} ^ {n} p _ {i} ^ {w} (V ^ {(\ell)}) \quad \text {s . t .} \quad \widehat {r} _ {i} ^ {w} := \frac {1}{L} \sum_ {\ell = 1} ^ {L} r _ {i} ^ {w} (V ^ {(\ell)}) = 0, \forall i \in N. \quad \quad (\widehat {\mathrm {L P}}) +$$ + +The learning problem $(\widehat{\mathbf{LP}})$ does not ensure (IR). However, this constraint is usually built into the parametrization (architecture) of the model: by design, the only auction mechanism considered satisfy (IR). Implementation details can be found in Duetting et al. (2019); Rahme et al. (2021) or in Sec 4. + +# 3 AUCTION LEARNING AS A TWO-PLAYER GAME + +We first present the optimization and the training procedures for (LP) proposed by Duetting et al. (2019). We then demonstrate with numerical evidence that this approach presents two limitations: hyperparameter sensitivity and lack of interpretability. Using the concept of $\varepsilon$ -truthful to truthful reductions, we construct a new loss function that circumvents these two aspects. Lastly, we resort to amortized optimization and reframe the auction learning problem as a two-player game. + +# 3.1 THE AUGMENTED LAGRANGIAN METHOD AND ITS SHORTCOMINGS + +Optimization and training. We briefly review the training procedure proposed by Duetting et al. (2019) to learn optimal auctions. The authors apply the augmented Lagrangian method to solve the constrained problem $(\widehat{\mathrm{LP}})$ and consider the loss: + +$$ +\mathcal {L} (w; \lambda ; \rho) = - \frac {1}{L} \sum_ {\ell = 1} ^ {L} \sum_ {i \in N} p _ {i} ^ {w} (V ^ {(\ell)}) + \sum_ {i \in N} \lambda_ {i} r _ {i} ^ {w} (V ^ {(\ell)}) + \frac {\rho}{2} \left(\sum_ {i \in N} r _ {i} ^ {w} (V ^ {(\ell)})\right) ^ {2}, +$$ + +where $\lambda \in \mathbb{R}^n$ is a vector of Lagrange multipliers and $\rho > 0$ is a parameter controlling the weight of the quadratic penalty. More details about the training procedure can be found in Appendix A. + +Scheduling consistency problem. The parameters $\lambda$ and $\rho$ are time-varying. Indeed, their value changes according to a pre-defined scheduling of the following form: 1) Initialize $\lambda$ and $\rho$ with respectively $\lambda^0$ and $\rho^0$ , 2) Update $\rho$ every $T_{\rho}$ iterations: $\rho^{t + 1} \gets \rho^t + c$ , where $c$ is a pre-defined constant, 3) Update $\lambda$ every $T_{\lambda}$ iterations according to $\lambda_i^t \gets \lambda_i^t + \rho^t \hat{r}_i^{w^t}$ . + +Therefore, this scheduling requires to set up five hyper parameters $(\lambda^0,\rho^0,c,T_\lambda ,T_\rho)$ . Some of the experiments found Duetting et al. (2019) were about learning an optimal mechanism for an $n$ -bidder $m$ -item auction $(n\times m)$ where the valuations are iid $\mathcal{U}[0,1]$ . Different scheduling parameters were used for different values of $n$ and $m$ . We report the values of the hyper parameters used for the $1\times 2$ , $3\times 10$ and $5\times 10$ settings in Table 1(a). A natural question is whether the choice of parameters heavily affects the performance. We proceed to a numerical investigation of this questions by trying different schedulings (columns) for different settings (rows) and report our the results in Table 1(b). + +Table 1: (a): Scheduling parameters values set in Duetting et al. (2019) to reach optimal auctions in $n \times m$ settings with $n$ bidders, $m$ objects and i.i.d. valuations sampled from $\mathcal{U}[0,1]$ . (b): Revenue $rev := \mathbb{E}_{V \sim D}[\sum_{i=1}^{n} p_i(V)]$ and average regret per bidder $reg := \frac{1}{n} \mathbb{E}_{V \in D}[\sum_{i=1}^{n} r_i(V)]$ for $n \times m$ settings when using the different parameters values set reported in (a). + +
1 × 23 × 105 × 10
λ0551
ρ0110.25
c5010.25
102102102
104104105
(a)
Scheduling
1 × 2
Setting
rev
rgt
rev
rgt
rev
rgt
0.552
0.0001
0.573
0.0012
0.332
0.0179
5.880
0.0047
6.749
+ +(b) + +The auction returned by the network dramatically varies with the choice of scheduling parameters. When applying the parameters of $1 \times 2$ to $5 \times 10$ , we obtain a revenue that is lower by $30\%$ . The performance of the learning algorithm strongly depends on the specific values of the hyperparameters. Finding an adequate scheduling requires an extensive and time consuming hyperparameter search. + +Lack of interpretability. How should one compare two mechanisms with different expected revenue and regret? Is a mechanism $M_1$ with revenue $P_1 = 1.01$ and an average total regret $R_1 = 0.02$ better than a mechanism $M_2$ with $P_2 = 1.0$ and $R_2 = 0.01$ ? The approach in Duetting et al. (2019) cannot answer this question. To see that, notice that when $\lambda_1 = \dots = \lambda_n = \lambda$ we can rewrite $\mathcal{L}(w; \lambda; \rho) = -P + \lambda R + \frac{\rho}{2} R^2$ . Which mechanism is better depends on the values of $\lambda$ and $\rho$ . For example if $\rho = 1$ and $\lambda = 0.1$ we find that $M_1$ is better, but if $\rho = 1$ and $\lambda = 10$ then $M_2$ is better. Since the values of $\lambda$ and $\rho$ change with time, the Lagrangian approach in Duetting et al. (2019) cannot provide metric to compare two mechanisms. + +# 3.2 A TIME-INDEPENDENT AND INTERPRETABLE LOSS FUNCTION FOR AUCTION LEARNING + +Our first contribution consists in introducing a new loss function for auction learning that addresses the two first limitations of Duetting et al. (2019) mentioned in Section 3.1. We first motivate this loss in the one bidder case and then extend it to auctions with many bidders. + +# 3.2.1 MECHANISMS WITH ONE BIDDER + +Proposition 1. [Balcan et al. (2005), attributed to Nisan] Let $\mathcal{M}$ be an additive auction with 1 bidder and $m$ items. Let $P$ and $R$ denote the expected revenue and regret, $P = \mathbb{E}_{V\in D}[p(V)]$ and $R = \mathbb{E}_{V\in D}[r(V)]$ . There exists a mechanism $\mathcal{M}^*$ with expected revenue $P^{*} = (\sqrt{P} -\sqrt{R})^{2}$ and zero regret $R^{*} = 0$ . + +A proof of this proposition can be found in Appendix C. Comparing two mechanisms is straightforward when both of them have zero-regret: the best one achieves the highest revenue. Prop. 1 allows a natural and simple extension of this criteria for non zero-regret mechanism with one bidder: we will say that $M_1$ is better than $M_2$ if and only if $M_1^*$ is better than $M_2^*$ : + +$$ +M _ {1} \geqslant M _ {2} \iff P ^ {*} (M _ {1}) \geqslant P ^ {*} (M _ {2}) \iff \sqrt {P _ {1}} - \sqrt {R _ {1}} \geqslant \sqrt {P _ {2}} - \sqrt {R _ {2}} +$$ + +Using our metric, we find that a one bidder mechanism with revenue of 1.00 and regret of 0.01 is "better" than one with revenue 1.01 and regret 0.02. + +# 3.2.2 MECHANISMS WITH MULTIPLE BIDDERS + +Let $M_1$ and $M_2$ be two mechanisms with $n$ bidders and $m$ objects. Let $P_i$ and $R_i$ denote their total expected revenue and regret, $P_i = \mathbb{E}_{V \in D} \left[ \sum_{j=1}^{n} p_j(V) \right]$ and $R_i = \mathbb{E}_{V \in D} \left[ \sum_{j=1}^{n} r_j(V) \right]$ . We can extend our metric derived in Section 3.2.1 to the multiple bidder by the following: + +$$ +M _ {1} \text {i s}" b e t t e r" t h a n} M _ {2} \iff M _ {1} \geqslant M _ {2} \iff \sqrt {P _ {1}} - \sqrt {R _ {1}} \geqslant \sqrt {P _ {2}} - \sqrt {R _ {2}} +$$ + +When $n = 1$ we recover the criteria from Section 3.2.1 that is backed by Prop. 1. When $n > 1$ , it is considered a major open problem whether the extension of Prop. 1 still holds. Note that a multibidder variant of Prop. 1 does hold under a different solution concept termed "Bayesian Incentive Compatible" (Rubinstein & Weinberg, 2018; Cai et al., 2019), supporting the conjecture that Prop. 1 + +indeed extends. $^2$ Independently of whether or not Prop. 1 holds, this reasoning implies a candidate loss function for the multi-bidder setting which we can evaluate empirically. + +This way of comparing mechanisms motivates the use of loss function: $\mathcal{L}(P,R) = -(\sqrt{P} -\sqrt{R})$ instead of the Lagrangian from Section 3, and indeed this loss function works well in practice. We empirically find the loss function $\mathcal{L}_m(P,R) = -(\sqrt{P} -\sqrt{R}) + R$ further accelerates training, as it further (slightly) biases towards mechanisms with low regret. Both of these loss functions are time-independent and hyperparameter-free. + +# 3.3 AMORTIZED MISREPORT OPTIMIZATION + +To compute the regret $r_i^w (V)$ one has to solve the optimization problem: $\max_{\vec{v}_i' \in \mathbb{R}^m} u_i^w (\vec{v}_i, (\vec{v}_i', V_{-i})) - u_i^w (\vec{v}_i, (\vec{v}_i, V_{-i}))$ . In Duetting et al. (2019), this optimization problem is solved with an inner optimization loop for each valuation profile. In other words, computing the regret of each valuation profile is solved separately and independently, from scratch. If two valuation profiles are very close to each other, one should expect that the resulting optimization problems have close results. We leverage this to improve training efficiency. + +We propose to amortize this inner loop optimization. Instead of solving all these optimization problems independently, we will instead learn one neural network $M^{\varphi}$ that tries to predict the solution of all of them. $M^{\varphi}$ takes as entry a valuation profile and maps it to the optimal misreport: + +$$ +M ^ {\varphi}: \left\{ \begin{array}{l l} \mathbb {R} ^ {n \times m} & \to \mathbb {R} ^ {n \times m} \\ V = [ \vec {v _ {i}} ] _ {i \in N} & \to \big [ \operatorname {a r g m a x} _ {\vec {v ^ {\prime}} \in D} u _ {i} (\vec {v _ {i}}, (\vec {v ^ {\prime}}, V _ {- i})) \big ] _ {i \in N} \end{array} \right. +$$ + +The loss $\mathcal{L}_r$ that $M^{\varphi}$ is trying to minimize follows naturally from that definition and is then given by: $\mathcal{L}_r(\varphi ,w) = -\mathbb{E}_{V\in D}\left[\sum_{i = 1}^{n}u_i^w (\vec{v_i},([M^\varphi (V)]_i,V_{-i}))\right]$ . + +# 3.4 AUCTION LEARNING AS A TWO-PLAYER GAME + +In this section, we combine the ideas from Sections 3.2 and 3.3 to obtain a new formulation for the auction learning problem as a two-player game between an Auctioneer with parameter $w$ and a Misreporter with parameter $\varphi$ . The optimal parameters for the auction learning problem $(w^{*},\varphi^{*})$ are a Nash Equilibrium for this game. + +The Auctioneer is trying to design a truthful (IC) and rational (IR) auction that maximizes revenue. The Misreporter is trying to maximize the bidders' utility, for the current auction selected by Auctioneer, $w$ . This is achieved by minimizing the loss function $\mathcal{L}_r(\varphi, w)$ wrt to $\varphi$ (as discussed in Sec 3.3). The Auctioneer in turn maximizes expected revenue, for the current misreports as chosen by Misreporter. This is achieved by minimizing $\mathcal{L}_m(w, \varphi) = -\left( \sqrt{P^w} + \sqrt{R^{w,\varphi}} \right) + R^{w,\varphi}$ with respect to $w$ (as discussed in Sec 3.2). Here, $R^{w,\varphi}$ is an estimate of the total regret that auctioneer computes for the current Misreporter $\varphi$ , $R^{w,\varphi} = \frac{1}{L} \sum_{\ell=1}^{L} \sum_{i \in N} \left( u_i^w(\vec{v}_i, ([M^\varphi(V)]_i, V_{-i})) - u_i^w(\vec{v}_i, (\vec{v}_i, V_{-i})) \right)$ . This game formulation can be summarized as follows: + +![](images/553994d0a53342f2e59d0ca6327a1d24cf5a64a0ee328eccbb144c398aeb2085.jpg) + +Remark 1. The game formulation (G) reminds us of Generative Adversarial Networks (Goodfellow et al., 2014). Contrary to GANs, it is not a zero-sum game. + +# 4 ARCHITECTURE AND TRAINING PROCEDURE + +We describe ALGnet, a feed-forward architecture solving for the game formulation (G) and then provide a training procedure. ALGnet consists in two modules that are the auctioneer's module and the misreporter's module. These components take as input a bid matrix $B = (b_{i,j}) \in \mathbb{R}^{n \times m}$ and are trained jointly. Their outputs are used to compute the regret and revenue of the auction. + +Notation. We use $\mathrm{MLP}(d_{\mathrm{in}},n_l,h,d_{\mathrm{out}})$ to refer to a fully-connected neural network with input dimension $d_{\mathrm{in}}$ , output dimension $d_{\mathrm{out}}$ and $n_l$ hidden layers of width $h$ and tanh activation function. sig denotes the sigmoid activation function. Given a matrix $B = [\vec{b}_1,\dots ,\vec{b}_n]^\top \in \mathbb{R}^{n\times m}$ , we define for a fixed $i\in N$ , the matrix $B_{(i)}\coloneqq [\vec{b}_i,\vec{b}_1,\dots ,\vec{b}_{i - 1},\vec{b}_{i + 1},\dots ,\vec{b}_n]$ . + +# 4.1 THE AUCTIONER'S MODULE + +It is composed of an allocation network that encodes a randomized allocation $g^w \colon \mathbb{R}^{nm} \to [0,1]^{nm}$ and a payment network that encodes a payment rule $p^w \colon \mathbb{R}^{nm} \to \mathbb{R}^n$ . + +Allocation network. It computes the allocation probability of item $j$ to bidder $i$ $[g^{w}(B)]_{ij}$ as $[g^{w}(B)]_{ij} = [f_{1}(B)]_{j} \cdot [f_{2}(B)]_{ij}$ where $f_{1} \colon \mathbb{R}^{n \times m} \to [0,1]^{m}$ and $f_{2} \colon \mathbb{R}^{n \times m} \to [0,1]^{m \times n}$ are functions computed by two feed-forward neural networks. + +- $[f_1(B)]_j$ is the probability that object $j \in M$ is allocated and is given by $[f_1(B)]_j = \mathrm{sig}(\mathbf{MLP}(nm, n_a, h_a, n))$ . +- $[f_2(B)]_{ij}$ is the probability that item $j \in M$ is allocated to bidder $i \in N$ conditioned on object $j$ being allocated. A first MLP computes $l_j := \mathrm{MLP}(nm, n_a, h_a, m)(B_{(j)})$ for all $j \in M$ . The network then concatenates all these vectors $l_j$ into a matrix $L \in \mathbb{R}^{n \times m}$ . A softmax activation function is finally applied to $L$ to ensure feasibility i.e. for all $j \in M$ , $\sum_{i \in N} L_{ij} = 1$ . + +Payment network. It computes the payment $[p^w (B)]_i$ for bidder $i$ as $[p^w (B)]_i = \tilde{p}_i\sum_{j = 1}^m B_{ij}[g^w (B)]_{ij}$ , where $\tilde{p}\colon \mathbb{R}^{n\times m}\to [0,1]^n$ . $\tilde{p}_i$ is the fraction of bidder's $i$ utility that she has to pay to the mechanism. We compute $\tilde{p}_i = \mathrm{sig}(\mathrm{MLP}(nm,n_p,h_p,1))(B_{(i)})$ . Finally, notice that by construction $[p^w (B)]_i\leqslant \sum_{j = 1}^m B_{ij}g^w (B)_{ij}$ which ensures that (IR) is respected. + +# 4.2 THE MISREPORTER'S MODULE + +The module consists in an $\mathrm{MLP}(nm, n_M, h_M, m)$ followed by a projection layer $\mathrm{Proj}$ that ensures that the output of the network is in the domain $D$ of the valuation. For example when the valuations are restricted to $[0,1]$ , we can take $\mathrm{Proj} = \mathrm{sig}$ , if they are non-negative numbers, we can take $\mathrm{Proj} = \mathrm{SoftPlus}$ . The optimal misreport for bidder $i$ is then given by $\mathrm{Proj} \circ \mathrm{MLP}(nm, n_M, h_M, m)(B_{(i)}) \in \mathbb{R}^m$ . Stacking these vectors gives us the misreport matrix $M^\varphi(B)$ . + +# 4.3 TRAINING PROCEDURE AND OPTIMIZATION + +We optimize the game (G) over the space of neural networks parameters $(w, \varphi)$ . The algorithm is easy to implement (Alg. 1). + +At each time $t$ , we sample a batch of valuation profiles of size $B$ . The algorithm performs $\tau$ updates for the Misreporter's network (line 9) and one update on the Auctioneer's network (line 10). Moreover, we often reinitialize the Misreporter's network every $T_{init}$ steps in the early phases of the training ( $t \leqslant T_{limit}$ ). This step is not necessary but we found empirically that it speeds up training. + +# Algorithm 1 ALGnet training + +1: Input: number of agents, number of objects. +2: Parameter: $\gamma > 0$ ; $B, T, T_{init}, T_{limit}, \tau \in \mathbb{N}$ . +3: Initialize misreport's and auctioneer's nets. +4: for $t = 1, \dots, T$ do + +5: if $t \equiv 0 \mod T_{init}$ and $t < T_{Limit}$ then: +6: Reinitialize Misreport Network +7: Sample valuation batch $S$ of size $B$ . +8: for $\bar{s} = 1,\dots ,\tau$ do +9: $\varphi^{s + 1}\gets \varphi^s -\gamma \nabla_\varphi \mathcal{L}_r(\varphi^s,w^t)(S).$ +10: $w^{t + 1}\gets w^t -\gamma \nabla_w\mathcal{L}_m(w^t,\varphi)(S).$ + +# 5 EXPERIMENTAL RESULTS + +We show that ALGnet can recover near-optimal auctions for settings where the optimal solution is known and that it can find new auctions for settings where analytical solutions are not known. Since RegretNet is already capable of discovering near optimal auctions, one cannot expect ALGnet to achieve significantly higher optimal revenue than RegretNet. The results obtained are competitive or better than the ones obtained in Duetting et al. (2019) while requiring much less hyperparameters (Section 3). We also evaluate ALGnet in online auctions and compare it to RegretNet. + +For each experiment, we compute the total revenue $rev := \mathbb{E}_{V \sim D}[\sum_{i \in N} p_i^w(V)]$ and average regret $rgt := \frac{1}{n} \mathbb{E}_{V \sim D}[\sum_{i \in N} r_i^w(V)]$ on a test set of 10,000 valuation profiles. We run each experiment 5 times with different random seeds and report the average and standard deviation of these runs. In our comparisons we make sure that ALGnet and RegretNet have similar sizes for fairness (Appendix D). + +# 5.1 AUCTIONS WITH KNOWN AND UNKNOWN OPTIMA + +Known settings. We show that ALGnet is capable of recovering near optimal auction in different well-studied auctions that have an analytical solution. These are one bidder and two items auctions where the valuations of the two items $v_{1}$ and $v_{2}$ are independent. We consider the following settings. (A): $v_{1}$ and $v_{2}$ are i.i.d. from $\mathcal{U}[0,1]$ , (B): $v_{1} \sim \mathcal{U}[4,16]$ and $v_{2} \sim \mathcal{U}[4,7]$ , (C): $v_{1}$ has density $f_{1}(x) = 5 / (1 + x)^{6}$ and $v_{2}$ has density $f_{2}(y) = 6 / (1 + y)^{7}$ . + +(A) is the celebrated Manelli-Vincent auction (Manelli & Vincent, 2006); (B) is a non-i.i.d. auction and (C) is a non-i.i.d. heavy-tail auction and both of them are studied in Daskalakis et al. (2017). We compare our results to the theoretical optimal auction (Table 2). (Duetting et al. (2019) does not evaluate RegretNet on settings (B) & (C)). During the training process, reg decreases to 0 while $rev$ and $P^*$ converge to the optimal revenue. For (A), we also plot $rev$ , $rgt$ and $P^*$ as function of the number of epochs and we compare it to RegretNet (Fig. 1). + +Contrary to ALGnet, we observe that RegretNet overestimates the revenue in the early stages of training at the expense of a higher regret. As a consequence, ALGnet learns the optimal auction faster than RegretNet while being schedule-free and requiring less hyperparameters. + +Table 2: Revenue & regret of ALGnet for settings (A)-(C). + +
OptimalALGnet (Ours)
revrgtrevrgt (×10-3)
(A)0.55000.555 (±0.0019)0.55 (±0.14)
(B)9.78109.737 (±0.0443)0.75 (±0.17)
(C)0.170600.1712 (±0.0012)0.14 (±0.07)
+ +![](images/0424ae0b7922bbdeb10334962f5f1bcac8a56eefc9db08bd83626d025791fd7f.jpg) +(a) + +![](images/129d2c69a51344d1808bb312b3447070b115e404898596102826f84496a45cc3.jpg) +(b) + +![](images/f536d49b377f80b9324768d52fa35ddf6ebe7a1ee11c73d192c9ac4abef3baad.jpg) +(c) + +![](images/fc672cd99e89019f268635a4bbb22c922e27d8c42142ef314215983754336c25.jpg) +(d) + +![](images/3e67cb26ff84bf451b40dcb41f9299f8af8632a8d015060d68c72615575fee3c.jpg) +(e) +Figure 1: (a-b-c) compares the evolution of the revenue, regret and $P^{*}$ as a function of the number of epoch for RegretNet and ALGnet for setting (A). (d-e-f) plots the revenue, regret and $P^{*}$ as a function of time for ALGnet and (offline & online) RegretNet for an online auction (Section 5.2). + +![](images/027651006e4d3e882eb333d292e83f8d1d3a0a8d468f70ee42b55ffe3cebe146.jpg) +(f) + +Unknown and large-scale auctions. We now consider settings where the optimal auction is unknown. We look at $n$ -bidder $m$ -item additive settings where the valuations are sampled i.i.d from $\mathcal{U}[0,1]$ which we will denote by $n \times m$ . In addition to "reasonable"-scale auctions $(1 \times 10$ and $2 \times 2$ ), we investigate large-scale auctions $(3 \times 10$ and $5 \times 10$ ) that are much more complex. Only deep learning methods are able to solve them efficiently. Table 3 shows that ALGnet is able to discover auctions that yield comparable or better results than RegretNet. + +# 5.2 ONLINE AUCTIONS + +ALGnet is an online algorithm with a time-independent loss function. We would expect it to perform well in settings where the underlying distribution of the valuations changes over time. We consider a one bidder and two items additive auction with valuations $v_{1}$ and $v_{2}$ sampled i.i.d from $\mathcal{U}[0,1 + t]$ where $t$ in increased from 0 to 1 at a steady rate. The optimal auction at time $t$ has revenue + +Table 3: Comparison of RegretNet and ALGnet. The values reported for RegretNet are found in Duetting et al. (2019), the numerical values for rgt and standard deviations are not available. + +
SettingRegretNetALGnet (Ours)
revrgtrevrgt
1 × 20.554< 1.0 · 10-30.555 (±0.0019)0.55 · 10-3(±0.14 · 10-3)
1 × 103.461< 3.0 · 10-33.487 (±0.0135)1.65 · 10-3(±0.57 · 10-3)
2 × 20.878< 1.0 · 10-30.879 (±0.0024)0.58 · 10-3(±0.23 · 10-3)
3 × 105.541< 2.0 · 10-35.562 (±0.0308)1.93 · 10-3(±0.33 · 10-3)
5 × 106.778< 5.0 · 10-36.781 (±0.0504)3.85 · 10-3(±0.43 · 10-3)
+ +$0.55 \times (1 + t)$ . We use ALGnet and two versions of RegretNet, the original offline version (Appendix A) and our own online version (Appendix B) and plot $rev(t)$ , $rgt(t)$ and $P^{*}(t)$ (Fig. 1). The offline version learns from a fixed dataset of valuations sampled at $t = 0$ (i.e. with $V \sim \mathcal{U}[0,1]^{nm}$ ) while the online versions (as ALGnet) learn from a stream of data at each time $t$ . Overall, ALGnet performs better than the other methods. It learns an optimal auction faster at the initial (especially compared to RegretNet Online) and keep adapting to the distributional shift (contrary to vanilla RegretNet). + +# 6 CONCLUSION + +We identified two inefficiencies in previous approaches to deep auction design and propose solutions, building upon recent trends and results from machine learning (amortization) and theoretical auction design (stationary Lagrangian). This resulted in a novel formulation of auction learning as a two-player game between an Auctioneer and a Misreporter and a new architecture ALGnet. ALGnet requires significantly fewer hyperparameters than previous Lagrangian approaches. We demonstrated the effectiveness of ALGnet on a variety of examples by comparing it to the theoretical optimal auction when it is known, and to RegretNet when the optimal solution is not known. + +Acknowledgements. Jad Rahme would like to thank Ryan P. Adams for helpful discussions and feedback on the manuscript. Samy Jelassi thanks Arthur Mensch for fruitful discussions on the subject and feedback on the manuscript. The work of Jad Rahme was funded by a Princeton SEAS Innovation Grant. The work of Samy Jelassi is supported by the NSF CAREER CIF 1845360. The work of S. Matthew Weinberg was supported by NSF CCF-1717899. + +# REFERENCES + +Maria-Florina Balcan, Avrim Blum, Jason D. Hartline, and Yishay Mansour. Mechanism design via machine learning. In 46th Annual IEEE Symposium on Foundations of Computer Science (FOCS 2005), 23-25 October 2005, Pittsburgh, PA, USA, Proceedings, pp. 605-614. IEEE Computer Society, 2005. doi: 10.1109/SFCS.2005.50. URL https://doi.org/10.1109/SFCS.2005.50. +Maria-Florina F Balcan, Tuomas Sandholm, and Ellen Vitercik. Sample complexity of automated mechanism design. In Advances in Neural Information Processing Systems, pp. 2083-2091, 2016. +Xiaohui Bei and Zhiyi Huang. Bayesian Incentive Compatibility via Fractional Assignments. In the Twenty-Second Annual ACM-SIAM Symposium on Discrete Algorithms (SODA), 2011. +Sebastien Bubeck, Nikhil R Devanur, Zhiyi Huang, and Rad Niazadeh. Online auctions and multiscale online learning. In Proceedings of the 2017 ACM Conference on Economics and Computation, pp. 497-514, 2017. +Yang Cai, Nikhil Devanur, and S. Matthew Weinberg. A duality based unified approach to bayesian mechanism design. In Proceedings of the 48th ACM Conference on Theory of Computation(STOC), 2016. +Yang Cai, Argyris Oikonomou, Grigoris Velegkas, and Mingfei Zhao. An efficient $\varepsilon$ -bic to BIC transformation and its application to black-box reduction in revenue maximization. CoRR, abs/1911.10172, 2019. URL http://arxiv.org/abs/1911.10172. + +Xi Chen, Ilias Diakonikolas, Dimitris Paparas, Xiaorui Sun, and Mihalis Yannakakis. The complexity of optimal multidimensional pricing. In Proceedings of the Twenty-Fifth Annual ACM-SIAM Symposium on Discrete Algorithms, SODA 2014, Portland, Oregon, USA, January 5-7, 2014, pp. 1319-1328, 2014. doi: 10.1137/1.9781611973402.97. URL http://dx.doi.org/10.1137/1.9781611973402.97. +Xi Chen, Ilias Diakonikolas, Anthi Orfanou, Dimitris Paparas, Xiaorui Sun, and Mihalis Yannakakis. On the complexity of optimal lottery pricing and randomized mechanisms. In 2015 IEEE 56th Annual Symposium on Foundations of Computer Science, pp. 1464-1479. IEEE, 2015. +Xi Chen, George Matikas, Dimitris Paparas, and Mihalis Yannakakis. On the complexity of simple and optimal deterministic mechanisms for an additive buyer. In Proceedings of the Twenty-Ninth Annual ACM-SIAM Symposium on Discrete Algorithms, pp. 2036-2049. SIAM, 2018. +Constantinos Daskalakis and Seth Matthew Weinberg. Symmetries and optimal multi-dimensional mechanism design. In Proceedings of the 13th ACM Conference on Electronic Commerce, pp. 370-387, 2012. +Constantinos Daskalakis, Alan Deckelbaum, and Christos Tzamos. The complexity of optimal mechanism design. In Proceedings of the twenty-fifth annual ACM-SIAM symposium on Discrete algorithms, pp. 1302-1318. SIAM, 2014. +Constantinos Daskalakis, Alan Deckelbaum, and Christos Tzamos. Strong duality for a multiple-good monopolist. *Econometrica*, 85(3):735-767, 2017. +Paul Duetting, Zhe Feng, Harikrishna Narasimhan, David Parkes, and Sai Srivatsa Ravindranath. Optimal auctions through deep learning. In Kamalika Chaudhuri and Ruslan Salakhutdinov (eds.), Proceedings of the 36th International Conference on Machine Learning, volume 97 of Proceedings of Machine Learning Research, pp. 1706-1715, Long Beach, California, USA, 09-15 Jun 2019. PMLR. URL http://proceedings.mlr.press/v97/duetting19a.html. +Shaddin Dughmi, Li Han, and Noam Nisan. Sampling and representation complexity of revenue maximization. In International Conference on Web and Internet Economics, pp. 277-291. Springer, 2014. +Shaddin Dughmi, Jason D. Hartline, Robert Kleinberg, and Rad Niazadeh. Bernoulli factories and black-box reductions in mechanism design. In Proceedings of the 49th Annual ACM SIGACT Symposium on Theory of Computing, STOC 2017, Montreal, QC, Canada, June 19-23, 2017, pp. 158-169, 2017. doi: 10.1145/3055399.3055492. URL http://doi.acm.org/10.1145/3055399.3055492. +Paul Dütting, Felix Fischer, Pichayut Jirapinyo, John K Lai, Benjamin Lubin, and David C Parkes. Payment rules through discriminant-based classifiers. ACM Transactions on Economics and Computation (TEAC), 3(1):1-41, 2015. +Zhe Feng, Harikrishna Narasimhan, and David C Parkes. Deep learning for revenue-optimal auctions with budgets. In Proceedings of the 17th International Conference on Autonomous Agents and Multiagent Systems, pp. 354-362. International Foundation for Autonomous Agents and Multiagent Systems, 2018. +Noah Golowich, Harikrishna Narasimhan, and David C. Parkes. Deep learning for multi-facility location mechanism design. In Proceedings of the 17th International Joint Conference on Artificial Intelligence (IJCAI 2018), pp. 261-267, 2018. URL https://econcs.seas.harvard.edu/files/econcs/files/golowich_ijcai18.pdf. +Yannai A. Gonczarowski and Noam Nisan. Efficient empirical revenue maximization in single-parameter auction environments. In Proceedings of the 49th Annual ACM SIGACT Symposium on Theory of Computing, STOC 2017, Montreal, QC, Canada, June 19-23, 2017, pp. 856-868, 2017. doi: 10.1145/3055399.3055427. URL http://doi.acm.org/10.1145/3055399.3055427. +Yannai A. Gonczarowski and S. Matthew Weinberg. The sample complexity of up-to- $\varepsilon$ multidimensional revenue maximization. In 59th IEEE Annual Symposium on Foundations of Computer Science, FOCS, 2018. + +Ian Goodfellow, Jean Pouget-Abadie, Mehdi Mirza, Bing Xu, David Warde-Farley, Sherjil Ozair, Aaron Courville, and Yoshua Bengio. Generative adversarial nets. In Advances in Neural Information Processing Systems, pp. 2672-2680, 2014. +Chenghao Guo, Zhiyi Huang, and Xinzhi Zhang. Settling the sample complexity of single-parameter revenue maximization. In Proceedings of the 51st Annual ACM SIGACT Symposium on Theory of Computing, STOC 2019, Phoenix, AZ, USA, June 23-26, 2019., pp. 662-673, 2019. doi: 10.1145/3313276.3316325. URL https://doi.org/10.1145/3313276.3316325. +Sergiu Hart and Noam Nisan. Approximate Revenue Maximization with Multiple Items. In the 13th ACM Conference on Electronic Commerce (EC), 2012. +Sergiu Hart and Philip J. Reny. Maximizing Revenue with Multiple Goods: Nonmonotonicity and Other Observations. Theoretical Economics, 10(3):893-922, 2015. +Jason D. Hartline and Brendan Lucier. Bayesian Algorithmic Mechanism Design. In the 42nd ACM Symposium on Theory of Computing (STOC), 2010. +Jason D. Hartline and Samuel Taggart. Sample complexity for non-truthful mechanisms. In Proceedings of the 2019 ACM Conference on Economics and Computation, EC 2019, Phoenix, AZ, USA, June 24-28, 2019., pp. 399-416, 2019. doi: 10.1145/3328526.3329632. URL https://doi.org/10.1145/3328526.3329632. +Jason D. Hartline, Robert Kleinberg, and Azarakhsh Malekian. Bayesian Incentive Compatibility via Matchings. In the Twenty-Second Annual ACM-SIAM Symposium on Discrete Algorithms (SODA), 2011. +Zhiyi Huang, Yishay Mansour, and Tim Roughgarden. Making the most of your samples. SIAM Journal on Computing, 47(3):651-674, 2018. +Sébastien Lahaie. A kernel-based iterative combinatorial auction. In Twenty-Fifth AAAI Conference on Artificial Intelligence, 2011. +Xinye Li and Andrew Chi-Chih Yao. On revenue maximization for selling multiple independently distributed items. Proceedings of the National Academy of Sciences, 110(28):11232-11237, 2013. +Ilya Loshchilov and Frank Hutter. Decoupled weight decay regularization. arXiv preprint arXiv:1711.05101, 2017. +Alejandro Manelli and Daniel Vincent. Bundling as an optimal selling mechanism for a multiple-good monopolist. Journal of Economic Theory, 127(1):1-35, 2006. +Jamie Morgenstern and Tim Roughgarden. Learning simple auctions. In Conference on Learning Theory, pp. 1298-1318, 2016. +Jamie H Morgenstern and Tim Roughgarden. On the pseudo-dimension of nearly optimal auctions. In Advances in Neural Information Processing Systems, pp. 136-144, 2015. +Roger B Myerson. Optimal auction design. Mathematics of operations research, 6(1):58-73, 1981. +Harikrishna Narasimhan and David C Parkes. A general statistical framework for designing strategy-proof assignment mechanisms. In UAI'16 Proceedings of the Thirty-Second Conference on Uncertainty in Artificial Intelligence, 2016. +Jad Rahme, Samy Jelassi, Joan Bruna, and S. Matthew Weinberg. A permutation-equivariant neural network architecture for auction design. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 35, 2021. +Tim Roughgarden and Okke Schrijvers. Ironing in the dark. In Proceedings of the 2016 ACM Conference on Economics and Computation, EC '16, Maastricht, The Netherlands, July 24-28, 2016, pp. 1-18, 2016. doi: 10.1145/2940716.2940723. URL http://doi.acm.org/10.1145/2940716.2940723. + +Aviad Rubinstein and S Matthew Weinberg. Simple mechanisms for a subadditive buyer and applications to revenue monotonicity. ACM Transactions on Economics and Computation (TEAC), 6(3-4):1-25, 2018. +Weiran Shen, Pingzhong Tang, and Song Zuo. Automated mechanism design via neural networks. In Proceedings of the 18th International Conference on Autonomous Agents and Multiagent Systems, pp. 215-223. International Foundation for Autonomous Agents and Multiagent Systems, 2019. +Vasilis Syrgkanis. A sample complexity measure with applications to learning optimal auctions. In Advances in Neural Information Processing Systems, pp. 5352-5359, 2017. +Andrea Tacchetti, DJ Strouse, Marta Garnelo, Thore Graepel, and Yoram Bachrach. A neural architecture for designing truthful and efficient auctions. arXiv preprint arXiv:1907.05181, 2019. +John Thanassoulis. Haggling over substitutes. Journal of Economic Theory, 117:217-245, 2004. +William Vickrey. Counterspeculation, auctions, and competitive sealed tenders. The Journal of finance, 16(1):8-37, 1961. + +# A TRAINING ALGORITHM FOR REGRET NET + +We present the training algorithm for RegretNet, more details can be found in Duetting et al. (2019). + +Algorithm 2 Training Algorithm. +1: Input: Minibatches $S_{1},\ldots ,S_{T}$ of size $B$ +2: Parameters: $\gamma >0,\eta >0,c > 0,R\in \mathbb{N},T\in \mathbb{N},T_{\rho}\in \mathbb{N},T_{\lambda}\in \mathbb{N}.$ +3: Initialize Parameters: $\rho^0\in \mathbb{R},w^0\in \mathbb{R}^d,\lambda^0\in \mathbb{R}^n,$ +4: Initialize Misreports: $v_{i}^{\prime (\ell)}\in \mathcal{D}_{i},\forall \ell \in [B],i\in N.$ +5: +6: for $t = 0,\dots ,T$ do +7: Receive minibatch $S_{t} = \{V^{(1)},\dots ,V^{(B)}\}$ +8: for $r = 0,\dots ,R$ do $\forall \ell \in [B],i\in n:$ $v_{i}^{\prime (\ell)}\gets v_{i}^{\prime (\ell)} + \gamma \nabla_{v_{i}^{\prime}}u_{i}^{w^{t}}(v_{i}^{(\ell)};(v_{i}^{\prime (\ell)},V_{-i}^{(\ell)}))$ +10: +11: Get Lagrangian gradient and update $w^{t}$ . +12: $w^{t + 1}\gets w^t -\eta \nabla_w\mathcal{L}(w^t;\lambda^t;\rho^t).$ +13: +14: Update $\rho$ once in $T_{\rho}$ iterations: +15: if $t$ is a multiple of $T_{\rho}$ then +16: $\rho^{t + 1}\leftarrow \rho^t +c$ +17: else +18: $\rho^{t + 1}\leftarrow \rho^t$ +19: +20: Update Lagrange multipliers once in $T_{\lambda}$ iterations: +21: if $t$ is a multiple of $T_{\lambda}$ then +22: $\lambda_i^{t + 1}\gets \lambda_i^t +\rho^t\hat{r}_i(w^t),\forall i\in N$ +23: else +24: $\lambda^{t + 1}\gets \lambda^t$ + +# B TRAINING ALGORITHM FOR ONLINE REGRET NET + +We present an online version of the training algorithm for RegretNet, more details can be found in Duetting et al. (2019). This version is mentioned in the original paper but the algorithm is not explicitly written there. The following code is our own adaptation of the original RegretNet algorithm for online settings. + +Algorithm 3 Training Algorithm. +1: Input: Valuation's Distribution $\mathcal{D}$ +2: Parameters: $\gamma > 0$ , $\eta > 0$ , $c > 0$ , $R \in \mathbb{N}$ , $T \in \mathbb{N}$ , $T_{\rho} \in \mathbb{N}$ , $T_{\lambda} \in \mathbb{N}$ , $B \in \mathbb{N}$ +3: Initialize Parameters: $\rho^0 \in \mathbb{R}$ , $w^0 \in \mathbb{R}^d$ , $\lambda^0 \in \mathbb{R}^n$ +4: for $t = 0, \ldots, T$ do +5: Sample minibatch $S_t = \{V^{(1)}, \ldots, V^{(B)}\}$ from distribution $\mathcal{D}$ . +6: Initialize Misreports: $v_i^{(\ell)} \in \mathcal{D}_i$ , $\forall \ell \in [B]$ , $i \in N$ . +7: +8: for $r = 0, \ldots, R$ do +9: $\forall \ell \in [B]$ , $i \in n : v_i^{(\ell)} \gets v_i^{(\ell)} + \gamma \nabla_{v_i'} u_i^{w^t}(v_i^{(\ell)}; (v_i'^{(\ell)}, V_{-i}^{(\ell)}))$ +10: +11: Get Lagrangian gradient and update $w^t$ : $w^{t+1} \gets w^t - \eta \nabla_w \mathcal{L}(w^t; \lambda^t; \rho^t)$ . +12: Update $\rho$ once in $T_{\rho}$ iterations: +13: if $t$ is a multiple of $T_{\rho}$ then +14: Update $\rho$ once in $T_{\rho}$ iterations: +15: if $t$ is a multiple of $T_{\rho}$ then +16: else +17: Update Lagrange multipliers once in $T_{\lambda}$ iterations: +18: else +19: +20: Update Lagrange multipliers once in $T_{\lambda}$ iterations: +21: if $t$ is a multiple of $T_{\lambda}$ then +22: $\lambda_i^{t+1} \gets \lambda_i^t + \rho^t \widehat{r}_i(w^t)$ , $\forall i \in N$ +23: else +24: + +# C PROOF OF PROP. 1 + +Lemma 1. Let $M$ be a one bidder $m$ item mechanism with expected revenue $P$ and expected regret $R$ , then $\forall \varepsilon > 0$ , there exists a mechanism $M'$ with expected revenue $P' = (1 - \varepsilon)P - \frac{1 - \varepsilon}{\varepsilon}R$ and zero expected regret, $R' = 0$ . + +Proof. For every valuation vector $v \in D$ , let $g(v)$ and $p(v)$ denote the allocation vector and price that $M$ assigns to $v$ . + +We now consider the mechanism $M^{\prime}$ that does the following: + +$g^{\prime}(v) = g(v^{\prime})$ +$p^{\prime}(v) = (1 - \varepsilon)p(v^{\prime})$ + +Where $v'$ is given by: $v' = \operatorname{argmax}_{\tilde{v} \in D} \langle v, g(\tilde{v}) \rangle - (1 - \varepsilon)p(\tilde{v})$ . By construction, the mechanism $M'$ has zero regret, all we have to do now is bound its revenue. If we denote by $R(v)$ the regret of the profile $v$ in the mechanism $M$ , $R(v) = \max_{\tilde{v} \in D} \langle v, g(\tilde{v}) - g(v) \rangle - (p(\tilde{v}) - p(v))$ we have. + +$$ +\begin{array}{l} \langle v, g \left(v ^ {\prime}\right) \rangle - p \left(v ^ {\prime}\right) = \langle v, g (v) \rangle - p (v) + \langle v, g \left(v ^ {\prime}\right) - g (v) \rangle - \left(p \left(v ^ {\prime}\right) - p (v)\right) \\ \leqslant \langle v, g (v) \rangle - p (v) + R (v) \\ \end{array} +$$ + +Which we will write as: + +$$ +\langle v, g (v) \rangle - p (v) \geqslant \langle v, g \left(v ^ {\prime}\right) \rangle - p \left(v ^ {\prime}\right) - R (v) +$$ + +Second, we have by construction: + +$$ +\langle v, g \left(v ^ {\prime}\right) \rangle - (1 - \varepsilon) p \left(v ^ {\prime}\right) \geqslant \langle v, g (v) \rangle - (1 - \varepsilon) p (v) +$$ + +By summing these two relations we find : + +$$ +p \left(v ^ {\prime}\right) \geqslant p (v) - \frac {R (v)}{\varepsilon} +$$ + +Finally we get that: + +$$ +p ^ {\prime} (v) \geqslant (1 - \varepsilon) p (v) - \frac {1 - \varepsilon}{\varepsilon} R (v) +$$ + +Taking the expectation we get: + +$$ +P ^ {\prime} \geqslant (1 - \varepsilon) P - \frac {1 - \varepsilon}{\varepsilon} R +$$ + +Proposition 1. Let $\mathcal{M}$ be an additive auction with 1 bidders and $m$ items. Let $P$ and $R$ denote the total expected revenue and regret, $P = \mathbb{E}_{V\in D}[p(V)]$ and $R = \mathbb{E}_{V\in D}[r(V)]$ . There exists a mechanism $\mathcal{M}^*$ with expected revenue $P^{*} = \left(\sqrt{P} -\sqrt{R}\right)^{2}$ and zero regret $R^{*} = 0$ . + +Proof. From Lemma 1 we know that $\forall \varepsilon > 0$ , we can find a zero regret mechanism with revenue $P' = (1 - \varepsilon)P - \frac{1 - \varepsilon}{\varepsilon}R$ . By optimizing over $\varepsilon$ we find that the best mechanism is the one corresponding to $\varepsilon = \sqrt{\frac{R}{P}}$ . The resulting optimal revenue is given by: + +$$ +P ^ {*} = (1 - \sqrt {\frac {R}{P}}) P - \frac {\sqrt {\frac {R}{P}}}{\sqrt {\frac {R}{P}}} R = P - 2 \sqrt {P R} + R = \left(\sqrt {P} - \sqrt {R}\right) ^ {2} +$$ + +□ + +# D IMPLEMENTATION AND SETUP + +We implemented ALGnet in PyTorch and all our experiments can be run on Google's Colab platform (with GPU). In Alg. 1, we used batches of valuation profiles of size $B \in \{500\}$ and set $T \in \{160000, 240000\}$ , $T_{limit} \in \{40000, 60000\}$ , $T_{init} \in \{800, 1600\}$ and $\tau \in \{100\}$ . + +We used the AdamW optimizer (Loshchilov & Hutter, 2017) to train the Auctioneer's and the Misreporter's networks with learning rate $\gamma \in \{0.0005, 0.001\}$ . Typical values for the architecture's parameters are $n_a = n_p = n_m \in [3, 7]$ and $h_p = h_n = h_m \in \{50, 100, 200\}$ . These networks are similar in size to the ones used for RegretNet in Duetting et al. (2019). + +For each experiment, we compute the total revenue $rev \coloneqq \mathbb{E}_{V \sim D}[\sum_{i \in N} p_i^w(V)]$ and average regret $rgt \coloneqq 1 / n \mathbb{E}_{V \sim D}[\sum_{i \in N} r_i^w(V)]$ using a test set of 10,000 valuation profiles. We run each experiment 5 times with different random seeds and report the average and standard deviation of these runs. \ No newline at end of file diff --git a/auctionlearningasatwoplayergame/images.zip b/auctionlearningasatwoplayergame/images.zip new file mode 100644 index 0000000000000000000000000000000000000000..f56143758fa202604b3cb6da6f5f1c70f5a74e57 --- /dev/null +++ b/auctionlearningasatwoplayergame/images.zip @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2bf216e00249350b5484b35514a1c01632fff47621fb1d35d21cdffa28bb8c0b +size 323682 diff --git a/auctionlearningasatwoplayergame/layout.json b/auctionlearningasatwoplayergame/layout.json new file mode 100644 index 0000000000000000000000000000000000000000..e40b242ee26d95f0754deb4ba6f832ac18cee646 --- /dev/null +++ b/auctionlearningasatwoplayergame/layout.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e195497ee438399e4f7cb3f5627c2e93a77dd00c8630c2b45d2920509d54dfc9 +size 729036 diff --git a/autolrsautomaticlearningrateschedulebybayesianoptimizationonthefly/d6d44d12-39ed-4868-9a0f-b1c48452e21c_content_list.json b/autolrsautomaticlearningrateschedulebybayesianoptimizationonthefly/d6d44d12-39ed-4868-9a0f-b1c48452e21c_content_list.json new file mode 100644 index 0000000000000000000000000000000000000000..b0c72454c0dadfaace3e2475c474def769219bb8 --- /dev/null +++ b/autolrsautomaticlearningrateschedulebybayesianoptimizationonthefly/d6d44d12-39ed-4868-9a0f-b1c48452e21c_content_list.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3eb12319fe9d13006fec7b69995f20a6c4370338143ead0b9bfc2b1ba5cb02e5 +size 138980 diff --git a/autolrsautomaticlearningrateschedulebybayesianoptimizationonthefly/d6d44d12-39ed-4868-9a0f-b1c48452e21c_model.json b/autolrsautomaticlearningrateschedulebybayesianoptimizationonthefly/d6d44d12-39ed-4868-9a0f-b1c48452e21c_model.json new file mode 100644 index 0000000000000000000000000000000000000000..79a4ea3c3a38aa312aeb6bd287d5a06d2dffc9e1 --- /dev/null +++ b/autolrsautomaticlearningrateschedulebybayesianoptimizationonthefly/d6d44d12-39ed-4868-9a0f-b1c48452e21c_model.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3b1d0cb3ccb96f46a391e98699fb0b04d3022a83b1ecfa9493972aba1985a5a5 +size 167318 diff --git a/autolrsautomaticlearningrateschedulebybayesianoptimizationonthefly/d6d44d12-39ed-4868-9a0f-b1c48452e21c_origin.pdf b/autolrsautomaticlearningrateschedulebybayesianoptimizationonthefly/d6d44d12-39ed-4868-9a0f-b1c48452e21c_origin.pdf new file mode 100644 index 0000000000000000000000000000000000000000..2ce7cc2ac97fa0b658d25e55a245da5e3b0bbcd4 --- /dev/null +++ b/autolrsautomaticlearningrateschedulebybayesianoptimizationonthefly/d6d44d12-39ed-4868-9a0f-b1c48452e21c_origin.pdf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2cf5361655e7979bf36cd5eb8aa21e530a404b009ac519d6077081f26dbecb3a +size 1033829 diff --git a/autolrsautomaticlearningrateschedulebybayesianoptimizationonthefly/full.md b/autolrsautomaticlearningrateschedulebybayesianoptimizationonthefly/full.md new file mode 100644 index 0000000000000000000000000000000000000000..3634eb497eee799127b0c9679730721eee8cd2cc --- /dev/null +++ b/autolrsautomaticlearningrateschedulebybayesianoptimizationonthefly/full.md @@ -0,0 +1,463 @@ +# AUTOLRS: AUTOMATIC LEARNING-RATE SCHEDULE BY BAYESIAN OPTIMIZATION ON THE FLY + +Yuchen Jin, Tianyi Zhou, Liangyu Zhao + +University of Washington + +{yuchenj, tianyizh, liangyu}@cs.washington.edu + +Yibo Zhu, Chuanxiong Guo + +ByteDance Inc. + +{zhuyibo, guochuanxiong}@bytedance.com + +Marco Canini + +KAUST + +marco@kaust.edu.sa + +Arvind Krishnamurthy + +University of Washington + +arvind@cs.washington.edu + +# ABSTRACT + +The learning rate (LR) schedule is one of the most important hyper-parameters needing careful tuning in training DNNs. However, it is also one of the least automated parts of machine learning systems and usually costs significant manual effort and computing. Though there are pre-defined LR schedules and optimizers with adaptive LR, they introduce new hyperparameters that need to be tuned separately for different tasks/datasets. In this paper, we consider the question: Can we automatically tune the LR over the course of training without human involvement? We propose an efficient method, AutoLRS, which automatically optimizes the LR for each training stage by modeling training dynamics. AutoLRS aims to find an LR applied to every $\tau$ steps that minimizes the resulted validation loss. We solve this black-box optimization on the fly by Bayesian optimization (BO). However, collecting training instances for BO requires a system to evaluate each LR queried by BO's acquisition function for $\tau$ steps, which is prohibitively expensive in practice. Instead, we apply each candidate LR for only $\tau' \ll \tau$ steps and train an exponential model to predict the validation loss after $\tau$ steps. This mutual-training process between BO and the loss-prediction model allows us to limit the training steps invested in the BO search. We demonstrate the advantages and the generality of AutoLRS through extensive experiments of training DNNs for tasks from diverse domains using different optimizers. The LR schedules auto-generated by AutoLRS lead to a speedup of $1.22 \times$ , $1.43 \times$ , and $1.5 \times$ when training ResNet-50, Transformer, and BERT, respectively, compared to the LR schedules in their original papers, and an average speedup of $1.31 \times$ over state-of-the-art heavily-tuned LR schedules. + +# 1 INTRODUCTION + +In the regime of deep learning, the success of training largely depends on the choice of the learning rate (LR) schedule, since most optimizers will have difficulty traversing a non-smooth and non-convex loss landscape with multiple local minimums and possibly saddle points (Kawaguchi, 2016; Jin et al., 2017; Goodfellow et al., 2016; Li et al., 2018a). To achieve stable and fast convergence towards a solution with good generalization performance, one has to tune the LR schedules carefully for different tasks (Nar & Sastry, 2018; Jastrzebski et al., 2017). This tuning is usually non-trivial and requires many trial-and-error iterations that are computationally expensive. Moreover, the randomness of the widely-used mini-batch stochastic gradient descent (SGD) may introduce more uncertainty and difficulty in the tuning process. For the same reasons, it is also hard to directly formulate the search of the LR schedule as a well-posed optimization problem and address it through standard optimization. + +The broadly-adopted strategy is to either pick one from a family of pre-defined LR schedules or apply an optimizer that has a built-in mechanism changing the LR adaptively. However, we have a limited number of choices for pre-defined LR schedules, most of which are simple functions such as exponent or cosine and thus cannot perfectly align with the non-smooth loss landscape. The latter set of adaptive optimizers, e.g., Adam (Kingma & Ba, 2015) and Adadelta (Zeiler, 2012), are extended from convex optimization and rely on strong assumptions to make the convergence properties hold. Moreover, the methods in both categories introduce new hyper-parameters that have to be tuned separately for different tasks or datasets, requiring significant human involvement. + +In this paper, we study the question: can we automatically tune the LR over the course of training without human involvement? At the beginning of every $\tau$ steps (i.e., a "stage" in our method), we seek to identify an LR that optimizes the validation loss (i.e., an empirical estimate of the generalization error) at the end of the stage. To do so, we employ Bayesian optimization (BO) that treats the validation loss as a black-box function of LR. BO simultaneously updates a posterior estimation of the black-box function and searches for the best LR with respect to the posterior. This approach is, however, computationally expensive since estimating the posterior needs many (input, output) instances of the function, and acquiring each instance costs $\tau$ steps of training. We, therefore, develop a simple yet efficient approximation: for every LR that BO decides to evaluate, we train the model by using the LR for only $\tau' \ll \tau$ steps and use the validation loss over the $\tau'$ steps to train a time-series forecasting model that provides a prediction of the validation loss after $\tau$ steps. As we will show later, an exponential model suffices to produce accurate predictions when using a small $\tau' = \tau / 10$ . Then, AutoLRS can allow BO to explore ten different LRs in each stage and still bound the total running time to approximately twice the training cost associated with the generated schedule, i.e., the time spent to find the stage-specific LRs is roughly equal to the time spent training the model with the identified LRs. + +AutoLRS does not depend on a pre-defined LR schedule, dataset, or a specified task and is compatible with almost all optimizers. Hence, it can be generally deployed across a broad range of ML tasks without much human involvement or expensive tuning over choices of LR schedules and their hyperparameters. Moreover, since it directly minimizes the validation loss, it does not only accelerate the convergence but also improves the generalization compared to just minimizing the training loss. Furthermore, AutoLRS only needs to update two extremely light-weight models, i.e., the BO posterior and the exponential forecasting model, and it is efficient in exploring the loss landscape. Hence, it does not result in notable extra costs in either memory or computation. Note that AutoLRS searches for better LRs based on the training dynamics, which can be seen as a form of self-supervision. The interaction between BO and the forecasting model is an example of mutual learning, where one produces training data for the other. + +In experiments, we apply AutoLRS to train three representative DNNs widely used in practice, i.e., ResNet-50 (He et al., 2016a) on ImageNet classification (Russakovsky et al., 2015); Transformer (Vaswani et al., 2017) and BERT (Devlin et al., 2019) for NLP tasks. Though they have been extensively studied and have hand-tuned LR schedules, the LR schedules computed by AutoLRS are faster than the original, hand-tuned, LR schedules by $1.22 \times$ , $1.43 \times$ , and $1.5 \times$ for training ResNet-50, Transformer, and BERT, respectively, in terms of the training steps used to update the DNN (i.e., excluding the costs of the LR/hyperparameter search). It meanwhile achieves test-set performance better or on par with state-of-the-art results. We also carefully hand-tuned two state-of-the-art learning rate schedules, CLR (Smith, 2017) and SGDR (Loshchilov & Hutter, 2017), and conducted more than ten experiments with different CLR/SGDR hyperparameters on each model. AutoLRS still has an average speedup of $1.29 \times$ and $1.34 \times$ across the three models, in terms of training steps, compared to the best CLR and SGDR LR schedules, respectively. The AutoLRS implementation is available at https://github.com/YuchenJin/autolrs. + +# 2 RELATED WORK + +Learning rate scheduling: In contrast to traditional LR schedules with a monotone decreasing sequence of LRs and multi-step LR schedule, a recent class of LR schedules propose to apply multiple cycles of LR decay. Cyclical Learning Rate (CLR) changes LR from a maximal LR $(\eta_{\mathrm{max}})$ to a minimal LR $(\eta_{\mathrm{min}})$ at a pre-defined frequency and achieves faster convergence for some DNNs (Smith, 2017). The approach requires a "LR range test" to estimate the minimal and maximal LR. The $LR$ range test trains the model with a linearly-increasing LR between a low LR + +and a high LR, and finds the LR range $([\eta_{\mathrm{min}},\eta_{\mathrm{max}}])$ over which the training loss decreases. The authors proposed three variants of CLR: triangular2 that halves the maximum LR bound after each cycle; $exp\_range$ that exponentially reduces the maximum LR bound after each cycle; and 1cycle containing only one triangular cycle (Smith, 2018). Similar to CLR, Stochastic Gradient Descent with Warm Restarts (SGDR) restarts the LR and then applies cosine annealing/decay at a pre-defined frequency (Loshchilov & Hutter, 2017). Neither CLR or SGDR is automatic, because they are quite sensitive to their hyperparameters, which require careful hand-tuning. CLR and SGDR may even cause undesirable divergence in loss during training with suboptimal hyperparameters (see §5). + +Learning rate adaptation with hypergradient descent: Aiming for the same goal of automatically tuning the LR, the hypergradient based technique (Almeida et al., 1998; Franceschi et al., 2017; Baydin et al., 2018; Donini et al., 2020) optimizes the LR schedule by applying gradient descent of the objective function w.r.t. the LR during training. In addition to the initial value of the regular LR, it introduces an additional hypergradient LR whose initial value is another hyperparameter to be specified. We experimentally show that this technique is subject to overfitting, it is quite sensitive to its two hyperparameters, and it is unable to match the state-of-the-art test-set performance on the models we test (§A.5.1). We also compare its performance against AutoLRS (§A.5.2). + +DNN hyperparameter optimization: Automatic hyperparameter searching for DNNs has been broadly studied in recent years. When applied to learning rates, they can determine an optimized value for LR that is kept constant (or constrained to be a pre-defined shape) through the entire training process, as opposed to determining an LR schedule. They can be primarily categorized into Bayesian optimization based approaches (Hutter et al., 2011; Snoek et al., 2012; Bergstra et al., 2013), bandit-based solutions (Li et al., 2017; 2018b), hybrid approaches that combine bandit-based and Bayesian optimization based approaches (Falkner et al., 2018; Zela et al., 2018), and population-based methods (Jaderberg et al., 2017; Parker-Holder et al., 2020). It might be possible to extend these techniques to determine a LR schedule with an optimized LR for each training stage, but it is not sample-efficient and time-efficient to do so since the LR schedule would correspond to hundreds or thousands of hyperparameters. + +Optimization methods with adaptive LR: These optimizers can adaptively adjust LR for each training step by maintaining an estimate of a better learning rate separately for each parameter in the DNN. Adagrad (Duchi et al., 2011) applies lower LRs to parameters with larger accumulated gradients and higher learning rates to the ones with smaller accumulated gradients. RMSprop (Tieleman & Hinton, 2012), AdaDelta (Zeiler, 2012), and Adam (Kingma & Ba, 2015) were later proposed to address the issue in Adagrad that the model stops learning due to the continual decay of LR. These optimizers with adaptive LR are orthogonal to our automatic LR scheduler, and they still require a global learning rate schedule, which can be obtained from our AutoLRS. In particular, their default hyperparameters do not always work well and need careful tuning, e.g., Adam's default LR 0.001 performs poorly in training BERT and Transformer, and a better-tuned LR schedule can significantly reduce the training time (\$5). Recent optimization methods (Schaul et al., 2013; Mahsereci & Hennig, 2015) proposed to remove the need for LR tuning in SGD altogether, but they are not widely used potentially due to their limited applicability and sub-optimal performance (Baydin et al., 2018). + +# 3 PROBLEM FORMULATION + +Training of DNNs can be written in a general form of minimizing a loss function $L(x; \theta)$ over training samples $x \in D_{train}$ , where $\theta$ represents the model weights being optimized. The minimization is conducted by applying an optimizer that updates $\theta$ iteratively. For example, at each step $t$ , mini-batch SGD updates $\theta$ using the gradient computed on a mini-batch of samples $B_{train} \subseteq D_{train}$ : + +$$ +\theta_ {t + 1} = \theta_ {t} - \frac {\eta_ {t}}{\left| B _ {\text {t r a i n}} \right|} \sum_ {x \in B _ {\text {t r a i n}}} \nabla_ {\theta} L (x; \theta_ {t}), \tag {1} +$$ + +where $\eta_t$ is the learning rate (LR) at step $t$ and $\nabla_{\theta}L(x;\theta_t)$ denotes the gradient of the loss $L(x;\theta)$ w.r.t. $\theta_t$ at step $t$ . Given $B_{train}$ and $\theta_t, \theta_{t+1}$ can be represented as a function of LR $\eta_t$ , i.e., $\theta_{t+1}(\eta_t)$ . + +Our ultimate goal is to search for an optimal schedule of LR, i.e., a sequence of LRs $\eta_{1:T} \triangleq (\eta_1, \eta_2, \dots, \eta_T)$ applied to the total $T$ training steps, such that the generalization error can be minimized. Ideally, we need to optimize the entire sequence of LRs. This, however, is intractable in practice given the large number of possible LR schedules and since evaluating each one of those possible LR schedules requires a full training of $T$ steps. Hence, we break down the LR schedule optimization into a dynamic optimization of a constant LR for every $\tau$ steps, which we refer to + +as a "training stage". Since most tasks prefer a relatively small LR due to the non-smoothness of DNNs' loss landscapes, when $\tau$ is also small, the LR-resulted change on the validation loss might be too small and overwhelmed by the randomness of mini-batch SGD. Hence, in this case, we need to increase $\tau$ , so the effect of LR $\eta$ on the validation loss can be accumulated for more steps to overcome noise. A large $\tau$ also reduces the frequency of applying LR search and saves computation. On the other hand, setting $\tau$ to be too large might lose some optimality of the induced LR schedule. Therefore, we need to trade-off the above two issues to find an appropriate $\tau$ . In our final algorithm, we propose a curriculum for $\tau$ , i.e., we start from a small $\tau$ , in line with the greater volatility during early stages, and gradually increase $\tau$ as training proceeds (as described in §4.4). Since we mainly focus on LR search within a stage, for simplicity, we will use $\tau$ instead of $\tau_{t}$ for the exposition below. + +We study a greedy approach and split the whole training process into multiple stages of $\tau$ steps each. We choose an LR at the beginning of each stage and apply $\tau$ steps of optimization using this LR, i.e., at step- $t = 0, \tau, 2\tau, \dots, T - \tau$ , we aim to find the LR $\eta_{t:t + \tau}$ that minimizes the validation loss on $D_{val}$ (i.e., an estimate of the generalization error) after step- $(t + \tau)$ . This can be formulated as: + +$$ +\min _ {\eta} \sum_ {x \in D _ {v a l}} L (x; \theta_ {t + \tau} (\eta)), t = 0, \tau , 2 \tau , \dots , T - \tau . \tag {2} +$$ + +We try to sequentially solve $\lfloor T / \tau \rfloor$ sub-problems of the above form. However, we cannot apply standard optimization to solve each sub-problem in practice because: (i) it is a high-order optimization of $\eta$ since we need to unroll $\theta_{t + \tau}$ in Eq. (2) backward for $\tau$ steps using Eq. (1), which requires prohibitive memory and is unstable for DNNs; (ii) one step of optimizing $\eta$ needs to apply $\tau$ steps of optimization on $\theta$ , which is costly and weakens the advantage of searching LR for better efficiency. To avoid these issues, we treat the objective function in Eq. (2) for $t:t + \tau$ as a black-box function $f_{t}(\eta)$ and study how to optimize it based on the observed training dynamics through Bayesian optimization (BO). + +# 4 AUTOMATIC LEARNING RATE SCHEDULE SEARCH + +We first elaborate on the details of our BO algorithm (§4.1) that identifies the LR for each stage1. However, collecting even one data point $(\eta, f(\eta))$ for BO requires us to train the model for $\tau$ steps, which is costly and impractical since the LR computed by the entire BO process is used for only $\tau$ steps. To reduce the cost of generating instances of $(\eta, f(\eta))$ , in §4.2 and §A.3, we propose to train a light-weight time-series forecasting model to predict $f(\eta)$ based on the validation loss observed during the first $\tau'$ ( $\tau' \ll \tau$ ) steps of applying LR $\eta$ . We find that a simple exponential model suffices to produce accurate predictions. Our LR search then reduces to a multi-training process between BO and the forecasting model, where one produces training instances for the other. The resulting algorithm can automatically find an LR schedule without introducing significant extra computation. + +# 4.1 BAYESIAN OPTIMIZATION + +BO (Shahriari et al., 2016) is one of the state-of-the-art techniques for black-box optimization. It applies exploration and exploitation to the objective by sequentially and actively querying the function values of some input instances. Specifically, BO uses Gaussian process as a surrogate model (prior) to fit the black-box objective function $f(\eta)$ . It sequentially updates a posterior of $f(\eta)$ by using its likelihood on newly evaluated $(\eta_i', y_i = f(\eta_i') + \epsilon)$ pairs $^2$ , where $y_i$ is a noisy observation of $f(\eta_i')$ and is the validation loss after $\tau$ steps. Then, it finds the next $\eta_{i+1}'$ to evaluate based on an acquisition function $u_i(\eta)$ defined by the posterior mean $\mu_i(\eta)$ and standard deviation $\sigma_i(\eta)$ . $u_i(\eta)$ performs a trade-off between exploration (i.e., large $\sigma_i(\eta)$ ) and exploitation (i.e., small $\mu_i(\eta)$ ). In AutoLRS, we use Lower Confidence Bound (LCB) (Cox & John, 1992; Auer, 2002) as $u_i(\eta)$ . Given $\eta_{1:i}^{\prime}$ and their corresponding validation loss $y_{1:i}$ , we determine the next LR $\eta_{i+1}$ by minimizing LCB, i.e., + +$$ +\eta_ {i + 1} ^ {\prime} = \arg \min _ {\eta} u _ {i} (\eta), u _ {i} (\eta) \triangleq \mu_ {i} (\eta) - \kappa \sigma_ {i} (\eta), \tag {3} +$$ + +where $\mu_i(\eta)$ and $\sigma_i(\eta)$ are defined in Eq. (7) in §A.1, $\kappa$ is a positive hyper-parameter to balance exploration and exploitation. In experiments, $\kappa = 1000$ works consistently well. BO repeats the above process until it achieves a precise posterior distribution of $f(\eta)$ . See §A.1 for more details. + +Algorithm 1: AutoLRS +Input: (1) Number of steps in each training stage, $\tau$ (2) Learning-rate search interval $(\eta_{\mathrm{min}},\eta_{\mathrm{max}})$ (3) Number of LRs to evaluate by BO in each training stage, k (4) Number of training steps to evaluate each LR in BO, $\tau^{\prime}$ (5) Trade-off weight in the acquisition function of BO, $\kappa$ +1 while not converge do +2 initialize a GP prior: $\mu_0(\eta) = 0,\sigma_0^2 (\eta) = K(\eta ,\eta)$ defined in Eq. (4) in $\S \mathrm{A}.1$ . +3 $c\gets$ checkpoint of model parameters and optimizer states; +4 for $i\gets 1$ to k do /\* mutual-training loop between BO and loss forecasting model \*/ +5 choose the next LR to explore: $\eta_i^\prime = \arg \min_\eta \mu_{i - 1}(\eta) - \kappa \sigma_{i - 1}(\eta);$ +6 $y_{1:\tau '}\gets$ train the DNN with LR $\eta_i^\prime$ for $\tau '$ steps and record the corresponding validation loss series; +7 $y_{n}\gets$ train an exponential forecasting model on $y_{1:\tau '}$ and predict the validation loss after $\tau$ steps; +8 update the GP posterior by $(\eta_i^\prime ,y_i)$ and update new $\mu_{i}(\eta)$ and $\sigma_{i}(\eta)$ using Eq. (7) in $\S \mathrm{A}.1$ +9 restore the checkpoint $c$ of model parameters and optimizer states; +10 end +11 $\eta^{*}\gets$ the LR with the minimal predicted validation loss $\mu_k(\eta)$ among the k explored LRs $\eta_{1:k}^{\prime}$ above; +12 train the DNN using LR $\eta^{*}$ for $\tau$ steps; /\* training model using BO-searched best learning rate \*/ +13 end + +# 4.2 TIME-SERIES FORECASTING MODEL OF LOSS + +Typically, BO would require $\tau$ training steps to measure the validation loss associated with every LR $\eta$ that it considers during a stage. This is computationally expensive. We now introduce a simple yet effective approach that substantially reduces the number of training steps required to evaluate each LR candidate: for each LR $\eta$ that is evaluated, we only apply it for $\tau'\ll \tau$ steps and use the validation loss observed in the $\tau'$ steps to train a short-term time-series forecasting model. We then use the resulting forecasting model to predict the validation loss after $\tau$ steps. + +In numerous experiments, we observed that when a DNN is trained with a reasonable LR, the validation loss typically decreases exponentially and converges to a small value. We show examples of practical loss time series and their exponential-model fitting results in Figure 3. Moreover, recent deep learning theory (Allen-Zhu et al., 2019b) also proves the linear convergence of training DNNs. In addition, a simple model to fit the observed loss time-series can filter the noise and avoid possible overfitting. Hence, we propose to train an exponential model in the form of $L(t) = a\exp (bt) + c$ with parameters $a, c$ and $b < 0$ and for $t = 1,\dots ,\tau$ , as the forecasting model for the time series of the validation loss in a training stage of $\tau$ steps with a given LR $\eta$ . §A.2 describes how we estimate $a$ , $b$ , and $c$ based on the validation loss observed in the first $\tau^{\prime}$ steps, and §A.3 describes how we filter out noise and outliers. + +# 4.3 MUTUAL TRAINING BETWEEN BO AND EXPONENTIAL PREDICTION + +We present the complete procedure of AutoLRS in Algorithm 1. It sequentially optimizes LR for every training stage during the training of a DNN model, solely based on the observed training dynamics, and it can be seen as a form of self-supervision. For each training stage, it searches for the LR that leads to the largest improvement in the validation loss via an efficient black-box function optimization conducted by a mutual training loop between Bayesian optimization and a short-term forecasting model for each loss series. It then applies the best LR among the explored ones for $\tau$ steps and repeats the above process until convergence. + +In line 5, the algorithm solves a constrained optimization problem over $\eta$ , in the range of $[\eta_{min}, \eta_{max}]$ . In practice, we prefer a large learning-rate search interval $(\eta_{\mathrm{min}}, \eta_{\mathrm{max}})$ , across orders of magnitude, but also need fine-grained optimization over small LRs. Hence, we operate on $\eta$ in its log-scale space, i.e., we replace $\eta$ by $\log \eta$ in Algorithm 1, except in lines 6 and 12 when we use the original LR (rather than $\log \eta$ ) to train the DNN. + +At the end of each iteration in the mutual training loop (line 9), we restore the checkpoint $c$ of model parameters and optimizer states to the one saved at the beginning of the training stage3. By doing so, + +we guarantee that the $k$ different LRs all start from the same model and their losses can be compared. $\S A.4$ illustrates how BO learns the underlying function in practice for early and late stages of training. + +Hyperparameters: AutoLRS substantially reduces the amount of hyperparameters that need to be hand-tuned in existing LR schedules or policies. However, as shown in Algorithm 1, we still have hyperparameters in AutoLRS. First, we need to set a search interval $(\eta_{\mathrm{min}}, \eta_{\mathrm{max}})$ for LR. However, this interval can be reasonably wide by using an $LR$ range test (Loshchilov & Hutter, 2017) as we will show in §5. Secondly, our default settings of $k$ , $\tau'$ , $\tau$ , and $\kappa$ work well for a diverse set of DNN models from different domains and tasks, though it is possible to achieve further improvements by fine-tuning them. + +# 4.4 PRACTICAL IMPROVEMENTS + +We found the following modifications can further improve the performance of AutoLRS in practice. + +Gradually increase $\tau$ over the course of training: Often, in DNN training, the loss and the model parameters experience rapid changes only during the first few epochs before they enter a phase of stable improvement. Our approach can adapt to this phenomenon. For the early stages, when the loss is less predictable for the time-series forecasting model, we use a small $\tau$ (and $\tau'$ ). As training proceeds and the model becomes stable, we gradually increase $\tau$ (and $\tau'$ ) and adjust the LR more lazily. This curriculum of increasing $\tau$ places more exploration in earlier stages and more exploitation in later stages. In practice, we start with $\tau = 1000$ and $\tau' = 100$ , and double them after every stage until it reaches $\tau_{\mathrm{max}}$ . $\tau_{\mathrm{max}}$ is a hyperparameter that limits the maximum number of steps in a stage. We will discuss more of $\tau_{\mathrm{max}}$ in §5. This gradual increase of $\tau$ can provide stability to the LR schedule search. Similar strategies have been widely used in previous pre-defined LR schedules, e.g., the multi-stage schedule with increasing epochs within each stage, and some recent cyclical LR schedules (Loshchilov & Hutter, 2017). + +Minimizing training loss in early stages: Computing the validation loss series for a candidate $\eta^{\prime}$ requires considerable computation if we were to use the entire validation dataset at each step of mutual training. Recall, however, that the primary purpose of minimizing the validation loss instead of the training loss is to avoid overfitting on the training set when the training loss notoriously deviates from the generalization error. However, a variety of empirical evidence and recent theory (Allen-Zhu et al., 2019a) show that overfitting is unlikely while training over-parameterized DNNs due to the inductive bias of random initialization and SGD, especially during the early phase of training. Hence, in practice, for the first several training stages, we can safely approximate the validation loss in our method by the corresponding training loss, which is a by-product of forward propagation and free to obtain. In later stages (i.e., once $\tau$ reaches $\tau_{\mathrm{max}}$ ), since the model is stable and the loss changes smoothly, we can evaluate the validation loss on a small subset of the validation set without compromising robustness. In our experiments, this set is composed of merely 10 mini-batches, and we evaluate the validation loss on them every 50 training steps (as opposed to every step). Therefore, the evaluation of validation loss in our approach does not introduce notable extra computations4. + +# 5 EXPERIMENTS + +We now evaluate AutoLRS by applying it to three widely-used and representative DNNs: ResNet-50, Transformer, and BERT. Here are some highlights: + +- The LR schedules computed by AutoLRS are $1.22 \times$ , $1.43 \times$ , and $1.5 \times$ faster, in terms of training steps, than the original, hand-tuned LR schedules for ResNet-50, Transformer, and BERT, respectively. Meanwhile, it improves or matches the test-set performance. +- For each model, we carefully hand-tuned CLR and SGDR using more than ten experiments with different CLR/SGDR hyperparameters. Across the three models, the LR schedules computed by AutoLRS achieve an average speedup of $1.29 \times$ and $1.34 \times$ , in terms of training steps, over the best tuned LR schedules under CLR and SGDR, respectively. While CLR and SGDR had to be run + +for at least 10 trials to find a good LR schedule, AutoLRS only costs slightly over $2 \times$ the training time associated with the computed LR schedule even after accounting for the BO search cost. + +- AutoLRS is robust to the change of hyperparameters and consistently finds better LR schedules than other baselines. In contrast, CLR and SGDR are sensitive to the choices of hyperparameters. +- We perform ablation studies in §A.5.4 to demonstrate that both BO and the exponential forecasting model are essential for AutoLRS to find good LR schedules. +- Hypergradient descent is subject to overfitting, and it is unable to match the state-of-the-art test-set performance using all the guideline values of its two hyperparameters on VGG-16 (Simonyan & Zisserman, 2015) and ResNet-50 ( $\S$ A.5.1). In contrast, AutoLRS can consistently improve or match the state-of-the-art test-set performance with different $\tau_{\mathrm{max}}$ values using fewer training steps than the hand-tuned LR schedules ( $\S$ A.5.2). +- Using Hyperband (Li et al., 2017) for LR schedule search incurs a high computational overhead. Moreover, it cannot find an LR schedule that matches the state-of-the-art accuracy (§A.5.3). + +Baseline Setup: ML practitioners typically need to hand-tune the LR schedules carefully for a long time to achieve satisfying performance, so the LR schedule adopted in each model's original paper is a presumably tough-to-beat baseline to compare with. For CLR and SGDR, we hand-tune their hyperparameters separately for each DNN. Hyperparameters in CLR include the high/low LR for the $LR$ range test to sweep, the number of steps to perform the test, the number of steps in each triangular cycle, and the choice of variants (triangular2, exp_range, 1cycle) introduced in §2. Hyperparameters in SGDR include the number of steps/epochs in each cycle and the initial LR at the beginning of each cycle. We carefully tuned these hyperparameters separately for each DNN and chose the LR schedule producing the best validation-set performance among $\geq 10$ trials of different hyperparameters. + +Hyperparameters in AutoLRS: In our default setting, we set $k = 10$ and $\tau' = \tau / 10$ so that the training steps spent on BO equals the training steps spent on updating the DNN model. We start from $\tau = 1000$ and $\tau' = 100$ and double $\tau$ and $\tau'$ after each stage until $\tau$ reaches $\tau_{\max}$ . We use $\tau_{\max} = 8000$ for ResNet-50 and Transformer, $\tau_{\max} = 32000$ for BERT. We also tried $\tau_{\max} = 8000$ , 16000, and 32000 for each DNN and found that the resulting LR schedules are not very sensitive to $\tau_{\max}$ . (An analysis of the sensitivity to $\tau_{\max}$ is in §A.5.2.) The LR search interval $(\eta_{\min}, \eta_{\max})$ for ResNet-50, Transformer, and BERT are $(10^{-3}, 1)$ , $(10^{-4}, 10^{-2})$ , and $(10^{-6}, 10^{-3})$ , respectively. These are easily found by an LR range test (Loshchilov & Hutter, 2017). + +ResNet-50: ResNet (He et al., 2016a;b) is one of the most popular DNNs in computer vision tasks. We train ResNet-50 on ImageNet (Russakovsky et al., 2015) using SGD with momentum on 32 NVIDIA Tesla V100 GPUs with data parallelism and a mini-batch size of 1024. The LR schedule in the original paper adopts a warmup phase of 5 epochs at the beginning and performs a 3-step decay as in (Goyal et al., 2017). Figure 1a presents different LR schedules for training ResNet-50 on ImageNet. We report how their top-1 accuracy on the validation set changes during training in Figure 1b. AutoLRS achieves a speedup of $1.19 \times$ and $1.22 \times$ over SGDR and the original LR schedule respectively but is slightly (i.e., $5.4\%$ ) slower than CLR. Note that the best CLR result is achieved after 10 trials of heavy hand-tuning to hyperparameters. (In fact, 7 out of 10 CLR trials failed to achieve the best possible test-set accuracy, and the second best and the third best trials are $5.4\%$ and $7.9\%$ slower than AutoLRS). AutoLRS achieves competitive speed even though it invests a significantly lower search cost that is comparable to the overall model update time associated with the identified LR schedule. + +Transformer: Transformer (Vaswani et al., 2017) is a neural machine translation (NMT) model that is built upon a multi-head self-attention mechanism to capture the contextual dependencies and achieves promising translation performance. We train $\mathrm{Transformer}^6$ on a standard benchmark, i.e., WMT 2014 English-German dataset, using 8 NVIDIA Tesla V100 GPUs. Following (Vaswani et al., 2017), we use Adam (Kingma & Ba, 2015) with $\beta_{1} = 0.9$ , $\beta_{2} = 0.98$ , and $\epsilon = 10^{-9}$ . The LR schedule in the original paper starts from a linear warmup of 4,000 steps from 0 to $7e^{-4}$ , followed by 96,000 steps of decaying the LR proportionally to $1/\sqrt{t}$ for step- $t$ . In AutoLRS, we also use the same linear warmup. The current AutoLRS does not search LR for warmup steps since warmup + +![](images/e7fb691beb46b0600cb596f5c7fc52108a9d9901d1ce3e20a6d39c8fd7a3270d.jpg) +(a) LR on ResNet-50. + +![](images/89f0568afc998189359234d64203846d597ca01e4f5f4e0ea97373f1abcd9573.jpg) +(b) Val.Acc. on ResNet-50. + +![](images/2b1b30bb2efcb2f12cb658ee6d1dc35eb10fba58534787cbf41732595e541801.jpg) +(c) LR for Transformer. + +![](images/907a3c2578ae9fa5512f508fe58201b9afb3892b5aac5b1073deb25c1c2f5ebd.jpg) +(d) BLEU of Transformer. + +![](images/34744b8b8980f021398cf82c0efc7c0b358ea89259cbe9c7536ce77b6b9f6452.jpg) +Figure 1: Comparison of different LR schedules in training ResNet-50 on ImageNet (a, b), and the Transformer base model (c, d). When training ResNet-50, AutoLRS, CLR, SGDR, and the original LR achieve $75.9\%$ top-1 accuracy at epoch 74, 70, 88, and 90, respectively. When training Transformer base, AutoLRS, SGDR, and original achieve 27.3 BLEU score (uncased) at step 69,000, 91,000, 98,000, respectively. CLR (the best we were able to find) achieves 27.2 BLEU score at step 99,000. +(a) LR schedules (Phase $1 + 2$ +Figure 2: Comparison of different LR schedules and training loss in pre-training $\mathrm{BERT}_{\mathrm{BASE}}$ + +![](images/9c47e0c63807c82d3391fa903c24f625871fec37acbf24143ccccc4cf739a40d.jpg) +(b) Training loss in Phase 1. + +![](images/f9731c283823513a7f5d82a8d3a179bf403f9ebf6b98150b6d091ee872672b57.jpg) +(c) Training loss in Phase 2. + +does not have an explicit optimization objective, such as minimizing the validation loss. Warmup usually takes very few steps, and its main purpose is to prevent deeper layers in a DNN from creating training instability (Gotmare et al., 2019). Figure 1c visualizes different LR schedules in training the Transformer model. Their BLEU scores on the test set during training are reported in Figure 1d. Overall, the LR schedule searched by AutoLRS yields a $1.32 - 1.43 \times$ speedup over the hand-tuned LR schedules. AutoLRS consistently achieves a similar amount of speedup over three trials – they achieve 27.3 BLEU score (uncased) at step 69,000, 69,000, and 70,000, respectively. Interestingly, if we continue the LR search of AutoLRS, we can get 27.4 BLEU score (uncased) at step 99,000. + +BERT Pre-training: BERT (Devlin et al., 2019) is a recent model that achieved state-of-the-art results on 11 NLP tasks. It first pre-trains a language representation model on a large text corpus by unsupervised learning and then fine-tunes it for downstream NLP tasks. The $\mathrm{BERT}_{\mathrm{BASE}}$ model has 110M parameters, which makes the pre-training phase expensive, and hand-tuning the LR schedule might be impractical. We pre-train $\mathrm{BERT}_{\mathrm{BASE}}$ with mixed precision (Micikevicius et al., 2018) on the English Wikipedia and the BooksCorpus dataset7 (Zhu et al., 2015a). Following the original paper, we use Adam with L2 weight decay of 0.01 and $\beta_{1} = 0.9$ , $\beta_{2} = 0.999$ . The pre-training is divided into two phases: Phase 1 includes $90\%$ of the total training steps and uses a sequence length of 128, while Phase 2 uses a sequence length of 512 for the rest $10\%$ of training steps. We apply this two-phase training in the experiments of all LR schedules. We pre-train $\mathrm{BERT}_{\mathrm{BASE}}$ on 32 NVIDIA Tesla V100 GPUs using a mini-batch size of 1024 sequences, which is $4\times$ the batch size in the original paper. To adapt the original LR schedule to our batch size, we tried both the linear scaling rule (Goyal et al., 2017) and the square root scaling rule (Krizhevsky, 2014), and found that the square root scaling rule works better while the linear scaling rule made the loss diverge. + +As shown in Figure 2, Phase 1 contains 150,000/225,000 steps and Phase 2 contains 16,000/25,000 steps respectively for AutoLRS and all baselines, since AutoLRS requires much less total steps. In both AutoLRS and SGDR, we apply a linear warmup in the first 2,500 steps to make the deeper layers of BERT stable. In Figures 2b and 2c, we report the training loss achieved by different schemes. + +We fine-tune the pre-trained models on four downstream NLP tasks: Microsoft Research Paraphrase Corpus (MRPC) for identifying semantic textual similarity (Dolan & Brockett, 2005); Multi-Genre Natural Language Inference (MNLI) for entailment classification (Williams et al., 2018); Corpus of Linguistic Acceptability (CoLA) for predicting whether an English sentence is linguistically acceptable (Warstadt et al., 2019); and Stanford Question Answering Dataset (SQuAD) v1.1 (Rajpurkar et al., 2016). Table 1 reports the after-fine-tuning performance on the four tasks. Since fine-tuning performance is unstable on small datasets like MRPC, we fine-tuned on each task several times and report the best Dev-set performance. It shows that the model pre-trained by AutoLRS outperforms + +Table 1: Fine-tuning $\mathrm{{BERT}}{}_{\mathrm{{BASE}}}$ that is pre-trained using different LR schedules on 4 downstream tasks. We report the accuracy on the Dev set of MRPC, MNLI, and CoLA, and F1 scores on the Dev set of SQuAD v1.1. + +
LR schedule (Phase 1/Phase 2)MRPCMNLICoLASQuAD v1.1
Original (225,000/25,000)86.582.247.887.0
CLR (225,000/25,000)86.080.744.486.5
SGDR (225,000/25,000)84.881.638.786.2
AutoLRS (150,000/16,000)88.082.547.687.1
+ +Table 2: Performance comparison with LR schedules searched by prior solutions on CIFAR-10 training with VGG-16 (batch size = 128). Note that the hand-tuned LR schedule can achieve 93.70% top-1 test accuracy in 350 epochs. The Runtime column shows how long each method takes on one NVIDIA Titan RTX GPU to find the LR schedule shown in the previous column. The runtime of HD and MARTHE include trying the guideline values of their hyperparameters to get a decent LR schedule. + +
MethodBest top-1 accuracy achieved in 350 epochsRuntime (seconds)
HD91.31%187,110
MARTHE92.99%67,578
Hyperband93.24%109,454
AutoLRS94.13%6,538
+ +those using other LR schedules in most downstream tasks and meanwhile achieves a speedup of $1.5 \times$ . Note AutoLRS consistently achieves this speedup over 3 trials (details in §A.5.5). We also tried pre-training using other LR schedules for fewer steps but the fine-tuning performances were worse. Notably, when we use CLR and SGDR for pre-training $\mathrm{BERT}_{\mathrm{BASE}}$ , the training loss diverged after 100,000 steps in several trials, even as we decreased the maximal LR and increased the number of steps per cycle. This illustrates how difficult and computationally intensive it is to hand-tune the hyperparameters of existing LR schedules on complicated models and tasks. In contrast, AutoLRS significantly simplifies the process and saves human effort. + +Experimental comparison to prior methods: Hypergradient descent (HD) (Baydin et al., 2018) is a hypergradient based method to adjust the learning rate in an online fashion by deriving the derivative of the training loss with respect to the learning rate, and performing gradient descent on the learning rate during training. MARTHE (Donini et al., 2020) is a generalization of two hypergradient based methods, HD and RTHO (Franceschi et al., 2017). One distinction between MARTHE and HD is that MARTHE computes the gradient of the validation loss instead of training loss with respect to the learning rate. Hyperband is a multi-armed bandit approach for DNN hyperparameter optimization. We use HD, MARTHE, and Hyperband to tune the LR schedules for CIFAR-10 training with VGG-16, and compare their performance with AutoLRS in Table 2. AutoLRS achieves higher best top-1 test accuracy than the other methods as well as the hand-tuned LR schedule, with much less overhead. Detailed descriptions of these methods and the experimental results are in §A.5.1 and §A.5.3. + +# 6 CONCLUSION + +We propose an automatic learning-rate schedule method, AutoLRS, as a more efficient and versatile alternative to hand-tuning that can be broadly applied to train different DNNs for tasks in diverse application domains. We break down the sequence optimization to learning rate search for minimizing validation loss in each training stage and then solve this sub-problem by Bayesian optimization (BO). To reduce the cost of BO exploration, we train a light-weight loss-forecasting model from the early-stage training dynamics of BO exploration. AutoLRS achieves a speedup of $1.22 \times 1.43 \times 1.5 \times$ on training ResNet-50, Transformer, and BERT compared to their highly hand-tuned schedules. + +# ACKNOWLEDGMENTS + +We would like to thank the anonymous ICLR reviewers for their valuable feedback. We would also like to thank Damien Fay for his suggestions on time series analysis. This work was partially supported by DARPA. For computer time, this research used the resources at ByteDance and the Supercomputing Laboratory at KAUST. + +# REFERENCES + +Zeyuan Allen-Zhu, Yuanzhi Li, and Yingyu Liang. Learning and generalization in overparameterized neural networks, going beyond two layers. In Advances in neural information processing systems, pp. 6158-6169, 2019a. +Zeyuan Allen-Zhu, Yanzhi Li, and Zhao Song. A convergence theory for deep learning via overparameterization. In Proceedings of the 36th International Conference on Machine Learning, volume 97, pp. 242-252, 2019b. +Luís B Almeida, Thibault Langlois, José D Amaral, and Alexander Plakhov. Parameter adaptation in stochastic optimization. On-Line Learning in Neural Networks, Publications of the Newton Institute, pp. 111-134, 1998. +Peter Auer. Using confidence bounds for exploitation-exploration trade-offs. Journal of Machine Learning Research, 3(Nov):397-422, 2002. +Attilim Güneş Baydin, Robert Cornish, David Martínez Rubio, Mark Schmidt, and Frank Wood. Online learning rate adaptation with hypergradient descent. In International Conference on Learning Representations, 2018. +James Bergstra, Dan Yamins, and David D Cox. Hyperopt: A python library for optimizing the hyperparameters of machine learning algorithms. In Proceedings of the 12th Python in science conference, pp. 13-20. CiteSeer, 2013. +Dennis D Cox and Susan John. A statistical method for global optimization. In Proceedings of the 1992 IEEE International Conference on Systems, Man, and Cybernetics, pp. 1241-1246. IEEE, 1992. +Zhongxiang Dai, Haibin Yu, Bryan Kian Hsiang Low, and Patrick Jaillet. Bayesian optimization meets Bayesian optimal stopping. In International Conference on Machine Learning, pp. 1496-1506, 2019. +Jacob Devlin, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova. BERT: Pre-training of deep bidirectional transformers for language understanding. In Proceedings of the 2019 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, Volume 1 (Long and Short Papers), pp. 4171-4186, Minneapolis, Minnesota, June 2019. Association for Computational Linguistics. +William B Dolan and Chris Brockett. Automatically constructing a corpus of sentential paraphrases. In Proceedings of the Third International Workshop on Paraphrasing (IWP2005), 2005. +Tobias Domhan, Jost Tobias Springenberg, and Frank Hutter. Speeding up automatic hyperparameter optimization of deep neural networks by extrapolation of learning curves. In *IJCAI*, pp. 3460-3468, 2015. +Michele Donini, Luca Franceschi, Orchid Majumder, Massimiliano Pontil, and Paolo Frasconi. MARTHE: Scheduling the learning rate via online hypergradients. In *IJCAI-20*, pp. 2119–2125, 2020. +John Duchi, Elad Hazan, and Yoram Singer. Adaptive subgradient methods for online learning and stochastic optimization. Journal of Machine Learning Research, 12(61):2121-2159, 2011. +Stefan Falkner, Aaron Klein, and Frank Hutter. BOHB: Robust and efficient hyperparameter optimization at scale. arXiv preprint arXiv:1807.01774, 2018. +Luca Franceschi, Michele Donini, Paolo Frasconi, and Massimiliano Pontil. Forward and reverse gradient-based hyperparameter optimization. In Proceedings of the 34th International Conference on Machine Learning, volume 70 of Proceedings of Machine Learning Research, pp. 1165-1173. PMLR, 2017. +Marc G Genton. Classes of kernels for machine learning: a statistics perspective. Journal of machine learning research, 2(Dec):299-312, 2001. +Ian Goodfellow, Yoshua Bengio, and Aaron Courville. Deep Learning. MIT press, 2016. + +Deepak Akhilesh Gotmare, Shirish Nitish Keskar, Caiming Xiong, and Richard Socher. A closer look at deep learning heuristics: Learning rate restarts, warmup and distillation. international conference on learning representations, 2019. +Priya Goyal, Piotr Dólar, Ross Girshick, Pieter Noordhuis, Lukasz Wesolowski, Aapo Kyrola, Andrew Tulloch, Yangqing Jia, and Kaiming He. Accurate, large minibatch SGD: Training ImageNet in 1 hour. arXiv preprint arXiv:1706.02677, 2017. +Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Deep residual learning for image recognition. In The IEEE Conference on Computer Vision and Pattern Recognition (CVPR), June 2016a. +Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Identity mappings in deep residual networks. In European conference on computer vision, pp. 630-645. Springer, 2016b. +Frank Hutter, Holger H Hoos, and Kevin Leyton-Brown. Sequential model-based optimization for general algorithm configuration. In International conference on learning and intelligent optimization, pp. 507-523. Springer, 2011. +Max Jaderberg, Valentin Dalibard, Simon Osindero, Wojciech M Czarnecki, Jeff Donahue, Ali Razavi, Oriol Vinyals, Tim Green, Iain Dunning, Karen Simonyan, et al. Population based training of neural networks. arXiv preprint arXiv:1711.09846, 2017. +Kevin Jamieson and Ameet Talwalkar. Non-stochastic best arm identification and hyperparameter optimization. In Artificial Intelligence and Statistics, pp. 240-248, 2016. +Stanisław Jastrzejbski, Zachary Kenton, Devansh Arpit, Nicolas Ballas, Asja Fischer, Yoshua Bengio, and Amos Storkey. Three factors influencing minima in SGD. arXiv preprint arXiv:1711.04623, 2017. +Chi Jin, Rong Ge, Praneeth Netrapalli, Sham M Kakade, and Michael I Jordan. How to escape saddle points efficiently. In Proceedings of the 34th International Conference on Machine Learning-Volume 70, pp. 1724-1732. JMLR.org, 2017. +Kenji Kawaguchi. Deep learning without poor local minima. In Advances in neural information processing systems, pp. 586-594, 2016. +Diederick P Kingma and Jimmy Ba. Adam: A method for stochastic optimization. In International Conference on Learning Representations, 2015. +A. Klein, Stefan Falkner, Jost Tobias Springenberg, and F. Hutter. Learning curve prediction with Bayesian neural networks. In International Conference on Learning Representations, 2017. +A. Krizhevsky and G. Hinton. Learning multiple layers of features from tiny images. Master's thesis, Department of Computer Science, University of Toronto, 2009. +Alex Krizhevsky. One weird trick for parallelizing convolutional neural networks. arXiv preprint arXiv:1404.5997, 2014. +Alex Krizhevsky, Vinod Nair, and Geoffrey Hinton. CIFAR-100 (Canadian Institute for Advanced Research). URL http://www.cs.toronto.edu/~kriz/cifar.html. +Hao Li, Zheng Xu, Gavin Taylor, Christoph Studer, and Tom Goldstein. Visualizing the loss landscape of neural nets. In Advances in Neural Information Processing Systems, pp. 6389-6399, 2018a. +Liam Li, KG Jamieson, Afshin Rostamizadeh, Ekaterina Gonina, MH Jonathan Ben-Tzur, B Recht, and A Talwalkar. A system for massively parallel hyperparameter tuning. In Conference on Machine Learning and Systems, 2020a, volume 1, 2018b. +Lisha Li, Kevin Jamieson, Giulia DeSalvo, Afshin Rostamizadeh, and Ameet Talwalkar. Hyperband: A novel bandit-based approach to hyperparameter optimization. The Journal of Machine Learning Research, 18(1):6765-6816, 2017. +Ilya Loshchilov and Frank Hutter. SGDR: stochastic gradient descent with warm restarts. In International Conference on Learning Representations, 2017. + +Maren Mahsereci and Philipp Hennig. Probabilistic line searches for stochastic optimization. In Advances in Neural Information Processing Systems, volume 28, 2015. +Paulius Micikevicius, Sharan Narang, Jonah Alben, Gregory Diamos, Erich Elsen, David Garcia, Boris Ginsburg, Michael Houston, Oleksii Kuchaiev, Ganesh Venkatesh, and Hao Wu. Mixed precision training. In International Conference on Learning Representations, 2018. +Kamil Nar and Shankar Sastry. Step size matters in deep learning. In Advances in Neural Information Processing Systems, pp. 3436-3444, 2018. +Jack Parker-Holder, Vu Nguyen, and Stephen Roberts. Provably efficient online hyperparameter optimization with population-based bandits. Advances in Neural Information Processing Systems, 2020. +Pranav Rajpurkar, Jian Zhang, Konstantin Lopyrev, and Percy Liang. SQuAD: 100,000+ questions for machine comprehension of text. In Proceedings of the 2016 Conference on Empirical Methods in Natural Language Processing, pp. 2383-2392, Austin, Texas, November 2016. Association for Computational Linguistics. +CE. Rasmussen and CKI. Williams. Gaussian Processes for Machine Learning. Adaptive Computation and Machine Learning. MIT Press, Cambridge, MA, USA, January 2006. +Olga Russakovsky, Jia Deng, Hao Su, Jonathan Krause, Sanjeev Satheesh, Sean Ma, Zhiheng Huang, Andrej Karpathy, Aditya Khosla, Michael Bernstein, Alexander C. Berg, and Li Fei-Fei. ImageNet Large Scale Visual Recognition Challenge. International Journal of Computer Vision (IJCV), 115 (3):211-252, 2015. +Tom Schaul, Sixin Zhang, and Yann LeCun. No more pesky learning rates. In International Conference on Machine Learning, pp. 343-351, 2013. +Bobak Shahriari, Kevin Swersky, Ziyu Wang, Ryan P. Adams, and Nando De Freitas. Taking the human out of the loop: A review of Bayesian optimization. Proceedings of the IEEE, 104(1): 148-175, January 2016. ISSN 0018-9219. +Karen Simonyan and Andrew Zisserman. Very deep convolutional networks for large-scale image recognition. In International Conference on Learning Representations, 2015. +Leslie N Smith. Cyclical learning rates for training neural networks. In 2017 IEEE Winter Conference on Applications of Computer Vision (WACV), pp. 464-472. IEEE, 2017. +Leslie N Smith. A disciplined approach to neural network hyper-parameters: Part 1-learning rate, batch size, momentum, and weight decay. arXiv preprint arXiv:1803.09820, 2018. +Jasper Snoek, Hugo Larochelle, and Ryan P Adams. Practical bayesian optimization of machine learning algorithms. In Advances in neural information processing systems, pp. 2951-2959, 2012. +Kevin Swersky, Jasper Snoek, and Ryan Prescott Adams. Freeze-thaw bayesian optimization. arXiv preprint arXiv:1406.3896, 2014. +T. Tieleman and G. Hinton. Lecture 6.5—RmsProp: Divide the gradient by a running average of its recent magnitude. COURSERA: Neural Networks for Machine Learning, 2012. +Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N Gomez, Lukasz Kaiser, and Illia Polosukhin. Attention is all you need. In Advances in neural information processing systems, pp. 5998-6008, 2017. +Alex Warstadt, Amanpreet Singh, and Samuel R Bowman. Neural network acceptability judgments. Transactions of the Association for Computational Linguistics, 7:625-641, 2019. +Yeming Wen, Paul Vicol, Jimmy Ba, Dustin Tran, and Roger Grosse. Flipout: Efficient pseudo-independent weight perturbations on mini-batches. In International Conference on Learning Representations, 2018. + +Adina Williams, Nikita Nangia, and Samuel Bowman. A broad-coverage challenge corpus for sentence understanding through inference. In Proceedings of the 2018 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, Volume 1 (Long Papers), pp. 1112–1122, New Orleans, Louisiana, June 2018. Association for Computational Linguistics. +Yuhuai Wu, Mengye Ren, Renjie Liao, and Roger Grosse. Understanding short-horizon bias in stochastic meta-optimization. In International Conference on Learning Representations, 2018. +Matthew D Zeiler. Adadelta: an adaptive learning rate method. arXiv preprint arXiv:1212.5701, 2012. +Arber Zela, Aaron Klein, Stefan Falkner, and Frank Hutter. Towards automated deep learning: Efficient joint neural architecture and hyperparameter search. In ICML 2018 AutoML Workshop, July 2018. +Yukun Zhu, Ryan Kiros, Rich Zemel, Ruslan Salakhutdinov, Raquel Urtasun, Antonio Torralba, and Sanja Fidler. Aligning books and movies: Towards story-like visual explanations by watching movies and reading books. In Proceedings of the 2015 IEEE International Conference on Computer Vision (ICCV), ICCV '15, pp. 19-27, USA, 2015a. IEEE Computer Society. ISBN 9781467383912. +Yukun Zhu, Ryan Kiros, Richard Zemel, Ruslan Salakhutdinov, Raquel Urtasun, Antonio Torralba, and Sanja Fidler. BookCorpus website. https://yknzhu.wixsite.com/web, 2015b. + +# A APPENDIX + +# A.1 BAYESIAN OPTIMIZATION (MORE DETAILS) + +BO (Shahriari et al., 2016) is one of the state-of-the-art techniques for black-box optimization. It applies exploration and exploitation to the black-box objective by sequentially and actively querying the function values of some input instances. Specifically, BO uses Gaussian process as a surrogate model to fit the black-box objective function $f(\eta)$ . It updates a posterior distribution of $f(\eta)$ by using its likelihood on newly evaluated $(\eta, y = f(\eta) + \epsilon)$ pairs, where $y$ is a noisy observation of $f(\eta)$ and is the validation loss after $\tau$ steps in our case. Then, it determines the next LR $\eta$ to evaluate as the one maximizing an acquisition function, which is computed from the updated posterior. The acquisition function performs a trade-off between exploration and exploitation in evaluating the candidates of LR. BO repeats the above process until achieving a precise posterior predictive distribution of $f(\eta)$ . + +Surrogate model (prior): We apply a commonly used surrogate model — Gaussian process (GP) (Rasmussen & Williams, 2006) as the prior of the black-box objective function in Eq. (2). A GP prior is specified by its mean function $\mu(\cdot)$ and its covariance function (i.e., kernel function) $K(\cdot, \cdot)$ . We adopt a common choice $\mu(\cdot) = 0$ and set $K(\cdot, \cdot)$ to be the Matern kernel (Genton, 2001) with smoothness factor $\nu = 2.5$ and length scale $l = 1$ , which is defined as + +$$ +K \left(\eta_ {i}, \eta_ {j}\right) = \frac {1}{\Gamma (\nu) 2 ^ {\nu - 1}} \left(\frac {\sqrt {2 \nu} \| \eta_ {i} - \eta_ {j} \| _ {2}}{l}\right) ^ {\nu} K _ {\nu} \left(\frac {\sqrt {2 \nu} \| \eta_ {i} - \eta_ {j} \| _ {2}}{l}\right), \tag {4} +$$ + +where $K_{\nu}(\cdot)$ is a modified Bessel function and $\Gamma (\cdot)$ is the gamma function, and $K(\eta_i,\eta_j)$ performs a convolution of the unit ball. Comparing to the radial basis function (RBF) kernel which always generates infinitely differentiable functions that might be overly smooth, GP with Matern kernel can control the smoothness of generated functions to be $\lceil \nu \rceil -1$ times differentiable (Rasmussen & Williams, 2006). This helps to capture the less-smooth local changes. In our case, $\nu = 2.5$ leads to twice-differentiable functions. + +Posterior prediction: In the following, we will use simplified notations $\eta_{1:k}^{\prime}$ and $f(\eta_{1:k}^{\prime})$ for vectors composed of $\{\eta_i'\}_{i=1}^k$ and $\{f(\eta_i')\}_{i=1}^k$ , respectively. The GP prior indicates a Gaussian distribution over function values, i.e., $f(\eta_{1:k}') \sim \mathcal{N}(\mathbf{0}, \mathbf{K})$ where $\mathbf{K}_{i,j} = K(\eta_i', \eta_j')$ , $\forall i, j \in [k]$ . After $\tau$ training steps using LR $\eta_i'$ , we evaluate the validation loss denoted by $y_i$ as a noisy observation of $f(\eta_i')$ . i.e., $y_i = f(\eta_i') + \epsilon$ where Gaussian white noise $\epsilon \sim \mathcal{N}(0, \sigma^2)$ . Given the noisy observations $y_{1:k}$ , we can update the GP posterior of the black-box function $f(\cdot)$ as + +$$ +f \left(\eta_ {1: k} ^ {\prime}\right) \mid \eta_ {1: k} ^ {\prime}, y _ {1: k} \sim \mathcal {N} \left(y _ {1: k}, \mathbf {K} + \sigma^ {2} \mathbf {I}\right). \tag {5} +$$ + +Given a new LR $\eta$ , we can now use the above GP posterior to predict the distribution of $f(\eta)$ by the following reasoning based on Bayes' theorem, i.e., + +$$ +P (f (\eta) \mid \eta_ {1: k} ^ {\prime}, y _ {1: k}) = \int P (f (\eta) \mid f \left(\eta_ {1: k} ^ {\prime}\right)) P (f \left(\eta_ {1: k} ^ {\prime}\right) \mid \eta_ {1: k} ^ {\prime}, y _ {1: k}) d f \left(\eta_ {1: k} ^ {\prime}\right), \tag {6} +$$ + +which yields the posterior predictive distribution of $f(\eta)$ as + +$$ +f (\eta) | \eta_ {1: k} ^ {\prime}, y _ {1: k} \sim \mathcal {N} \left(\mu_ {n} (\eta), \sigma_ {n} ^ {2} (\eta)\right), +$$ + +$$ +\mu_ {n} (\eta) \triangleq \mathbf {k} (\mathbf {K} + \sigma^ {2} \mathbf {I}) ^ {- 1} y _ {1: k}, \tag {7} +$$ + +$$ +\sigma_ {n} ^ {2} (\eta) \triangleq K (\eta , \eta) - \mathbf {k} ^ {T} (\mathbf {K} + \sigma^ {2} \mathbf {I}) ^ {- 1} \mathbf {k}. +$$ + +where $\mathbf{k}_i = K(\eta, \eta_i')$ . The above result about single LR $\eta$ can be trivially extended to multiple LRs. + +Acquisition function: Given the posterior predictive distribution of $f(\eta)$ in Eq (7), BO finds the next $\eta_{i+1}'$ to evaluate based on an acquisition function $u_i(\eta)$ defined by the posterior mean $\mu_i(\eta)$ and standard deviation $\sigma_i(\eta)$ . A promising acquisition function should balance the trade-off between exploration (i.e., large $\sigma_i(\eta)$ ) and exploitation (i.e., small $\mu_i(\eta)$ ). In AutoLRS, we use Lower Confidence Bound (LCB) (Cox & John, 1992; Auer, 2002) as our acquisition function. In particular, given $\eta_{1:k}'$ and their corresponding validation loss $y_{1:k}$ , we determine the next LR $\eta_{i+1}'$ by minimizing LCB, i.e., + +$$ +\eta_ {i + 1} ^ {\prime} = \underset {\eta} {\arg \min } u _ {i} (\eta), u _ {i} (\eta) \triangleq \mu_ {i} (\eta) - \kappa \sigma_ {i} (\eta), \tag {8} +$$ + +where $\mu_{i}(\eta)$ and $\sigma_{i}(\eta)$ were defined in Eq. (7), $\kappa$ is a positive hyper-parameter to balance the trade-off between exploration and exploitation. In experiments, we set $\kappa = 1000$ and it works consistently well. + +![](images/98dc143c9206801a2b6603680cad3a8f3ae383713bbf77bc62d4f60776881aed.jpg) +(a) Training loss during 100 training steps and fitting it by an exponential time-series forecasting model. + +![](images/1e55b415c1b03c7c782a9311d136390ca40c7d858b3051c4ef798b8e0a2408e1.jpg) +(b) Validation loss during 800 training steps and fitting it by an exponential time-series forecasting model. + +![](images/d5bffea81711484a8b1fe06beefb92fe4a2324a21c7decc3dd4c34770ddf03b8.jpg) +(c) A corner case when exponential model cannot fully capture the non-monotone change of the loss during the first 50 steps. +Figure 3: Fitting the time-series of loss by exponential model when training ResNet-50 on ImageNet. + +# A.2 EXPONENTIAL MODEL (MORE DETAILS) + +We take two steps to estimate $a, b$ , and $c$ in fitting the exponential model $L(t) = a\exp (bt) + c$ , based on the validation loss observed in the first $\tau^{\prime}$ steps, which is represented by $y_{t}, t = 1,\dots ,\tau^{\prime}$ . First, we reduce the fitting problem to an optimization problem. Define function $g(b)$ as the least squared error between predictions and observations w.r.t. $a$ and $c$ . We can write the original fitting problem in the following two-stage form. + +$$ +\min _ {b < 0} g (b), \quad g (b) \triangleq \min _ {a, c} \sum_ {t = 1} ^ {\tau^ {\prime}} \left(a \exp (b t) + c - y _ {t}\right) ^ {2} \tag {9} +$$ + +It is a 1-dimensional optimization problem. Moreover, with $b$ fixed, the minimization problem w.r.t. $a, c$ is a linear regression problem that has a closed-form solution. Hence, we apply a simple gradient descent method that starts from an initial $b$ , computes the linear least squares w.r.t. $a, c$ under $b$ , search for the next $b$ by the gradient descent method, and repeats these two steps. Thereby, in practice we can achieve a fast decrease on the regression error. In addition, to enforce the negative constraint for $b$ , we re-parameterize it to be $b \gets -\exp(b')$ . The problem now reduces to + +$$ +\min _ {b ^ {\prime}} \min _ {a, c} \sum_ {t = 1} ^ {\tau^ {\prime}} \left(a \exp \left(- \exp \left(b ^ {\prime}\right) t\right) + c - y _ {t}\right) ^ {2} \tag {10} +$$ + +Although there might exist other possible strategies to optimize Eq. (9), we find the above method is stable and fast in reducing the regression error and thus keeps the fitting process highly efficient. + +We empirically test whether the exponential model obtained by our method can ideally fit the loss time-series in different cases. Figure 3a and Figure 3b are two typical examples fitting the time series of training loss and validation loss by the proposed model. They show that the model can precisely predict the main trends of the time-varying loss, though ruling out some less informative noises. + +In Figure 3c, we also show a rare corner case when the model fails to fit the increasing loss in early steps. However, the loss-increasing stage usually does not last long and thus the inaccuracy is not so harmful to the prediction of later-stage loss, which is our major goal since $\tau$ is usually larger than the length of loss-increasing stage. To overcome such corner cases and outliers in the observed validation loss series, we present a pre-processing strategy to make stable exponential fitting in §A.3. Every time we predict the validation loss after $\tau$ steps, we first pre-process the loss observed in the $\tau'$ steps, and then fit the pre-processed loss series with the exponential model. + +In our empirical study, we also tried other more sophisticated time-series forecasting models including Holt-Winters, autoregressive integrated moving average (ARIMA) and singular spectrum analysis (SSA). We show two examples to compare their performance with our simple exponential prediction model in Figure 4. Some prior works also fit and predict learning curves (Swersky et al., 2014; Domhan et al., 2015; Klein et al., 2017; Dai et al., 2019) for early termination of evaluations of poorly-performing hyperparameters when doing DNN hyperparameter optimization, but they need non-negligible time for training their models and performing inference. They are much more computationally intensive than our lightweight exponential prediction model, and this makes them less practical to be used in automatic LR schedule tuning. + +![](images/5d2e946573a538d4ee5c22296eb3e39e792ec51a9aa3d3048f9d61b8300333dd.jpg) +(a) Predict the training loss after 2000 steps. + +![](images/ebb2bbdf1c90a1d0684b54343a7becb556e525f25750cd230b119dd9feff593c.jpg) +(b) Predict the training loss after 4000 steps. + +![](images/8a1b46e833f6f10f61bccd2abbd77ef7c5e610ca6151e31efb1530fde1f59f28.jpg) +Figure 4: Examples of forecasting the loss series by various time-series forecasting models when training ResNet-50 on ImageNet. Our simple exponential prediction model yields the least mean squared error (MSE) among all the models. + +![](images/9314267c048d10516bd05678aa27f6265223718ec54b782d01a242e580047ce1.jpg) +Figure 5: The loss sequence in Figure 3c and its quadratic spline smoothing result after 1, 5, and 10 iterations of our spline smoothing. + +![](images/570df1adb88b8ec70e2ba15f309496355ce498233f8d4aa4338fb41380005a1f.jpg) + +# A.3 PRE-PROCESS LOSS SERIES BY ITERATIVE SPLINE SMOOTHING + +We show a corner case in Figure 3c where the loss decreases rapidly at first, then increases for a while, but finally decreases stably. It might be a result of a large LR or happens when escaping from a possibly poor local minimum or a saddle point (Goodfellow et al., 2016). Our exponential model cannot fully capture the loss change in early steps of this case. But we also consistently observe in our experiments that the early instability of loss only lasts for at most hundreds of steps after we switch to a new LR. + +Nevertheless, we find that adding a pre-processing step to eliminate the noises, anomalies, and corner cases in the observed validation loss series makes the exponential fitting easier and more stable. Hence, we propose to apply an iterative spline smoothing to the validation loss observed in $\tau'$ steps before training the forecasting model. In particular, when evaluating a LR $\eta$ for a training stage, we firstly run $\tau'$ training steps and fit the observed sequence of validation loss by a quadratic spline. We do such spline smoothing for multiple iterations. At the end of each iteration, we remove the loss values that are among the farthest $3\%$ from the spline smoothing results if they are collected in the first $\tau'/2$ steps (when the corner cases like the one in Figure 3c might happen). So the next iteration's spline smoothing only aims to fit the rest loss values. After certain number of iterations, we use the final spline smoothing values to train the exponential forecasting model. + +Empirically, we find that 10 iterations of the above spline smoothing are necessary before training the exponential forecasting model. Figure 5 shows the loss sequence from Figure 3c before smoothing and after 1, 5 and 10 iterations of smoothing. As shown in the plots, the iterative spline smoothing can effectively remove the unnecessary noise and unstable changes during the early phase. + +# A.4 POSTERIOR LEARNED BY BO + +Figure 6 shows how the BO posterior gradually learns an increasingly more accurate estimation of the underlying black-box objective. We also visualize the "learning progress" of BO in an earlier stage and a later stage during training. It shows that in both early and late stages, by exploring more LRs, BO can achieve a more accurate posterior estimation of the objective function, and $k = 10$ suffices to obtain a satisfying estimate. Moreover, the posteriors in the later stages have much smaller variance/uncertainty than in the earlier stages. + +![](images/005b1a7648ebad24261976aaa9de765c25bb16d65f7ca3a6d902d542f176533d.jpg) +Figure 6: BO's posterior of the black-box objective function after exploring $i$ LRs (red dots $\bullet$ ) determined by Eq. (3) at an early stage and a late stage during the training of ResNet-50 on ImageNet. The dashed lines show the mean function $\mu_i(\eta)$ (indicating the predicted validation loss of applying LR $\eta$ for $\tau$ steps) and the shaded areas show the standard deviation $\sigma_i(\eta)$ (indicating the prediction uncertainty) in the form of $\mu_i(\eta) \pm \sigma_i(\eta)$ . + +# A.5 EXPERIMENTS (MORE DETAILS) + +# A.5.1 ANALYSIS OF ONLINE LEARNING RATE ADAPTATION WITH HYPERGRADIENT-BASED METHODS + +Hypergradient descent (HD) (Baydin et al., 2018) is a method to adjust the learning rate in an online fashion by performing gradient descent on the learning rate at the same time as the underlying DNN is optimized. For simplicity, we rewrite Eq. (1), which performs mini-batch SGD updates on model weights $\theta$ at each step $t$ , as: + +$$ +\theta_ {t + 1} = \theta_ {t} - \eta_ {t} \nabla L (\theta_ {t}), \tag {11} +$$ + +where $\eta_{t}$ is the learning rate (LR) at step $t$ and $\nabla L(\theta_t)$ denotes the gradient of the loss function $L$ w.r.t. the model weights $\theta_{t}$ at step $t$ . By making the assumption that the optimal value of LR does not change much between two consecutive iterations, HD derives the partial derivative of the loss function $L$ with respect to the learning rate $\eta$ : + +$$ +\frac {\partial L \left(\theta_ {t}\right)}{\partial \eta} = \nabla L \left(\theta_ {t}\right) \frac {\partial \left(\theta_ {t - 1} - \eta \nabla L \left(\theta_ {t - 1}\right)\right)}{\partial \eta} = \nabla L \left(\theta_ {t}\right) (- \nabla L \left(\theta_ {t - 1}\right)) \tag {12} +$$ + +An update rule for the learning rate is constructed as: + +$$ +\eta_ {t + 1} = \eta_ {t} - \beta \frac {\partial L \left(\theta_ {t}\right)}{\eta} = \eta_ {t} + \beta \nabla L \left(\theta_ {t}\right) \nabla L \left(\theta_ {t - 1}\right), \tag {13} +$$ + +which introduces a hyperparameter $\beta$ as the hypergradient learning rate. Updating the learning rate is a single vector multiplication between the gradient of the model weights at the previous step and the one at the current step. By updating both the learning rate $\eta_t$ and the model weights $\theta_t$ using Eq.(13) and Eq.(11) in each step, the HD algorithm performs gradient descent on both learning rate and the model weights during training. + +HD can be applied to optimizers including SGD, SGD with Nesterov momentum, and Adam. The original paper empirically shows that these optimizers equipped with HD are much less sensitive to the choice of the initial regular learning rate and the convergence rate is improved on a set of tasks. However, the paper only compares HD with constant LR baselines on small models and small datasets. To study how HD compares to hand-tuned LR schedules on larger models and datasets, we train VGG-16 (Simonyan & Zisserman, 2015) and ResNet-50 neural networks on the CIFAR-10 image recognition dataset (Krizhevsky & Hinton, 2009) with a mini-batch size of 128 using a PyTorch implementation. A hand-tuned LR schedule consists of a total of 350 epochs, starting with 0.1 and multiplying the learning rate by 0.1 at epoch 150 and 250. This hand-tuned LR schedule can achieve around $93.70\%$ and $95.56\%$ top-1 accuracy on the test set for VGG-16 and ResNet-50, respectively when we train the models on one NVIDIA Titan RTX GPU. We apply SGD with HD (SGD-HD) to train the two models, sweep all the guideline values of the two hyperparameters (regular LR and + +hypergradient LR) in SGD-HD, and report the best top-1 accuracy that SGD-HD can achieve for VGG-16 and ResNet-50 within 500 epochs in Table 4 and Table 5. We have three observations: (1) Hypergradient descent is very sensitive to the selection of the regular LR and the hypergradient LR. The top-1 accuracy ranges from $10.00\%$ to $91.80\%$ for VGG-16 and ranges from $10.00\%$ to $92.52\%$ for ResNet-50, with all suggested values of the two hyperparameters. (2) It cannot match the top-1 accuracy achieved with hand-tuned LR schedules: the best top-1 accuracy it can achieve among all the different hyperparameter settings are $1.90\%$ and $3.04\%$ behind the accuracy achieved with hand-tuned LR schedules for VGG-16 and ResNet-50, even though we ran each of them 150 epochs more than the hand-tuned LR schedule. (3) It is prone to overfitting. For example, when using regular $\mathrm{LR} = 10^{-3}$ and hypergradient $\mathrm{LR} = 10^{-5}$ to train VGG-16, the top-1 accuracy is only $90.74\%$ while the training accuracy is already $99.98\%$ . + +MARTHE (Donini et al., 2020) adaptively interpolates between two hypergradient based methods, HD and RTHO (Franceschi et al., 2017), and it computes the gradient of the loss function on the validation set instead of training set w.r.t. the learning rate. Besides the two hyperparameters in HD, MARTHE introduces another hyperparameter $\mu$ that controls how quickly past history is forgotten. We sample $\mu$ between 0.9 and 0.999, sample the hypergradient LR in $[10^{-3}, 10^{-6}]$ log-uniformly, and set the initial LR to 0.1, as how the MARTHE paper sets its hyperparameters for training VGG-11 on CIFAR-10. We apply SGD with MARTHE $^{10}$ to train VGG-16 on CIFAR-10. The best top-1 accuracy MARTHE can achieve among all the hyperparameter settings in 350 epochs is $92.99\%$ , which is $0.71\%$ lower than the accuracy achieved with the hand-tuned LR schedule. + +# A.5.2 SENSITIVITY TEST OF $\tau_{\mathrm{max}}$ IN AutoLRS AND MEASURE OF VARIABILITY + +Recall from §4.4 that AutoLRS starts with $\tau = 1000$ and $\tau' = 100$ , and doubles them after every stage until it reaches $\tau_{\mathrm{max}}$ . We test the sensitivity of AutoLRS to this hyperparameter, $\tau_{\mathrm{max}}$ , by comparing the generated LR schedules with different $\tau_{\mathrm{max}}$ values for the VGG-16 neural network on CIFAR-10 as in §A.5.1. The LR search interval $(\eta_{\mathrm{min}}, \eta_{\mathrm{max}})$ we use is $(10^{-3}, 10^{-1})$ . We report the training epochs to reach the target $93.70\%$ top-1 accuracy using the LR schedules generated among 5 trials for different $\tau_{\mathrm{max}}$ values in Table 6. AutoLRS with different $\tau_{\mathrm{max}}$ values can consistently achieve the target top-1 accuracy achieved with the hand-tuned LR schedule (i.e., $93.70\%$ ) in fewer training steps. We also see that the best AutoLRS-generated LR schedule can achieve $94.13\%$ top-1 accuracy within 350 training epochs (excluding the costs of the LR search). + +In the last column of Table 6, we report the mean and standard deviation of the top-1 accuracy achieved by AutoLRS over 5 trials for each $\tau_{\mathrm{max}}$ . To further measure the variability of AutoLRS, we train VGG-16 on CIFAR-100 (Krizhevsky et al.) with a mini-batch size of 128. A carefully hand-tuned LR schedule consists of a total of 200 epochs, starting with 0.1 and dividing the learning rate by 5 at epoch 60, 120, and 160. This hand-tuned LR schedule can achieve $72.93\%$ top-1 accuracy. We train VGG-16 on CIFAR-100 for 200 epochs with AutoLRS for 10 trials using different random seeds, and report the top-1 accuracy they achieve in Table 9. The LR search interval $(\eta_{\mathrm{min}}, \eta_{\mathrm{max}})$ we use is $(10^{-3}, 10^{-1})$ , and $\tau_{\mathrm{max}}$ is set to 8000. The top-1 accuracy achieved by AutoLRS-generated LR schedules over 10 trials are distributed with a mean of $73.05\%$ and a standard deviation of $0.14\%$ . The best AutoLRS-generated LR schedule can achieve $73.30\%$ top-1 accuracy, which is $0.37\%$ higher than the accuracy achieved using the hand-tuned LR schedule. + +# A.5.3 LEARNING RATE SCHEDULE SEARCH WITH HYPERBAND + +Hyperband is a multi-armed bandit approach for DNN hyperparameter optimization. It dynamically allocates resources to randomly sampled configurations and uses successive halving (Jamieson & Talwalkar, 2016) to early stop poorly-performing configurations. We attempt to use Hyperband to optimize the LR schedule on CIFAR-10 training with VGG-16 by searching for an exponential decay LR schedule, which can be parameterized with an initial learning rate and a decay factor. The learning rate is decayed by the decay factor every epoch. Exponential decay is a commonly used LR schedule and is also used in other DNN hyperparameter optimization methods (Falkner et al., 2018). We use the search space of $(10^{-3}, 10^{-1})$ for the initial LR, and the search space of $(0.9, 1)$ for the decay rate. The decay rate is uniformly random sampled, and the initial LR is uniformly random sampled in its log-scale space. We use the default setting of Hyperband that sets the maximum epochs that can be + +allocated to a single configuration to 350 and discards two-thirds of the configurations in each round of successive halving. This results in evaluating 384 configurations with different numbers of epochs with a total of 12600 epochs, which has a computational overhead of $36 \times$ compared to a single run of training with the hand-tuned LR schedule. The best configuration found by Hyperband achieves $93.24\%$ top-1 accuracy, which is $0.46\%$ lower than the accuracy achieved with the hand-tuned LR schedule. + +# A.5.4 ABLATION STUDY + +To illustrate the effects of the exponential model and BO of AutoLRS, we perform ablation studies using the VGG-16 neural network on CIFAR-10 as in §A.5.1. + +Exponential model: What if we remove the exponential forecasting model and simply use the validation loss at $\tau'$ step to update the BO posterior? Will the LR schedules generated by AutoLRS be significantly worse? We apply AutoLRS without the exponential forecasting to find the LR schedules for VGG-16 on CIFAR-10. With $\tau_{\mathrm{max}}$ being chosen from the set of $\{4000, 8000, 16000\}$ , the best top-1 test accuracy that AutoLRS can achieve within 350 training epochs are $91.73\%$ , $92.59\%$ , $92.24\%$ , respectively. Therefore, it is unable to match the target accuracy in reasonable training steps without the exponential forecasting model. The reason for this is that the objective of BO has become to minimize the validation loss at the $\tau'$ step, which will lead to short-horizon issues (Wu et al., 2018). As a consequence, it tends to select a conservative LR, which is often a small LR around $\eta_{\mathrm{min}}$ in the late stages. In contract, with the exponential forecasting model, the goal of the BO is to find the LR that minimizes the predicted validation loss in $\tau$ steps. This allows the LR selected in the current stage to be higher than that in the past stages, and the loss to even increase in a short period of time, as long as the predicted loss in $\tau$ steps is low. This phenomenon can be seen in Figure 1 and Figure 2. + +Bayesian Optimization: What if we replace BO in AutoLRS with random search or grid search? Will the LR schedules generated by AutoLRS get worse? We replace the BO part in AutoLRS with random search and grid search while keeping the exponential forecasting part of it, and apply it to find the LR schedules for VGG-16 on CIFAR-10. The LR search interval is $(10^{-3}, 10^{-1})$ , the same as in §A.5.2. Table 7 and Table 8 show the results of random search and grid search with different $\tau_{\mathrm{max}}$ values, respectively. We observe that both random search and grid search have at least one trial that fails to match the hand-tuned LR schedule to achieve $93.70\%$ top-1 test accuracy within 350 epochs (denoted by N/A in the tables). The top-1 accuracy achieved on average across trials in 350 epochs by random search and grid search is $0.09\%$ and $0.24\%$ behind AutoLRS with BO, respectively. We also replace BO with grid search and apply it to find the LR schedules for VGG-16 on CIFAR-100. The top-1 accuracy achieved over 10 trials are distributed with a mean of $72.63\%$ and a standard deviation of $0.56\%$ . Compared to the AutoLRS-generated LR schedules in Table 9, the mean of the grid search accuracy is out of two standard deviations from the BO accuracy $73.05\% \pm 0.14\%$ . + +# A.5.5 AutoLRS FINE-TUNING RESULTS OF BERTBASE ACROSS 3 TRIALS + +We pre-trained $\mathrm{BERT}_{\mathrm{BASE}}$ with AutoLRS for 3 trials, and report their fine-tuning results in Table 3. + +Table 3: Fine-tuning results of $\mathrm{{BERT}}{}_{\mathrm{{BASE}}}$ models pre-trained with AutoLRS for 3 trials. Accuracy scores on the Dev set are reported for MRPC, MNLI, and CoLA. F1 scores on the Dev set are reported for SQuAD v1.1. + +
MRPCMNLICoLASQuAD v1.1
Trial 188.082.547.687.1
Trial 288.082.746.587.0
Trial 387.882.347.086.6
+ +Table 4: The accuracy information of tuning the regular LR and the hypergradient LR of SGD-HD for CIFAR-10 training with VGG-16 (batch size = 128). We train the model for 500 epochs using SGD-HD with each suggested value for the regular LR and the hypergradient LR, and report the best top-1 test accuracy it can achieve, its corresponding training accuracy, and the epoch number. Note that a hand-tuned LR schedule can achieve $93.70\%$ top-1 test accuracy in 350 epochs. + +
regular LRhypergradient LRTop-1 Test AccuracyTraining AccuracyEpoch
10-610-686.13%99.77%438
10-610-588.79%99.98%480
10-610-486.31%98.10%494
10-610-390.70%99.95%499
10-610-210.30%9.90%40
10-610-110.00%10.00%1
10-510-686.14%99.73%394
10-510-588.49%99.95%448
10-510-487.67%98.78%483
10-510-388.70%99.49%469
10-510-210.22%9.92%170
10-510-110.00%10.00%1
10-410-686.09%99.84%481
10-410-588.82%99.94%304
10-410-486.63%95.37%479
10-410-310.22%10.13%1
10-410-210.02%10.00%1
10-410-110.00%10.00%1
10-310-686.13%99.73%406
10-310-588.78%99.94%346
10-310-490.74%99.98%484
10-310-344.12%43.02%500
10-310-288.48%99.55%467
10-310-110.00%10.00%1
10-210-691.69%99.97%389
10-210-588.53%99.89%397
10-210-489.11%99.92%484
10-210-310.07%9.90%265
10-210-210.00%10.02%1
10-210-110.00%9.99%1
10-110-691.80%99.93%476
10-110-591.48%99.85%317
10-110-488.81%99.57%499
10-110-390.42%99.80%393
10-110-211.24%10.45%1
10-110-110.00%10.02%1
+ +Table 5: The accuracy information of tuning the regular LR and the hypergradient LR of SGD-HD for CIFAR-10 training with ResNet-50 (batch size = 128). We train the model for 500 epochs using SGD-HD with each suggested value for the regular LR and the hypergradient LR, and report the best top-1 test accuracy it can achieve, its corresponding training accuracy, and the epoch number. Note that a hand-tuned LR schedule can achieve $95.56\%$ top-1 test accuracy in 350 epochs. + +
regular LRhypergradient LRTop-1 Test AccuracyTraining AccuracyEpoch
10-610-683.67%99.71%410
10-610-588.75%99.44%490
10-610-483.77%99.68%494
10-610-371.03%72.14%491
10-610-210.11%10.03%261
10-610-110.0%10.0%1
10-510-683.99%99.64%420
10-510-589.15%99.97%460
10-510-410.12%9.95%206
10-510-319.73%18.53%13
10-510-210.03%9.98%137
10-510-110.0%10.0%1
10-410-684.98%99.85%488
10-410-589.27%99.94%482
10-410-484.36%97.78%424
10-410-388.72%99.84%484
10-410-210.00%10.00%1
10-410-110.00%10.00%1
10-310-683.22%99.81%487
10-310-588.56%99.98%492
10-310-486.00%97.32%440
10-310-310.10%9.76%367
10-310-242.80%40.11%497
10-310-110.00%10.00%1
10-210-692.40%99.99%459
10-210-588.51%99.98%440
10-210-490.72%99.91%452
10-210-310.19%9.64%315
10-210-210.05%9.99%8
10-210-110.00%10.00%1
10-110-692.18%99.97%487
10-110-592.52%99.97%494
10-110-487.74%99.86%492
10-110-384.32%97.23%477
10-110-210.00%10.11%1
10-110-110.00%10.00%1
+ +Table 6: Performance of AutoLRS with different $\tau_{\mathrm{max}}$ values for CIFAR-10 training with VGG-16 (batch size = 128). Note that a hand-tuned LR schedule can achieve 93.70% top-1 test accuracy in 350 epochs. We report the top-1 accuracy achieved within 350 epochs for each trial, and the mean and standard deviation of the top-1 accuracy achieved by AutoLRS over 5 trials for each $\tau_{\mathrm{max}}$ . + +
τmaxTrial NumberEpoch to 93.70% Top-1 AccuracyTop-1 Accuracy AchievedMean±std
4000Trial 110894.13%94.01%±0.13%
Trial 218193.96%
Trial 322394.07%
Trial 431593.82%
Trial 528794.09%
8000Trial 111594.03%93.96%±0.07%
Trial 226593.92%
Trial 320393.94%
Trial 419494.02%
Trial 530593.87%
16000Trial 122993.77%93.80%±0.10%
Trial 225093.95%
Trial 326793.73%
Trial 431393.71%
Trial 533093.82%
+ +Table 7: Experimental results after replacing BO in AutoLRS with random search for CIFAR-10 training with VGG-16 (batch size = 128). We also report the top-1 accuracy achieved within 350 epochs for each trial. + +
τmaxTrial NumberEpoch to 93.70% Top-1 AccuracyTop-1 Accuracy Achieved
4000Trial 119993.80%
Trial 220993.97%
Trial 329893.84%
8000Trial 134493.71%
Trial 222593.98%
Trial 317593.91%
16000Trial 1N/A93.64%
Trial 231693.96%
Trial 331093.86%
+ +Table 8: Experimental results after replacing BO in AutoLRS with grid search for CIFAR-10 training with VGG-16 (batch size = 128). We also report the top-1 accuracy achieved within 350 epochs for each trial. + +
τmaxTrial NumberEpoch to 93.70% Top-1 AccuracyTop-1 Accuracy Achieved
4000Trial 130493.88%
Trial 223393.88%
Trial 318093.91%
8000Trial 123993.72%
Trial 229693.95%
Trial 3N/A93.32%
16000Trial 1N/A93.02%
Trial 215393.78%
Trial 328893.70%
+ +Table 9: Top-1 test accuracy achieved by AutoLRS-generated LR schedules for CIFAR-100 training with VGG-16 over 10 trials. + +
73.12%73.20%72.90%72.93%73.03%
73.16%73.30%72.85%73.00%72.97%
\ No newline at end of file diff --git a/autolrsautomaticlearningrateschedulebybayesianoptimizationonthefly/images.zip b/autolrsautomaticlearningrateschedulebybayesianoptimizationonthefly/images.zip new file mode 100644 index 0000000000000000000000000000000000000000..fb19c7c8f194d0f3278027776629082cb70c3a6a --- /dev/null +++ b/autolrsautomaticlearningrateschedulebybayesianoptimizationonthefly/images.zip @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:652ce0c331319726ea7da92f484ff681a7c9b0297fc18c29265a6f80e4841010 +size 795429 diff --git a/autolrsautomaticlearningrateschedulebybayesianoptimizationonthefly/layout.json b/autolrsautomaticlearningrateschedulebybayesianoptimizationonthefly/layout.json new file mode 100644 index 0000000000000000000000000000000000000000..aeac8a8c0acabc5bb6c62753afc3a87fa771f8a8 --- /dev/null +++ b/autolrsautomaticlearningrateschedulebybayesianoptimizationonthefly/layout.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0238290dbc21347a0cbc3ca65358fdea4fad95fbe48eb1e67d0e96e0e93cf47e +size 857101 diff --git a/autoregressivedynamicsmodelsforofflinepolicyevaluationandoptimization/f7793aa3-ff60-4924-84b7-8a987c0c05b6_content_list.json b/autoregressivedynamicsmodelsforofflinepolicyevaluationandoptimization/f7793aa3-ff60-4924-84b7-8a987c0c05b6_content_list.json new file mode 100644 index 0000000000000000000000000000000000000000..0e4dfdfd145d940e702f204ff0d3dd45c83baebe --- /dev/null +++ b/autoregressivedynamicsmodelsforofflinepolicyevaluationandoptimization/f7793aa3-ff60-4924-84b7-8a987c0c05b6_content_list.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b1a8392dd2d7d546528dae1da5efe0e6f223885ce5d1d7a3675d28b2a3a55353 +size 104819 diff --git a/autoregressivedynamicsmodelsforofflinepolicyevaluationandoptimization/f7793aa3-ff60-4924-84b7-8a987c0c05b6_model.json b/autoregressivedynamicsmodelsforofflinepolicyevaluationandoptimization/f7793aa3-ff60-4924-84b7-8a987c0c05b6_model.json new file mode 100644 index 0000000000000000000000000000000000000000..ff90ddb6add73951269af69e7bf1e0dd58e122ed --- /dev/null +++ b/autoregressivedynamicsmodelsforofflinepolicyevaluationandoptimization/f7793aa3-ff60-4924-84b7-8a987c0c05b6_model.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:bf11e08fc7895d809a2c30a79282ffc8938073bd5d5dad41c0165e144f506c17 +size 121617 diff --git a/autoregressivedynamicsmodelsforofflinepolicyevaluationandoptimization/f7793aa3-ff60-4924-84b7-8a987c0c05b6_origin.pdf b/autoregressivedynamicsmodelsforofflinepolicyevaluationandoptimization/f7793aa3-ff60-4924-84b7-8a987c0c05b6_origin.pdf new file mode 100644 index 0000000000000000000000000000000000000000..88a876e73d9138cefd8d8f213d4606a08ddbf6f8 --- /dev/null +++ b/autoregressivedynamicsmodelsforofflinepolicyevaluationandoptimization/f7793aa3-ff60-4924-84b7-8a987c0c05b6_origin.pdf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5260f0ef1dea6fa5fb249798e9b95c56037b7dc101f94cf906a324ea0b5294da +size 1878434 diff --git a/autoregressivedynamicsmodelsforofflinepolicyevaluationandoptimization/full.md b/autoregressivedynamicsmodelsforofflinepolicyevaluationandoptimization/full.md new file mode 100644 index 0000000000000000000000000000000000000000..20d591ae4c240f912fc71dd7398e3d3f4ceb1601 --- /dev/null +++ b/autoregressivedynamicsmodelsforofflinepolicyevaluationandoptimization/full.md @@ -0,0 +1,409 @@ +# AUTOREGRESSIVE DYNAMICS MODELS FOR OFFLINE POLICY EVALUATION AND OPTIMIZATION + +Michael R. Zhang\*1 Tom Le Paine2 Ofir Nachum3 Cosmin Paduraru2 George Tucker3 Ziyu Wang3 Mohammad Norouzi3 + +1University of Toronto 2DeepMind 3Google Brain +michael@cs.toronto.edu, mnorouzi@google.com + +# ABSTRACT + +Standard dynamics models for continuous control make use of feedforward computation to predict the conditional distribution of next state and reward given current state and action using a multivariate Gaussian with a diagonal covariance structure. This modeling choice assumes that different dimensions of the next state and reward are conditionally independent given the current state and action and may be driven by the fact that fully observable physics-based simulation environments entail deterministic transition dynamics. In this paper, we challenge this conditional independence assumption and propose a family of expressive autoregressive dynamics models that generate different dimensions of the next state and reward sequentially conditioned on previous dimensions. We demonstrate that autoregressive dynamics models indeed outperform standard feedforward models in log-likelihood on held-out transitions. Furthermore, we compare different model-based and model-free off-policy evaluation (OPE) methods on RL Unplugged, a suite of offline MuJoCo datasets, and find that autoregressive dynamics models consistently outperform all baselines, achieving a new state-of-the-art. Finally, we show that autoregressive dynamics models are useful for offline policy optimization by serving as a way to enrich the replay buffer through data augmentation and improving performance using model-based planning. + +# 1 INTRODUCTION + +Model-based Reinforcement Learning (RL) aims to learn an approximate model of the environment's dynamics from existing logged interactions to facilitate efficient policy evaluation and optimization. Early work on Model-based RL uses simple tabular (Sutton, 1990; Moore and Atkeson, 1993; Peng and Williams, 1993) and locally linear (Atkeson et al., 1997) dynamics models, which often result in a large degree of model bias (Deisenroth and Rasmussen, 2011). Recent work adopts feedforward neural networks to model complex transition dynamics and improve generalization to unseen states and actions, achieving a high level of performance on standard RL benchmarks (Chua et al., 2018; Wang et al., 2019). However, standard feedforward dynamics models assume that different dimensions of the next state and reward are conditionally independent given the current state and action, which may lead to a poor estimation of uncertainty and unclear effects on RL applications. + +In this work, we propose a new family of autoregressive dynamics models and study their effectiveness for off-policy evaluation (OPE) and offline policy optimization on continuous control. Autoregressive dynamics models generate each dimension of the next state conditioned on previous dimensions of the next state, in addition to the current state and action (see Figure 1). This means that to sample the next state from an autoregressive dynamics model, one needs $n$ sequential steps, where $n$ is the number of state dimensions, and one more step to generate the reward. By contrast, standard feedforward dynamics models take current state and action as input and predict the distribution of the next state and reward as a multivariate Gaussian with a diagonal covariance structure (e.g., Chua et al. (2018); Janner et al. (2019)). This modeling choice assumes that different state dimensions are conditionally independent. + +Autoregressive generative models have seen success in generating natural images (Parmar et al., 2018), text (Brown et al., 2020), and speech (Oord et al., 2016), but they have not seen use in Model-based RL for continuous control. + +We find that autoregressive dynamics models achieve higher log-likelihood compared to their feedforward counterparts on heldout validation transitions of all DM continuous control tasks (Tassa et al., 2018) from the RL Unplugged dataset (Gulcehre et al., 2020). To determine the impact of improved transition dynamics models, we primarily focus on OPE because it allows us to isolate contributions of the dynamics model in value estimation vs. the many other factors of variation in policy optimization and data collection. We find that autoregressive dynamics models consistently outperform existing Model-based and Model-free OPE baselines on continuous control in both ranking and value estimation metrics. We expect that our advances in model-based OPE will improve offline policy selection for offline RL (Paine et al., 2020). Finally, we show that our autoregressive dynamics models can help improve offline policy optimization by model predictive control, achieving a new state-of-the-art on cheetah-run and fish-swim from RL Unplugged (Gulcehre et al., 2020). + +Key contributions of this paper include: + +- We propose autoregressive dynamics models to capture dependencies between state dimensions in forward prediction. We show that autoregressive models improve log-likelihood over non-autoregressive models for continuous control tasks from the DM Control Suite (Tassa et al., 2018). +- We apply autoregressive dynamics models to Off-Policy Evaluation (OPE), surpassing the performance of state-of-the-art baselines in median absolute error, rank correlation, and normalized top-5 regret across 9 control tasks. +- We show that autoregressive dynamics models are more useful than feedforward models for offline policy optimization, serving as a way to enrich experience replay by data augmentation and improving performance via model-based planning. + +# 2 PRELIMINARIES + +Here we introduce relevant notation and discuss off-policy (offline) policy evaluation (OPE). We refer the reader to Lange et al. (2012) and Levine et al. (2020) for background on offline RL, which is also known as batch RL in the literature. + +A finite-horizon Markov Decision Process (MDP) is defined by a tuple $\mathcal{M} = (\mathcal{S},\mathcal{A},\mathcal{T},d_0,r,\gamma)$ , where $\mathcal{S}$ is a set of states $s\in S$ , $\mathcal{A}$ is a set of actions $a\in \mathcal{A}$ , $\mathcal{T}$ defines transition probability distributions $p(s_{t + 1}|s_t,a_t)$ , $d_0$ defines the initial state distribution $d_0\equiv p(s_0)$ , $r$ defines a reward function $r:\mathcal{S}\times \mathcal{A}\to \mathbb{R}$ , and $\gamma$ is a scalar discount factor. A policy $\pi (a\mid s)$ defines a conditional distribution over actions conditioned on states. A trajectory consists of a sequence of states and actions $\tau = (s_0,a_0,s_1,a_1,\dots ,s_H)$ of horizon length $H$ . We use $s_{t,i}$ to denote the $i$ -th dimension of the state at time step $t$ (and similarly for actions). In reinforcement learning, the objective is to maximize the expected sum of discounted rewards over the trajectory distribution induced by the policy: + +$$ +V _ {\gamma} (\pi) = \mathbb {E} _ {\tau \sim p _ {\pi} (\tau)} \left[ \sum_ {t = 0} ^ {H} \gamma^ {t} r \left(s _ {t}, a _ {t}\right) \right]. \tag {1} +$$ + +The trajectory distribution is characterized by the initial state distribution, policy, and transition probability distribution: + +$$ +p _ {\pi} (\tau) = d _ {0} \left(s _ {0}\right) \prod_ {t = 0} ^ {H - 1} \pi \left(a _ {t} \mid s _ {t}\right) p \left(s _ {t + 1} \mid s _ {t}, a _ {t}\right). \tag {2} +$$ + +In offline RL, we are given access to a dataset of transitions $\mathcal{D} = \{(s_t^i,a_t^i,r_{t + 1}^i,s_{t + 1}^i)\}_{i = 1}^N$ and a set of initial states $S_0$ . Offline RL is inherently a data-driven approach since the agent needs to optimize the same objective as in Eq. (1) but is not allowed additional interactions with the environment. Even though offline RL offers the promise of leveraging existing logged datasets, current offline RL algorithms (Fujimoto et al., 2019; Agarwal et al., 2020; Kumar et al., 2019) are typically evaluated using online interaction, which limits their applicability in the real world. + +![](images/7a185cc43a59f3aaec0464004b4367b0359c3bd71475ee99486d40eb7b44541e.jpg) +Standard Feedforward Dynamics Models + +![](images/0381dc385f60ecd791a781c5dabae1cc55329492b2aa98aea8faaf04f92678ef.jpg) +Proposed Autoregressive Dynamics Model +Figure 1: Standard probabilistic dynamics models (e.g., Chua et al. (2018)) use a neural network to predict the mean and standard deviation of different dimensions of the next state and reward simultaneously. By contrast, we use the same neural network architectures with several additional inputs and predict the mean and standard deviation of each dimension of the next state conditional on previous dimensions of the next state. As empirical results indicate, this small change makes a big difference in the expressive power of dynamics models. Note that reward prediction is not shown on the right to reduce clutter, but it can be thought of as $(n + 1)$ th state dimension. + +The problem of off-policy (offline) policy evaluation (OPE) entails estimating $V_{\gamma}(\pi)$ , the value of a target policy $\pi$ , based on a fixed dataset of transitions denoted $\mathcal{D}$ , without access to the environment's dynamics. Some OPE methods assume that $\mathcal{D}$ is generated from a known behavior (logging) policy $\mu$ and assume access to $\mu$ in addition to $\mathcal{D}$ . In practice, the logged dataset $\mathcal{D}$ may be the result of following some existing system that does not have a probabilistic form. Hence, in our work, we will assume no access to the original behavior policy $\mu$ for OPE. That said, for methods that require access to $\mu$ , we train a behavior cloning policy on $\mathcal{D}$ . + +# 3 PROBABILISTIC DYNAMICS MODELS + +Feedforward dynamics model. In the context of our paper, we use the term "model" to jointly refer to the forward dynamics model $p_{s}(s_{t + 1}|s_{t},a_{t})$ and reward model $p_{r}(r_{t + 1}|s_{t},a_{t})$ . We use neural nets to parameterize both distributions since they are powerful function approximators that have been effective for model-based RL (Chua et al., 2018; Nagabandi et al., 2018; Janner et al., 2019). + +Let $\theta$ denote the parameters of a fully connected network used to model $p_{\theta}(s_{t + 1},r_{t + 1}\mid s_t,a_t)$ . We expect joint modeling of the next state and reward to benefit from sharing intermediate network features. Similar to prior work (Janner et al., 2019), our baseline feedforward model outputs the mean and log variance of all state dimensions and reward simultaneously, as follows: + +$$ +p _ {\theta} \left(s _ {t + 1}, r _ {t + 1} \mid s _ {t}, a _ {t}\right) = \mathcal {N} \left(\mu \left(s _ {t}, a _ {t}\right), \operatorname {D i a g} \left(\exp \left\{l \left(s _ {t}, a _ {t}\right) \right\}\right)\right), \tag {3} +$$ + +where $\mu (s_t,a_t)\in \mathbb{R}^{n + 1}$ denotes the mean for the concatenation of the next state and reward, $l(s_{t},a_{t})\in \mathbb{R}^{n + 1}$ denotes the log variance, and $\operatorname {Diag}(v)$ is an operator that creates a diagonal matrix with the main diagonal specified by the vector $v$ . During training, we seek to minimize the negative log likelihood of the parameters given observed transitions in the dataset $\mathcal{D}$ .. + +$$ +\ell (\theta \mid \mathcal {D}) = - \sum_ {(s, a, r ^ {\prime}, s ^ {\prime}) \in \mathcal {D}} \log p _ {\theta} \left(s ^ {\prime}, r ^ {\prime} \mid s, a\right). \tag {4} +$$ + +While it is possible to place different weights on the loss for next state and reward prediction, we did not apply any special weighting and treated the reward as an additional state dimension in all of our experiments. This is straightforward to implement and does not require tuning an additional hyperparameter, which is challenging for OPE. Note that the input has $|s| + |a|$ dimensions. + +Autoregressive dynamics model. We now describe our autoregressive model. We seek to demonstrate the utility of predicting state dimensions in an autoregressive way. Therefore, rather than using a complex neural network architecture, where improvements in log-likelihood and policy evaluation are confounded by architectural differences, we opt to make simple modifications to the feedforward model described above. This allows us to isolate the source of performance improvements. + +The autoregressive model we use is a fully connected model that predicts the mean and log variance of a single state dimension. We augment the input space of the baseline with the previous predicted + +state dimensions and a one-hot encoding to indicate which dimension to predict. This is illustrated in Figure 1. The autoregressive model therefore has $3|s| + |a|$ input dimensions. Hence, the autoregressive model has a small number of additional weights in the first fully connected layer, but as will be shown in our experiments, these extra parameters are not the reason for a performance gain. + +At training time, the autoregressive model has a similar computational cost to the fully connected model as we can mask ground truth states and use data parallelism to compute all state dimensions simultaneously. At inference, the autoregressive model requires additional forward passes, on the order of the number of state dimensions in a given environment. We use the default ordering for the state dimensions in a given environment, though it is interesting to explore different orderings in future works. The negative log-likelihood for an autoregressive model takes the form of: + +$$ +\ell (\theta \mid \mathcal {D}) = - \sum_ {(s, a, r ^ {\prime}, s ^ {\prime}) \in \mathcal {D}} \left[ \log p _ {\theta} \left(r ^ {\prime} \mid s, a, s ^ {\prime}\right) + \sum_ {i = 1} ^ {n} \log p _ {\theta} \left(s _ {i} ^ {\prime} \mid s, a, s _ {1} ^ {\prime}, \dots , s _ {i - 1} ^ {\prime}\right) \right], \tag {5} +$$ + +where we use chain rule to factorize the joint probability of $p(s', r' \mid s, a)$ . + +The main advantage of the autoregressive model is that it makes no conditional independence assumption between next state dimensions. This class of models can therefore capture non-unimodal dependencies, e.g., between different joint angles of a robot. Paduraru (2007) demonstrates this increased expressivity in the tabular setting, constructing an example on which a model assuming conditional independence fails. While the expressive power of autoregressive models have been shown in various generative models (Parmar et al., 2018; Oord et al., 2016), autoregressive dynamics models have not seen much use in Model-based RL for continuous control before this work. + +Model-based OPE. Once a dynamics model is trained from offline data, OPE can be performed in a direct and primitive way. We let the policy and model interact—the policy generates the next action, the model plays the role of the environment and generates the next state and reward. Due to the stochasticity in the model and the policy, we estimate the return for a policy with Monte-Carlo sampling and monitor standard error. See Algorithm 1 for pseudocode. + +# 4 RELATED WORK + +Our work follows a long line of OPE research, which is especially relevant to many practical domains such as medicine (Murphy et al., 2001), recommendation systems (Li et al., 2011), and education (Mandel et al., 2014) in order to avoid the costs and risks associated + +# Algorithm 1 Model-based OPE + +
Require: Number of rollouts n, discount factor γ, horizon length H, policy π, dynamics model p, set of initial states S0
for i = 1, 2, ... n do
Ri← 0
sample initial state s0 ~ S0
for t = 0, 1, 2, ..., H-1 do
sample from policy: at ∼ π(· | st)
sample from the dynamics model: st+1, rt+1 ∼ p(·, · | st, at)
Ri← Ri + γtrt+1
end for
end for
return 1/n ∑i=1n Ri
+ +with online evaluation. There exists a large body of work on OPE, including methods based on importance weighting (Precup, 2000; Li et al., 2014) and Lagrangian duality (Nachum et al., 2019; Yang et al., 2020; Uehara and Jiang, 2019). The model-based approach that we focus on in this paper lies within the class of algorithms referred to as the direct method (Kostrikov and Nachum, 2020; Dudík et al., 2011; Voloshin et al., 2019), which approximate the value of a new policy by either explicitly or implicitly estimating the transition and reward functions of the environment. While model-based policy evaluation has been considered by previous works (Paduraru, 2007; Thomas and Brunskill, 2016a; Hanna et al., 2017), it has largely been confined to simple domains with finite state and action spaces where function approximation is not necessary. By contrast, our work provides an extensive demonstration of model-based OPE in challenging continuous control benchmark domains. Previous instances of the use of function approximation for model-based OPE (Hallak et al., 2015) impose strong assumptions on the probabilistic dynamics models, such as factorability of the MDP. Our results indicate that even seemingly benign assumptions about the independence of different state dimensions can have detrimental consequences for the effectiveness of a model-based OPE estimate. + +While the use of model-based principles in OPE has been relatively rare, it has been more commonly used for policy optimization. The field of model-based RL has matured in recent years to yield impressive results for both online (Nagabandi et al., 2018; Chua et al., 2018; Kurutach et al., 2018; Janner et al., 2019) and offline (Matsushima et al., 2020; Kidambi et al., 2020; Yu et al., 2020; Argenson and Dulac-Arnold, 2020) policy optimization. Several of the techniques we employ, such + +Table 1: Summary of the offline datasets used. Dataset size indicates the number of $(s, a, r', s')$ tuples. + +
cartpole swingupcheetah runfinger turn hardfish swimhumanoid runwalker standwalker walkmanipulator insert ballmanipulator insert peg
State dim.51712246724244444
Action dim.1625216655
Dataset size40K300K500K200K3M200K200K1.5M1.5M
+ +Table 2: Negative log-likelihood on heldout validation sets for different RL Unplugged tasks (lower is better). For both family of dynamics models, we train 48 models with different hyperparameters. We report the Top-1 NLL on the top and average of Top-5 models on the bottom. On all of the tasks autoregressive dynamics models significantly outperform feedforward models in terms of NLL for both Top-1 and Top-5. + +
Dynamics model architecturecartpole swingupcheetah runfinger turn hardfish swimhumanoid runwalker standwalker walkmanipulator insert ballmanipulator insert peg
Top1Feedforward-6.81-4.90-5.58-4.91-3.42-4.52-3.84-4.74
Top5Autoregressive-7.21-6.36-6.14-5.21-4.18-4.73-4.17-5.62
Top5Feedforward-6.75-4.85-5.50-4.90-3.40-4.49-3.81-4.64
Top5Autoregressive-7.14-6.32-5.94-5.18-4.15-4.71-4.15-5.58
+ +as the normalization of the observation space, are borrowed from this previous literature (Nagabandi et al., 2018; Chua et al., 2018). Conversely, we present strong empirical evidence that the benefits of our introduced autoregressive generative models of state observations do carry over to model-based policy optimization, at least in the offline setting, and this is an interesting avenue for future work. + +# 5 RESULTS + +We conduct our experiments on the DeepMind control suite (Tassa et al., 2018), a set of control tasks implemented in MuJoCo (Todorov et al., 2012). We use the offline datasets from RL Unplugged (Gulcehre et al., 2020), the details of which are provided in Table 1. These environments capture a wide range of complexity, from 40K transitions in a 5-dimensional cartpole environment to 1.5 million transitions on complex manipulation tasks. We follow the evaluation protocol in the Deep OPE (Fu et al., 2021) benchmark and use policies generated by four different algorithms: behavioral cloning (Bain, 1995), D4PG (Barth-Maron et al., 2018), Critic Regularized Regression (Wang et al., 2020), and ABM (Siegel et al., 2019). With varied hyperparameters, these form a diverse set of policies of varying quality. + +We perform a thorough hyperparameter sweep in the experiments and use standard practice from generative modeling to improve the quality of the models. We allocate $80\%$ of the data for training and $20\%$ of the data for model selection. We vary the depth and width of the neural networks (number of layers $\in \{3,4\}$ , layer size $\in \{512,1024\}$ ), add different amounts of noise to input states and actions, and consider two levels of weight decay for regularization (input noise $\in \{0,1\mathrm{e} - 6,1\mathrm{e} - 7\}$ , weight decay $\in \{0,1\mathrm{e} - 6\}$ ). For the choice of optimizer, we consider both Adam (Kingma and Ba, 2014) and SGD with momentum and find Adam to be more effective at maximizing log-likelihood across all tasks in preliminary experiments. We thus use Adam in all of our experiments with two learning rates $\in \{1\mathrm{e} - 3,3\mathrm{e} - 4\}$ . We decay the optimizer's learning rate linearly to zero throughout training, finding this choice to outperform a constant learning rate. Lastly, we find that longer training often improves log-likelihood results. We use 500 epochs for training final models. + +For each task we consider in total 48 hyperparameter combinations (listed above) for both models and pick the best model in each model family based on validation log-likelihood. This model is then used for model-based OPE and policy optimization. Note that, in our experiments, $20\%$ of the transitions are used only for validation, but we believe one can re-train the models with the best hyperparameter configuration on the full transition datasets to improve the results even further. + +# 5.1 AUTOREGRESSIVE DYNAMICS MODELS OUTPERFORM FEEDFORWARD MODELS IN NLL + +To evaluate the effectiveness of autoregressive dynamics models compared to feedforward counterparts, Table 2 reports negative log-likelihood (NLL) on the heldout validation set for the best + +![](images/67c687b668b06a8163327833ace4230f2f0d91071db484349353788eb2f115ae.jpg) +Figure 2: Network parameter count vs. validation negative log-likelihood for autoregressive and feedforward models. Autoregressive models often have a lower validation NLL irrespective of parameter count. + +![](images/91e1fa63ef8217e8f47707a1717c73c3cd42c7ae50fb2ee1cddb890adaede2d4.jpg) + +![](images/3ed8d49a5e819b39b97750cc5e44ba9fbb7cc55695ad2f6615af6710c05f76b9.jpg) + +![](images/95d598fda8df92ab7592df5e26a5215a28f3a23fd8a0ae83bf450beb08e7f5ae.jpg) + +![](images/5952d6549cb6cded9557d192435093ddb03b52cfb357b4a5f18b0fa1dcff80a6.jpg) +Figure 3: Validation negative log-likelihood vs. OPE correlation coefficients on different tasks. On 4 RL Unplugged tasks, we conduct an extensive experiment in which 48 Autoregressive and 48 Feedforward Dynamics models are used for OPE. For each dynamics model, we calculate the correlation coefficient between model-based value estimates and ground truth values at a discount factor of 0.995. We find that low validation NLL numbers generally correspond to accurate policy evaluation, while higher NLL numbers are less meaningful. + +![](images/dbc4ad7e6d4bea2747b58572bc2492f11237692ab7e6fc1a39bf74ed7f8fab05.jpg) + +![](images/8589b99614a9c025a51bebfc216d2c4d17a98aae6b093e10253bf516421c3ead.jpg) + +![](images/c5c56537f5993f6e91c3a0506379ec24b12b1d82bc4510713d3450efb4e2feb2.jpg) + +performing models from our hyperparameter sweep. For each environment, we report the NLL for the best-performing model (Top-1) and the average NLL across the Top-5 models. The autoregressive model has lower NLL on all environments, indicating that it generalizes better to unseen data. + +To study the impact of model size on NLL, Figure 2 shows validation NLL as a function of parameter count. We find that on small datasets large models hurt, but more importantly autoregressive models outperform feedforward models regardless of the parameter count regime, i.e., even small autoregressive models attain a lower validation NLL compared to big feedforward models. This indicates that autoregressive models have a better inductive bias in modeling the transition dynamics than feedforward models that make a conditional independence assumption. + +# 5.2 ARE DYNAMICS MODELS WITH LOWER NLL BETTER FOR MODEL-BASED OPE? + +We ultimately care not just about the log-likelihood numbers, but also whether or not the dynamics models are useful in policy evaluation and optimization. To study the relationship of NLL and OPE performance for model-based methods, we compute OPE estimates via Algorithm 1 and compute the Pearson correlation between the OPE estimates and the true discounted returns. This serves as a measure of the effectiveness of the model for OPE. We repeat this for all 96 dynamics models we trained on a given environment and plot the correlation coefficients against validation NLL in Figure 3. + +Models with low NLL are generally more accurate in OPE. Lambert et al. (2020) have previously demonstrated that in Model-based RL, "training cost does not hold a strong correlation to maximization of episode reward." We use validation NLL instead, and our results on policy evaluation decouple the model from policy optimization, suggesting a more nuanced picture: low validation NLL numbers generally correspond to accurate policy evaluation, while higher NLL numbers are generally less meaningful. In other words, if the dynamics model does not capture the transition dynamics accurately enough, then it is very hard to predict its performance on OPE. However, once the model starts to capture the dynamics faithfully, we conjecture that NLL starts to become a reasonable metric for model selection. For instance, validation NLL does not seem to be a great metric for ranking feedforward models, whereas it is more reasonable for autoregressive models. + +![](images/f52c5e171c66f2d781a6787f26ff5dff5b15df2a2948081ea7b06d1394cdf9d9.jpg) + +![](images/0e88856a6aed4d8bc4446e3dff8484bff7db03578c01c5bc66fd601d8341b07a.jpg) + +![](images/c1118c029520a682b8b60e01556851a54fb958bd786e3eb2a9467c0378da1a0b.jpg) + +![](images/765bd0e599bf822b400420936847bd845d434acbdce9a93c17c521f7bdf916c0.jpg) + +![](images/a7d66c32ce24e9b4d4a984136f0c9be8d42f95a5591ad88ea5c8ae852b101aa9.jpg) + +![](images/21679b0277f7c966e2f35db9ad4f644c114ba44245eeacfc8d1f1dd484e847ff.jpg) + +![](images/7ade3de1a425afaca4654416755d783204a13ce9fc4ad415bbcd24c1622e4441.jpg) + +![](images/4b98d3fa0f10818eea6ab3bd1fcd7ccb07cb2e7b3ce575b096fa9a0601214827.jpg) + +![](images/5426b5504a393e106ed2c24dfedfd779d10846c4d220f920e8c75db902c7a9fd.jpg) + +![](images/e8443f02b3be3df3a7f926d7502884d561fefcf510428645e87a48b5192ef91b.jpg) + +![](images/d4e35e73a3cc4750a36f0cf2e1e6afacf5094860478654e6693667b2e765ada7.jpg) + +![](images/0d22eebdc7609f82ed76c31b6ae6c4a8b4674fb7187f782c3de9ea2ca971b2a1.jpg) + +![](images/99e525231b8c65c06bb5de3b533a8f40cef19bbb4e86cf8077010f9808461244.jpg) +Figure 4: Comparison of model-based OPE using autoregressive and feedforward dynamics models with state-of-the-art FQE methods based on L2 and distributional Bellman error. We plot OPE estimates on the y-axis against ground truth returns with a discount of .995 on the x-axis. We report the Pearson correlation coefficient $(r)$ in the title. While feedforward models fall behind FQE on most tasks, autoregressive dynamics models are often superior. See Figure B.4 for additional scatter plots on the other environments. + +![](images/3e28b910c91b07d0cbacd57233a58b65aaf7e3950831e97fff52d263fab4b538.jpg) + +![](images/0338e4a731b79b255c1232611ec0973a8e2bfa7277e43e5363a6ddecc5fbc55c.jpg) + +![](images/2777ca571228cac2a4f9bb4a4b913d1f76adbe21e87cae92621f6b430a3b4287.jpg) + +# 5.3 COMPARISON WITH OTHER OPE METHODS + +We adopt a recently proposed benchmark for OPE (Fu et al., 2021) and compare our model-based approaches with state-of-the-art OPE baselines therein. Figures 4 and B.4 compare OPE estimates from two Fitted-Q Evaluation (FQE) baselines (Le et al., 2019; Kostrikov and Nachum, 2020; Paine et al., 2020), our feedforward models, and the autoregressive approach. Each plot reports the Pearson correlation between the OPE estimates and the true returns. The autoregressive model consistently outperforms the feedforward model and FQE methods on most environments. We report ensembling results in the appendix, but compare single models for fairness in the rest of the paper. + +We compute summary statistics for OPE methods in Table 3, Table A.1, and Table A.2. These tables report the Spearman's rank correlation, regret, and absolute error, respectively. These metrics capture different desirable properties of OPE methods (Fu et al., 2021); more details about how they are computed are in the appendix. In all three metrics, the autoregressive model achieves the best median performance across nine environments, whereas the baseline model is not as good as FQE. The only environment in which the autoregressive model has negative rank correlation is manipulator insert ball. In addition, a major advantage of our model-based approach over FQE is that the model only needs to be trained once per environment—we do not need to perform additional policy-specific optimization, whereas FQE needs to optimize a separate Q-function approximator per policy. + +
Cartpole swingupCheetah runFinger turn hardFish swimHumanoid run
Rank Correlation btw. OPE and ground truthImportance Sampling-0.23±0.11-0.01±0.12-0.45±0.08-0.17±0.110.91±0.02
Best DICE-0.16±0.110.07±0.11-0.22±0.110.44±0.09-0.10±0.10
Variational power method0.01±0.110.01±0.12-0.25±0.110.56±0.080.36±0.09
Doubly Robust (IS, FQE)0.55±0.090.56±0.080.67±0.050.11±0.12-0.03±0.12
Feedforward Model0.83±0.050.64±0.080.08±0.110.95±0.020.35±0.10
FQE (distributional)0.69±0.070.67±0.060.94±0.010.59±0.100.74±0.06
FQE (L2)0.70±0.070.56±0.080.83±0.040.10±0.12-0.02±0.12
Autoregressive Model0.91±0.020.74±0.070.57±0.090.96±0.010.90±0.02
Walker standWalker walkManipulator insert ballManipulator insert pegMedian ↑
Rank Correlation btw. OPE and ground truthImportance Sampling0.59±0.080.38±0.10-0.72±0.05-0.25±0.08-0.17
Best DICE-0.11±0.12-0.58±0.080.19±0.11-0.35±0.10-0.11
Variational power method-0.35±0.10-0.10±0.110.61±0.080.41±0.090.01
Doubly Robust (IS, FQE)0.88±0.030.85±0.040.42±0.10-0.47±0.090.55
Feedforward Model0.82±0.040.80±0.050.06±0.10-0.56±0.080.64
FQE (distributional)0.87±0.020.89±0.030.63±0.08-0.23±0.100.69
FQE (L2)0.96±0.010.94±0.020.70±0.07-0.48±0.080.70
Autoregressive Model0.96±0.010.98±0.00-0.33±0.090.47±0.090.90
+ +Table 3: Spearman's rank correlation $(\rho)$ coefficient (bootstrap mean $\pm$ standard deviation) between different OPE metrics and ground truth values at a discount factor of 0.995. In each column, rank correlation coefficients that are not significantly different from the best $(p > 0.05)$ are bold faced. Methods are ordered by median. Also see Table A.1 and Table A.2 for Normalized Regret@5 and Average Absolute Error results. + +![](images/2570983863efb56af66aafa2f3d7d581f27cfc8987cc88b33380dfe20ce21f31.jpg) +Figure 5: Model-based offline policy optimization results. With planning and data augmentation, we improve the performance over CRR exp (our baseline algorithm). When using autoregressive dynamics models (CRR-planning AR), we outperform state-of-the-art on Cheetah run and Fish swim. Previous SOTA results (Gulcehre et al., 2020; Wang et al., 2020) are obtained using different offline RL algorithms: Cheetah run - CRR exp, Fish swim - CRR binary max, Finger turn hard - CRR binary max, Cartpole swingup - BRAC (Wu et al., 2019). + +# 5.4 AUTOREGRESSIVE DYNAMICS MODELS FOR OFFLINE POLICY OPTIMIZATION + +Policy evaluation is an integral part of reinforcement learning. Improvement in policy evaluation can therefore be adapted for policy optimization. In this section, we explore two possibilities of using models to improve offline reinforcement learning. In all experiments, we use Critic Regularized Regression (CRR) as a base offline reinforcement learning algorithm (Wang et al., 2020). + +First, we utilize the model during test time for planning by using a modified version of Model Predictive Path Integral (MPPI) (Williams et al., 2015). Unlike MPPI, we truncate the planning process after 10 steps of rollout and use the CRR critic to evaluate future discounted returns. We provide additional details in the appendix. Secondly, we use the model to augment the transition dataset to learn a better critic for CRR. More precisely, given $s_t^i \sim \mathcal{D}$ , and the current policy $\pi$ , we can generate additional data using the following process: $\hat{a}_t^i \sim \pi(\cdot | s_t^i)$ , $\hat{s}_{t+1}^i$ , $\hat{r}_{t+1}^i \sim p(\cdot, \cdot | s_t^i, \hat{a}_t)$ . + +These two options are orthogonal and can be applied jointly. We implemented both techniques on top of the CRR exp variant (Wang et al., 2020) and show their combined effect in Figure 5. The + +figure shows that autoregressive dynamics models also outperform feedforward ones in the policy optimization context. Notably, in the case of cheetah run and fish swim, using autoregressive models for planning as well as data augmentation enables us to outperform the previous state-of-the-art on these offline datasets. Additionally, when using autoregressive dynamics models, both techniques improve performance. In the appendix, we show this result as well as more ablations. + +# 6 CONCLUSION + +This paper shows the promise of autoregressive models in learning transition dynamics for continuous control, showing strong results for off-policy policy evaluation and offline policy optimization. Our contributions to offline model-based policy optimization are orthogonal to prior work that uses ensembles to lower the values when ensemble components disagree (Kidambi et al., 2020). Incorporating conservative value estimation into our method is an interesting avenue for future research. We use relatively primitive autoregressive neural architectures in this paper to enable a fair comparison with existing feedforward dynamics models. That said, it will be exciting to apply more sophisticated autoregressive neural network architectures with cross attention (Bahdanau et al., 2014) and self-attention (Vaswani et al., 2017) to Model-based RL for continuous control. + +Acknowledgements We thank Jimmy Ba, William Chan, Rishabh Agarwal, Dale Schuurmans, and Silviu Pitis for fruitful discussions on our work. We are also grateful for the helpful comments from Lihong Li, Jenny Liu, Harris Chan, Keiran Paster, Sheng Jia, and Tingwu Wang on earlier drafts. + +# REFERENCES + +Rishabh Agarwal, Dale Schuurmans, and Mohammad Norouzi. An optimistic perspective on offline reinforcement learning. International Conference on Machine Learning, 2020. +Arthur Argenson and Gabriel Dulac-Arnold. Model-based offline planning. arXiv:2008.05556, 2020. +Christopher G Atkeson, Andrew W Moore, and Stefan Schaal. Locally weighted learning. In Lazy learning, pages 11-73. Springer, 1997. +Dzmitry Bahdanau, Kyunghyun Cho, and Yoshua Bengio. Neural machine translation by jointly learning to align and translate. arXiv preprint arXiv:1409.0473, 2014. +Michael Bain. A framework for behavioural cloning. In Machine Intelligence 15, pages 103-129, 1995. +Gabriel Barth-Maron, Matthew W Hoffman, David Budden, Will Dabney, Dan Horgan, Dhruva Tb, Alistair Muldal, Nicolas Heess, and Timothy Lillicrap. Distributed distributional deterministic policy gradients. arXiv:1804.08617, 2018. +Tom B Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah, Jared Kaplan, Prafulla Dhariwal, Arvind Neelakantan, Pranav Shyam, Girish Sastry, Amanda Askell, et al. Language models are few-shot learners. arXiv:2005.14165, 2020. +Kurtland Chua, Roberto Calandra, Rowan McAllister, and Sergey Levine. Deep reinforcement learning in a handful of trials using probabilistic dynamics models. In Advances in Neural Information Processing Systems, 2018. +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), pages 465–472, 2011. +Miroslav Dudík, John Langford, and Lihong Li. Doubly robust policy evaluation and learning. arXiv:1103.4601, 2011. +Justin Fu, Mohammad Norouzi, Ofir Nachum, George Tucker, Ziyu Wang, Alexander Novikov, Mengjiao Yang, Michael R. Zhang, Yutian Chen, Aviral Kumar, Cosmin Paduraru, Sergey Levine, and Thomas Paine. Benchmarks for deep off-policy evaluation. In International Conference on Learning Representations, 2021. + +Scott Fujimoto, David Meger, and Doina Precup. Off-policy deep reinforcement learning without exploration. In International Conference on Machine Learning, pages 2052-2062, 2019. +Caglar Gulcehre, Ziyu Wang, Alexander Novikov, Tom Le Paine, Sergio Gomez Colmenarejo, Konrad Zolna, Rishabh Agarwal, Josh Merel, Daniel Mankowitz, Cosmin Paduraru, et al. Rl unplugged: Benchmarks for offline reinforcement learning. arXiv:2006.13888, 2020. +Assaf Hallak, François Schnitzler, Timothy Mann, and Shie Mannor. Off-policy model-based learning under unknown factored dynamics. In International Conference on Machine Learning, pages 711-719, 2015. +Josiah Hanna, Scott Niekum, and Peter Stone. Importance sampling policy evaluation with an estimated behavior policy. In International Conference on Machine Learning, pages 2605-2613. PMLR, 2019. +Josiah P Hanna, Peter Stone, and Scott Niekum. Bootstrapping with models: Confidence intervals for off-policy evaluation. In Thirty-First AAAI Conference on Artificial Intelligence, 2017. +Michael Janner, Justin Fu, Marvin Zhang, and Sergey Levine. When to trust your model: Model-based policy optimization. In Advances in Neural Information Processing Systems, 2019. +Rahul Kidambi, Aravind Rajeswaran, Praneeth Netrapalli, and Thorsten Joachims. MOReL: Model-based offline reinforcement learning. arXiv:2005.05951, 2020. +Diederik P Kingma and Jimmy Ba. Adam: A method for stochastic optimization. arXiv:1412.6980, 2014. +Ilya Kostrikov and Ofir Nachum. Statistical bootstrapping for uncertainty estimation in off-policy evaluation, 2020. +Aviral Kumar, Justin Fu, Matthew Soh, George Tucker, and Sergey Levine. Stabilizing off-policy q-learning via bootstrapping error reduction. In Advances in Neural Information Processing Systems, pages 11784-11794, 2019. +Thanard Kurutach, Ignasi Clavera, Yan Duan, Aviv Tamar, and Pieter Abbeel. Model-Ensemble Trust-Region Policy Optimization. In International Conference on Learning Representations, 2018. +Nathan Lambert, Brandon Amos, Omry Yadan, and Roberto Calandra. Objective mismatch in model-based reinforcement learning. arXiv:2002.04523, 2020. +Sascha Lange, Thomas Gabel, and Martin Riedmiller. Batch reinforcement learning. In Reinforcement learning, pages 45-73. Springer, 2012. +Hoang M Le, Cameron Voloshin, and Yisong Yue. Batch policy learning under constraints. arXiv preprint arXiv:1903.08738, 2019. +Sergey Levine, Aviral Kumar, George Tucker, and Justin Fu. Offline reinforcement learning: Tutorial, review, and perspectives on open problems. arXiv:2005.01643, 2020. +Lihong Li, Wei Chu, John Langford, and Xuanhui Wang. Unbiased offline evaluation of contextual-bandit-based news article recommendation algorithms. In Proceedings of the fourth ACM international conference on Web search and data mining, pages 297-306. ACM, 2011. +Lihong Li, Remi Munos, and Csaba Szepesvári. On minimax optimal offline policy evaluation. arXiv:1409.3653, 2014. +Qiang Liu, Lihong Li, Ziyang Tang, and Dengyong Zhou. Breaking the curse of horizon: Infinite-horizon off-policy estimation. In Advances in Neural Information Processing Systems, pages 5356-5366, 2018. +Travis Mandel, Yun-En Liu, Sergey Levine, Emma Brunskill, and Zoran Popovic. Offline policy evaluation across representations with applications to educational games. In Proceedings of the 2014 international conference on Autonomous agents and multi-agent systems, pages 1077-1084. International Foundation for Autonomous Agents and Multiagent Systems, 2014. + +Tatsuya Matsushima, Hiroki Furuta, Yutaka Matsuo, Ofir Nachum, and Shixiang Gu. Deployment-efficient reinforcement learning via model-based offline optimization. arXiv:2006.03647, 2020. +Andrew W Moore and Christopher G Atkeson. Memory-based reinforcement learning: Efficient computation with prioritized sweeping. In Advances in neural information processing systems, pages 263-270, 1993. +Susan A Murphy, Mark J van der Laan, James M Robins, and Conduct Problems Prevention Research Group. Marginal mean models for dynamic regimes. Journal of the American Statistical Association, 96(456):1410-1423, 2001. +Ofir Nachum, Yinlam Chow, Bo Dai, and Lihong Li. Dualdice: Behavior-agnostic estimation of discounted stationary distribution corrections. In Advances in Neural Information Processing Systems, pages 2318-2328, 2019. +Anusha Nagabandi, Gregory Kahn, Ronald S Fearing, and Sergey Levine. Neural network dynamics for model-based deep reinforcement learning with model-free fine-tuning. In 2018 IEEE International Conference on Robotics and Automation (ICRA), pages 7559-7566. IEEE, 2018. +Aaron van den Oord, Sander Dieleman, Heiga Zen, Karen Simonyan, Oriol Vinyals, Alex Graves, Nal Kalchbrenner, Andrew Senior, and Koray Kavukcuoglu. Wavenet: A generative model for raw audio. arXiv:1609.03499, 2016. +Cosmin Paduraru. Planning with approximate and learned models of markov decision processes. *MsC Thesis, University of Alberta, 2007.* +Tom Le Paine, Cosmin Paduraru, Andrea Michi, Caglar Gulcehre, Konrad Zolna, Alexander Novikov, Ziyu Wang, and Nando de Freitas. Hyperparameter selection for offline reinforcement learning. arXiv:2007.09055, 2020. +Niki Parmar, Ashish Vaswani, Jakob Uszkoreit, Lukasz Kaiser, Noam Shazeer, Alexander Ku, and Dustin Tran. Image transformer. arXiv:1802.05751, 2018. +Jing Peng and Ronald J Williams. Efficient learning and planning within the dyna framework. Adaptive behavior, 1(4):437-454, 1993. +Doina Precup. Eligibility traces for off-policy policy evaluation. Computer Science Department Faculty Publication Series, page 80, 2000. +Noah Siegel, Jost Tobias Springenberg, Felix Berkenkamp, Abbas Abdelmaleki, Michael Neunert, Thomas Lampe, Roland Hafner, Nicolas Heess, and Martin Riedmiller. Keep doing what worked: Behavior modelling priors for offline reinforcement learning. In International Conference on Learning Representations, 2019. +Richard S Sutton. Integrated architectures for learning, planning, and reacting based on approximating dynamic programming. In Machine learning proceedings 1990, pages 216-224. Elsevier, 1990. +Yuval Tassa, Yotam Doron, Alistair Muldal, Tom Erez, Yazhe Li, Diego de Las Casas, David Budden, Abbas Abdelmaleki, Josh Merel, Andrew Lefrancq, et al. Deepmind control suite. arXiv:1801.00690, 2018. +P. Thomas and E. Brunskill. Data-efficient off-policy policy evaluation for reinforcement learning. In Proceedings of the 33rd International Conference on Machine Learning, pages 2139-2148, 2016a. +Philip Thomas and Emma Brunskill. Data-efficient off-policy policy evaluation for reinforcement learning. In International Conference on Machine Learning, pages 2139-2148, 2016b. +Emanuel Todorov, Tom Erez, and Yuval Tassa. Mujoco: A physics engine for model-based control. In 2012 IEEE/RSJ International Conference on Intelligent Robots and Systems, pages 5026-5033. IEEE, 2012. +Masatoshi Uehara and Nan Jiang. Minimax weight and q-function learning for off-policy evaluation. arXiv:1910.12809, 2019. + +Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N Gomez, Lukasz Kaiser, and Illia Polosukhin. Attention is all you need. In Advances in neural information processing systems, pages 5998-6008, 2017. +Cameron Voloshin, Hoang M Le, Nan Jiang, and Yisong Yue. Empirical study of off-policy policy evaluation for reinforcement learning. arXiv:1911.06854, 2019. +Tingwu Wang, Xuchan Bao, Ignasi Clavera, Jerrick Hoang, Yeming Wen, Eric Langlois, Shunshi Zhang, Guodong Zhang, Pieter Abbeel, and Jimmy Ba. Benchmarking model-based reinforcement learning. arXiv:1907.02057, 2019. +Ziyu Wang, Alexander Novikov, Konrad Zolna, Jost Tobias Springenberg, Scott Reed, Bobak Shahriari, Noah Siegel, Josh Merel, Caglar Gulcehre, Nicolas Heess, et al. Critic regularized regression. arXiv:2006.15134, 2020. +Junfeng Wen, Bo Dai, Lihong Li, and Dale Schuurmans. Batch stationary distribution estimation. arXiv preprint arXiv:2003.00722, 2020. +Grady Williams, Andrew Aldrich, and Evangelos Theodorou. Model predictive path integral control using covariance variable importance sampling. arXiv:1509.01149, 2015. +Yifan Wu, George Tucker, and Ofir Nachum. Behavior regularized offline reinforcement learning. arXiv:1911.11361, 2019. +Mengjiao Yang, Ofir Nachum, Bo Dai, Lihong Li, and Dale Schuurmans. Off-policy evaluation via the regularized lagrangian, 2020. +Tianhe Yu, Garrett Thomas, Lantao Yu, Stefano Ermon, James Zou, Sergey Levine, Chelsea Finn, and Tengyu Ma. MOPO: Model-based offline policy optimization. arXiv:2005.13239, 2020. + +# A OFFLINE POLICY EVALUATION + +We use the baseline results in Fu et al. (2021). For convenience, we replicate their description of the OPE baselines and metrics. + +# A.1 OPE METRICS + +To evaluate the OPE algorithms, we compute three different metrics between the estimated returns and the ground truth returns: + +1. Rank correlation This metric assesses how well estimated values rank policies. It is equal to the correlation between the ranking (sorted order) by the OPE estimates and the ranking by the ground truth values. +2. Absolute Error: This metric measures the deviations of the estimates from the ground truth and does not directly access the usefulness for ranking. +3. Regret@k This metric measures how much worse the best policies identified by the estimates are than the best policy in the entire set. Regret@k is the difference between the actual expected return of the best policy in the entire set, and the actual value of the best policy in the top-k set. + +# A.2 OPE BASELINES + +Fitted Q-Evaluation (FQE) As in Le et al. (2019), we train a neural network to estimate the value of the evaluation policy $\pi_{e}$ by bootstrapping from $Q(s^{\prime},\pi_{e}(s^{\prime}))$ . We tried two different implementations, one from Kostrikov and Nachum (2020) and another from Paine et al. (2020). + +Importance Sampling (IS) We perform importance sampling with a learned behavior policy. We use the implementation from Kostrikov and Nachum (2020), which uses self-normalized (also known as weighted) step-wise importance sampling (Liu et al., 2018; Nachum et al., 2019). Since the behavior policy is not known explicitly, we learn an estimate of it via a max-likelihood objective over the dataset $\mathcal{D}$ , as advocated by Hanna et al. (2019). In order to be able to compute log-probabilities when the target policy is deterministic, we add artificial Gaussian noise with standard deviation 0.01 for all deterministic target policies. + +Doubly-Robust (DR) We perform weighted doubly-robust policy evaluation based on Thomas and Brunskill (2016b) and using the implementation of Kostrikov and Nachum (2020). Specifically, this method combines the IS technique above with a value estimator for variance reduction. The value estimator is learned according to Kostrikov and Nachum (2020), using deep FQE with an L2 loss function. + +DICE This method uses a saddle-point objective to estimate marginalized importance weights $d^{\pi}(s,a) / d^{\pi_B}(s,a)$ ; these weights are then used to compute a weighted average of reward over the offline dataset, and this serves as an estimate of the policy's value in the MDP. We use the implementation from Yang et al. (2020) corresponding to the algorithm BestDICE. + +Variational Power Method (VPM) This method runs a variational power iteration algorithm to estimate the importance weights $d^{\pi}(s,a) / d^{\pi_B}(s,a)$ without the knowledge of the behavior policy. It then estimates the target policy value using weighted average of rewards similar to the DICE method. Our implementation is based on the same network and hyperparameters for OPE setting as in Wen et al. (2020). We further tune the hyperparameters including the regularization parameter $\lambda$ , learning rates $\alpha_{\theta}$ and $\alpha_{v}$ , and number of iterations on the Cartpole swingup task using ground-truth policy value, and then fix them for all other tasks. + +# A.3 ENSEMBLING + +As in Chua et al. (2018); Janner et al. (2019), we can form an ensemble using our best-performing models. We generate rollouts using the procedure detailed in Janner et al. (2019), forming an ensemble with 4 models. We see some improvement in policy evaluation results, as shown in Figure A.1. Ensembling could likely be further improved by forcing unique hyperparameter settings and seeds. + +
Cartpole swingupCheetah runFinger turn hardFish swimHumanoid run
Regret@5 for OPE vs. ground truthImportance Sampling0.73±0.160.40±0.210.64±0.050.12±0.050.31±0.09
Best DICE0.68±0.410.27±0.050.44±0.040.35±0.240.84±0.22
Variational power method0.50±0.130.37±0.040.45±0.130.02±0.020.56±0.08
Doubly Robust (IS, FQE)0.28±0.050.09±0.050.56±0.120.61±0.120.99±0.00
FQE (L2)0.06±0.040.17±0.050.30±0.110.50±0.030.99±0.00
Feedforward Model0.02±0.020.24±0.120.43±0.040.00±0.000.44±0.02
FQE (distributional)0.03±0.090.11±0.090.10±0.120.49±0.060.24±0.15
Autoregressive Model0.00±0.020.01±0.020.63±0.110.03±0.020.32±0.06
Walker standWalker walkManipulator insert ballManipulator insert pegMedian ↓
Regret@5 for OPE vs. ground truthImportance Sampling0.54±0.110.54±0.230.83±0.050.22±0.030.54
Best DICE0.24±0.070.55±0.060.44±0.070.75±0.040.44
Variational power method0.41±0.020.39±0.020.52±0.200.32±0.020.41
Doubly Robust (IS, FQE)0.02±0.010.05±0.070.30±0.100.73±0.010.30
FQE (L2)0.04±0.020.00±0.020.37±0.070.74±0.010.30
Feedforward Model0.18±0.100.03±0.050.83±0.060.74±0.010.24
FQE (distributional)0.03±0.030.01±0.020.50±0.300.73±0.010.11
Autoregressive Model0.04±0.020.04±0.020.85±0.020.30±0.040.04
+ +Table A.1: Normalized Regret@5 (bootstrap mean ± standard deviation) for OPE methods vs. ground truth values at a discount factor of 0.995. In each column, normalized regret values that are not significantly different from the best $(p > 0.05)$ are bold faced. Methods are ordered by median. + +
Cartpole swingupCheetah runFinger turn hardFish swimHumanoid run
Absolute Error btw. OPE and ground truthVariational power method37.53 ±3.5061.89 ±4.2546.22 ±3.9331.27 ±0.9935.29 ±3.03
Importance Sampling68.75 ±2.3944.29 ±1.9190.10 ±4.6834.82 ±1.9327.89 ±1.98
Best DICE22.73 ±1.6523.35 ±1.3233.52 ±3.4859.48 ±2.4731.42 ±2.04
Feedforward Model6.80 ±0.8513.64 ±0.5935.99 ±3.004.75 ±0.2330.12 ±2.40
FQE (L2)19.02 ±1.3448.26 ±1.7827.91 ±1.1819.82 ±1.5756.28 ±3.52
Doubly Robust (IS, FQE)24.38 ±2.5140.27 ±2.0525.26 ±2.4820.28 ±1.9053.64 ±3.68
FQE (distributional)12.63 ±1.2136.50 ±1.6210.23 ±0.937.76 ±0.9532.36 ±2.27
Autoregressive Model5.32 ±0.544.64 ±0.4622.93 ±1.724.31 ±0.2220.95 ±1.61
Walker standWalker walkManipulator insert ballManipulator insert pegMedian ↓
Absolute Error btw. OPE and ground truthVariational power method96.76 ±3.5987.24 ±4.2579.25 ±6.1921.95 ±1.1746.22
Importance Sampling66.50 ±1.9067.24 ±2.7029.93 ±1.1012.78 ±0.6644.29
Best DICE27.58 ±3.0147.28 ±3.13103.45 ±5.2122.75 ±3.0031.42
Feedforward Model23.34 ±2.4152.23 ±2.3434.30 ±2.55121.12 ±1.5830.12
FQE (L2)6.51 ±0.7118.34 ±0.9536.32 ±1.0731.12 ±2.3727.91
Doubly Robust (IS, FQE)26.82 ±2.6624.63 ±1.6913.33 ±1.1622.28 ±2.3424.63
FQE (distributional)21.49 ±1.4127.57 ±1.549.75 ±1.1012.66 ±1.3912.66
Autoregressive Model19.12 ±1.235.14 ±0.4917.13 ±1.349.71 ±0.709.71
+ +Table A.2: Average absolute error between OPE metrics and ground truth values at a discount factor of 0.995. In each column, absolute error values that are not significantly different from the best $(p > 0.05)$ are bold faced. Methods are ordered by median. + +![](images/7a13c0fa6283042d1d610889b4f991fa7be119ba7714cabbb36d9fc4d4ab67d8.jpg) + +![](images/afaf02057da00280e60e165da54bb8fe6ef3495facfcf1ec46dd024db0e74021.jpg) + +![](images/f788299ba5f4fc1b7caa0504407a043b101cef3ab4675af0f7dac066cbc4881a.jpg) + +![](images/6edd8128466a5a8dbc83d41f514d513b3277830581fee1072b944d3e042a44a6.jpg) + +![](images/a6dc6ca33c268201efa2612cee5b597c7d30ee7249f01b1b4d14929dbedc17cc.jpg) +Figure A.1: Estimates of returns using the top model versus estimates of returns using an ensemble of the top-4 models. + +![](images/7161d44adaebc829ccc46982b440908ae2cd419be1427bcc4a9aa36644ff4667.jpg) + +![](images/9b87787f00f521dd7fc499de416203312d4eab7ec8ca4d8091e9dafacb1749a1.jpg) + +![](images/9dec635be28d80725a67d4945bc25affba9807980a92779e671937ae43228e53.jpg) + +Algorithm 2 Model Predictive Path Integral Planning +Require: state $s$ , policy $\pi$ , dynamics model $p$ , critic $Q$ , temperature $\beta$ , and noise variance $\sigma^2$ . +for $m = 1, \dots, M$ do +for $n = 1, \dots, N$ do + $s_0 \gets s$ $R_n \gets 0$ +for $\tau = 0, \dots, H - 1$ do + $a_n^\tau \sim \pi(\cdot | s_n^\tau)$ $s_n^{\tau + 1}, r_n^{\tau + 1} \sim \pi(\cdot, \cdot | s_n^\tau, a_n^\tau)$ $R_n \gets R_n + \gamma^\tau r_n^{\tau + 1}$ +end for + $a^H \sim \pi(\cdot | s^H)$ $R_n \gets R_n + \gamma^H Q(s_n^H, a_n^H)$ +end for +Re-define $\pi$ such that $\pi(\cdot | \hat{s}^\tau) = \sum_{n} \frac{\exp(R_n / \beta)}{\sum_{m} \exp(R_m / \beta)} \mathcal{N}(\cdot | a_n^\tau, \sigma^2 I)$ . ( $\pi$ depends on $\tau$ and not $\hat{s}$ .) +end for +sample final action $a \sim \sum_{n} \frac{\exp(R_n / \beta)}{\sum_{m} \exp(R_m / \beta)} \delta(a_n^0)$ +return $a$ + +# B ADDITIONAL DETAILS REGARDING POLICY OPTIMIZATION + +To test dynamic models for policy optimization, we implement the two methods discussed in Section 5.4 on top of CRR $exp$ , one of the CRR variants (Wang et al., 2020). We use the RL Unplugged datasets (Gulcehre et al., 2020) for all environments studied in this section. When using data augmentation, we adopt a 1-to-1 ratio between the original dataset and the augmented dataset. + +To take advantage of the dynamics models at test time, we use a variant of Model Predictive Path Integral (MPPI) for planning. To reduce the planning horizon, we truncate the model rollout using CRR critics. The details of the planning procedure is summarized in Algorithm 2. All hyperparameter tuning for the planning process is conducted on the "cartpole swingup" task. The hyperparameters used in the planning process are $M = 3$ , $N = 16$ , $H = 10$ , $\beta = 0.1$ , and $\sigma^2 = 0.01$ . To match the temperature used in the planning component, we choose $\beta = 0.1$ for the CWP component of CRR. This change, however, does not impact the baseline CRR agent performance much. With the exception of $\beta$ and the planning component, all hyperparameters are kept the same as CRR exp. + +![](images/edb0aab7540567ced046adfa9d85117683f36672890400dacca7f005842d1e3d.jpg) +Figure B.2: Effects of the planning procedure. Here we compare using planning (CRR-planning AR) vs not ((CRR AR)) while using augmented data generated by the autoregressive model. Planning with autoregressive models helps in all environments tested. + +![](images/c801e1d06452ed86c4df95c67f0a6dbf23dd01ef2b470cb842d874f1fe178b93.jpg) + +![](images/217c05f29441b41638dc91386f9b64e3bc7f93d3da7ce8cdba50f8ce9c1c3bc7.jpg) + +![](images/f0748027b1b815691ba36cdc7be9881f0dff478ac50d7597b8cb856e0b9a602b.jpg) + +![](images/13c95538381bdc62f33c972daa30bb452e06af4d71355931f49992c27d2b083b.jpg) +Figure B.3: Effects of the data augmentation on cheetah run. [LEFT] In the absence of planning, data augmentation significantly increase the performance of CRR agent. [RIGHT] With the planning procedure, data augmentation is still effective albeit to a lesser extent. + +![](images/cd9c408bd47e01d9a6bcb77a1e0d6cbaa26cdac0ce48286f10e8f0eeedc1cf69.jpg) + +We compare the agents' performance with and without the planning procedure to test its effects. As shown in Figure B.2, planning using an autoregressive model significantly increases performance. + +Data augmentation does not change the agents' performance on cartpole swingup, fish swim, or finger turn hard. It, however, boosts performance considerably on cheetah run. In Figure B.3, we show the effects of data augmentation on cheetah run. + +![](images/08e3d8133268b7b1573867cf24cfe16c6aa323e8460de80e63fc0a98924d9e97.jpg) + +![](images/822d63d0301047861d2fa8db91a1b7b3530cf25deffc858ba63f2e8ad3bf43ea.jpg) + +![](images/b59729696f9f172bdcc03986ee841a2238b2d57fa29bae24be02b4f68846f269.jpg) + +![](images/9ee36fb248988b55583644f8ac7f517ff8bf89886558289b0c2cfcc903c6ec03.jpg) + +![](images/ee8f9332e4ff88f71b2acd9f2b6e26f815d30cb1be1875d31eb6e5b09ecfee43.jpg) + +![](images/94e8efc264ac30b6ebf010e1732e921b3c5a184eb171bdb4abf894c1499f5470.jpg) + +![](images/9232ae8aecb6fef96f7e5978536d3228ca5c14da30f646979c3856e07513508f.jpg) + +![](images/fcc415919de9025a813ee46d6a7defa1c1b3dcb03e7a0438d396cee5257a5547.jpg) + +![](images/aafe55240cf296e851ba68888dd078ed2142865fb59353b56f0ff91229f909cb.jpg) + +![](images/92fe14c9f745b4e4a867b85cfca8c81ef21eabc1c8a73a6d07e0916a2c7a389b.jpg) + +![](images/1937c046f9e56c2b6c14c2c88203997a488c8a8ce75ee5e7deadcba7ddff7bb5.jpg) + +![](images/49918ff47b03ef87a1498923010210ac316c219ddda6d18c803b0e83cf25d803.jpg) + +![](images/f5e37bd1a26b2d2d6e4cf2207faae2b939601c7c4b8058cf18332c1be8544ce5.jpg) + +![](images/6aeb8ad342a910dd0a6475d766d3e16e511b2f06171fcb99131f0bf82ae14969.jpg) + +![](images/0ab452a9915bdf1a4694755b446f60a1b951153dd4878a7117e3fd0b472b50c7.jpg) + +![](images/c3e16b2e4cd123d7a5251534a86f3cf820159636c554034056b6398b89e2f30a.jpg) + +![](images/7ec5606f4007fa1d5aeb638e595d4b4ac376ff29490342ccb3c70e06724b2032.jpg) +Figure B.4: Comparison of model-based OPE using autoregressive and feedforward dynamics models with state-of-the-art FQE methods based on L2 and distributional Bellman error. We plot ground truth returns on the x-axis against estimates of returns from various OPE methods on the y-axis. While feedforward models fall behind FQE on most tasks, autoregressive dynamics models are often superior. The remaining environments are plotted in Figure 4. + +![](images/f20ad0ff4d1fafc066721c9a3309d4422eadb578c8e573b7e1f194d68e5f9b3a.jpg) + +![](images/a44cedf434b657aa43725e5e81f7e700c7e444f86707f3ab7c607d6b03498e4c.jpg) + +![](images/d9e3102544de6d9d5a0d96291cd3a67d1298637e4836dd87adbd7a6b3c7076fd.jpg) \ No newline at end of file diff --git a/autoregressivedynamicsmodelsforofflinepolicyevaluationandoptimization/images.zip b/autoregressivedynamicsmodelsforofflinepolicyevaluationandoptimization/images.zip new file mode 100644 index 0000000000000000000000000000000000000000..0d7bb103dd6b06aaa69c6ff178211060d75d5d93 --- /dev/null +++ b/autoregressivedynamicsmodelsforofflinepolicyevaluationandoptimization/images.zip @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:bc1e044f1834adb1bf0191b85208ee55dbd22189863a9663e94185d1f7046368 +size 1321975 diff --git a/autoregressivedynamicsmodelsforofflinepolicyevaluationandoptimization/layout.json b/autoregressivedynamicsmodelsforofflinepolicyevaluationandoptimization/layout.json new file mode 100644 index 0000000000000000000000000000000000000000..2feb05a3aa943d560a9e4e9a58c385a3c46712ec --- /dev/null +++ b/autoregressivedynamicsmodelsforofflinepolicyevaluationandoptimization/layout.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9c51b6db0dfb110e5cc4e227e782e59fcb08f40a8be0ee4fd5dbe28cd9a95442 +size 523913 diff --git a/autoseglosssearchingmetricsurrogatesforsemanticsegmentation/2802d650-3a45-4a26-97d7-c37c1d6ee49e_content_list.json b/autoseglosssearchingmetricsurrogatesforsemanticsegmentation/2802d650-3a45-4a26-97d7-c37c1d6ee49e_content_list.json new file mode 100644 index 0000000000000000000000000000000000000000..9d3f1d0708ffa7ff553ef96c3a166c46ff9640db --- /dev/null +++ b/autoseglosssearchingmetricsurrogatesforsemanticsegmentation/2802d650-3a45-4a26-97d7-c37c1d6ee49e_content_list.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:93d27ff0e079a88798e11aac93b71bff9e6c506d682e2b63fe0fe5a7409795be +size 79211 diff --git a/autoseglosssearchingmetricsurrogatesforsemanticsegmentation/2802d650-3a45-4a26-97d7-c37c1d6ee49e_model.json b/autoseglosssearchingmetricsurrogatesforsemanticsegmentation/2802d650-3a45-4a26-97d7-c37c1d6ee49e_model.json new file mode 100644 index 0000000000000000000000000000000000000000..e4f3ae47e758ce6c2ea4957d6e3cea54b84db103 --- /dev/null +++ b/autoseglosssearchingmetricsurrogatesforsemanticsegmentation/2802d650-3a45-4a26-97d7-c37c1d6ee49e_model.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:394d1324a1e893457fc4a3a01cf3deec564f0279ed8fe0a6470321fc26d0c4f4 +size 94414 diff --git a/autoseglosssearchingmetricsurrogatesforsemanticsegmentation/2802d650-3a45-4a26-97d7-c37c1d6ee49e_origin.pdf b/autoseglosssearchingmetricsurrogatesforsemanticsegmentation/2802d650-3a45-4a26-97d7-c37c1d6ee49e_origin.pdf new file mode 100644 index 0000000000000000000000000000000000000000..b502062417def563eb848e5080e73764a48316e6 --- /dev/null +++ b/autoseglosssearchingmetricsurrogatesforsemanticsegmentation/2802d650-3a45-4a26-97d7-c37c1d6ee49e_origin.pdf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ef08494e796d6dab6efc56d326468a7ce54ee2feac99a1be8e00608ba5858c6f +size 1617393 diff --git a/autoseglosssearchingmetricsurrogatesforsemanticsegmentation/full.md b/autoseglosssearchingmetricsurrogatesforsemanticsegmentation/full.md new file mode 100644 index 0000000000000000000000000000000000000000..a8d5a3816c5fcf3ccb92909c5f7d3f735e975455 --- /dev/null +++ b/autoseglosssearchingmetricsurrogatesforsemanticsegmentation/full.md @@ -0,0 +1,331 @@ +# AUTO SEG-LOSS: SEARCHING METRIC SURROGATES FOR SEMANTIC SEGMENTATION + +Hao Li $^{1*†}$ , Chenxin Tao $^{2*†}$ , Xizhou Zhu $^{3}$ , Xiaogang Wang $^{1,3}$ , Gao Huang $^{2}$ , Jifeng Dai $^{3,4‡}$ + +1The Chinese University of Hong Kong 2Tsinghua University + +$^{3}$ SenseTime Research $^{4}$ Qing Yuan Research Institute, Shanghai Jiao Tong University + +haoli@link.cuhk.edu.hk, tcx20@mails.tsinghua.edu.cn + +{zhuwalter, daijifeng}@sensetime.com + +xgwang@ee.cuhk.edu.hk, gaohuang@tsinghua.edu.cn + +# ABSTRACT + +Designing proper loss functions is essential in training deep networks. Especially in the field of semantic segmentation, various evaluation metrics have been proposed for diverse scenarios. Despite the success of the widely adopted cross-entropy loss and its variants, the mis-alignment between the loss functions and evaluation metrics degrades the network performance. Meanwhile, manually designing loss functions for each specific metric requires expertise and significant manpower. In this paper, we propose to automate the design of metric-specific loss functions by searching differentiable surrogate losses for each metric. We substitute the non-differentiable operations in the metrics with parameterized functions, and conduct parameter search to optimize the shape of loss surfaces. Two constraints are introduced to regularize the search space and make the search efficient. Extensive experiments on PASCAL VOC and Cityscapes demonstrate that the searched surrogate losses outperform the manually designed loss functions consistently. The searched losses can generalize well to other datasets and networks. Code shall be released at https://github.com/fundamentalvision/ Auto-Seg-Loss. + +# 1 INTRODUCTION + +Loss functions are of indispensable components in training deep networks, as they drive the feature learning process for various applications with specific evaluation metrics. However, most metrics, like the commonly used 0-1 classification error, are non-differentiable in their original forms and cannot be directly optimized via gradient-based methods. Empirically, the cross-entropy loss serves well as an effective surrogate objective function for a variety of tasks concerning categorization. This phenomenon is especially prevailing in image semantic segmentation, where various evaluation metrics have been designed to address the diverse task focusing on different scenarios. Some metrics measure the accuracy on the whole image, while others focus more on the segmentation boundaries. Although cross-entropy and its variants work well for many metrics, the mis-alignment between network training and evaluation still exist and inevitably leads to performance degradation. + +Typically, there are two ways for designing metric-specific loss functions in semantic segmentation. The first is to modify the standard cross-entropy loss to meet the target metric (Ronneberger et al., 2015; Wu et al., 2016). The other is to design other clever surrogate losses for specific evaluation metrics (Rahman & Wang, 2016; Milletari et al., 2016). Despite the improvements, these handcrafted losses need expertise and are non-trivial to extend to other evaluation metrics. + +In contrast to designing loss functions manually, an alternative approach is to find a framework that can design proper loss functions for different evaluation metrics in an automated manner, motivated by recent progress in AutoML (Zoph & Le, 2017; Pham et al., 2018; Liu et al., 2018; Li et al., 2019). Although automating the design process for loss functions is attractive, it is non-trivial to apply an + +AutoML framework to loss functions. Typical AutoML algorithms require a proper search space, in which some search algorithms are conducted. Previous search spaces are either unsuitable for loss design, or too general to be searched efficiently. Recently Li et al. (2019) and Wang et al. (2020) proposed search spaces based on existing handcrafted loss functions. And the algorithm searches for the best combination. However, these search spaces are still limited to the variants of cross-entropy loss, and thus do not address the mis-alignment problem well. + +In this paper, we propose a general framework for searching surrogate losses for mainstream non-differentiable segmentation metrics. The key idea is that we can build the search space according to the form of evaluation metrics. In this way, the training criteria and evaluation metrics are unified. Meanwhile, the search space is compact enough for efficient search. Specifically, the metrics are first relaxed to the continuous domain by substituting the one-hot prediction and logical operations, which are the non-differentiable parts in most metrics, with their differentiable approximations. Parameterized functions are introduced to approximate the logical operations, ensuring that the loss surfaces are smooth while effective for training. The loss parameterization functions can be of arbitrary families defined on $[0,1]$ . Parameter search is further conducted on the chosen family so as to optimize the network performance on the validation set with the given evaluation metric. Two essential constraints are introduced to regularize the parameter search space. We find that the searched surrogate losses can effectively generalize to different networks and datasets. Extensive experiments on Pascal VOC (Everingham et al., 2015) and Cityscapes (Cordts et al., 2016) show our approach delivers accuracy superior than the existing losses specifically designed for individual segmentation metrics with a mild computational overhead. + +Our contributions can be summarized as follows: 1) Our approach is the first general framework of surrogate loss search for mainstream segmentation metrics. 2) We propose an effective parameter regularization and parameter search algorithm, which can find loss surrogates optimizing the target metric performance with mild computational overhead. 3) The surrogate losses obtained via the proposed searching framework promote our understandings on loss function design and by themselves are novel contributions, because they are different from existing loss functions specifically designed for individual metrics, and are transferable across different datasets and networks. + +# 2 RELATED WORK + +Loss function design is an active topic in deep network training (Ma, 2020). In the area of image semantic segmentation, cross-entropy loss is widely used (Ronneberger et al., 2015; Chen et al., 2018). But the cross-entropy loss is designed for optimizing the global accuracy measure (Rahman & Wang, 2016; Patel et al., 2020), which is not aligned with many other metrics. Numerous studies are conducted to design proper loss functions for the prevalent evaluation metrics. For the mIoU metric, many works (Ronneberger et al., 2015; Wu et al., 2016) incorporate class frequency to mitigate the class imbalance problem. For the boundary F1 score, the losses at boundary regions are up-weighted (Caliva et al., 2019; Qin et al., 2019), so as to deliver more accurate boundaries. These works carefully analyze the property of specific evaluation metrics, and design the loss functions in a fully handcrafted way, which needs expertise. By contrast, we propose a unified framework for deriving parameterized surrogate losses for various evaluation metrics. Wherein, the parameters are searched by reinforcement learning in an automatic way. The networks trained with the searched surrogate losses deliver accuracy on par or even superior than those with the best handcrafted losses. + +Direct loss optimization for non-differentiable evaluation metrics has long been studied for structural SVM models (Joachims, 2005; Yue et al., 2007; Ranjbar et al., 2012). However, the gradients w.r.t. features cannot be derived from these approaches. Therefore, they cannot drive the training of deep networks through back-propagation. Hazan et al. (2010) proposes to optimize structural SVM with gradient descent, where loss-augmented inference is applied to get the gradients of the expectation of evaluation metrics. Song et al. (2016) further extends this approach to non-linear models (e.g., deep neural networks). However, the computational complexity is very high during each step in gradient descent. Although Song et al. (2016) and Mohapatra et al. (2018) have designed efficient algorithms for the Average Precision (AP) metric, other metrics still need specially designed efficient algorithms. Our method, by contrast, is general for the mainstream segmentation metrics. Thanks to the good generalizability, our method only needs to perform the search process + +once for a specific metric, and the searched surrogate loss can be directly used henceforth. Applying the searched loss for training networks brings very little additional computational cost. + +Surrogate loss is introduced to derive loss gradients for the non-differentiable evaluation metrics. There are usually two ways for designing surrogate losses. The first is to handcraft an approximated differentiable metric function. For the IoU measure, Rahman & Wang (2016) propose to approximate the intersection and union separately using the softmax probabilities in a differentiable form, and show its effectiveness on binary segmentation tasks. Berman et al. (2018) further deal with multi-class segmentation problems by extending mIoU from binary inputs to the continuous domain with the convex Lovász extension, and their method outperforms standard cross entropy loss in multi-class segmentation tasks. For the F1 measure, dice loss is proposed by Milletari et al. (2016) as a direct objective by substituting the binary prediction with the softmax probability. In spite of the success, they do not apply for other metrics. + +The second solution is to train a network to approximate the target metric. Nagendar et al. (2018) train a network to approximate mIoU. Patel et al. (2020) design a neural network to learn embeddings for predictions and ground truths for tasks other than segmentation. This line of research focuses on minimizing the approximation error w.r.t. the target metrics. But there is no guarantee that their approximations provide good loss signals for training. These approximated losses are just employed in a post-tuning setup, still relying on cross-entropy pre-trained models. Our method significantly differs in that we search surrogate losses to directly optimize the evaluation metrics in applications. + +AutoML is a long-pursued target of machine learning (He et al., 2019). Recently a sub-field of AutoML, neural architecture search (NAS), has attracted much attention due to its success in automating the process of neural network architecture design (Zoph & Le, 2017; Pham et al., 2018; Liu et al., 2018). As an essential element, loss function has also raised the interest of researchers to automate its design process. Li et al. (2019) and Wang et al. (2020) design search spaces based on existing human-designed loss functions and search for the best combination parameters. There are two issues: a) the search process outputs whole network models rather than loss functions. For every new network or dataset, the expensive search procedure is conducted again, and b) the search space are filled with variants of cross-entropy, which cannot solve the mis-alignment between cross-entropy loss and many target metrics. By contrast, our method outputs the searched surrogate loss functions of close form with the target metrics, which are transferable between networks and datasets. + +# 3 REVISITING EVALUATION METRICS FOR SEMANTIC SEGMENTATION + +Various evaluation metrics are defined for semantic segmentation, to address the diverse task focusing on different scenarios. Most of them are of three typical classes: Acc-based, IoU-based, and F1-score-based. This section revisits the evaluation metrics, under a unified notation set. + +Table 1 summarizes the mainstream evaluation metrics. The notations are as follows: suppose the validation set is composed of $N$ images, labeled with categories from $C$ classes (background included). Let $I_{n}, n \in \{1, \ldots, N\}$ be the $n$ -th image, and $Y_{n}$ be the corresponding ground-truth segmentation mask. Here $Y_{n} = \{y_{n,c,h,w}\}_{c,h,w}$ is a one-hot vector, where $y_{n,c,h,w} \in \{0,1\}$ indicates whether the pixel at spatial location $(h,w)$ belongs to the $c$ -th category $(c \in \{1, \ldots, C\})$ . In evaluation, the ground-truth segmentation mask $Y_{n}$ is compared to the network prediction $\hat{Y}_{n} = \{\hat{y}_{n,c,h,w}\}_{c,h,w}$ , where $\hat{y}_{n,c,h,w} \in \{0,1\}$ . $\hat{y}_{n,c,h,w}$ is quantized from the continuous scores produced by the network (by argmax operation). + +Acc-based metrics. The global accuracy measure (gAcc) counts the number of pixels correctly classified. It can be written with logical operator AND as Eq. (1). The gAcc metric counts each pixel equally, so the results of the long-tailed categories have little impact on the metric number. The mean accuracy (mAcc) metric mitigates this by normalizing within each category as in Eq. (2). + +IoU-based metrics. The evaluation is on set similarity rather than pixel accuracy. The intersection-over-union (IoU) score is evaluated between the prediction and the ground-truth mask of each category. The mean IoU (mIoU) metric averages the IoU scores of all categories, as in Eq. (3). + +In the variants, the frequency weighted IoU (FWIoU) metric weighs each category IoU score by the category pixel number, as in Eq. (4). The boundary IoU (BIoU) (Kohli et al., 2009) metric only cares about the segmentation quality around the boundary, so it picks the boundary pixels out in evaluation + +Table 1: Revisiting mainstream metrics for semantic segmentation. The metrics with $\dagger$ measure the segmentation accuracy on the whole image. The metrics with * focus on the boundary quality. + +
TypeNameFormula
Acc-basedGlobal Accuracy†gAcc = ∑n,c,h,w帽子n,c,h,w AND yn,c,h,w / ∑n,c,h,w yn,c,h,w (1)
Mean Accuracy†mAcc = 1/C ∑c ∑n,h,w帽子n,c,h,w AND yn,c,h,w / ∑n,h,w yn,c,h,w (2)
IoU-basedMean IoU†mIoU = 1/C ∑c ∑n,h,w帽子n,c,h,w AND yn,c,h,w OR yn,c,h,w (3)
Frequency Weighted IoU†FWIoU = ∑c ∑n,h,w yn,c,h,w ∑n,h,w帽子n,c,h,w AND yn,c,h,w / ∑n,c,h,w yn,c,h,w OR yn,c,h,w (4)
Boundary IoU*BIoU = 1/C ∑c ∑n,h,w∈BD(yn)帽子n,c,h,w AND yn,c,h,w OR yn,c,h,w where BD(y) = y XOR Min-Pooling(y) (5)
F1-score-basedBoundary F1 Score*BF1-score = 1/C ∑c ∑n,h,w 2×precc×recallc / (precc + recallc) where precc = ∑n,h,w BD(ŷn)c,h,w AND Max-Pooling(BD(yn)c,h,w) / ∑n,h,w BD(ŷn)c,h,w recallc = ∑n,h,w Max-Pooling(BD(ŷn)c,h,w) AND(BD(yn)c,h,w) / ∑n,h,w BD(yn)c,h,w
+ +and ignores the rest pixels. It can be calculated with Eq. (5), in which $\mathrm{BD}(y_n)$ denotes the boundary region in map $y_{n}$ . $\mathrm{BD}(y_n)$ is derived by applying XOR operation on the min-pooled ground-truth mask. The stride of the Min-Pooling(·) is 1. + +F1-score-based metrics. F1-score is a criterion that takes both precision and recall into consideration. A well-known metric of this type is boundary F1-score (BF1-score) (Csurka et al., 2013), which is widely used for evaluating boundary segmentation accuracy. The computation of precision and recall in BF1-score is as in Eq. (6), where $\mathrm{BD}(\hat{y}_n)$ and $\mathrm{BD}(y_n)$ are derived from Eq. (5). Max pooling with stride 1, Max-Pooling( $\cdot$ ), is applied on the boundary regions to allow error tolerance. + +# 4 AUTO SEG-LOSS FRAMEWORK + +In the Auto Seg-Loss framework, the evaluation metrics are transferred into continuous surrogate losses with learnable parameters, which are further optimized. Fig. 1 illustrates our approach. + +# 4.1 EXTENDING METRICS TO SURROGATES + +As shown in Section 3, most segmentation metrics are non-differentiable because they take one-hot prediction maps as input, and contain binary logical operations. We extend these metrics to be continuous loss surrogates by smoothing the non-differentiable operations within. + +Extending One-hot Operation. The one-hot prediction map, $\hat{Y}_n = \{\hat{y}_{n,c,h,w}\}_{c,h,w}$ , is derived by picking the highest scoring category at each pixel, which is further turned into one-hot form. Here, we approximate the one-hot predictions with softmax probabilities, as, + +$$ +\hat {y} _ {n, c, h, w} \approx \widetilde {y} _ {n, c, h, w} = \operatorname {S o f t m a x} _ {c} \left(z _ {n, c, h, w}\right), \tag {7} +$$ + +where $z_{n,c,h,w} \in \mathbb{R}$ is the category score output by the network (without normalization). The approximated one-hot prediction is denoted by $\widetilde{y}_{n,c,h,w}$ . + +Extending Logical Operations. As shown in Table 1, the non-differentiable logical operations, $f_{\mathrm{AND}}(y_1,y_2)$ , $f_{\mathrm{OR}}(y_1,y_2)$ , and $f_{\mathrm{XOR}}(y_1,y_2)$ , are of indispensable components in these metrics. Because the XOR operation can be constructed by AND and OR, $f_{\mathrm{XOR}}(y_1,y_2) = f_{\mathrm{OR}}(y_1,y_2) - f_{\mathrm{AND}}(y_1,y_2)$ , we focus on extending $f_{\mathrm{AND}}(y_1,y_2)$ and $f_{\mathrm{OR}}(y_1,y_2)$ to the continuous domain. + +Following the common practice, the logical operators are substituted with arithmetic operators + +$$ +f _ {\mathrm {A N D}} \left(y _ {1}, y _ {2}\right) = y _ {1} y _ {2}, f _ {\mathrm {O R}} \left(y _ {1}, y _ {2}\right) = y _ {1} + y _ {2} - y _ {1} y _ {2}, \tag {8} +$$ + +![](images/25e19249d6ceb7421ca31dd1c272d96035bda398a7177633af5614070d0acf24.jpg) +Figure 1: Overview of the proposed Auto Seg-Loss framework. The surfaces of $h_{\mathrm{AND}}$ and $h_{\mathrm{OR}}$ shown in the "Optimal Parameterization" illustrate the searched optimal parameterization for mIoU, where $y_1, y_2 \in \{0,1\}$ . Eq. (8) can be directly extended to take continuous $y_1, y_2 \in [0,1]$ as inputs. By such an extension, together with the approximated one-hot operation, a naive version of differentiable surrogate losses can be obtained. The strength of such surrogates is that they are directly derived from the metrics, which significantly reduces the gap between training and evaluation. However, there is no guarantee that the loss surfaces formed by naively extending Eq. (8) provide accurate loss signals. To adjust the loss surfaces, we parameterize the AND and OR functions as + +$$ +\begin{array}{l} h _ {\text {A N D}} \left(y _ {1}, y _ {2}; \theta_ {\text {A N D}}\right) = g \left(y _ {1}; \theta_ {\text {A N D}}\right) g \left(y _ {2}; \theta_ {\text {A N D}}\right), \\ h _ {\text {O R}} \left(y _ {1}, y _ {2}; \theta_ {\text {O R}}\right) = g \left(y _ {1}; \theta_ {\text {O R}}\right) + g \left(y _ {2}; \theta_ {\text {O R}}\right) - g \left(y _ {1}; \theta_ {\text {O R}}\right), \tag {9} \\ \end{array} +$$ + +where $g(y;\theta):[0,1]\to \mathbb{R}$ is a scalar function parameterized by $\theta$ + +The parameterized function $g(y; \theta)$ can be from arbitrary function families defined on [0, 1], e.g., piecewise linear functions and piecewise Bézier curves. With a chosen function family, the parameters $\theta$ control the shape of loss surfaces. We seek to search for the optimal parameters $\theta$ so as to maximize the given evaluation metric. + +Meanwhile, optimal parameter search is non-trivial. With the introduced parameters, the plasticity of loss surfaces is strong. The parameterized loss surfaces may well be chaotic, or be far away from the target evaluation metric even at the binary inputs. For more effective parameter search, we regularize the loss surfaces by introducing two constraints on $g(y; \theta)$ . + +Truth-table constraint is introduced to enforce the surrogate loss surfaces taking the same values as the evaluation metric score at binary inputs. This is applied by enforcing + +$$ +g (0; \theta) = 0, g (1; \theta) = 1. \tag {10} +$$ + +Thus, the parameterized functions $h(y_1, y_2; \theta)$ preserve the behavior of the corresponding logical operations $f(y_1, y_2)$ on binary inputs $y_1, y_2 \in \{0, 1\}$ . + +Monotonicity constraint is introduced based on the observation of monotonicity tendency in the truth tables of AND and OR. It pushes the loss surfaces towards a benign landscape, avoiding dramatic non-smoothness. The monotonicity constraint is enforced on $h_{\mathrm{AND}}(y_1,y_2)$ and $h_{\mathrm{OR}}(y_1,y_2)$ , as + +$$ +\partial h _ {\text {A N D}} / \partial y _ {i} \geq 0, \partial h _ {\text {O R}} / \partial y _ {i} \geq 0, \forall y _ {i} \in [ 0, 1 ], i = 1, 2. +$$ + +Applying the chain rule and the truth table constraint, the monotonicity constraint implies + +$$ +\partial g (y; \theta) / \partial y \geq 0, \forall y \in [ 0, 1 ]. \tag {11} +$$ + +Empirically we find it important to enforce these two constraints in parameterization. + +Extending Evaluation Metrics. Now we can extend the metrics to surrogate losses by a) replacing the one-hot predictions with softmax probabilities, and b) substituting the logical operations with parameterized functions. Note that if the metric contains several logical operations, their parameters will not be shared. The collection of parameters in one metric are denoted as $\Theta$ . For a segmentation network N and evaluation dataset $S$ , the score of the evaluation metric is denoted as $\xi(N; S)$ . And the parameterized surrogate loss is denoted as $\widetilde{\xi}_{\Theta}(N; S)$ . + +# 4.2 SURROGATE PARAMETERIZATION + +The parameterized function can be from any function families defined on $[0, 1]$ , such as piecewise Bézier curve and piecewise linear functions. Here we choose the piecewise Bézier curve for parameterizing $g(y; \theta)$ , which is widely used in computer graphics and is easy to enforce the constraints via its control points. We also verify the effectiveness of parameterizing $g(y; \theta)$ by piecewise linear functions. See Fig. 2 for visualization and Appendix B for more details. + +A piecewise Bézier curve consists of a series of quadratic Bézier curves, where the last control point of one curve segment coincides with the first control point of the next curve segment. If there are $n$ segments in a piecewise Bézier curve, the $k$ -th segment is defined as + +$$ +B (k, s) = (1 - s) ^ {2} B _ {2 k} + 2 s (1 - s) B _ {2 k + 1} + s ^ {2} B _ {2 k + 2}, 0 \leq s \leq 1 \tag {12} +$$ + +where $s$ transverses the $k$ -th segment, $B_{2k + i} = (B_{(2k + i),u}, B_{(2k + i),v})$ $(i = 0,1,2)$ denotes the $i$ -th control point on the $k$ -th segment, in which $u, v$ index the 2-d plane axes. A piecewise Bézier curve with $n$ segments has $2n + 1$ control points in total. To parameterize $g(y;\theta)$ , we assign + +$$ +y = (1 - s) ^ {2} B _ {2 k, u} + 2 s (1 - s) B _ {(2 k + 1), u} + s ^ {2} B _ {(2 k + 2), u}, \tag {13a} +$$ + +$$ +g (y; \theta) = (1 - s) ^ {2} B _ {2 k, v} + 2 s (1 - s) B _ {(2 k + 1), v} + s ^ {2} B _ {(2 k + 2), v}, \tag {13b} +$$ + +$$ +\text {s . t .} B _ {2 k, u} \leq y \leq B _ {(2 k + 2), u}, \tag {13c} +$$ + +where $\theta$ is the control point set, $B_{2k,u} < B_{(2k + 1),u} < B_{(2k + 2),u}$ , $0 \leq k \leq n - 1$ . Given an input $y$ , the segment index $k$ and the transversal parameter $s$ are derived from Eq. (13c) and Eq. (13a), respectively. Then $g(y;\theta)$ is assigned as Eq. (13b). Because $g(y;\theta)$ is defined on $y \in [0,1]$ , we arrange the control points in the $u$ -axis as, $B_{0,u} = 0$ , $B_{2n,u} = 1$ , where the $u$ -coordinate of the first and the last control points are at 0 and 1, respectively. + +The strength of the piecewise Bézier curve is that the curve shape is defined explicitly via the control points. Here we enforce the truth-table and the monotonicity constraints on the control points via, + +$$ +B _ {0, v} = 0, B _ {2 n, v} = 1; +$$ + +$$ +(\text {t r u t h - t a b l e c o n s t r a i n t}) +$$ + +$$ +B _ {2 k, v} \leq B _ {(2 k + 1), v} \leq B _ {(2 k + 2), v}, \quad k = 0, 1, \dots , n - 1. +$$ + +$$ +(m o n o t o n i c i t y c o n s t r a i n t) +$$ + +To fulfill the above restrictions in optimization, the specific form of the parameters is given by + +$$ +\theta = \left\{\left(\frac {B _ {i , u} - B _ {(i - 1) , u}}{B _ {2 n , u} - B _ {(i - 1) , u}}, \frac {B _ {i , v} - B _ {(i - 1) , v}}{B _ {2 n , v} - B _ {(i - 1) , v}}\right) \mid i = 1, 2, \dots , 2 n - 1 \right\}, +$$ + +with $B_0 = (0,0)$ and $B_{2n} = (1,1)$ fixed. So every $\theta_i = (\theta_{i,u},\theta_{i,v})$ is in range $[0,1]^2$ and it is straightforward to compute the actual coordinates of control points from this parameterized form. Such parameterization makes each $\theta_i$ independent with each other, and thus simplifies the optimization. By default, we use piecewise Bézier curve with two segments to parameterize $g(y,\theta)$ . + +![](images/3d25b312b95e80952a99bf9722996f38b211fd68712a98a9220c7dcdfc33daa0.jpg) +Figure 2: Parameterization of $g(y;\theta)$ using Piecewise Bézier curve with four segments. The red points are control points. The purple point is on the curve, which shows the relationship among $y$ , $g(y;\theta)$ and the transversal parameter $s$ . + +# Algorithm 1: Auto Seg-Loss Parameter Search + +Input: Initialized network $\mathrm{N}_{\omega_0}$ , initialized distribution $\mu_{1}$ and $\sigma^2$ , target metric $\xi$ , training set $S_{train}$ and hold-out training set $S_{hold - out}$ + +Result: Obtained optimal parameters $\Theta^{*}$ + +for $t = 1$ to $T$ do + +for $i = 1$ to $M$ do + +Sample parameter $\Theta_{i}^{(t)}\sim \mathcal{N}_{\mathrm{trunc}[0,1]}(\mu_t,\sigma^2 I)$ Network training + +$\omega^{*}(\Theta_{i}^{(t)}) = \arg \max_{\omega}\tilde{\xi}_{\Theta^{(t)}}(\mathrm{N}_{\omega};\mathcal{S}_{\mathrm{train}}),$ + +with $w$ initialized from $w_{0}$ + +Compute the evaluation metric score + +$$ +\xi (\Theta_ {i} ^ {(t)}) = \xi (N _ {\omega^ {*} (\Theta_ {i} ^ {(t)})}; S _ {\text {h o l d - o u t}}); +$$ + +end + +Update $\mu_{t + 1} = \arg \max_{\mu}\frac{1}{M}\sum_{i = 1}^{M}R(\mu ,\mu_{t},\Theta_{i}^{(t)})$ + +end + +return $\Theta^{*} = \arg \max_{\mu_t}\sum_{i = 1}^M\xi (\Theta_i^{(t)}),\forall t = 1,\ldots ,T + 1$ + +# 4.3 SURROGATE PARAMETER OPTIMIZATION + +Algorithm 1 describes our parameter search algorithm. The training set is split into two subsets, $S_{\text{train}}$ for training and $S_{\text{hold-out}}$ for evaluation in the search algorithm, respectively. Specifically, suppose we have a segmentation network $N_{\omega}$ with weights $\omega$ , our search target is the parameters that maximize the evaluation metric on the hold-out training set $\xi(N_{\omega}; S_{\text{hold-out}})$ . + +$$ +\max _ {\Theta} \xi (\Theta) = \xi \left(\mathrm {N} _ {\omega^ {*} (\Theta)}; \mathcal {S} _ {\text {h o l d - o u t}}\right), \quad \text {s . t .} \quad \omega^ {*} (\Theta) = \underset {\omega} {\arg \max } \widetilde {\xi_ {\Theta}} \left(\mathrm {N} _ {\omega}; \mathcal {S} _ {\text {t r a i n}}\right). \tag {14} +$$ + +To optimize Eq. (14), the segmentation network is trained with SGD as the inner-level problem. At the outer-level, we use reinforcement learning as our searching algorithm, following the common practice in AutoML (Zoph & Le, 2017; Pham et al., 2018). Other searching algorithms, such as evolutionary algorithm, may also be employed. Specifically, the surrogate parameters are searched via the PPO2 algorithm (Schulman et al., 2017). The process consists of $T$ sampling steps. In the $t$ -th step, we aim to explore the search space around that from $t - 1$ . Here $M$ sets of parameters $\{\Theta_i^{(t)}\}_{i = 1}^M$ are sampled independently from a truncated normal distribution (Burkardt, 2014), as $\Theta \sim \mathcal{N}_{\mathrm{trunc}[0,1]}(\mu_t,\sigma^2 I)$ , with each variable in range [0,1]. In it, $\mu_t$ and $\sigma^2 I$ denote the mean and covariance of the parent normal distribution ( $\sigma$ is fixed as 0.2 in this paper). $\mu_t$ summarizes the information from the $(t - 1)$ -th step. $M$ surrogate losses are constructed with the sampled parameters, which drive the training of $M$ segmentation networks separately. To optimize the outer-level problem, we evaluate these models with the target metric and take the evaluation scores as rewards for PPO2. Following the PPO2 algorithm, $\mu_{t + 1}$ is computed as $\mu_{t + 1} = \arg \max_{\mu}\frac{1}{M}\sum_{i = 1}^{M}R(\mu ,\mu_{t},\Theta_{i})$ , where the reward $R(\mu ,\mu_t,\Theta_i)$ is as + +$$ +R (\mu , \mu_ {t}, \Theta_ {i}) = \min \left(\frac {p (\Theta_ {i} ; \mu , \sigma^ {2} I)}{p (\Theta_ {i} ; \mu_ {t} , \sigma^ {2} I)} \xi (\Theta_ {i}), \mathrm {C L I P} \left(\frac {p (\Theta_ {i} ; \mu , \sigma^ {2} I)}{p (\Theta_ {i} ; \mu_ {t} , \sigma^ {2} I)}, 1 - \epsilon , 1 + \epsilon\right) \xi (\Theta_ {i})\right), +$$ + +where $\min (\cdot ,\cdot)$ picks the smaller item from its inputs, $\mathrm{CLIP}(x,1 - \epsilon ,1 + \epsilon)$ clips $x$ to be within $1 - \epsilon$ and $1 + \epsilon$ , and $p(\Theta_i;\mu ,\sigma^2 I)$ is the PDF of the truncated normal distribution. Note that the mean reward of the $M$ samples is subtracted when computing $\xi (\Theta_{i})$ for better convergence. After $T$ steps, the mean $\mu_t$ with the highest average evaluation score is output as the final parameters $\Theta^{*}$ . + +Empirically we find the searched losses have good transferability, i.e., they can be applied for different datasets and networks. Benefiting from this, we use a light proxy task for parameter search. In it, we utilize a smaller image size, a shorter learning schedule and a lightweight network. Thus, the whole search process is quite efficient (8 hours on PASCAL VOC with 8 NVIDIA Tesla V100 GPUs). More details are in Appendix A. In addition, the search process can be conducted only once for a specific metric and the resulting surrogate loss can be directly used for training henceforth. + +# 5 EXPERIMENTS + +We evaluate on the PASCAL VOC 2012 (Everingham et al., 2015) and the Cityscapes (Cordts et al., 2016) datasets. We use Deeplabv3+ (Chen et al., 2018) with ResNet-50/101 (He et al., 2016) as the network model. During the surrogate parameter search, we randomly sample 1500 training images in PASCAL VOC and 500 training images in Cityscapes to form the hold-out set $S_{\mathrm{hold - out}}$ , respectively. The remaining training images form the training set $S_{\mathrm{train}}$ in search. $\mu_0$ is set to make $g(y;\theta) = y$ . The backbone network is ResNet-50. The images are down-sampled to be of $128\times 128$ resolution. SGD lasts only 1000 iterations with a mini-batch size of 32. After the search procedure, we re-train the segmentation networks with ResNet-101 using the searched losses on the full training set and evaluate them on the actual validation set. The re-train settings are the same as Deeplabv3+ (Chen et al., 2018), except that the loss function is substituted by the obtained surrogate loss. The search time is counted on 8 NVIDIA Tesla V100 GPUs. More details are in Appendix A. + +# 5.1 SEARCHING FOR DIFFERENT METRICS + +In Table 2, we compare our searched surrogate losses against the widely-used cross-entropy loss and its variants, and some other metric-specific surrogate losses. We also seek to compare with the AutoML-based method in Li et al. (2019), which was originally designed for other tasks. But we cannot get reasonable results due to convergence issues. The results show that our searched losses + +are on par or better the previous losses on their target metrics. It is interesting to note that the obtained surrogates for boundary metrics (such as BIoU and BF1) only focus on the boundary areas, see Appendix C for further discussion. We also tried training segmentation networks driven by both searched mIoU and BIoU/BF1 surrogate losses. Such combined losses refine the boundaries while keeping reasonable global performance. + +Table 2: Performance of different losses on PASCAL VOC and Cityscapes segmentation. The results of each loss function's target metrics are underlined. The scores whose difference with the highest is less than 0.3 are marked in bold. + +
DatasetPASCAL VOCCityscapes
Loss FunctionmIoUFWIoUBIoUBF1mAccgAccmIoUFWIoUBIoUBF1mAccgAcc
Cross Entropy78.6991.3170.6165.3087.3195.1779.9793.3362.0762.2487.0196.44
WCE (Ronneberger et al., 2015)69.6085.6461.8037.5992.6191.1173.0190.5153.0751.1989.2294.56
DPCE (Caliva et al., 2019)79.8291.7671.8766.5487.7695.4580.2793.3862.5765.9986.9996.46
SSIM (Qin et al., 2019)79.2691.6871.5466.3587.8795.3880.6593.2263.0472.2086.8896.39
DiceLoss (Milletari et al., 2016)77.7891.3469.8564.3887.4795.1179.3093.2560.9359.9486.3896.39
Lovasz (Berman et al., 2018)79.7291.7872.4766.6588.6495.4277.6792.5156.7153.4882.0596.03
Searched mIoU80.9792.0973.4468.8688.2395.6880.6793.3063.0567.9787.2096.44
Searched FWIoU80.0091.9375.1465.6789.2395.4479.4293.3361.7159.6887.9696.37
Searched BIoU48.9769.8979.2738.9981.2862.6445.8939.8063.8938.2962.8058.15
Searched BF11.930.967.3974.836.512.666.783.1918.3777.4012.098.19
Searched mAcc69.8085.8672.8535.6292.6691.2874.1090.7954.6253.4589.2294.75
Searched gAcc79.7391.7674.0964.4188.9595.4779.4193.3061.6562.0487.0896.51
Searched mIoU + BIoU81.1992.1976.8969.5688.3695.7580.4393.3463.8865.8787.0396.45
Searched mIoU + BF178.7290.8071.8173.5786.7094.8878.3093.0061.6271.7387.1396.23
+ +# 5.2 GENERALIZATION OF THE LOSS + +Generalization among datasets. Table 3 evaluates the generalization ability of our searched loss surrogates among different datasets. Due to limited computational resource, we train networks only with the searched mIoU, BF1 and mAcc surrogate losses. The results show that our searched surrogate losses generalize well between these two datasets with quite different scenes and categories. + +Table 3: Generalization of our searched surrogate losses between PASCAL VOC and Cityscapes. + +
DatasetsCityscapes → VOCVOC → Cityscapes
Loss FunctionmIoUFWIoUBIoUBF1mAccgAccmIoUFWIoUBIoUBF1mAccgAcc
Cross Entropy78.6991.3170.6165.3087.3195.1779.9793.3362.0762.2487.0196.44
Searched mIoU80.0591.7273.9767.6188.0195.4580.6793.3162.9666.4887.3696.44
Searched BF11.840.937.4275.856.481.476.673.2019.0077.9912.124.09
Searched mAcc70.9086.2973.4337.1893.1991.4373.5090.6854.3454.0488.6694.68
+ +Generalization among segmentation networks. The surrogate losses are searched with ResNet-50 + DeepLabv3+ on PASCAL VOC. The searched losses drive the training of ResNet-101 + DeepLabv3+, PSPNet (Zhao et al., 2017) and HRNet (Sun et al., 2019) on PASCAL VOC. Table 4 shows the results. The results demonstrate that our searched loss functions can be applied to various semantic segmentation networks. + +# 5.3 ABLATION + +Parameterization and constraints. Table 5 ablates the parameterization and the search space constraints. In it, a surrogate without parameters refers to Eq. (8), with the domain extended from discrete points $\{0,1\}$ to continuous interval [0, 1]. This naive surrogate delivers much lower accuracy, indicating the essence of parameterization. Without the truth-table constraint, the training process diverges at the very beginning, where the loss gradients become "NaN". And the performance drops if the monotonicity constraint is not enforced. The performance drops or even the algorithm fails without the constraints. + +Table 4: Generalization of our searched surrogate losses among different network architectures on PASCAL VOC. The losses are searched with ResNet-50 + DeepLabv3+ on PASCAL VOC. + +
NetworkR50-DeepLabv3+R101-DeepLabv3+R101-PSPNetHRNetV2p-W48
Loss FunctionmIoUBF1mAccmIoUBF1mAccmIoUBF1mAccmIoUBF1mAcc
Cross Entropy76.2261.7585.4378.6965.3087.3177.9164.7085.7176.3561.1985.12
Searched mIoU78.3566.9385.5380.9768.8688.2378.9365.6587.4277.2663.5286.80
Searched BF11.3570.816.051.9374.836.511.6271.846.331.3468.415.99
Searched mAcc69.8236.9291.6169.8035.6292.6671.6639.4492.0668.2235.9091.46
+ +Proxy tasks for parameter search. Table 6 ablates this. The bottom row is our default setting with a light-weight backbone, down-sampled image size and shorter learning schedule. The default setting delivers on par accuracy with heavier settings. This is consistent with the generalization ability of our surrogate losses. Thus we can improve the search efficiency via light proxy tasks. + +Parameter search algorithm. Fig. 3 compares the employed PPO2 (Schulman et al., 2017) algorithm with random search. The much better performance of PPO2 suggests that surrogate loss search is non-trivial and reinforcement learning helps to improve the search efficiency. + +Table 5: Ablation on search space constraints. + +
ParameterTruth-tableMonotonicityVOC mIoU
XXX46.99
XXFail
X77.76
80.64
+ +Table 6: Ablation on search proxy tasks. + +
BackboneImage SizeIterationsTime(hours)VOC mIoU
R50256 × 256100033.081.15
R50128 × 128200017.180.56
R101128 × 128100013.380.75
R50128 × 12810008.580.97
+ +![](images/4338645f8798a7738d15eb89afa95a1054de459edae7d95eb6a535c284577856.jpg) +(a) search for mIoU + +![](images/55b6a81260edb784928469c912377827d9353c723ef4643360b5e4cbc9176e31.jpg) +(b) search for BF1 + +![](images/6d94ad2cf19964fdea0c57e53888ed4cee533f02b89db8e5e118974c90d759af.jpg) +(c) search for mAcc +Figure 3: Ablation on loss parameter search. Each curve presents the highest average evaluation score up to the $t$ -th step in one search process. The search process is repeated four times. + +# 6 CONCLUSION + +The introduced Auto Seg-Loss is a powerful framework to search for the parameterized surrogate losses for mainstream segmentation evaluation metrics. The non-differentiable operators are substituted by their parameterized continuous counterparts. The parameters are optimized to improve the final evaluation metrics with essential constraints. It would be interesting to extend the framework to more tasks, like object detection, pose estimation and machine translation problems. + +# ACKNOWLEDGMENTS + +The work is supported by the National Key R&D Program of China (2020AAA0105200), Beijing Academy of Artificial Intelligence and the Institute for Guo Qiang of Tsinghua University. + +# REFERENCES + +Maxim Berman, Amal Rannen Triki, and Matthew B Blaschko. The lovasz-softmax loss: A tractable surrogate for the optimization of the intersection-over-union measure in neural networks. In Pro + +ceedings of IEEE Conference on Computer Vision and Pattern Recognition (CVPR), pp. 4413-4421, 2018. +John Burkardt. The truncated normal distribution. Department of Scientific Computing Website, Florida State University, pp. 1-35, 2014. +Francesco Caliva, Claudia Iriondo, Alejandro Morales Martinez, Sharmila Majumdar, and Valentina Pedoia. Distance map loss penalty term for semantic segmentation. In International Conference on Medical Imaging with Deep Learning-Extended Abstract Track, 2019. +Liang-Chieh Chen, George Papandreou, Iasonas Kokkinos, Kevin Murphy, and Alan L Yuille. Deep plab: Semantic image segmentation with deep convolutional nets, atrous convolution, and fully connected crfs. IEEE Transactions on Pattern Analysis and Machine Intelligence, 40(4): 834-848, 2017. +Liang-Chieh Chen, Yukun Zhu, George Papandreou, Florian Schroff, and Hartwig Adam. Encoder-decoder with atrous separable convolution for semantic image segmentation. In Proceedings of the European Conference on Computer Vision (ECCV), pp. 801-818, 2018. +Marius Cordts, Mohamed Omran, Sebastian Ramos, Timo Rehfeld, Markus Enzweiler, Rodrigo Benenson, Uwe Franke, Stefan Roth, and Bernt Schiele. The cityscapes dataset for semantic urban scene understanding. In Proceedings of IEEE Conference on Computer Vision and Pattern Recognition (CVPR), pp. 3213-3223, 2016. +Gabriela Csurka, Diane Larlus, Florent Perronnin, and France Meylan. What is a good evaluation measure for semantic segmentation? In Proceedings of the British Machine Vision Conference (BMVC), volume 27, pp. 2013, 2013. +Mark Everingham, SM Ali Eslami, Luc Van Gool, Christopher KI Williams, John Winn, and Andrew Zisserman. The Pascal visual object classes challenge: A retrospective. International Journal of Computer Vision, 111(1):98-136, 2015. +Bharath Hariharan, Pablo Arbeláez, Lubomir Bourdev, Subhransu Maji, and Jitendra Malik. Semantic contours from inverse detectors. In Proceedings of IEEE International Conference on Computer Vision (ICCV), pp. 991-998, 2011. +Tamir Hazan, Joseph Keshet, and David A McAllester. Direct loss minimization for structured prediction. In Advances in Neural Information Processing Systems (NIPS), pp. 1594-1602, 2010. +Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Deep residual learning for image recognition. In Proceedings of IEEE Conference on Computer Vision and Pattern Recognition (CVPR), pp. 770-778, 2016. +Xin He, Kaiyong Zhao, and Xiaowen Chu. Automl: A survey of the state-of-the-art. arXiv preprint arXiv:1908.00709, 2019. +Thorsten Joachims. A support vector method for multivariate performance measures. In Proceedings of the 22nd International Conference on Machine Learning (ICML), pp. 377-384. PMLR, 2005. +Pushmeet Kohli, Philip HS Torr, et al. Robust higher order potentials for enforcing label consistency. International Journal of Computer Vision, 82(3):302-324, 2009. +Chuming Li, Xin Yuan, Chen Lin, Minghao Guo, Wei Wu, Junjie Yan, and Wanli Ouyang. Am-lds: Automl for loss function search. In Proceedings of the IEEE International Conference on Computer Vision (CVPR), pp. 8410-8419, 2019. +Hanxiao Liu, Karen Simonyan, and Yiming Yang. Darts: Differentiable architecture search. In Proceedings of the 6th International Conference on Learning Representations (ICLR), 2018. +Jun Ma. Segmentation loss odyssey. arXiv preprint arXiv:2005.13449, 2020. +Fausto Miletari, Nassir Navab, and Seyed-Ahmad Ahmadi. V-net: Fully convolutional neural networks for volumetric medical image segmentation. In 2016 Fourth International Conference on 3D Vision (3DV), pp. 565-571. IEEE, 2016. + +Pritish Mohapatra, Michal Rolinek, CV Jawahar, Vladimir Kolmogorov, and M Pawan Kumar. Efficient optimization for rank-based loss functions. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition (CVPR), pp. 3693-3701, 2018. +Gattigorla Nagendar, Digvijay Singh, Vineeth N Balasubramanian, and CV Jawahar. Neuro-iou: Learning a surrogate loss for semantic segmentation. In Proceedings of the British Machine Vision Conference (BMVC), pp. 278, 2018. +Yash Patel, Tomas Hodan, and Jiri Matas. Learning surrogates via deep embedding. In Proceedings of the European Conference on Computer Vision (ECCV), 2020. +Hieu Pham, Melody Guan, Barret Zoph, Quoc Le, and Jeff Dean. Efficient neural architecture search via parameters sharing. In Proceedings of the 35th International Conference on Machine Learning (ICML), pp. 4095-4104. PMLR, 2018. +Xuebin Qin, Zichen Zhang, Chenyang Huang, Chao Gao, Masood Dehghan, and Martin Jagersand. Basnet: Boundary-aware salient object detection. In Proceedings of IEEE Conference on Computer Vision and Pattern Recognition (CVPR), pp. 7479-7489, 2019. +Md Atiqur Rahman and Yang Wang. Optimizing intersection-over-union in deep neural networks for image segmentation. In International Symposium on Visual Computing, pp. 234–244. Springer, 2016. +Mani Ranjbar, Tian Lan, Yang Wang, Steven N Robinovitch, Ze-Nian Li, and Greg Mori. Optimizing nondecomposable loss functions in structured prediction. IEEE Transactions on Pattern Analysis and Machine Intelligence, 35(4):911-924, 2012. +Olaf Ronneberger, Philipp Fischer, and Thomas Brox. U-net: Convolutional networks for biomedical image segmentation. In International Conference on Medical Image Computing and Computer-Assisted Intervention, pp. 234-241. Springer, 2015. +John Schulman, Filip Wolski, Prafulla Dhariwal, Alec Radford, and Oleg Klimov. Proximal policy optimization algorithms. arXiv preprint arXiv:1707.06347, 2017. +Yang Song, Alexander Schwing, Raquel Urtasun, et al. Training deep neural networks via direct loss minimization. In Proceedings of the 33rd International Conference on Machine Learning (ICML), pp. 2169-2177. PMLR, 2016. +Ke Sun, Bin Xiao, Dong Liu, and Jingdong Wang. Deep high-resolution representation learning for human pose estimation. In Proceedings of IEEE Conference on Computer Vision and Pattern Recognition (CVPR), pp. 5693-5703, 2019. +Xiaobo Wang, Shuo Wang, Cheng Chi, Shifeng Zhang, and Tao Mei. Loss function search for face recognition. In Proceedings of the 37th International Conference on Machine Learning (ICML). PMLR, 2020. +Zifeng Wu, Chunhua Shen, and Anton van den Hengel. Bridging category-level and instance-level semantic image segmentation. arXiv preprint arXiv:1605.06885, 2016. +Yisong Yue, Thomas Finley, Filip Radlinski, and Thorsten Joachims. A support vector method for optimizing average precision. In Proceedings of the 30th Annual International ACM SIGIR Conference on Research and Development in Information Retrieval, pp. 271-278, 2007. +Hengshuang Zhao, Jianping Shi, Xiaojuan Qi, Xiaogang Wang, and Jiaya Jia. Pyramid scene parsing network. In Proceedings of IEEE Conference on Computer Vision and Pattern Recognition (CVPR), pp. 2881-2890, 2017. +Barret Zoph and Quoc V. Le. Neural architecture search with reinforcement learning. In Proceedings of the 5th International Conference on Learning Representations (ICLR), 2017. \ No newline at end of file diff --git a/autoseglosssearchingmetricsurrogatesforsemanticsegmentation/images.zip b/autoseglosssearchingmetricsurrogatesforsemanticsegmentation/images.zip new file mode 100644 index 0000000000000000000000000000000000000000..9249bc0036bf7a7ce32ea5c9b889bb9f38c42393 --- /dev/null +++ b/autoseglosssearchingmetricsurrogatesforsemanticsegmentation/images.zip @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:14bb63f8102209ad6da0b89342f2091471e04e3cf928787963cdb5f2bd90b1e6 +size 624841 diff --git a/autoseglosssearchingmetricsurrogatesforsemanticsegmentation/layout.json b/autoseglosssearchingmetricsurrogatesforsemanticsegmentation/layout.json new file mode 100644 index 0000000000000000000000000000000000000000..104bcac5b0ffb3c489dc2aa689420dc1cd993824 --- /dev/null +++ b/autoseglosssearchingmetricsurrogatesforsemanticsegmentation/layout.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c6637bcb8f9aa87822dc5abe925b34828651d5adc4361f70042560ceb6b96a01 +size 420522 diff --git a/auxiliarylearningbyimplicitdifferentiation/ec102424-6e52-4b06-9cc2-c97f7dd83d6e_content_list.json b/auxiliarylearningbyimplicitdifferentiation/ec102424-6e52-4b06-9cc2-c97f7dd83d6e_content_list.json new file mode 100644 index 0000000000000000000000000000000000000000..c5b5cc0c3092342788cbe4509d5667a5f9c06406 --- /dev/null +++ b/auxiliarylearningbyimplicitdifferentiation/ec102424-6e52-4b06-9cc2-c97f7dd83d6e_content_list.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c930221afa118f682d0a6926bb172b9f42682db9e8b9b5b83827931500f0aa97 +size 131018 diff --git a/auxiliarylearningbyimplicitdifferentiation/ec102424-6e52-4b06-9cc2-c97f7dd83d6e_model.json b/auxiliarylearningbyimplicitdifferentiation/ec102424-6e52-4b06-9cc2-c97f7dd83d6e_model.json new file mode 100644 index 0000000000000000000000000000000000000000..96817aaed70b41e33025114f9eb892a41e137a6c --- /dev/null +++ b/auxiliarylearningbyimplicitdifferentiation/ec102424-6e52-4b06-9cc2-c97f7dd83d6e_model.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5ac390d16a51a820b71dfd2fe2cb2483f093b252b39ccd59293c3c17598953a7 +size 157736 diff --git a/auxiliarylearningbyimplicitdifferentiation/ec102424-6e52-4b06-9cc2-c97f7dd83d6e_origin.pdf b/auxiliarylearningbyimplicitdifferentiation/ec102424-6e52-4b06-9cc2-c97f7dd83d6e_origin.pdf new file mode 100644 index 0000000000000000000000000000000000000000..46de0908ffd27963815bcc3ae1787585dab7d778 --- /dev/null +++ b/auxiliarylearningbyimplicitdifferentiation/ec102424-6e52-4b06-9cc2-c97f7dd83d6e_origin.pdf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1b73fc4ce83f0bc7e29b3da0d6ccf46cd268b169ec5660e0120b13df9aa35611 +size 4529694 diff --git a/auxiliarylearningbyimplicitdifferentiation/full.md b/auxiliarylearningbyimplicitdifferentiation/full.md new file mode 100644 index 0000000000000000000000000000000000000000..11276b19d634b81eec721a78e1303bd959de9ce6 --- /dev/null +++ b/auxiliarylearningbyimplicitdifferentiation/full.md @@ -0,0 +1,497 @@ +# AUXILIARY LEARNING BY IMPLICIT DIFFERENTIATION + +Aviv Navon* + +Bar-Ilan University, Israel + +aviv.navon@biu.ac.il + +Idan Achituve* + +Bar-Ilan University, Israel + +idan.achituve@biu.ac.il + +Haggai Maron + +NVIDIA, Israel + +hmaron@nvidia.com + +Gal Chechik† + +Bar-Ilan University, Israel + +NVIDIA, Israel + +gal.checkik@biu.ac.il + +Ethan Fetaya† + +Bar-Ilan University, Israel + +ethan.fetaya@biu.ac.il + +# ABSTRACT + +Training neural networks with auxiliary tasks is a common practice for improving the performance on a main task of interest. Two main challenges arise in this multi-task learning setting: (i) designing useful auxiliary tasks; and (ii) combining auxiliary tasks into a single coherent loss. Here, we propose a novel framework, AuxiLearn, that targets both challenges based on implicit differentiation. First, when useful auxiliaries are known, we propose learning a network that combines all losses into a single coherent objective function. This network can learn nonlinear interactions between tasks. Second, when no useful auxiliary task is known, we describe how to learn a network that generates a meaningful, novel auxiliary task. We evaluate AuxiLearn in a series of tasks and domains, including image segmentation and learning with attributes in the low data regime, and find that it consistently outperforms competing methods. + +# 1 INTRODUCTION + +The performance of deep neural networks can significantly improve by training the main task of interest with additional auxiliary tasks (Goyal et al., 2019; Jaderberg et al., 2016; Mirowski, 2019). For example, learning to segment an image into objects can be more accurate when the model is simultaneously trained to predict other properties of the image like pixel depth or 3D structure (Standley et al., 2019). In the low data regime, models trained with the main task only are prone to overfit and generalize poorly to unseen data (Vinyals et al., 2016). In this case, the benefits of learning with multiple tasks are amplified (Zhang and Yang, 2017). Training with auxiliary tasks adds an inductive bias that pushes learned models to capture meaningful representations and avoid overfitting to spurious correlations. + +In some domains, it may be easy to design beneficial auxiliary tasks and collect supervised data. For example, numerous tasks were proposed for self-supervised learning in image classification, including masking (Doersch et al., 2015), rotation (Gidaris et al., 2018) and patch shuffling (Doersch and Zisserman, 2017; Noroozi and Favaro, 2016). In these cases, it is not clear what would be the best way to combine all auxiliary tasks into a single loss (Doersch and Zisserman, 2017). The common practice is to compute a weighted combination of pretext losses by tuning the weights of individual losses using hyperparameter grid search. This approach, however, limits the potential of learning with auxiliary tasks because the run time of grid search grows exponentially with the number of tasks. + +In other domains, obtaining good auxiliaries in the first place may be challenging or may require expert knowledge. For example, for point cloud classification, few self-supervised tasks have been proposed; however, their benefits so far are limited (Achituve et al., 2020; Hassani and Haley, 2019; + +Sauder and Sievers, 2019; Tang et al., 2020). For these cases, it would be beneficial to automate the process of generating auxiliary tasks without domain expertise. + +Our work takes a step forward in automating the use and design of auxiliary learning tasks. We name our approach AuxiLearn. AuxiLearn leverages recent progress made in implicit differentiation for optimizing hyperparameters (Liao et al., 2018; Lorraine et al., 2020). We demonstrate the effectiveness of AuxiLearn in two types of problems. First, in combining auxiliaries, for cases where auxiliary tasks are predefined. We describe how to train a deep neural network (NN) on top of auxiliary losses and combine them non-linearly into a unified loss. For instance, we combine per-pixel losses in image segmentation tasks using a convolutional NN (CNN). Second, designing auxiliaries, for cases where predefined auxiliary tasks are not available. We present an approach for learning such auxiliary tasks without domain knowledge and from input data alone. This is achieved by training an auxiliary network to generate auxiliary labels while training another, primary network to learn both the original task and the auxiliary task. One important distinction from previous works, such as (Kendall et al., 2018; Liu et al., 2019a), is that we do not optimize the auxiliary parameters using the training loss but rather on a separate (small) auxiliary set, allocated from the training data. This is a key difference since the goal of auxiliary learning is to improve generalization rather than help optimization on the training data. + +To validate our proposed solution, we extensively evaluate AuxiLearn in several tasks in the low-data regime. In this regime, the models suffer from severe overfitting and auxiliary learning can provide the largest benefits. Our results demonstrate that using AuxiLearn leads to improved loss functions and auxiliary tasks, in terms of the performance of the resulting model on the main task. We complement our experimental section with two interesting theoretical insights regarding our model. The first shows that a relatively simple auxiliary hypothesis class may overfit. The second aims to understand which auxiliaries benefit the main task. + +To summarize, we propose a novel general approach for learning with auxiliaries using implicit differentiation. We make the following novel contributions: (a) We describe a unified approach for combining multiple loss terms and for learning novel auxiliary tasks from the data alone; (b) We provide a theoretical observation on the capacity of auxiliary learning; (c) We show that the key quantity for determining beneficial auxiliaries is the Newton update; (d) We provide new results on a variety of auxiliary learning tasks with a focus on the low data regime. We conclude that implicit differentiation can play a significant role in automating the design of auxiliary learning setups. + +# 2 RELATED WORK + +Learning with multiple tasks. Multitask Learning (MTL) aims at simultaneously solving multiple learning problems while sharing information across tasks. In some cases, MTL benefits the optimization process and improves task-specific generalization performance compared to single-task learning (Standley et al., 2019). In contrast to MTL, auxiliary learning aims at solving a single, main task, and the purpose of all other tasks is to facilitate the learning of the primary task. At test time, only the main task is considered. This approach has been successfully applied in multiple domains, including computer vision (Zhang et al., 2014), natural language processing (Fan et al., 2017; Trinh et al., 2018), and reinforcement learning (Jaderberg et al., 2016; Lin et al., 2019). + +Dynamic task weighting. When learning a set of tasks, the task-specific losses are combined into an overall loss. The way individual losses are combined is crucial because MTL-based models are sensitive to the relative weightings of the tasks (Kendall et al., 2018). A common approach for combining task losses is in a linear fashion. When the number of tasks is small, task weights are commonly tuned with a simple grid search. However, this approach does not extend to a large number of tasks, or a more complex weighting scheme. Several recent studies proposed scaling task weights using gradient magnitude (Chen et al., 2018), task uncertainty (Kendall et al., 2018), or the rate of loss change (Liu et al., 2019b). Sener and Koltun (2018) proposed casting the multitask learning problem as a multi-objective optimization. These methods assume that all tasks are equally important, and are less suited for auxiliary learning. Du et al. (2018) and Lin et al. (2019) proposed to weight auxiliary losses using gradient similarity. However, these methods do not scale well with the number of auxiliaries and do not take into account interactions between auxiliaries. In contrast, we propose to learn from data how to combine auxiliaries, possibly in a non-linear manner. + +![](images/2b903459aa83948262563de8df24c14d6359a52fe887be37981778e98cc22957.jpg) +(a) Combining losses + +![](images/14ecb9fe7e65d31ef39cc2cf9ca1e0910232eddb44c4d8e1ed341ff64263646a.jpg) +(b) Learning a new auxiliary task +Figure 1: The AuxiLearn framework. (a) Learning to combine losses into a single coherent loss term. Here, the auxiliary network operates over a vector of losses. (b) Generating a novel auxiliary task. Here the auxiliary network operates over the input space. In both cases, $g(\cdot ;\phi)$ is optimized using IFT based on $\mathcal{L}_A$ . + +Devising auxiliaries. Designing an auxiliary task for a given main task is challenging because it may require domain expertise and additional labeling effort. For self-supervised learning (SSL), many approaches have been proposed (see Jing and Tian (2020) for a recent survey), but the joint representation learned through SSL may suffer from negative transfer and hurt the main task (Standley et al., 2019). Liu et al. (2019a) proposed learning a helpful auxiliary in a meta-learning fashion, removing the need for handcrafted auxiliaries. However, their system is optimized for the training data, which may lead to degenerate auxiliaries. To address this issue, an entropy term is introduced to force the auxiliary network to spread the probability mass across classes. + +Implicit differentiation based optimization. Our formulation gives rise to a bi-level optimization problem. Such problems naturally arise in the context of meta-learning (Finn et al., 2017; Rajeswaran et al., 2019) and hyperparameter optimization (Bengio, 2000; Foo et al., 2008; Larsen et al., 1996; Liao et al., 2018; Lorraine et al., 2020; Pedregosa, 2016). The Implicit Function Theorem (IFT) is often used for computing gradients of the upper-level function, this operation requires calculating a vector-inverse Hessian product. However, for modern neural networks, it is infeasible to calculate it explicitly, and an approximation must be devised. Luketina et al. (2016) proposed approximating the Hessian with the identity matrix, whereas Foo et al. (2008); Pedregosa (2016); Rajeswaran et al. (2019) used conjugate gradient (CG) to approximate the product. Following Liao et al. (2018); Lorraine et al. (2020), we use a truncated Neumann series and efficient vector-Jacobian products, as it was empirically shown to be more stable than CG. + +# 3 OUR METHOD + +We now describe the general AuxiLearn framework for learning with auxiliary tasks. For that purpose, we use two networks, a primary network that is optimized on all tasks and an auxiliary network that is optimized on the main task only. First, we introduce our notations and formulate the general objective. Then, we describe two instances of this framework: combining auxiliaries and learning new auxiliaries. Finally, we present our optimization approach for both instances. + +# 3.1 PROBLEM DEFINITION + +Let $\{(\mathbf{x}_i^t,\pmb {y}_i^t)\}_{i}$ be the training set and $\{(\mathbf{x}_i^a,\pmb {y}_i^a)\}_{i}$ be a distinct independent set which we term auxiliary set. Let $f(\cdot ;W)$ denote the primary network, and let $g(\cdot ;\phi)$ denote the auxiliary network. Here, $W$ are the parameters of the model optimized on the training set, and $\phi$ are the auxiliary parameters trained on the auxiliary set. The training loss is defined as: + +$$ +\mathcal {L} _ {T} = \mathcal {L} _ {T} (W, \phi) = \sum_ {i} \ell_ {\text {m a i n}} \left(\mathbf {x} _ {i} ^ {t}, \boldsymbol {y} _ {i} ^ {t}; W\right) + h \left(\mathbf {x} _ {i} ^ {t}, \boldsymbol {y} _ {i} ^ {t}, W; \phi\right), \tag {1} +$$ + +where $\ell_{main}$ denotes the loss of the main task and $h$ is the overall auxiliary loss, controlled by $\phi$ . In Sections 3.2 & 3.3 we will describe two instances of $h$ . We note that $h$ has access to both $W$ and $\phi$ . The loss on the auxiliary set is defined as $\mathcal{L}_A = \sum_i \ell_{main}(\mathbf{x}_i^a, \mathbf{y}_i^a; W)$ , since we are interested in the generalization performance of the main task. + +We wish to find auxiliary parameters $(\phi)$ such that the primary parameters $(W)$ , trained with the combined objective, generalize well. More formally, we seek + +$$ +\phi^ {*} = \arg \min _ {\phi} \mathcal {L} _ {A} \left(W ^ {*} (\phi)\right), \quad \text {s . t .} \quad W ^ {*} (\phi) = \arg \min _ {W} \mathcal {L} _ {T} (W, \phi). \tag {2} +$$ + +# 3.2 LEARNING TO COMBINE AUXILIARY TASKS + +Suppose we are given $K$ auxiliary tasks, usually designed using expert domain knowledge. We wish to learn how to optimally leverage these auxiliaries by learning to combine their corresponding losses. Let $\ell (\mathbf{x},\mathbf{y};W) = (\ell_{main}(\mathbf{x},y^{main};W),\ell_1(\mathbf{x},y^1;W),\dots,\ell_K(\mathbf{x},y^K;W))$ denote a loss vector. We wish to learn an auxiliary network $g:\mathbb{R}^{K + 1}\to \mathbb{R}$ over the losses that will be added to $\ell_{main}$ in order to output the training loss $\mathcal{L}_T = \ell_{main} + g(\ell ;\phi)$ . Here, $h$ from Eq. (1) is given by $h(\cdot ;\phi) = g(\ell ;\phi)$ . + +Typically, $g(\ell; \phi)$ is chosen to be a linear combination of the losses: $g(\ell; \phi) = \sum_{j} \phi_{j} \ell_{j}$ , with positive weights $\phi_{j} \geq 0$ that are tuned using a grid search. However, this method can only scale to a few auxiliaries, as the run time of grid search is exponential in the number of tasks. Our method can handle a large number of auxiliaries and easily extends to a more flexible formulation in which $g$ parametrized by a deep NN. This general form allows us to capture complex interactions between tasks, and learn non-linear combinations of losses. See Figure 1a for illustration. + +One way to view a non-linear combination of losses is as an adaptive linear weighting, where losses have a different set of weights for each datum. If the loss at point $\mathbf{x}$ is $\ell_{\text{main}}(\mathbf{x}, y^{\text{main}}) + g(\ell(\mathbf{x}, \mathbf{y}))$ , then the gradients are $\nabla_W \ell_{\text{main}}(\mathbf{x}, y^{\text{main}}) + \sum_j \frac{\partial g}{\partial \ell_j} \nabla_W \ell_j(\mathbf{x}, y^j)$ . This is equivalent to an adaptive loss where the loss of datum $\mathbf{x}$ is $\ell_{\text{main}} + \sum_j \alpha_{j,\mathbf{x}} \ell_j$ and, $\alpha_{j,\mathbf{x}} = \frac{\partial g}{\partial \ell_j}$ . This observation connects our approach to other studies that assign adaptive loss weights (e.g., Du et al. (2018); Liu et al. (2019b)). + +Convolutional loss network. In certain problems there exists a spatial relation among losses. For example, semantic segmentation and depth estimation for images. A common approach is to average the losses over all locations. In contrast, AuxiLearn can leverage this spatial relation for creating a loss-image in which each task forms a channel of pixel-losses induced by the task. We then parametrize $g$ as a CNN that acts on this loss-image. This yields a spatial-aware loss function that captures interactions between task losses. See an example of a loss image in Figure 3 + +Monotonicity. It is common to parametrize the function $g(\ell ;\phi)$ as a linear combination with non-negative weights. Under this parameterization, $g$ is a monotonic non-decreasing function of the losses. A natural question that arises is whether we should generalize this behavior and constrain $g(\ell ;\phi)$ to be non-decreasing w.r.t. the input losses as well? Empirically, we found that training with monotonic non-decreasing networks tends to be more stable and has a better or equivalent performance. We impose monotonicity during training with negative weights clipping. See Appendix C.2 for a detailed discussion and empirical comparison to non-monotonic networks. + +# 3.3 LEARNING NEW AUXILIARY TASKS + +The previous subsection focused on situations where auxiliary tasks are given. In many cases, however, no useful auxiliary tasks are known in advance, and we are only presented with the main task. We now describe how to use AuxiLearn in such cases. The intuition is simple: We wish to learn an auxiliary task that pushes the representation of the primary network to generalize better on the main task, as measured using the auxiliary set. We do so in a student-teacher manner: an auxiliary "teacher" network produces labels for the primary network (the "student") which tries to predict these labels as an auxiliary task. Both networks are trained jointly. + +More specifically, for auxiliary classification, we learn a soft labeling function $g(\mathbf{x};\phi)$ which produces pseudo labels $y_{aux}$ for input samples $\mathbf{x}$ . These labels are then provided to the main network $f(\mathbf{x};W)$ for training (see Figure 1b). During training, the primary network $f(\mathbf{x};W)$ outputs two predictions, $\hat{y}_{main}$ for the main task and $\hat{y}_{aux}$ for the auxiliary task. We then compute the full training loss $\mathcal{L}_T = \ell_{main}(\hat{y}_{main},y_{main}) + \ell_{aux}(\hat{y}_{aux},y_{aux})$ to update $W$ . Here, the $h$ component of $\mathcal{L}_T$ in Eq. (1) is given by $h(\cdot ;\phi) = \ell_{aux}(f(\mathbf{x}_i^t;W),g(\mathbf{x}_i^t;\phi))$ . As before, we update $\phi$ using the auxiliary set with the loss $\mathcal{L}_A = \ell_{main}$ . Intuitively, the teacher auxiliary network $g$ is rewarded when it provides labels to the student that help it succeed in the main task, as measured using $\mathcal{L}_A$ . + +# 3.4 OPTIMIZING AUXILIARY PARAMETERS + +We now return to the bi-level optimization problem in Eq. (2) and present the optimizing method for $\phi$ . Solving Eq. (2) for $\phi$ poses a problem due to the indirect dependence of $\mathcal{L}_A$ on the auxiliary parameters. To compute the gradients of $\phi$ , we need to differentiate through the optimization process over $W$ , since $\nabla_{\phi}\mathcal{L}_A = \nabla_W\mathcal{L}_A\cdot \nabla_{\phi}W^*$ . As in Liao et al. (2018); Lorraine et al. (2020), we use the implicit function theorem (IFT) to evaluate $\nabla_{\phi}W^{*}$ : + +$$ +\nabla_ {\phi} W ^ {*} = - \underbrace {(\nabla_ {W} ^ {2} \mathcal {L} _ {T}) ^ {- 1}} _ {| W | \times | W |} \cdot \underbrace {\nabla_ {\phi} \nabla_ {W} \mathcal {L} _ {T}} _ {| W | \times | \phi |}. \tag {3} +$$ + +We can leverage the IFT to approximate the gradients of the auxiliary parameters $\phi$ : + +$$ +\nabla_ {\phi} \mathcal {L} _ {A} \left(W ^ {*} (\phi)\right) = - \underbrace {\nabla_ {W} \mathcal {L} _ {A}} _ {1 \times | W |} \cdot \underbrace {\left(\nabla_ {W} ^ {2} \mathcal {L} _ {T}\right) ^ {- 1}} _ {| W | \times | W |} \cdot \underbrace {\nabla_ {\phi} \nabla_ {W} \mathcal {L} _ {T}} _ {| W | \times | \phi |}. \tag {4} +$$ + +See Appendix A for a detailed derivation. To compute the vector and Hessian inverse product, we use the algorithm proposed by Lorraine et al. (2020), which uses Neumann approximation and efficient vector-Jacobian product. We note that accurately computing $\nabla_{\phi}\mathcal{L}_A$ by IFT requires finding a point such that $\nabla_W\mathcal{L}_T = 0$ . In practice, we only approximate $W^{*}$ , and simultaneously train both $W$ and $\phi$ by altering between optimizing $W$ on $\mathcal{L}_T$ , and optimizing $\phi$ using $\mathcal{L}_A$ . We summarize our method in Alg. 1 and 2. Theoretical considerations regarding our method are given in Appendix D. + +Algorithm 1: AuxiLearn +Initialize auxiliary parameters $\phi$ and weights $W$ ; while not converged do +for $k = 1, \dots, N$ do + $\mathcal{L}_T = \ell_{main}(\mathbf{x}, y; W) + h(\mathbf{x}, y, W; \phi)$ $W \gets W - \alpha \nabla_W \mathcal{L}_T|_{\phi, W}$ +end + $\phi \gets \phi - \text{Hypergradient}(\mathcal{L}_A, \mathcal{L}_T, \phi, W)$ +end +return $W$ + +Algorithm 2: Hypergradient +Input: training loss $\mathcal{L}_T$ , auxiliary loss $\mathcal{L}_A$ , a fixed point $(\phi^{\prime},W^{*})$ , number of iterations $J$ , learning rate $\alpha$ $v = p = \nabla_W\mathcal{L}_A|_{(\phi ',W*)}$ +for $j = 1,\dots ,J$ do + $|v - = \alpha v\cdot \nabla_W\nabla_W\mathcal{L}_T$ $p + = v$ +end +return $-p\nabla_{\phi}\nabla_{W}\mathcal{L}_{T}|_{(\phi^{\prime},W^{*})}$ + +# 4 ANALYSIS + +# 4.1 COMPLEXITY OF AUXILIARY HYPOTHESIS SPACE + +In our learning setup, an additional auxiliary set is used for tuning a large set of auxiliary parameters. A natural question arises: could the auxiliary parameters overfit this auxiliary set? and what is the complexity of the auxiliary hypothesis space $\mathcal{H}_{\phi}$ ? Analyzing the complexity of this space is difficult because it is coupled with the hypothesis space $\mathcal{H}_W$ of the main model. One can think of this hypothesis space as a subset of the original model hypothesis space $\mathcal{H}_{\phi} = \{h_W : \exists \phi \text{ s.t. } W = \arg \min_W \mathcal{L}_T(W, \phi)\} \subset \mathcal{H}_W$ . Due to the coupling with $\mathcal{H}_W$ the behavior can be unintuitive. We show that even simple auxiliaries can have infinite VC dimensions. + +Example: Consider the following 1D hypothesis space for binary classification $\mathcal{H}_W = \{\lceil \cos (Wx)\rceil ,W\in \mathbb{R}\}$ , which has infinite VC-dimension. Let the main loss be the zero-one loss and the auxiliary loss be $h(\phi ,W) = (\phi -W)^2$ , namely, an $L_{2}$ regularization with a learned center. Since the model hypothesis space $\mathcal{H}_W$ has an infinite VC-dimension, there exist training and auxiliary sets of any size that are shattered by $\mathcal{H}_W$ . Therefore, for any labeling of the auxiliary and training sets, we can let $\phi = \hat{\phi}$ , the parameter that perfectly classifies both sets. We then have that $\hat{\phi}$ is the optimum of the training with this auxiliary loss and we get that $\mathcal{H}_{\phi}$ also has an infinite VC-dimension. + +This important example shows that even seemingly simple-looking auxiliary losses can overfit due to the interaction with the model hypothesis space. Thus, it motivates our use of a separate auxiliary set. + +# 4.2 ANALYZING AN AUXILIARY TASK EFFECT + +When designing or learning auxiliary tasks, one important question is, what makes an auxiliary task useful? Consider the following loss with a single auxiliary task $\mathcal{L}_T(W,\phi) = \sum_i\ell_{main}(\mathbf{x}_i^t,\pmb {y}_i^t,W) +$ + +$\phi \cdot \ell_{aux}(\mathbf{x}_i^t,\mathbf{y}_i^t,W)$ . Here $h = \phi \cdot \ell_{aux}$ . Assume $\phi = 0$ so we optimize $W$ only on the standard main task loss. We can now check if $\frac{d\mathcal{L}_A}{d\phi} |_{\phi = 0} > 0$ , namely would it help to add this auxiliary task? + +Proposition 1. Let $\mathcal{L}_T(W,\phi) = \sum_i\ell_{main}(\mathbf{x}_i^t,\pmb {y}_i^t,W) + \phi \cdot \ell_{aux}(\mathbf{x}_i^t,\pmb {y}_i^t,W)$ . Suppose that $\phi = 0$ and that the main task was trained until convergence. We have + +$$ +\left. \frac {d \mathcal {L} _ {A} \left(W ^ {*} (\phi)\right)}{d \phi} \right| _ {\phi = 0} = - \left\langle \nabla_ {W} \mathcal {L} _ {A} ^ {T}, \nabla_ {W} ^ {2} \mathcal {L} _ {T} ^ {- 1} \nabla_ {W} \mathcal {L} _ {T} \right\rangle , \tag {5} +$$ + +i.e. the gradient with respect to the auxiliary weight is the inner product between the Newton methods update and the gradient of the loss on the auxiliary set. + +Proof. In the general case, the following holds $\frac{d\mathcal{L}_A}{d\phi} = -\nabla_W\mathcal{L}_A(\nabla_W^2\mathcal{L}_T)^{-1}\nabla_\phi \nabla_W\mathcal{L}_T$ . For a linear combination, we have $\nabla_{\phi}\nabla_{W}\mathcal{L}_{T} = \sum_{i}\nabla_{W}\ell_{aux}(\mathbf{x}_{i}^{t},\pmb{y}_{i}^{t})$ . Since $W$ is optimized till convergence of the main task we obtain $\nabla_{\phi}\nabla_{W}\mathcal{L}_{T} = \nabla_{W}\mathcal{L}_{T}$ . + +This simple result shows that the key quantity to observe is the Newton update, rather than the gradient which is often used (Lin et al., 2019; Du et al., 2018). Intuitively, the Newton update is the important quantity because if $\Delta \phi$ is small then we are almost at the optimum. Then, due to quadratic convergence, a single Newton step is sufficient for approximately converging to the new optimum. + +# 5 EXPERIMENTS + +We evaluate the AuxiLearn framework in a series of tasks of two types: combining given auxiliary tasks into a unified loss (Sections 5.1 - 5.3), and generating a new auxiliary task (Section 5.4). Further experiments and analysis of both modules are given in Appendix C. Throughout all experiments, we use an extra data split for the auxiliary set. Hence, we use four data sets: training set, validation set, test set, and auxiliary set. The samples for the auxiliary set are pre-allocated from the training set. For a fair comparison, these samples are used as part of the training set by all competing methods. Effectively, this means we have a slightly smaller training set for optimizing the parameters $W$ of the primary network. In all experiments, we report the mean performance (e.g., accuracy) along with the Standard Error of the Mean (SEM). Full implementation details of all experiments are given in Appendix B. Our code is available at https://github.com/AvivNavon/AuxiLearn. + +Model variants. For learning to combine losses, we evaluated the following variants of auxiliary networks: (1) Linear: A convex linear combination between the loss terms; (2) Linear neural network (Deep linear): A deep fully-connected NN with linear activations; (3) Nonlinear: A standard feed-forward NN over the loss terms. For Section 5.3 only (4) ConvNet: A CNN over the loss-images. The expressive power of the deep linear network is equivalent to that of a 1-layer linear network; However, from an optimization perspective, it was shown that the over-parameterization introduced by the network's depth could stabilize and accelerate convergence (Arora et al., 2018; Saxe et al., 2014). All variants are constrained to represent only monotone non-decreasing functions. + +# 5.1 AN ILLUSTRATIVE EXAMPLE + +We first present an illustrative example of how AuxiLearn changes the loss landscape and helps generalization in the presence of label noise and harmful tasks. Consider a regression problem with $y_{main} = \mathbf{w}^{\star T}\mathbf{x} + \epsilon_0$ and two auxiliary tasks. The first auxiliary is helpful, $y_{1} = \mathbf{w}^{\star T}\mathbf{x} + \epsilon_{1}$ , whereas the second auxiliary is harmful $y_{2} = \tilde{\mathbf{w}}^{T}\mathbf{x} + \epsilon_{2},\tilde{\mathbf{w}}\neq \mathbf{w}^{\star}$ . We let + +![](images/7b8f1945ccc3b4263ebb0521c8cbcc1c0ab00c4204cc6a3c1c629d2fc738f96e.jpg) +Figure 2: Loss landscape generated by the auxiliary network. Darker is higher. See text for details. + +![](images/33bf88e8894498229508d6f78806cef414467e83432bc6bb914b7ddaad9bb0f0.jpg) + +![](images/1b2e0eb7118d23d759c009b6316144a7e7802bbe5832bb21451bc920b5ac06be.jpg) + +$\epsilon_0 \sim \mathcal{N}(0, \sigma_{main}^2)$ and $\epsilon_1, \epsilon_2 \sim \mathcal{N}(0, \sigma_{aux}^2)$ , with $\sigma_{main}^2 > \sigma_{aux}^2$ . We optimize a linear model with weights $\mathbf{w} \in \mathbb{R}^2$ that are shared across tasks, i.e., no task-specific parameters. We set $\mathbf{w}^\star = (1, 1)^T$ and $\tilde{\mathbf{w}} = (2, -4)^T$ . We train an auxiliary network to output linear task weights and observe the changes to the loss landscape in Figure 2. The left plot shows the loss landscape for the main task, + +![](images/84835989d2b8273bfde4ab52251db815f7ffb632ac5f5333d90c3605fbc24e06.jpg) +(a) image +(b) GT labels +(c) aux. loss +(d) main loss +(e) pix. weight +Figure 3: Loss images on test examples from NYUv2: (a) original image; (b) semantic segmentation ground truth; (c) auxiliaries loss; (d) segmentation (main task) loss; (e) adaptive pixel-wise weight $\sum_{j}\partial \mathcal{L}_{T} / \partial \ell_{j}$ . + +with a training set optimal solution $\mathbf{w}_{train}$ . Note that $\mathbf{w}_{train} \neq \mathbf{w}^*$ due to the noise in the training data. The loss landscape of the weighted train loss at the beginning ( $t = 0$ ) and the end ( $t = T$ ) of training is shown in the middle and right plots, respectively. Note how AuxiLearn learns to ignore the harmful auxiliary and use the helpful one to find a better solution by changing the loss landscape. In Appendix C.3 we show that the auxiliary task weight is inversely proportional to the label noise. + +# 5.2 FINE-GRAINED CLASSIFICATION WITH MANY AUXILIARY TASKS + +In fine-grained visual classification tasks, annotators should have domain expertise, making data labeling challenging and potentially expensive (e.g., in the medical domain). In some cases, however, non-experts can annotate visual attributes that are informative about the main task. As an example, consider the case of recognizing bird species, which would require an ornithologist, yet a layman can describe the head color or bill shape of a bird. These features naturally form auxiliary tasks, which can be leveraged for training jointly with the main task of bird classification. + +We evaluate AuxiLearn in this setup of fine-grained classification using the CaltechUCSD Birds 200-2011 dataset (CUB) (Wah et al., 2011). CUB contains 200 bird species in 11,788 images, each associated with a set of 312 binary visual attributes, which we use as auxiliaries. Since we are interested in setups where optimizing the main task alone does not generalize well, we demonstrate our method in a semi-supervised setting: we assume that auxiliary labels are available for all images but only $K$ labels per class are available for the main task (noted as $K$ -shot). + +Table 1: Test classification accuracy on CUB 200-2011 dataset, averaged over three runs (± SEM). + +
5-shot10-shot
Top 1Top 3Top 1Top 3
STL35.50 ± 0.754.79 ± 0.754.79 ± 0.374.00 ± 0.1
Equal41.47 ± 0.462.62 ± 0.455.36 ± 0.375.51 ± 0.4
Uncertainty35.22 ± 0.354.99 ± 0.753.75 ± 0.673.25 ± 0.3
DWA41.82 ± 0.162.91 ± 0.454.90 ± 0.375.74 ± 0.3
GradNorm41.49 ± 0.463.12 ± 0.455.23 ± 0.175.62 ± 0.3
GCS42.57 ± 0.762.60 ± 0.155.65 ± 0.275.71 ± 0.1
AuxiLearn
Linear41.71 ± 0.463.73 ± 0.654.77 ± 0.275.51 ± 0.7
Deep Linear45.84 ± 0.366.21 ± 0.557.08 ± 0.275.3 ± 0.6
Nonlinear47.07 ± 0.168.25 ± 0.359.04 ± 0.278.08 ± 0.2
+ +We compare AuxiLearn with the following MTL and auxiliary learning baselines: (1) Single-task learning (STL): Training only on the main task. (2) Equal: Standard multitask learning with equal weights for all auxiliary tasks. (3) GradNorm (Chen et al., 2018): An MTL method that scales losses based on gradient magnitude. (4) Uncertainty (Kendall et al., 2018): An MTL approach that uses task uncertainty to adjust task weights. (5) Gradient Cosine Similarity (GCS) (Du et al., 2018): An auxiliary-learning approach that uses gradient similarity between the main and auxiliary tasks. (6) Dynamic weight averaging (DWA) (Liu et al., 2019b): An MTL approach that sets task weights based on the rate of loss change over time. The primary network in all experiments is ResNet-18 (He et al., 2016) pre-trained on ImageNet. We use a 5-layer fully connected NN for the auxiliary network. Sensitivity analysis of the network size and auxiliary set size is presented in Appendix C.4. + +Table 1 shows the test set classification accuracy. Most methods significantly improve over the STL baseline, highlighting the benefits of using additional (weak) labels. Our Nonlinear and Deep linear auxiliary network variants outperform all previous approaches by a large margin. As expected, a non-linear auxiliary network is better than its linear counterparts. This suggests that there are some non-linear interactions between the loss terms that the non-linear network is able to capture. Also, notice the effect of using deep-linear compared to a (shallow) linear model. This result indicates that at least part of the improvement achieved by our method is attributed to the over-parameterization of the auxiliary network. In the Appendix we further analyze properties of auxiliary networks. Appendix C.5 visualizes the full optimization path of a linear auxiliary network over a polynomial kernel on the losses, and Appendix C.6 shows that the last state of the auxiliary network is not informative enough. + +# 5.3 Pixel-WISE LOSSES + +We consider the indoor-scene segmentation task from Couprie et al. (2013), that uses the NYUv2 dataset (Silberman et al., 2012). We consider the 13-class semantic segmentation as the main task, with depth and surface-normal prediction (Eigen and Fergus, 2015) as auxiliaries. We use SegNet (Badrinarayanan et al., 2017) based model for the primary network, and a 4-layer CNN for the auxiliary network. + +Since losses in this task are given per-pixel, we can apply the ConvNet variant of the auxiliary network to the loss image. Namely, each task forms a channel with the per-pixel losses as values. Table 2 reports the mean Intersection over Union (mIoU) and pixel accuracy for the main segmentation task. Here, we + +Table 2: Test results for semantic segmentation on NYUv2, averaged over four runs (± SEM). + +
mIoUPixel acc.
STL18.90 ± 0.2154.74 ± 0.94
Equal19.20 ± 0.1955.37 ± 1.00
Uncertainty19.34 ± 0.1855.70 ± 0.79
DWA19.38 ± 0.1455.37 ± 0.35
GradNorm19.52 ± 0.2156.70 ± 0.33
MGDA19.53 ± 0.3556.28 ± 0.46
GCS19.94 ± 0.1356.58 ± 0.81
AuxiLearn (ours)
Linear20.04 ± 0.3856.80 ± 0.14
Deep Linear19.94 ± 0.1256.45 ± 0.79
Nonlinear20.09 ± 0.3456.80 ± 0.53
ConvNet20.54 ± 0.3056.69 ± 0.44
+ +also compare with MGDA (Sener and Koltun, 2018) which had extremely long training time in CUB experiments due to the large number of auxiliary tasks, and therefore was not evaluated in Section 5.2. All weighting methods achieve a performance gain over the STL model. The ConvNet variant of AuxiLearn outperforms all competitors in terms of test mIoU. + +Figure 3 shows examples of the loss-images for the auxiliary (c) and main (d) tasks, together with the pixel-wise weights (e). First, note how the loss-images resemble the actual input images. This suggests that a spatial relationship can be leveraged using a CNN auxiliary network. Second, pixel weights are a non-trivial combination of the main and auxiliary task losses. In the top (bottom) row, the plant (couch) has a low segmentation loss and intermediate auxiliary loss. As a result, a higher weight is allocated to these pixels which increases the error signal. + +# 5.4 LEARNING AUXILIARY LABELS + +Table 3: Learning auxiliary task. Test accuracy averaged over three runs (±SEM) without pre-training. + +
CIFAR10 (5%)CIFAR100 (5%)SVHN (5%)CUB (30-shot)Pet (30-shot)Cars (30-shot)
STL50.8 ± 0.819.8 ± 0.772.9 ± 0.337.2 ± 0.826.1 ± 0.559.2 ± 0.4
MAXL-F56.1 ± 0.120.4 ± 0.675.4 ± 0.339.6 ± 1.326.2 ± 0.359.6 ± 1.1
MAXL58.2 ± 0.321.0 ± 0.475.5 ± 0.440.7 ± 0.626.3 ± 0.660.4 ± 0.8
AuxiLearn60.7 ± 1.321.5 ± 0.376.4 ± 0.244.5 ± 0.337.0 ± 0.664.4 ± 0.3
+ +In many cases, designing helpful auxiliaries is challenging. We now evaluate AuxiLearn in learning multi-class classification auxiliary tasks. We use three multi-class classification datasets: CIFAR10, CIFAR100 (Krizhevsky et al., 2009), SVHN (Netzer et al., 2011), and three fine-grained classification datasets: CUB-200-2011, Oxford-IIIT Pet (Parkhi et al., 2012), and Cars (Krause et al., 2013). Pet contains 7349 images of 37 species of dogs and cats, and Cars contains 16,185 images of 196 cars. + +Following Liu et al. (2019a), we learn a different auxiliary task for each class of the main task. In all experiments and all learned tasks, we set the number of classes to 5. To examine the effect of the learned auxiliary losses in the low-data regime, we evaluate the performance while training with only $5\%$ of the training set in CIFAR10, CIFAR100, and SVHN datasets, and $\sim 30$ samples per + +![](images/a47abd6f6382da5690e085bb6b4e31161a7e2d81e1c77470907d148f057647ce.jpg) +Figure 4: t-SNE applied to auxiliary labels learned for Frog and Deer classes, in CIFAR10. Best viewed in color. + +![](images/948cfa89490828ebfd59f944ee17f0df154d6d75e3920b0e3edba391003f1a8b.jpg) + +class in CUB, Oxford-IIIT Pet, and Cars. We use VGG-16 (Simonyan and Zisserman, 2014) as the backbone for both CIFAR datasets, a 4-layers ConvNet for the SVHN experiment, and ResNet18 for the fine-grained datasets. In all experiments, the architectures of the auxiliary and primary networks were set the same and were trained from scratch without pre-training. + +We compared our approach with the following baselines: (1) Single-task learning (STL): Training the main task only. (2) MAXL: Meta AuXiliary Learning (MAXL) proposed by Liu et al. (2019a) for learning auxiliary tasks. MAXL optimizes the label generator in a meta-learning fashion. (3) MAXL-F: A frozen MAXL label generator, that is initialized randomly. It decouples the effect of having a teacher network from the additional effect brought by the training process. + +Table 3 shows that AuxiLearn outperforms all baselines in all setups, even though it sacrifices some of the training set for the auxiliary set. It is also worth noting that our optimization approach is significantly faster than MAXL, yielding $\times 3$ improvement in run-time. In Appendix C.9 and C.10 we show additional experiments for this setup, including an extension of the method to point-cloud part segmentation and experiments with varying training data sizes. + +Figure 4 presents a 2D t-SNE projection of the 5D vector of auxiliary (soft) labels that are learned using AuxiLearn. We use samples of the main classes Frog (left) and Deer (right) from the CIFAR10 dataset. t-SNE was applied to each auxiliary task separately. When considering how images are projected to this space of auxiliary soft labels, several structures emerge. The auxiliary network learns a fine partition of the Frog class that separates real images from illustrations. More interesting, the soft labels learned for the class Deer have a middle region that only contains deers with antlers (in various poses and varying backgrounds). By capturing this semantic feature in the learned auxiliary labels, the auxiliary task can help the primary network to discriminate between main task classes. + +# 6 DISCUSSION + +In this paper, we presented a novel and unified approach for two tasks: combining predefined auxiliary tasks, and learning auxiliary tasks that are useful for the primary task. We theoretically showed which auxiliaries can be beneficial and the importance of using a separate auxiliary set. We empirically demonstrated that our method achieves significant improvement over existing methods on various datasets and tasks. This work opens interesting directions for future research. First, when training deep linear auxiliary networks, we observed similar learning dynamics to those of non-linear models. As a result, they generated better performance compared to their linear counterparts. This effect was observed in standard training setup, but the optimization path in auxiliary networks is very different. Second, we find that reallocating labeled data from the training set to an auxiliary set is consistently helpful. A broader question remains what is the most efficient allocation. + +# ACKNOWLEDGEMENTS + +This study was funded by a grant to GC from the Israel Science Foundation (ISF 737/2018), and by an equipment grant to GC and Bar-Ilan University from the Israel Science Foundation (ISF 2332/18). IA and AN were funded by a grant from the Israeli innovation authority, through the AVATAR consortium. + +# REFERENCES + +Achituve, I., Maron, H., and Chechik, G. (2020). Self-supervised learning for domain adaptation on point-clouds. arXiv preprint arXiv:2003.12641. +Alemi, A. A., Fischer, I., Dillon, J. V., and Murphy, K. (2017). Deep variational information bottleneck. In International Conference on Learning Representations. +Arora, S., Cohen, N., and Hazan, E. (2018). On the optimization of deep networks: Implicit acceleration by overparameterization. In International Conference on Machine Learning. +Badrinarayanan, V., Kendall, A., and Cipolla, R. (2017). Segnet: A deep convolutional encoder-decoder architecture for image segmentation. IEEE transactions on pattern analysis and machine intelligence, 39(12):2481-2495. +Bengio, Y. (2000). Gradient-based optimization of hyperparameters. Neural computation, 12(8):1889-1900. +Chang, A. X., Funkhouser, T., Guibas, L., Hanrahan, P., Huang, Q., Li, Z., Savarese, S., Savva, M., Song, S., Su, H., et al. (2015). Shapenet: An information-rich 3d model repository. arXiv preprint arXiv:1512.03012. +Chen, Z., Badrinarayanan, V., Lee, C.-Y., and Rabinovich, A. (2018). Gradnorm: Gradient normalization for adaptive loss balancing in deep multitask networks. In International Conference on Machine Learning, pages 794-803. PMLR. +Cordts, M., Omran, M., Ramos, S., Rehfeld, T., Enzweiler, M., Benenson, R., Franke, U., Roth, S., and Schiele, B. (2016). The cityscapes dataset for semantic urban scene understanding. In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 3213-3223. +Couprie, C., Farabet, C., Najman, L., and LeCun, Y. (2013). Indoor semantic segmentation using depth information. In International Conference on Learning Representations. +Deng, J., Dong, W., Socher, R., Li, L.-J., Li, K., and Fei-Fei, L. (2009). Imagenet: A large-scale hierarchical image database. In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 248-255. +Doersch, C., Gupta, A., and Efros, A. A. (2015). Unsupervised visual representation learning by context prediction. In Proceedings of the IEEE International Conference on Computer Vision, pages 1422-1430. +Doersch, C. and Zisserman, A. (2017). Multi-task self-supervised visual learning. In Proceedings of the IEEE International Conference on Computer Vision, pages 2051-2060. +Du, Y., Czarnecki, W. M., Jayakumar, S. M., Pascanu, R., and Lakshminarayanan, B. (2018). Adapting auxiliary losses using gradient similarity. arXiv preprint arXiv:1812.02224. +Eigen, D. and Fergus, R. (2015). Predicting depth, surface normals and semantic labels with a common multi-scale convolutional architecture. In Proceedings of the IEEE international conference on computer vision, pages 2650-2658. +Fan, X., Monti, E., Mathias, L., and Dreyer, M. (2017). Transfer learning for neural semantic parsing. In Proceedings of the 2nd Workshop on Representation Learning for NLP, pages 48-56. +Finn, C., Abbeel, P., and Levine, S. (2017). Model-agnostic meta-learning for fast adaptation of deep networks. In International Conference on Machine Learning, pages 1126-1135. +Foo, C.-s., Do, C. B., and Ng, A. Y. (2008). Efficient multiple hyperparameter learning for log-linear models. In Advances in neural information processing systems, pages 377-384. +Ganin, Y. and Lempitsky, V. (2015). Unsupervised domain adaptation by backpropagation. In International Conference on Machine Learning. +Gidaris, S., Singh, P., and Komodakis, N. (2018). Unsupervised representation learning by predicting image rotations. In International Conference on Learning Representations. + +Goyal, P., Mahajan, D., Gupta, A., and Misra, I. (2019). Scaling and benchmarking self-supervised visual representation learning. In Proceedings of the IEEE/CVF International Conference on Computer Vision (ICCV). +Hassani, K. and Haley, M. (2019). Unsupervised multi-task feature learning on point clouds. In Proceedings of the IEEE International Conference on Computer Vision, pages 8160-8171. +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, pages 770-778. +Jaderberg, M., Mnih, V., Czarnecki, W. M., Schaul, T., Leibo, J. Z., Silver, D., and Kavukcuoglu, K. (2016). Reinforcement learning with unsupervised auxiliary tasks. arXiv preprint arXiv:1611.05397. +Jing, L. and Tian, Y. (2020). Self-supervised visual feature learning with deep neural networks: A survey. IEEE Transactions on Pattern Analysis and Machine Intelligence. +Kendall, A., Gal, Y., and Cipolla, R. (2018). Multi-task learning using uncertainty to weigh losses for scene geometry and semantics. In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 7482-7491. +Kingma, D. P. and Ba, J. (2014). ADAM: A method for stochastic optimization. In International Conference on Learning Representations. +Krause, J., Stark, M., Deng, J., and Fei-Fei, L. (2013). 3D object representations for fine-grained categorization. In 4th International IEEE Workshop on 3D Representation and Recognition, Sydney, Australia. +Krizhevsky, A., Hinton, G., et al. (2009). Learning multiple layers of features from tiny images. Technical report, University of Toronto. +Larsen, J., Hansen, L. K., Svarer, C., and Ohlsson, M. (1996). Design and regularization of neural networks: the optimal use of a validation set. In Neural Networks for Signal Processing VI. Proceedings of the IEEE Signal Processing Society Workshop, pages 62-71. IEEE. +Liao, R., Xiong, Y., Fetaya, E., Zhang, L., Yoon, K., Pitkow, X., Urtasun, R., and Zemel, R. (2018). Reviving and improving recurrent back-propagation. In International Conference on Machine Learning. +Lin, X., Baweja, H., Kantor, G., and Held, D. (2019). Adaptive auxiliary task weighting for reinforcement learning. In Advances in Neural Information Processing Systems, pages 4773-4784. +Liu, S., Davison, A., and Johns, E. (2019a). Self-supervised generalisation with meta auxiliary learning. In Advances in Neural Information Processing Systems, pages 1677-1687. +Liu, S., Johns, E., and Davison, A. J. (2019b). End-to-end multi-task learning with attention. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pages 1871-1880. +Lorraine, J., Vicol, P., and Duvenaud, D. (2020). Optimizing millions of hyperparameters by implicit differentiation. In International Conference on Artificial Intelligence and Statistics, pages 1540-1552. PMLR. +Luketina, J., Berglund, M., Greff, K., and Raiko, T. (2016). Scalable gradient-based tuning of continuous regularization hyperparameters. In International conference on machine learning, pages 2952-2960. +Mirowski, P. (2019). Learning to navigate. In 1st International Workshop on Multimodal Understanding and Learning for Embodied Applications, pages 25-25. +Netzer, Y., Wang, T., Coates, A., Bissacco, A., Wu, B., and Ng, A. Y. (2011). Reading digits in natural images with unsupervised feature learning. +Noroozi, M. and Favaro, P. (2016). Unsupervised learning of visual representations by solving jigsaw puzzles. In Proceedings of the European Conference on Computer Vision, pages 69-84. Springer. + +Parkhi, O. M., Vedaldi, A., Zisserman, A., and Jawahar, C. V. (2012). Cats and dogs. In IEEE Conference on Computer Vision and Pattern Recognition. +Pedregosa, F. (2016). Hyperparameter optimization with approximate gradient. In International Conference on Machine Learning, pages 737-746. +Qi, C. R., Su, H., Mo, K., and Guibas, L. J. (2017). Pointnet: Deep learning on point sets for 3d classification and segmentation. In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 652-660. +Rajeswaran, A., Finn, C., Kakade, S. M., and Levine, S. (2019). Meta-learning with implicit gradients. In Advances in Neural Information Processing Systems, pages 113-124. +Salimans, T. and Kingma, D. P. (2016). Weight normalization: A simple reparameterization to accelerate training of deep neural networks. In Advances in neural information processing systems, pages 901-909. +Sauder, J. and Sievers, B. (2019). Self-supervised deep learning on point clouds by reconstructing space. In Advances in Neural Information Processing Systems, pages 12942-12952. +Saxe, A. M., McClelland, J. L., and Ganguli, S. (2014). Exact solutions to the nonlinear dynamics of learning in deep linear neural network. In In International Conference on Learning Representations. Citeseer. +Sener, O. and Koltun, V. (2018). Multi-task learning as multi-objective optimization. In Advances in Neural Information Processing Systems, pages 527-538. +Silberman, N., Hoiem, D., Kohli, P., and Fergus, R. (2012). Indoor segmentation and support inference from RGBD images. In Proceedings of the European conference on computer vision, pages 746-760. Springer. +Simonyan, K. and Zisserman, A. (2014). Very deep convolutional networks for large-scale image recognition. arXiv preprint arXiv:1409.1556. +Standley, T., Zamir, A. R., Chen, D., Guibas, L., Malik, J., and Savarese, S. (2019). Which tasks should be learned together in multi-task learning? arXiv preprint arXiv:1905.07553. +Tang, L., Chen, K., Wu, C., Hong, Y., Jia, K., and Yang, Z. (2020). Improving semantic analysis on point clouds via auxiliary supervision of local geometric priors. arXiv preprint arXiv:2001.04803. +Trinh, T., Dai, A., Luong, T., and Le, Q. (2018). Learning longer-term dependencies in RNNs with auxiliary losses. In International Conference on Machine Learning, pages 4965-4974. +Vinyals, O., Blundell, C., Lillicrap, T., Wierstra, D., et al. (2016). Matching networks for one shot learning. In Advances in neural information processing systems, pages 3630-3638. +Wah, C., Branson, S., Welinder, P., Perona, P., and Belongie, S. (2011). The Caltech-UCSD Birds-200-2011 Dataset. Technical Report CNS-TR-2011-001, California Institute of Technology. +Wang, Y., Sun, Y., Liu, Z., Sarma, S. E., Bronstein, M. M., and Solomon, J. M. (2019). Dynamic graph cnn for learning on point clouds. ACM Transactions on Graphics, 38(5):1-12. +Yi, L., Kim, V. G., Ceylan, D., Shen, I.-C., Yan, M., Su, H., Lu, C., Huang, Q., Sheffer, A., and Guibas, L. (2016). A scalable active framework for region annotation in 3D shape collections. ACM Transactions on Graphics, 35(6):1-12. +Zhang, Y. and Yang, Q. (2017). A survey on multi-task learning. arXiv preprint arXiv:1707.08114. +Zhang, Z., Luo, P., Loy, C. C., and Tang, X. (2014). Facial landmark detection by deep multi-task learning. In European conference on computer vision, pages 94-108. Springer. + +# Appendix: Auxiliary Learning by Implicit Differentiation + +# A GRADIENT DERIVATION + +We provide here the derivation of Eq. (4) in Section 3. One can look at the function $\nabla_W\mathcal{L}_T(W,\phi)$ around a certain local-minima point $(\hat{W},\hat{\phi})$ and assume the Hessian $\nabla_W^2\mathcal{L}_T(\hat{W},\hat{\phi})$ is positive-definite. At that point, we have $\nabla_W\mathcal{L}_T(\hat{W},\hat{\phi}) = 0$ . From the IFT, we have that locally around $(\hat{W},\hat{\phi})$ , there exists a smooth function $W^{*}(\phi)$ such that $\nabla_W\mathcal{L}_T(W,\phi) = 0$ if $W = W^{*}(\phi)$ . Since the function $\nabla_W\mathcal{L}_T(W^* (\phi),\phi)$ is constant and equal to zero, we have that its derivative w.r.t. $\phi$ is also zero. Taking the total derivative we obtain + +$$ +0 = \nabla_ {W} ^ {2} \mathcal {L} _ {T} (W, \phi) \nabla_ {\phi} W ^ {*} (\phi) + \nabla_ {\phi} \nabla_ {W} \mathcal {L} _ {T} (W, \phi). \tag {6} +$$ + +Multiplying by $\nabla_W^2\mathcal{L}_T(W,\phi)^{-1}$ and reordering we obtain + +$$ +\nabla_ {\phi} W ^ {*} (\phi) = - \nabla_ {W} ^ {2} \mathcal {L} _ {T} (W, \phi) ^ {- 1} \nabla_ {\phi} \nabla_ {W} \mathcal {L} _ {T} (W, \phi). \tag {7} +$$ + +We can use this result to compute the gradients of the auxiliary set loss w.r.t $\phi$ + +$$ +\nabla_ {\phi} \mathcal {L} _ {A} \left(W ^ {*} (\phi)\right) = \nabla_ {W} \mathcal {L} _ {A} \cdot \nabla_ {\phi} W ^ {*} (\phi) = - \nabla_ {W} \mathcal {L} _ {A} \cdot \left(\nabla_ {W} ^ {2} \mathcal {L} _ {T}\right) ^ {- 1} \cdot \nabla_ {\phi} \nabla_ {W} \mathcal {L} _ {T}. \tag {8} +$$ + +As discussed in the main text, fully optimizing $W$ to convergence is too computationally expensive. Instead, we update $\phi$ once for every several update steps for $W$ , as seen in Alg. 1. To compute the vector inverse-Hessian product, we use Alg. 2 that was proposed in (Lorraine et al., 2020). + +# B EXPERIMENTAL DETAILS + +# B.1 CUB 200-2011 + +Data. To examine the effect of varying training set sizes we use all 5994 predefined images for training according to the official split and, we split the predefined test set to 2897 samples for validation and 2897 for testing. All images were resized to $256 \times 256$ and Z-score normalized. During training, images were randomly cropped to 224 and flipped horizontally. Test images were centered cropped to 224. The same processing was applied in all fine-grain experiments. + +Training details for baselines. We fine-tuned a ResNet-18 (He et al., 2016) pre-trained on ImageNet (Deng et al., 2009) with a classification layer on top for all tasks. Because the scale of auxiliary losses differed from that of the main task, we multiplied each auxiliary loss, on all compared method, by the scaling factor $\tau = 0.1$ . It was chosen based on a grid search over $\{0.1, 0.3, 0.6, 1.0\}$ using the Equal baseline. We applied grid search over the learning rates in $\{1e - 3, 1e - 4, 1e - 5\}$ and the weight decay in $\{5e - 3, 5e - 4, 5e - 5\}$ . For DWA (Liu et al., 2019b), we searched over the temperature in $\{0.5, 2, 5\}$ and for GradNorm (Chen et al., 2018), over $\alpha$ in $\{0.3, 0.8, 1.5\}$ . The computational complexity of GSC (Du et al., 2018) grows with the number of tasks. As a result, we were able to run this baseline only in a setup where there are two loss terms: the main and the sum of all auxiliary tasks. We ran each configuration with 3 different seeds for 100 epochs with ADAM optimizer (Kingma and Ba, 2014) and used early stopping based on the validation set. + +The auxiliary set and auxiliary network. In our experiments, we found that allocating as little as 20 samples from the training set for the auxiliary set and using a NN with 5 layers and 10 units in each layer yielded good performance for both deep linear and non-linear models. We found that our method was not sensitive to these design choices. We use skip connection between the main loss $\ell_{\text{main}}$ and the overall loss term and Softplus activation. + +Optimization of the auxiliary network. In all variants of our method, the auxiliary network was optimized using SGD with 0.9 momentum. We applied grid search over the auxiliary network learning rate in $\{1e - 2, 1e - 3\}$ and weight decay in $\{1e - 5, 5e - 5\}$ . The total training time of all methods was 3 hours on a 16GB Nvidia V100 GPU. + +# B.2 NYUv2 + +The data consists of 1449 RGB-D images, split into 795 train images and 654 test images. We further split the train set to allocate 79 images, $10\%$ of training examples, to construct a validation + +set. Following (Liu et al., 2019b), we resize images to $288 \times 384$ pixels for training and evaluation and use SegNet (Badrinarayanan et al., 2017) based architecture as the backbone. + +Similar to (Liu et al., 2019b), we train the model for 200 epochs using Adam optimizer (Kingma and Ba, 2014) with learning rate $1e - 4$ , and halve the learning rate after 100 epochs. We choose the best model with early stopping on a pre-allocated validation set. For DWA (Liu et al., 2019b) we set the temperature hyperparameter to 2, as in the NYUv2 experiment in (Liu et al., 2019b). For GradNorm (Chen et al., 2018) we set $\alpha = 1.5$ . This value for $\alpha$ was used in (Chen et al., 2018) for the NYUv2 experiments. In all variants of our method, the auxiliary networks are optimized using SGD with 0.9 momentum. We allocate $2.5\%$ of training examples to form an auxiliary set. We use grid search to tune the learning rate $\{1e - 3, 5e - 4, 1e - 4\}$ and weight decay $\{1e - 5, 1e - 4\}$ of the auxiliary networks. Here as well, we use skip connection between the main loss $\ell_{main}$ and the overall loss term and Softplus activation. + +# B.3 LEARNING AUXILIARIES + +Multi-class classification datasets. On the CIFAR datasets, we train the model for 200 epochs using SGD with momentum 0.9, weight decay $5e - 4$ , and initial learning rates $1e - 1$ and $1e - 2$ for CIFAR10 and CIFAR100, respectively. For the SVHN experiment, we train for 50 epochs using SGD with momentum 0.9, weight decay $5e - 4$ , and initial learning rates $1e - 1$ . The learning rate is modified using a cosine annealing scheduler. We use VGG-16 (Simonyan and Zisserman, 2014) based architecture for the CIFAR experiments, and a 4-layer ConvNet for the SVHN experiment. For MAXL (Liu et al., 2019a) label generating network, we tune the following hyperparameters: learning rate $\{1e - 3,5e - 4\}$ , weight decay $\{5e - 4,1e - 4,5e - 5\}$ , and entropy term weight $\{.2,.4,.6\}$ (see (Liu et al., 2019a) for details). We explore the same learning rate and weight decay for the auxiliary network in our method, and also tune the number of optimization steps between every auxiliary parameter update $\{5,15,25\}$ , and the size of the auxiliary set $\{1.5\%,2.5\% \}$ (of training examples). We choose the best model on the validation set and allow for early stopping. + +Fine-grain classification datasets. In CUB experiments we use the same data and splits as described in Sections 5.2 and B.1. Oxford-IIIT Pet contains 7349 images of 37 species of dogs and cats. We use the official train-test split. We pre-allocate $30\%$ from the training set to validation. As a results, the total number of train/validation/test images are 2576/1104/3669 respectively. Cars (Krause et al., 2013) contains 16, 185 images of 196 car classes. We use the official train-test split and pre-allocate $30\%$ from the training set to validation. As a results, the total number of train/validation/test images are 5700/2444/8041 respectively. In all experiments we use ResNet-18 as the backbone network for both the primary and auxiliary networks. Importantly, the networks are not pre-trained. The task specific (classification) heads in both the primary and auxiliary networks is implemented using a 2-layer NN with sizes 512 and $C$ . Where $C$ is number of labels (e.g., 200 for CUB and 37 for Oxford-IIIT Pet). In all experiments we use the same learning rate of $1e - 4$ and weight decay of $5e - 3$ which were shown to work best, based on a grid search applied on the STL baseline. For MAXL and AuxiLearn we applied a grid search over the auxiliary network learning rate and weight decay as described in the Multi-class classification datasets subsection. We tune the number of optimization steps between every auxiliary parameter update in $\{30,60\}$ for Oxford-IIIT Pet and $\{40,80\}$ for CUB and Cars. Also, the auxiliary set size was tuned over $\{0.084\%, 1.68\%, 3.33\%\}$ with stratified sampling. For our method, we leverage the module of AuxiLearn for combining auxiliaries. We use a Nonlinear network with either two or three hidden layers of sizes 10 (which was selected according to a grid search). The batch size was set to 64 in CUB and Cars experiments and to 16 in Oxford-IIIT Pet experiments. We ran each configuration with 3 different seeds for 150 epochs with ADAM optimizer and used early stopping based on the validation set. + +# C ADDITIONAL EXPERIMENTS + +# C.1 IMPORTANCE OF AUXILIARY SET + +In this section we illustrate the importance of the auxiliary set to complement our theoretical observation in Section 4. We repeat the experiment in Section 5.1, but this time we optimize the auxiliary parameters $\phi$ using the training data. Figure 5 shows how the tasks' weights change during training. The optimization procedure is reduced to single-task learning, which badly hurts + +![](images/741af778e6dafe4dc6a9c98190d4981a7bd40289183c667699785fad983c6570.jpg) +Figure 5: Optimizing task weights on the training set reduce to single-task learning. + +generalization (see Figure 2). These results are consistent with (Liu et al., 2019a) that added an entropy loss term to avoid the diminishing auxiliary task. + +# C.2 MONOTONOCITY + +As discussed in the main text, it is a common practice to combine auxiliary losses as a convex combination. This is equivalent to parametrize the function $g(\ell; \phi)$ as a linear combination over losses $g(\ell; \phi) = \sum_{j=1}^{K} \phi_j \ell_j$ , with non-negative weights, $\phi_j \geq 0$ . Under this parameterization, $g$ is a monotonic non-decreasing function of the losses, since $\partial \mathcal{L}_T / \partial \ell_j \geq 0$ . The non-decreasing property means that the overall loss grows (or is left unchanged) with any increase to the auxiliary losses. As a result, an optimization procedure that operates to minimize the combined loss also operates in the direction of reducing individual losses (or not changing them). + +A natural question that arises is whether the function $g$ should generalize this behavior, and be constrained to be non-decreasing w.r.t. the losses as well? Non-decreasing networks can "ignore" an auxiliary task by zeroing its corresponding loss, but cannot reverse the gradient of a task by negating its weight. While monotonicity is a very natural requirement, in some cases, negative task weights (i.e., non-monotonicity) seem desirable if one wishes to "delete" input information not directly related to the task at hand (Alemi et al., 2017; Ganin and Lempitsky, 2015). For example, in domain adaptation, one might want to remove information that allows a discriminator to recognize the domain of a given sample (Ganin and Lempitsky, 2015). Empirically, we found that training with monotonic non-decreasing networks to be more stable and has better or equivalent performance, see Table 4 for comparison. + +Table 4 compares monotonic and non-monotonic auxiliary networks in both the semi-supervised and the fully-supervised setting. Monotonic networks show a small but consistent improvement over non-monotonic ones. It is also worth mentioning that the non-monotonic networks were harder to stabilize. + +Table 4: CUB 200-2011: Monotonic vs non-monotonic test classification accuracy (± SEM) over three runs. + +
Top 1Top 3
5-shotNon-Monotonic46.3 ± 0.3267.46 ± 0.55
Monotonic47.07 ± 0.1068.25 ± 0.32
10-shotNon-Monotonic58.84 ± 0.0477.67 ± 0.08
Monotonic59.04 ± 0.2278.08 ± 0.24
Full DatasetNon-Monotonic74.74 ± 0.3088.3 ± 0.23
Monotonic74.92 ± 0.2188.55 ± 0.17
+ +# C.3 NOISY AUXILIARIES + +We demonstrate the effectiveness of AuxiLearn in identifying helpful auxiliaries and ignoring harmful ones. Consider a regression problem with main task $y = \mathbf{w}^T\mathbf{x} + \epsilon$ , where $\epsilon \sim \mathcal{N}(0,\sigma^2)$ . We learn this task jointly with $K = 100$ auxiliaries of the form $y_{j} = \mathbf{w}^{T}\mathbf{x} + |\epsilon_{j}|$ , where $\epsilon_{j} \sim \mathcal{N}(0,j\cdot \sigma_{aux}^{2})$ for $j = 1,\dots,100$ . We use the absolute value on the noise so that noisy estimations are no longer unbiased, making the noisy labels even less helpful as the noise increases. We use a linear auxiliary network to weigh the loss terms. Figure 6 shows the learned weight for each task. We can see that the auxiliary network captures the noise patterns, and assign weights based on the noise level. + +![](images/db61b71714b113ce073273f17bbd2594b1b9a780b173f4ffd17391112a9df8e9.jpg) +Figure 6: Learning with noisy labels: task ID is proportional to the label noise. + +# C.4 CUB SENSITIVITY ANALYSIS + +In this section, we provide further analysis for the experiments conducted on the CUB 200-2011 dataset in the 5-shot setup. We examine the sensitivity of a non-linear auxiliary network to the size of the auxiliary set, and the depth of the auxiliary network. In Figure 7a we test the effect of allocating (labeled) samples from the training set to the auxiliary set. As seen, allocating between $10 - 50$ samples results in similar performance picking at 20. The figure shows that removing too many samples from the training set can be damaging. Nevertheless, we notice that even when allocating 200 labeled samples (out of 1000), our nonlinear method is still better than the best competitor GSC (Du et al., 2018) (which reached an accuracy of 42.57). + +Figure 7b shows how accuracy changes with the number of hidden layers. As expected, there is a positive trend. As we increase the number of layers, the network expressivity increases, and the performance improves. Clearly, making the auxiliary network too large may cause the network to overfit the auxiliary set as was shown in Section 4, and empirically in (Lorraine et al., 2020). + +# C.5 LINEARLY WEIGHTED NON-LINEAR TERMS + +To further motivate the use of non-linear interactions between tasks, we train a linear auxiliary network over a polynomial kernel on the tasks segmentation, depth estimation and normal prediction from the NYUv2 dataset. Figure 8 shows the learned loss weights. From the figure, we learn that two of the three largest weights at the end of training belong to non-linear terms, specifically, $\text{Seg}^2$ and $\text{Seg} \cdot \text{Depth}$ . Also, we observe a scheduling effect, in which at the start of training, the auxiliary network focuses on the auxiliary tasks (first $\sim 50$ steps), and afterwards it draws most of the attention of the primary network towards the main task. + +# C.6 FIXED AUXILIARY + +As a result of alternating between optimizing the primary network parameters and the auxiliary parameters, the weighting of the loss terms are updated during the training process. This means that the loss landscape is changed during training. This effect is observed in the illustrative examples + +![](images/a8a2bace2b7cece8f9c24cf5045838a11a27b0d63cde56a100c07a8b2453fd4c.jpg) +(a) Effect of auxiliary set size + +![](images/5016743c851747e3b7232a357110797698d6bfa82022e5c23b01f56f67a43dac.jpg) +(b) Effect of Depth +Figure 7: Mean test accuracy $(\pm$ SEM) averaged over 3 runs as a function of the number of samples in the auxiliary set (left) and the number of hidden layers (right). Results are on 5-shot CUB 200-2011 dataset. + +![](images/047745223b62ef0dc26dc7eafc1709823fbfd3ac4af5acb3298ee411ebe0582d.jpg) +Polynomial kernel - linear weights +Figure 8: Learned linear weights for a polynomial kernel on the loss terms of the tasks segmentation, depth estimation and normal prediction from the NYUv2 dataset. + +described in Section 5.1 and Section C.5, where the auxiliary network focuses on different tasks during different learning stages. Since the optimization is non-convex, the end result may depend not only on the final parameters but also on the loss landscape during the entire process. + +We examined this effect with the following setup on the 5-shot setting on CUB 200-2011 dataset: we trained a non-linear auxiliary network and saved the best model. Then we retrain with the same configuration, only this time, the auxiliary network is initialized using the best model, and is kept fixed. We repeat this using ten different random seeds, affecting the primary network initialization and data shuffling. As a result, we observed a drop of $6.7\%$ on average in the model performance with an std of $1.2\%$ (46.7% compared to $40\%$ ). + +# C.7 FULL CUB DATASET + +In Section 5.2 we evaluated AuxiLearn and the baseline models performance under a semi-supervised scenario in which we have 5 or 10 labeled samples per class. For completeness sake, we show in Table 5 the test accuracy results in the standard fully-supervised scenario. As can be seen, in this case the STL baseline achieves the highest top-1 test accuracy while our nonlinear method is second on the top-1 and first on the top-3. Most baselines suffer from severe negative transfer due to the large number of auxiliary tasks (which are not needed in this case) while our method cause minimal performance degradation. + +Table 5: CUB 200-2011: Fully supervised test classification accuracy (± SEM) averaged over three runs. + +
Top 1Top 3
STL75.2 ± 0.5288.4 ± 0.36
Equal70.16 ± 0.1086.87 ± 0.22
Uncertainty74.70 ± 0.5688.21 ± 0.14
DWA69.88 ± 0.1086.62 ± 0.20
GradNorm70.04 ± 0.2186.63 ± 0.13
GSC71.30 ± 0.0186.91 ± 0.28
AuxiLearn (ours)
Linear70.97± 0.3186.92 ± 0.08
Deep Linear73.6 ± 0.7288.37 ± 0.21
Nonlinear74.92 ± 0.2188.55 ± 0.17
+ +# C.8 CITYSCAPES + +Cityscapes (Cordts et al., 2016) is a high-quality urban-scene dataset. We use the data provided in (Liu et al., 2019b) with 2975 training and 500 test images. The data comprises of four learning tasks: 19-classes, 7-classes and 2-classes semantic segmentation, and depth estimation. We use the 19-classes semantic segmentation as the main task, and all other tasks as auxiliaries. We allocate $10\%$ of the training data for validation set, to allow for hyperparameter tuning and early stopping. We further allocate $2.5\%$ of the remaining training examples to construct the auxiliary set. All images are resized to $128 \times 256$ to speed up computation. + +We train a SegNet (Badrinarayanan et al., 2017) based model for 150 epochs using Adam optimizer (Kingma and Ba, 2014) with learning rate $1e - 4$ , and halve the learning rate after 100 epochs. We search over weight decay in $\{1e - 4,1e - 5\}$ . We compare AuxiLearn to the same baselines used in Section 5.2 and search over the same hyperparameters as in the NYUv2 experiment. We set the DWA temperature to 2 similar to (Liu et al., 2019b), and the GradNorm hyperparameter $\alpha$ to 1.5, as used in (Chen et al., 2018) for the NYUv2 experiments. We present the results in Table 6. The ConvNet variant of the auxiliary network achieves best performance in terms of mIoU and pixel accuracy. + +Table 6: 19-classes semantic segmentation test set results on Cityscapes, averaged over three runs (± SEM). + +
mIoUPixel acc.
STL30.18 ± 0.0487.08 ± 0.18
Equal30.45 ± 0.1487.14 ± 0.08
Uncertainty30.49 ± 0.2186.89 ± 0.07
DWA30.79 ± 0.3286.97 ± 0.26
GradNorm30.62 ± 0.0387.15 ± 0.04
GCS30.32 ± 0.2387.02 ± 0.12
AuxiLearn (ours)
Linear30.63 ± 0.1986.88 ± 0.03
Nonlinear30.85 ± 0.1987.19 ± 0.20
ConvNet30.99 ± 0.0587.21 ± 0.11
+ +# C.9 LEARNING SEGMENTATION AUXILIARY FOR 3D POINT CLOUDS + +Recently, several methods were offered for learning auxiliary tasks in point clouds (Achituve et al., 2020; Hassani and Haley, 2019; Sauder and Sievers, 2019); however, this domain is still largely unexplored and it is not yet clear which auxiliary tasks could be beneficial beforehand. Therefore, it is desirable to automate this process, even at the cost of performance degradation to some extent compared to human designed methods. + +We further evaluate our method in the task of generating helpful auxiliary tasks for 3D point-cloud data. We propose to extend the use of AuxiLearn for segmentation tasks. In Section 5.4 we trained an auxiliary network to output soft auxiliary labels for classification task. Here, we use a similar + +Table 7: Learning auxiliary segmentation task. Test mean IOU on ShapeNet part dataset averaged over three runs (±SEM) - 30 shot + +
MeanAirplaneBagCapCarChairEarphoneGuitarKnifeLampLaptopMotorbikeMugPistolRocketSkateboardTable
Num. samples287434114111587041415980286835138441231848
STL75.668.782.985.265.682.370.286.175.168.494.355.191.072.660.272.374.2
DAE74.066.677.679.160.581.273.887.177.065.493.651.888.474.055.468.472.7
DefRec74.668.681.283.863.682.172.986.972.769.493.451.889.772.057.270.571.7
RS76.569.779.185.964.983.868.482.879.470.794.558.991.872.053.470.375.0
AuxiLearn76.268.978.383.664.983.469.787.480.768.394.653.292.173.761.672.474.6
+ +approach, assigning a soft label vector to each point. We then train the primary network on the main task and the auxiliary task of segmenting each point based on the learned labels. + +We evaluated the above approach in a part-segmentation task using the ShapeNet part dataset (Yi et al., 2016). This dataset contains 16,881 3D shapes from 16 object categories (including Airplane, Bag, Lamp), annotated with a total of 50 parts (at most 6 parts per object). The main task is to predict a part label for each point. We follow the official train/val/test split scheme in (Chang et al., 2015). We also follow the standard experimental setup in the literature, which assumes known object category labels during segmentation of a shape (see e.g., (Qi et al., 2017; Wang et al., 2019)). During training we uniformly sample 1024 points from each shape and we ignore points normal. During evaluation we use all points of a shape. For all methods (ours and baselines) we used the DGCNN architecture (Wang et al., 2019) as the backbone feature extractor and for part segmentation. We evaluated performance using point-Intersection over Union (IoU) following (Qi et al., 2017). + +We compared AuxiLearn with the following baselines: (1) Single Task Learning (STL): Training with the main task only. (2) DefRec: An auxiliary task of reconstructing a shape with a deformed region (Achituve et al., 2020). (3) Reconstructing Spaces (RS): An auxiliary task of reconstructing a shape from a shuffled version of it (Sauder and Sievers, 2019). and (4) Denoising Auto-encoder (DAE): An auxiliary task of reconstructing a point-cloud perturbed with an iid noise from $\mathcal{N}(0,0.01)$ . + +We performed hyper-parameter search over the primary network learning rate in $\{1e - 3,1e - 4\}$ , weight decay in $\{5e - 5,1e - 5\}$ and weight ratio between the main and auxiliary task of $\{1:1,1:0.5,1:0.25\}$ . We trained each method for 150 epochs, used the Adam optimizer with cosine scheduler. We applied early stopping based on the mean IoU of the validation set. We ran each configuration with 3 different seeds and report the average mean IoU along with the SEM. We used the segmentation network proposed in (Wang et al., 2019) with an exception that the network wasn't supplied with the object label as input. + +For AuxiLearn, we used a smaller version of PointNet (Qi et al., 2017) as the auxiliary network without input and feature transform layers. We selected PointNet because its model complexity is light and therefore is a good fit in our case. We learned a different auxiliary task per each object category (with 6 classes per category) since it showed better results. We performed hyper-parameter search over the auxiliary network learning rate in $\{1e - 2,1e - 3\}$ , weight decay in $\{5e - 3,5e - 4\}$ . Two training samples from each class were allocated for the auxiliary set. + +Table 7 shows the mean IOU per category when training with only 30 segmented point-clouds per object category (total of 480). As can be seen, AuxiLearn performance is close to RS (Sauder and Sievers, 2019) and improve upon other baselines. This shows that in this case, our method generates useful auxiliary tasks that has shown similar or better gain than those designed by humans. + +# C.10 LEARNING AN AUXILIARY CLASSIFIER + +In Section 5.4 we show how AuxiLearn learns a novel auxiliary to improve upon baseline methods. For the fine-grained classification experiments, we use only 30 samples per class. Here we also compare AuxiLearn with the baseline methods when there are only 15 images per class. Table 8 shows that AuxiLearn is superior to baseline methods in this setup as well, even though it requires to allocate some samples from the training data to the auxiliary set. + +To further examine the effect of learning novel auxiliary task with varying train set size, we provide here additional experiments on the CIFAR10 dataset. We evaluate the methods with of $10\%$ , $15\%$ and $100\%$ of training examples. The results are presented in Table 9. As expected, learning with + +Table 8: Learning auxiliary task. Test accuracy averaged over three runs (±SEM) - 15 shot + +
CUBPet
STL22.6 ± 0.213.6 ± 0.7
MAXL-F24.2 ± 0.714.1 ± 0.1
MAXL24.2 ± 0.814.2 ± 0.2
AuxiLearn26.1 ± 0.718.0 ± 0.9
+ +Table 9: CIFAR10 test results accuracy averaged over three runs (±SEM). + +
CIFAR10
10%15%100%
STL72.63 ± 2.1480.30 ± 0.0993.36 ± 0.05
MAXL75.85 ± 0.3281.37 ± 0.2693.49 ± 0.02
AuxiLearn76.75 ± 0.0881.42 ± 0.3093.54 ± 0.05
+ +auxiliaries is mostly helpful in the low data regime. Nonetheless, AuxiLearn improves over single task learning and MAXL for all training set sizes. + +# D THEORETICAL CONSIDERATIONS + +In this section, we discuss the theoretical limitations of AuxiLearn. First, we discuss the smoothness of our loss criterion while learning to combine losses using DNNs. Next, we present limitations that may arise from utilizing the IFT and their resolution. Finally, we discuss the approximations made for achieving an efficient optimization procedure. + +Smoothness of the loss criterion. When learning to combine losses as described in Section 3.2, one must take into consideration the smoothness of the learn loss criterion as a function of $W$ . This limits, at least in theory, the design choice of the auxiliary network. In our experiments we use smooth activation functions, namely Softplus, to ensure the existence of $\partial \mathcal{L}_T / \partial W$ . Nonetheless, using non-smooth activation (e.g. ReLU) results with a piecewise smooth loss function hence might work well in practice. + +Assumptions for IFT. One assumption for applying the IFT as described in Section 3.4, is that $\mathcal{L}_T$ is continuously differentiable w.r.t to the auxiliary and primary parameters. This assumption limits the design choice of both the auxiliary, and the primary networks. For instance, one must utilize only smooth activation functions. However, many non-smooth components can be replaced with smooth counterparts. For example, ReLU can be replaced with Softplus, $ReLU(x) = \lim_{\alpha \to \infty}\ln (1 + \exp (\alpha x)) / \alpha$ , and the beneficial effects of Batch-Normalization can be captured with Weight-Normalization as argued in (Salimans and Kingma, 2016). + +For the setup of learning to combine losses, we use the above substitutes, namely Softplus and Weight Normalization, however for the learning a novel auxiliary setup, we share architecture between primary and auxiliary network (e.g. ResNet18). While using non-smooth components may, in theory, cause issues, we show empirically through extensive experiment that AuxiLean performs well in practice, and its optimization is stable. Furthermore, we note that while RLUs are non-smooth, they are piecewise smooth, hence the set of non-smoothness points is a zero-measure set. + +Approximations. Our optimization procedure relies on several approximations to efficiently solve complex bi-level optimization. This trade-off between computation efficiency and accurate approximation can be controlled by (i) The number of Neumann series components, and; (ii) The number of optimization steps between auxiliary parameters update. While we cannot guarantee that the bi-level optimization process converges, empirically we observe a stable optimization process. + +Our work builds on previous studies in the field of hyperparameter optimization (Lorraine et al., 2020; Pedregosa, 2016). Lorraine et al. (2020) provide an error analysis for both approximations, in a setup for which the exact Hessian can be evaluated in closed form. We refer the readers to Pedregosa (2016) for theoretical analysis and results regarding the second approximation (i.e. sub-optimally of the inner optimization problem in Eq. 2). \ No newline at end of file diff --git a/auxiliarylearningbyimplicitdifferentiation/images.zip b/auxiliarylearningbyimplicitdifferentiation/images.zip new file mode 100644 index 0000000000000000000000000000000000000000..27402e7488a852390077c9fc90837cf4bcd3e04f --- /dev/null +++ b/auxiliarylearningbyimplicitdifferentiation/images.zip @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c4788182c79fd99b7cdfe419a3ec4ccb809dcca8585bf41d15e99599f68d7e3f +size 542032 diff --git a/auxiliarylearningbyimplicitdifferentiation/layout.json b/auxiliarylearningbyimplicitdifferentiation/layout.json new file mode 100644 index 0000000000000000000000000000000000000000..53ec9d15448a69600f462c5bc95e53cc56e4ee19 --- /dev/null +++ b/auxiliarylearningbyimplicitdifferentiation/layout.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3d8ac08e247db4e08c9cab67edafd221aa273c3206d0244cbb362e1d9bb572e6 +size 685069 diff --git a/averagecaseaccelerationforbilineargamesandnormalmatrices/a2131a7c-1207-4a46-87c5-3883e655b7ea_content_list.json b/averagecaseaccelerationforbilineargamesandnormalmatrices/a2131a7c-1207-4a46-87c5-3883e655b7ea_content_list.json new file mode 100644 index 0000000000000000000000000000000000000000..77a2747bef47bcc70af9f6e632408a174c0728ec --- /dev/null +++ b/averagecaseaccelerationforbilineargamesandnormalmatrices/a2131a7c-1207-4a46-87c5-3883e655b7ea_content_list.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ab5b26bc84db76dfc3f77cdca5b2478a35fbfbf9b050067c7d59ced04bccb6f3 +size 171403 diff --git a/averagecaseaccelerationforbilineargamesandnormalmatrices/a2131a7c-1207-4a46-87c5-3883e655b7ea_model.json b/averagecaseaccelerationforbilineargamesandnormalmatrices/a2131a7c-1207-4a46-87c5-3883e655b7ea_model.json new file mode 100644 index 0000000000000000000000000000000000000000..1689484ace280bea4eb9ec7c45448e550e839107 --- /dev/null +++ b/averagecaseaccelerationforbilineargamesandnormalmatrices/a2131a7c-1207-4a46-87c5-3883e655b7ea_model.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:fc33f12e807d4e7a948be6d22075d16afa899115406ab55495da781b4fbbd197 +size 193352 diff --git a/averagecaseaccelerationforbilineargamesandnormalmatrices/a2131a7c-1207-4a46-87c5-3883e655b7ea_origin.pdf b/averagecaseaccelerationforbilineargamesandnormalmatrices/a2131a7c-1207-4a46-87c5-3883e655b7ea_origin.pdf new file mode 100644 index 0000000000000000000000000000000000000000..9977d1aa278004142bb30ed2c49a04a76ec380ea --- /dev/null +++ b/averagecaseaccelerationforbilineargamesandnormalmatrices/a2131a7c-1207-4a46-87c5-3883e655b7ea_origin.pdf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:236d4d567420c1fb4f688eea4d7ab48979b03467fbe4445661dff825126d1acf +size 533883 diff --git a/averagecaseaccelerationforbilineargamesandnormalmatrices/full.md b/averagecaseaccelerationforbilineargamesandnormalmatrices/full.md new file mode 100644 index 0000000000000000000000000000000000000000..b2610e966b2682ba1dd7087cde0cbaf812a71692 --- /dev/null +++ b/averagecaseaccelerationforbilineargamesandnormalmatrices/full.md @@ -0,0 +1,999 @@ +# AVERAGE-CASE ACCELERATION FOR BILINEAR GAMES AND NORMAL MATRICES + +Carles Domingo-Enrich + +Computer Science Department + +Courant Institute of Mathematical Sciences + +New York University + +New York, NY 10012, USA + +cd2754@nyu.edu + +Fabian Pedregosa + +Google Research + +pedregosa@google.com + +Damien Scieur + +Samsung SAIT AI Lab & Mila + +Montreal, Canada + +damien.scieur@gmail.com + +# ABSTRACT + +Advances in generative modeling and adversarial learning have given rise to renewed interest in smooth games. However, the absence of symmetry in the matrix of second derivatives poses challenges that are not present in the classical minimization framework. While a rich theory of average-case analysis has been developed for minimization problems, little is known in the context of smooth games. In this work we take a first step towards closing this gap by developing average-case optimal first-order methods for a subset of smooth games. We make the following three main contributions. First, we show that for zero-sum bilinear games the average-case optimal method is the optimal method for the minimization of the Hamiltonian. Second, we provide an explicit expression for the optimal method corresponding to normal matrices, potentially non-symmetric. Finally, we specialize it to matrices with eigenvalues located in a disk and show a provable speed-up compared to worst-case optimal algorithms. We illustrate our findings through numerical simulations with a varying degree of mismatch with our assumptions. + +# 1 INTRODUCTION + +The traditional analysis of optimization algorithms is a worst-case analysis (Nemirovski, 1995; Nesterov, 2004). This type of analysis provides a complexity bound for any input from a function class, no matter how unlikely. However, since hard-to-solve inputs might rarely occur in practice, the worst-case complexity bounds might not be representative of the observed running time. + +A more representative analysis is given by the average-case complexity, averaging the algorithm's complexity over all possible inputs. This analysis is standard for analyzing, e.g., sorting (Knuth, 1997) and cryptography algorithms (Katz & Lindell, 2014). Recently, a line of work (Berthier et al., 2020; Pedregosa & Scieur, 2020; Lacotte & Pilanci, 2020; Paquette et al., 2020) focused on optimal methods for the optimization of quadratics, specified by a symmetric matrix. While worst-case analysis uses bounds on the matrix eigenvalues to yield upper and lower bounds on convergence, average-case analysis relies on the expected distribution of eigenvalues and provides algorithms with sharp optimal convergence rates. While the algorithms developed in this context have been shown to be efficient for minimization problems, these have not been extended to smooth games. + +A different line of work considers algorithms for smooth games but studies worst-case optimal methods (Azizian et al., 2020). In this work, we combine average-case analysis with smooth games, and develop novel average-case optimal algorithms for finding the root of a linear system determined by a (potentially non-symmetric) normal matrix. We make the following main contributions: + +1. Inspired by the problem of finding equilibria in smooth games, we develop average-case optimal algorithms for finding the root of a non-symmetric affine operator, both under a normality assumption (Thm. 4.1), and under the extra assumption that eigenvalues of the operator are supported in a disk (Thm. 4.2). The proposed method shows a polynomial speedup compared to the worst-case optimal method, verified by numerical simulations. +2. We make a novel connection between average-case optimal methods for optimization, and average-case optimal methods for bilinear games. In particular, we show that solving the Hamiltonian using an average-case optimal method is optimal (Theorem 3.1) for bilinear games. This result complements (Azizian et al., 2020), who proved that Polyak Heavy Ball algorithm on the Hamiltonian is asymptotically worst-case optimal for bilinear games. + +# 2 AVERAGE-CASE ANALYSIS FOR NORMAL MATRICES + +In this paper we consider the following class of problems. + +Definition 1. Let $\mathbf{A} \in \mathbb{R}^{d \times d}$ be a real matrix and $\mathbf{x}^{\star} \in \mathbb{R}^{d}$ a vector. The non-symmetric (affine) operator (NSO) problem is defined as: + +$$ +F i n d \boldsymbol {x}: F (\boldsymbol {x}) \stackrel {\text {d e f}} {=} A (\boldsymbol {x} - \boldsymbol {x} ^ {\star}) = \mathbf {0}. \tag {NSO} +$$ + +This problem generalizes that of minimization of a convex quadratic function $f$ , since we can cast the latter in this framework by setting the operator $F = \nabla f$ . The set of solutions is an affine subspace that we will denote $\mathcal{X}^{\star}$ . We will find convenient to consider the distance to this set, defined as + +$$ +\operatorname {d i s t} (\boldsymbol {x}, \mathcal {X} ^ {\star}) \stackrel {\text {d e f}} {=} \min _ {\boldsymbol {v} \in \mathcal {X} ^ {\star}} \| \boldsymbol {x} - \boldsymbol {v} \| ^ {2}, \quad \text {w i t h} \mathcal {X} ^ {\star} = \left\{\boldsymbol {x} \in \mathbb {R} ^ {d} \mid \boldsymbol {A} \left(\boldsymbol {x} - \boldsymbol {x} ^ {\star}\right) = \boldsymbol {0} \right\}. \tag {1} +$$ + +In this paper we will develop average-case optimal methods. For this, we consider $\mathbf{A}$ and $x^{\star}$ to be random vectors, and a random initialization $x_0$ . This induces a probability distribution over NSO problems, and we seek to find methods that have an optimal expected suboptimality w.r.t. this distribution. Denoting $\mathbb{E}_{(\mathbf{A},\mathbf{x}^{\star},\mathbf{x}_0)}$ the expectation over these random problems, we have that average-case optimal methods they verify the following property at each iteration $t$ + +$$ +\min _ {\boldsymbol {x} _ {t}} \mathbb {E} _ {\left(\boldsymbol {A}, \boldsymbol {x} ^ {\star}, \boldsymbol {x} _ {0}\right)} \operatorname {d i s t} \left(\boldsymbol {x} _ {t}, \mathcal {X} ^ {\star}\right) \quad \text {s . t .} \boldsymbol {x} _ {i} \in \boldsymbol {x} _ {0} + \operatorname {s p a n} \left(\left\{F \left(\boldsymbol {x} _ {j}\right) \right\} _ {j = 0} ^ {i - 1}\right), \forall i \in [ 1: t ]. \tag {2} +$$ + +The last condition on $\boldsymbol{x}_t$ stems from restricting the class of algorithms to first-order methods. The class of first-order methods encompasses many known schemes such as gradient descent with momentum, or full-matrix AdaGrad. However, methods such as Adam (Kingma & Ba, 2015) or diagonal AdaGrad (Duchi et al., 2011) are not in this class, as the diagonal re-scaling creates iterates $\boldsymbol{x}_t$ outside the span of previous gradients. Although we will focus on the distance to the solution, the results can be extended to other convergence criteria such as $\| F(\boldsymbol{x}_t)\|^2$ . + +Finally, note that the expectations in this paper are on the problem instance and not on the randomness of the algorithm. + +# 2.1 ORTHOGONAL RESIDUAL POLYNOMIALS AND FIRST-ORDER METHODS + +The analysis of first-order methods simplifies through the use of polynomials. This section provides the tools required to leverage this connection. + +Definition 2. A residual polynomial is a polynomial $P$ that satisfies $P(0) = 1$ . + +Proposition 2.1. (Hestenes et al., 1952) If the sequence $(\pmb{x}_t)_{t\in \mathbb{Z}_+}$ is generated by a first-order method, then there exist residual polynomials $P_{t}$ , each one of degree at most $t$ , verifying + +$$ +\boldsymbol {x} _ {t} - \boldsymbol {x} ^ {\star} = P _ {t} (\boldsymbol {A}) \left(\boldsymbol {x} _ {0} - \boldsymbol {x} ^ {\star}\right). \tag {3} +$$ + +As we will see, optimal average-case method are strongly related to orthogonal polynomials. We first define the inner product between polynomials, where we use $z^*$ for the complex conjugate of $z \in \mathbb{C}$ . + +Definition 3. For $P, Q \in \mathbb{R}[X]$ , we define the inner product $\langle \cdot, \cdot \rangle_{\mu}$ for a measure $\mu$ over $\mathbb{C}$ as + +$$ +\langle P, Q \rangle_ {\mu} \stackrel {\text {d e f}} {=} \int_ {\mathbb {C}} P (\lambda) Q (\lambda) ^ {*} \mathrm {d} \mu (\lambda). \tag {4} +$$ + +Definition 4. A sequence of polynomials $\{P_i\}$ is orthogonal (resp. orthonormal) w.r.t. $\langle \cdot, \cdot \rangle_{\mu}$ if + +$$ +\langle P _ {i}, P _ {i} \rangle_ {\mu} > 0 (r e s p. = 1); \quad \langle P _ {i}, P _ {j} \rangle_ {\mu} = 0 i f i \neq j. +$$ + +# 2.2 EXPECTED SPECTRAL DISTRIBUTION + +Following (Pedregosa & Scieur, 2020), we make the following assumption on the problem family. + +Assumption 1. $\pmb{x}_0 - \pmb{x}^\star$ is independent of $\pmb{A}$ , and $\mathbb{E}_{(\pmb{x}_0, \pmb{x}^\star)}[(\pmb{x}_0 - \pmb{x}^\star)(\pmb{x}_0 - \pmb{x}^\star)^\top] = \frac{R^2}{d}\pmb{I}_d$ . + +We will also require the following definitions to characterize difficulty of a problem class. Let $\{\lambda_1,\dots ,\lambda_d\}$ be the eigenvalues of a matrix $A\in \mathbb{R}^{d\times d}$ . We define the empirical spectral distribution of $A$ as the probability measure + +$$ +\hat {\mu} _ {\boldsymbol {A}} (\lambda) \stackrel {\text {d e f}} {=} \frac {1}{d} \sum_ {i = 1} ^ {d} \delta_ {\lambda_ {i}} (\lambda), \tag {5} +$$ + +where $\delta_{\lambda_i}$ is the Dirac delta, a distribution equal to zero everywhere except at $\lambda_i$ and whose integral over the entire real line is equal to one. Note that with this definition, $\int_{\mathcal{D}}\mathrm{d}\hat{\mu}_A(\lambda)$ corresponds to the proportion of eigenvalues in $\mathcal{D}$ . + +When $\mathbf{A}$ is a matrix-valued random variable, $\mu_{\mathbf{A}}$ is a measure-valued random variable. As such, we can define its expected spectral distribution + +$$ +\mu_ {\mathbf {A}} \stackrel {\text {d e f}} {=} \mathbb {E} _ {\mathbf {A}} [ \hat {\mu} _ {\mathbf {A}} ], \tag {6} +$$ + +which by the Riesz representation theorem is the measure that verifies $\int f\mathrm{d}\mu = \mathbb{E}_A[\int f\mathrm{d}\mu_A]$ for all measurable $f$ . Surprisingly, the expected spectral distribution is the only required characteristic to design optimal algorithms in the average-case. + +# 2.3 EXPECTED ERROR OF FIRST-ORDER METHODS + +In this section we provide an expression for the expected convergence in terms of the residual polynomial and the expected spectral distribution introduced in the previous section. To go further in the analysis, we have to assume that $A$ is a normal matrix. + +Assumption 2. The (real) random matrix $\mathbf{A}$ is normal, that is, it verifies $\mathbf{A}\mathbf{A}^{\top} = \mathbf{A}^{\top}\mathbf{A}$ . + +Normality is equivalent to $\mathbf{A}$ having the spectral decomposition $\mathbf{A} = \mathbf{U}\boldsymbol{\Lambda}\mathbf{U}^{*}$ , where $\mathbf{U}$ is unitary, i.e., $\mathbf{U}^{*}\mathbf{U} = \mathbf{U}\mathbf{U}^{*} = \mathbf{I}$ . We now have everything to write the expected error of a first-order algorithm applied to (NSO). + +Theorem 2.1. Consider the application of a first-order method associated to the sequence of polynomials $\{P_t\}$ (Proposition 2.1) on the problem (NSO). Let $\mu$ be the expected spectral distribution of $A$ . Under Assumptions 1 and 2, we have + +$$ +\mathbb {E} \left[ \operatorname {d i s t} \left(\boldsymbol {x} _ {t}, \boldsymbol {\mathcal {X}} ^ {\star}\right) \right] = R ^ {2} \int_ {\mathbb {C} \backslash \{0 \}} \left| P _ {t} \right| ^ {2} \mathrm {d} \mu , \tag {7} +$$ + +Before designing optimal algorithms for certain specific distributions, we compare our setting with the average-case accelerating for minimization problems of Pedregosa & Scieur (2020), who proposed optimal optimization algorithms in the average-case. + +# 2.4 DIFFICULTIES OF FIRST-ORDER METHODS ON GAMES AND RELATED WORK + +This section compares our contribution with the existing framework of average-case optimal methods for quadratic minimization problems. + +Definition 5. Let $\pmb{H} \in \mathbb{R}^{d \times d}$ be a random symmetric positive-definite matrix and $\pmb{x}^{\star} \in \mathbb{R}^{d}$ a random vector. These elements determine the following random quadratic minimization problem + +$$ +\min _ {\boldsymbol {x} \in \mathbb {R} ^ {d}} \left\{f (\boldsymbol {x}) \stackrel {{\text {d e f}}} {{=}} \frac {1}{2} \left(\boldsymbol {x} - \boldsymbol {x} ^ {\star}\right) ^ {\top} \boldsymbol {H} \left(\boldsymbol {x} - \boldsymbol {x} ^ {\star}\right) \right\}. \tag {OPT} +$$ + +As in our paper, Pedregosa & Scieur (2020) find deterministic optimal first-order algorithms in expectation w.r.t. the matrix $\pmb{H}$ , the solution $\pmb{x}^{\star}$ , and the initialization $\pmb{x}_0$ . Since they work with problem (OPT), their problem is equivalent to (NSO) with the matrix $A = H$ . However, they have the stronger assumption that the matrix is symmetric, which implies being normal. The normality assumption is restrictive in the case of game theory, as they do not always naturally fit such applications. However, this set is expressive enough to consider interesting cases, such as bilinear games, and our experiments show that our findings are also consistent with non-normal matrices. + +Using orthogonal residual polynomials and spectral distributions, they derive the explicit formula of the expected error. Their result is similar to Theorem 2.1, but the major difference is the domain of the integral, a real positive line in convex optimization, but a shape in the complex plane in our case. This shape plays a crucial role in the rate of converge of first-order algorithms, as depicted in the work of Azizian et al. (2020); Bollapragada et al. (2018). + +In the case of optimization methods, they show that optimal schemes in the average-case follow a simple three-term recurrence arising from the three-term recurrence for residual orthogonal polynomials for the measure $\lambda \mu (\lambda)$ . Indeed, by Theorem 2.1 the optimal method corresponds to the residual polynomials minimizing $\langle P,P\rangle_{\mu}$ , and the following result holds: + +Theorem 2.2. (Fischer, 1996, §2.4) When $\mu$ is supported in the real line, the residual polynomial of degree $t$ minimizing $\langle P, P \rangle_{\mu}$ is given by the degree $t$ residual orthogonal polynomial w.r.t. $\lambda \mu(\lambda)$ . + +However, the analogous result does not hold for general measures in $\mathbb{C}$ , and hence our arguments will make use of the following Theorem 2.3 instead, which links the residual polynomial of degree at most $t$ that minimizes $\langle P, P \rangle_{\mu}$ to the sequence of orthonormal polynomials for $\mu$ . + +Theorem 2.3. [Theorem 1.4 of Assche (1997)] Let $\mu$ be a positive Borel measure in the complex plane. The minimum of the integral $\int_{\mathbb{C}}|P(\lambda)|^2\mathrm{d}\mu (\lambda)$ over residual polynomials $P$ of degree lower or equal than $t$ is uniquely attained by the polynomial + +$$ +P ^ {\star} (\lambda) = \frac {\sum_ {k = 0} ^ {t} \phi_ {k} (\lambda) \phi_ {k} (0) ^ {*}}{\sum_ {k = 0} ^ {t} | \phi_ {k} (0) | ^ {2}}, \quad \text {w i t h o p t i m a l v a l u e} \int_ {\mathbb {C}} | P ^ {\star} (\lambda) | ^ {2} \mathrm {d} \mu (\lambda) = \frac {1}{\sum_ {k = 0} ^ {t} | \phi_ {k} (0) | ^ {2}}, \tag {8} +$$ + +where $(\phi_k)_k$ is the orthonormal sequence of polynomials with respect to the inner product $\langle \cdot, \cdot \rangle_{\mu}$ . + +In the next sections we consider cases where the optimal scheme is identifiable. + +# 3 AVERAGE-CASE OPTIMAL METHODS FOR BILINEAR GAMES + +We consider the problem of finding a Nash equilibrium of the zero-sum minimax game given by + +$$ +\min _ {\boldsymbol {\theta} _ {1}} \max _ {\boldsymbol {\theta} _ {2}} \ell \left(\boldsymbol {\theta} _ {1}, \boldsymbol {\theta} _ {2}\right) \stackrel {\text {d e f}} {=} \left(\boldsymbol {\theta} _ {1} - \boldsymbol {\theta} _ {1} ^ {\star}\right) ^ {\top} M \left(\boldsymbol {\theta} _ {2} - \boldsymbol {\theta} _ {2} ^ {\star}\right). \tag {9} +$$ + +Let $\pmb{\theta}_1, \pmb{\theta}_1^* \in \mathbb{R}^{d_1}, \pmb{\theta}_2, \pmb{\theta}_2^* \in \mathbb{R}^{d_2}, \pmb{M} \in \mathbb{R}^{d_1 \times d_2}$ and $d \stackrel{\mathrm{def}}{=} d_1 + d_2$ . The vector field of the game (Balduzzi et al., 2018) is defined as $F(\pmb{x}) = \pmb{A}(\pmb{x} - \pmb{x}^*)$ , where + +$$ +F \left(\boldsymbol {\theta} _ {1}, \boldsymbol {\theta} _ {2}\right) = \left[ \begin{array}{c} \nabla_ {\boldsymbol {\theta} _ {1}} \ell \left(\boldsymbol {\theta} _ {1}, \boldsymbol {\theta} _ {2}\right) \\ - \nabla_ {\boldsymbol {\theta} _ {2}} \ell \left(\boldsymbol {\theta} _ {1}, \boldsymbol {\theta} _ {2}\right) \end{array} \right] = \underbrace {\left[ \begin{array}{c c} 0 & M \\ - M ^ {\top} & 0 \end{array} \right]} _ {= A} \left(\underbrace {\left[ \begin{array}{l} \boldsymbol {\theta} _ {1} \\ \boldsymbol {\theta} _ {2} \end{array} \right]} _ {= x} - \underbrace {\left[ \begin{array}{l} \boldsymbol {\theta} _ {1} ^ {\star} \\ \boldsymbol {\theta} _ {2} ^ {\star} \end{array} \right]} _ {= x ^ {*}}\right) = A \left(x - x ^ {\star}\right). \tag {10} +$$ + +As before, $\mathcal{X}^{\star}$ denotes the set of points $\pmb{x}$ such that $F(\pmb{x}) = 0$ , which is equivalent to the set of Nash equilibrium. If $\pmb{M}$ is sampled independently from $\pmb{x}_0, \pmb{x}^\star$ and $\pmb{x}_0 - \pmb{x}^\star$ has covariance $\frac{R^2}{d}\pmb{I}_d$ , Assumption 1 is fulfilled. Since $\pmb{A}$ is skew-symmetric, it is in particular normal and Assumption 2 is also satisfied. + +We now show that the optimal average-case algorithm to solve bilinear problems is Hamiltonian gradient descent with momentum, described below in its general form. Contrary to the methods in Azizian et al. (2020), the method we propose is anytime (and not only asymptotically) average-case optimal. + +# Optimal average-case algorithm for bilinear games. + +Initialization. $\pmb{x}_{-1} = \pmb{x}_0 = (\pmb{\theta}_{1,0},\pmb{\theta}_{2,0})$ , sequence $\{h_t,m_t\}$ given by Theorem 3.1. + +Main loop. For $t \geq 0$ , + +$$ +\boldsymbol {g} _ {t} = F \left(\boldsymbol {x} _ {t} - F \left(\boldsymbol {x} _ {t}\right)\right) - F \left(\boldsymbol {x} _ {t}\right) \quad \left(= \frac {1}{2} \nabla \| F \left(\boldsymbol {x} _ {t}\right) \| ^ {2} \text {b y (1 2)}\right) \tag {11} +$$ + +$$ +\boldsymbol {x} _ {t + 1} = \boldsymbol {x} _ {t} - h _ {t + 1} \boldsymbol {g} _ {t} + m _ {t + 1} \left(\boldsymbol {x} _ {t - 1} - \boldsymbol {x} _ {t}\right) +$$ + +The quantity $\frac{1}{2}\| F(\pmb{x})\|^2$ is commonly known as the Hamiltonian of the game (Balduzzi et al., 2018), hence the name Hamiltonian gradient descent. Indeed, $\pmb{g}_t = \nabla \left(\frac{1}{2}\| F(\pmb{x})\|^2\right)$ when $F$ is affine: + +$$ +\begin{array}{l} F (\boldsymbol {x} - F (\boldsymbol {x})) - F (\boldsymbol {x}) = \boldsymbol {A} (\boldsymbol {x} - \boldsymbol {A} (\boldsymbol {x} - \boldsymbol {x} ^ {\star}) - \boldsymbol {x} ^ {\star}) - \boldsymbol {A} (\boldsymbol {x} - \boldsymbol {x} ^ {\star}) = - \boldsymbol {A} (\boldsymbol {A} (\boldsymbol {x} - \boldsymbol {x} ^ {\star})) \\ = \boldsymbol {A} ^ {\top} (\boldsymbol {A} (\boldsymbol {x} - \boldsymbol {x} ^ {\star})) = \nabla \left(\frac {1}{2} \| \boldsymbol {A} (\boldsymbol {x} - \boldsymbol {x} ^ {\star}) \| ^ {2}\right) = \nabla \left(\frac {1}{2} \| F (\boldsymbol {x}) \| ^ {2}\right). \tag {12} \\ \end{array} +$$ + +The following theorem shows that (11) is indeed the optimal average-case method associated to the minimization problem $\min_{\pmb{x}}\left(\frac{1}{2}\| F(\pmb{x})\| ^2\right)$ , as the following theorem shows. + +Theorem 3.1. Suppose that Assumption 1 holds and that the expected spectral distribution of $MM^{\top}$ is absolutely continuous with respect to the Lebesgue measure. Then, the method (11) is average-case optimal for bilinear games when $h_t$ , $m_t$ are chosen to be the coefficients of the average-case optimal minimization of $\frac{1}{2}\| F(\pmb{x})\|^2$ . + +How to find optimal coefficients? Since $\frac{1}{2}\| F(\pmb{x})\|^2$ is a quadratic problem, the coefficients $\{h_t, m_t\}$ can be found using the average-case framework for quadratic minimization problems of (Pedregosa & Scierur, 2020, Theorem 3.1). + +Proof sketch. When computing the optimal polynomial $\pmb{x}_t = P_t(\pmb{A})(\pmb{x}_0 - \pmb{x}^*)$ , we have that the residual orthogonal polynomial $P_t$ behaves differently if $t$ is even or odd. + +- Case 1: $t$ is even. In this case, we observe that the polynomial $P_{t}(\mathbf{A})$ can be expressed as $Q_{t/2}(-\mathbf{A}^{2})$ , where $(Q_{t})_{t \geq 0}$ is the sequence of orthogonal polynomials w.r.t. the expected spectral density of $-\mathbf{A}^{2}$ , whose eigenvalues are real and positive. This gives the recursion in (11). +- Case 2: $t$ is odd. There is no residual orthogonal polynomial of degree $t$ for $t$ odd. Instead, odd iterations do correspond to the intermediate computation of $g_t$ in (11), but not to an actual iterate. + +# 3.1 PARTICULAR CASE: M WITH I.I.D. COMPONENTS + +We now show the optimal method when the entries of $M$ are i.i.d. sampled. For simplicity, we order the players such that $d_{1} \leq d_{2}$ . + +Assumption 3. Assume that each component of $M$ is sampled iid from a distribution of mean 0 and variance $\sigma^2$ , and we take $d_1, d_2 \to \infty$ with $\frac{d_1}{d_2} \to r < 1$ . + +In such case, the spectral distribution of $\frac{1}{d_2} MM^\top$ tends to the Marchenko-Pastur law, supported in $[\ell, L]$ and with density: + +$$ +\rho_ {M P} (\lambda) \stackrel {\text {d e f}} {=} \frac {\sqrt {(L - \lambda) (\lambda - \ell)}}{2 \pi \sigma^ {2} r \lambda}, \quad \text {w h e r e} L \stackrel {\text {d e f}} {=} \sigma^ {2} (1 + \sqrt {r}) ^ {2}, \ell \stackrel {\text {d e f}} {=} \sigma^ {2} (1 - \sqrt {r}) ^ {2}. \tag {13} +$$ + +Proposition 3.1. When $M$ satisfies Assumption 3, the optimal parameter of scheme (11) are + +$$ +h _ {t} = - \frac {\delta_ {t}}{\sigma^ {2} \sqrt {r}}, \quad m _ {t} = 1 + \rho \delta_ {t}, \quad \text {w h e r e} \rho = \frac {1 + r}{\sqrt {r}}, \delta_ {t} = (- \rho - \delta_ {t - 1}) ^ {- 1}, \delta_ {0} = 0. \tag {14} +$$ + +Proof. By Theorem 3.1, the problem reduces to finding the optimal average-case algorithm for the problem $\min_{\boldsymbol{x}} \frac{1}{2} \| F(\boldsymbol{x}) \|^2$ . Since the expected spectral distribution of $\frac{1}{d_2} MM^\top$ is the Marchenko-Pastur law, we can use the optimal algorithm from (Pedregosa & Scieur, 2020, Section 5). + +# 4 GENERAL AVERAGE-CASE OPTIMAL METHOD FOR NORMAL OPERATORS + +In this section we derive general average-case optimal first-order methods for normal operators. First, we need to assume the existence of a three-term recurrence for residual orthogonal polynomials (Assumption 4). As mentioned in subsection 2.4, for general measures in the complex plane, the existence of a three-term recurrence of orthogonal polynomials is not ensured. In Proposition B.3 in Appendix B we give a sufficient condition for its existence, and in the next subsection we will show specific examples where the residual orthogonal polynomials satisfy the three-term recurrence. + +Assumption 4 (Simplifying assumption). The sequence of residual polynomials $\{\psi_t\}_{t\geq 0}$ orthogonal w.r.t. the measure $\mu$ , defined on the complex plane, admits the three-term recurrence + +$$ +\psi_ {- 1} = 0, \quad \psi_ {0} = 1, \quad \psi_ {t} (\lambda) = \left(a _ {t} + b _ {t} \lambda\right) \psi_ {t - 1} (\lambda) + (1 - a _ {t}) \psi_ {t - 2} (\lambda). \tag {15} +$$ + +Under Assumption 4, Theorem 4.1 shows that the optimal algorithm can also be written as an average of iterates following a simple three-terms recurrence. + +Theorem 4.1. Under Assumption 4 and the assumptions of Theorem 2.1, the following algorithm is optimal in the average case, with $\mathbf{y}_{-1} = \mathbf{y}_0 = \mathbf{x}_0$ : + +$$ +\boldsymbol {y} _ {t} = a _ {t} \boldsymbol {y} _ {t - 1} + (1 - a _ {t}) \boldsymbol {y} _ {t - 2} + b _ {t} F (\boldsymbol {y} _ {t - 1}) +$$ + +$$ +\boldsymbol {x} _ {t} = \frac {B _ {t}}{B _ {t} + \beta_ {t}} \boldsymbol {x} _ {t - 1} + \frac {\beta_ {t}}{B _ {t} + \beta_ {t}} \boldsymbol {y} _ {t}, \quad \beta_ {t} = \phi_ {t} ^ {2} (0), \quad B _ {t} = B _ {t - 1} + \beta_ {t - 1}, \quad B _ {0} = 0. \tag {16} +$$ + +where $(\phi_k(0))_{k\geq 0}$ can be computed using the three-term recurrence (upon normalization). Moreover, $\mathbb{E}_{(\pmb {A},\pmb{x}^{\star},\pmb {x}_0)}\mathrm{dist}(\pmb {x}_t,\mathcal{X}^\star)$ converges to zero at rate $1 / B_{t}$ + +Remark. Notice that it is not immediate that (16) fulfills the definition of first-order algorithms stated in (2), as $\pmb{y}_t$ is clearly a first-order method but $\pmb{x}_t$ is an average of the iterates $\pmb{y}_t$ . Using that $F$ is an affine function we see that $\pmb{x}_t$ indeed fulfills (2). + +Remark. Assumption 4 is needed for the sequence $(\pmb{y}_t)_{t\geq 0}$ to be computable using a three-term recurrence. However, for some distribution, the associated sequence of orthogonal polynomials may admit another recurrence that may not satisfy Assumption 4. + +# 4.1 CIRCULAR SPECTRAL DISTRIBUTIONS + +In random matrix theory, the circular law states that if $\mathbf{A}$ is an $n \times n$ matrix with i.i.d. entries of mean $C$ and variance $R^2 / n$ , as $n \to \infty$ the spectral distribution of $\mathbf{A}$ tends to the uniform distribution on $D_{C,R}$ . In this subsection we apply Theorem 4.1 to a class of spectral distributions specified by Assumption 5, which includes the uniform distribution on $D_{C,R}$ . Even though the random matrices with i.i.d entries are not normal, we will see in section 6 that the empirical results for such matrices are consistent with our theoretical results under the normality assumption. + +Assumption 5. Assume that the expected spectral distribution $\mu_A$ is supported in the complex plane on the disk $D_{C,R}$ of center $C\in \mathbb{R},C > 0$ and radius $R < C$ . Moreover, assume that the spectral density is circularly symmetric, i.e. there exists a probability measure $\mu_R$ supported on $[0,R]$ such for all $f$ measurable and $r\in [0,R]$ , $\mathrm{d}\mu_A(C + r e^{i\theta}) = \frac{1}{2\pi}\mathrm{d}\theta \mathrm{d}\mu_R(r)$ . + +Proposition 4.1. If $\mu$ satisfies Assumption 5, the sequence of orthonormal polynomials is $(\phi_t)_{t\geq 0}$ + +$$ +\phi_ {t} (\lambda) = \frac {(\lambda - C) ^ {t}}{K _ {t , R}}, \text {w h e r e} K _ {t, R} = \sqrt {\int_ {0} ^ {R} r ^ {2 t} \mathrm {d} \mu_ {R} (r)}. \tag {17} +$$ + +Example. The uniform distribution in $D_{C,R}$ is to $\mathrm{d}\mu_R = \frac{2r}{R^2}\mathrm{d}r$ , and $K_{t,R} = R^{t} / \sqrt{t + 1}$ . + +From Proposition 4.1, the sequence of residual polynomials is given by $\phi_t(\lambda) / \phi_t(0) = \left(1 - \frac{\lambda}{C}\right)^t$ , which implies that Assumption 4 is fulfilled with $a_{t} = 1, b_{t} = -\frac{1}{C}$ . Thus, by Theorem 4.1 we have + +Theorem 4.2. Given an initialization $\pmb{x}_0(\pmb{y}_0 = \pmb{x}_0)$ , if Assumption 5 is fulfilled with $R < C$ and the assumptions of Theorem 2.1 hold, then the average-case optimal first-order method is + +$$ +\boldsymbol {y} _ {t} = \boldsymbol {y} _ {t - 1} - \frac {1}{C} F (\boldsymbol {y} _ {t - 1}), \quad \beta_ {t} = C ^ {2 t} / K _ {t, R} ^ {2}, \quad B _ {t} = B _ {t - 1} + \beta_ {t - 1}, +$$ + +$$ +\boldsymbol {x} _ {t} = \frac {B _ {t}}{B _ {t} + \beta_ {t}} \boldsymbol {x} _ {t - 1} + \frac {\beta_ {t}}{B _ {t} + \beta_ {t}} \boldsymbol {y} _ {t}. \tag {18} +$$ + +Moreover, $\mathbb{E}_{(A,\pmb{x}^{\star},\pmb{x}_0)}\mathrm{dist}(\pmb{x}_t,\mathcal{X}^\star)$ converges to zero at rate $1 / B_{t}$ . + +We now compare Theorem 4.2 with worst-case methods studied in Azizian et al. (2020). They give a worst-case convergence lower bound of $(R / C)^{2t}$ on the quantity $\mathrm{dist}(\pmb {z}_t,\mathcal{X}^\star)$ for first-order methods $(\pmb {z}_t)_{t\geq 0}$ on matrices with eigenvalues in the disk $D_{C,R}$ . By the classical analysis of first-order methods, this rate is achievable by gradient descent with stepsize $1 / C$ , i.e. the iterates $\pmb{y}_{t}$ defined in (18). However, by equation (79) in Proposition D.3 we have that under slight additional assumptions (those of Proposition 5.2), $\lim_{t\to \infty}\mathbb{E}\left[\mathrm{dist}(\pmb{x}_t,\mathcal{X}^\star)\right] / \mathbb{E}\left[\mathrm{dist}(\pmb{y}_t,\mathcal{X}^\star)\right] = 1 - \frac{R^2}{C^2}$ holds. That is, the average-case optimal algorithm outperforms gradient descent by a constant factor depending on the conditioning $R / C$ . + +# 5 ASYMPTOTIC BEHAVIOR + +The recurrence coefficients of the average-case optimal method typically converges to limiting values when $t \to \infty$ , which gives an "average-case asymptotically optimal first-order method" with constant coefficients. For the case of symmetric operators with spectrum in $[\ell, L]$ , Scieur & Pedregosa (2020) show that under mild conditions, the asymptotically optimal algorithm is the Polyak momentum method with coefficients depending only on $\ell$ and $L$ . For bilinear games, since the average-case optimal algorithm is the average-case optimal algorithm of an optimization algorithm, we can make use of their framework to obtain the asymptotic algorithm (see Theorem 3 of Scieur & Pedregosa (2020)). + +Proposition 5.1. Assume that the expected spectral density $\mu_{MM^{\top}}$ of $MM^{\top}$ is supported in $[\ell, L]$ for $0 < \ell < L$ , and strictly positive in this interval. Then, the asymptotically optimal algorithm for bilinear games is the following version of Polyak momentum: + +$$ +\boldsymbol {g} _ {t} = F \left(\boldsymbol {x} _ {t} - F \left(\boldsymbol {x} _ {t}\right)\right) - F \left(\boldsymbol {x} _ {t}\right) +$$ + +$$ +\boldsymbol {x} _ {t + 1} = \boldsymbol {x} _ {t} + \left(\frac {\sqrt {L} - \sqrt {\ell}}{\sqrt {L} + \sqrt {\ell}}\right) ^ {2} \left(\boldsymbol {x} _ {t - 1} - \boldsymbol {x} _ {t}\right) - \left(\frac {2}{\sqrt {L} + \sqrt {\ell}}\right) ^ {2} \boldsymbol {g} _ {t} \tag {19} +$$ + +Notice that the algorithm in (19) is the worst-case optimal algorithm from Proposition 4 of Azizian et al. (2020). For the case of circularly symmetric spectral densities with support on disks, we can also compute the asymptotically optimal algorithm. + +Proposition 5.2. Suppose that the assumptions of Theorem 4.2 hold with $\mu_R \in \mathcal{P}([0, R])$ fulfilling $\mu_R([r, R]) = \Omega((R - r)^\kappa)$ for $r$ in $[r_0, R]$ for some $r_0 \in [0, R)$ and for some $\kappa \in \mathbb{Z}$ . Then, the average-case asymptotically optimal algorithm is, with $\pmb{y}_0 = \pmb{x}_0$ : + +$$ +\boldsymbol {y} _ {t} = \boldsymbol {y} _ {t - 1} - \frac {1}{C} F (\boldsymbol {y} _ {t - 1}), +$$ + +$$ +\boldsymbol {x} _ {t} = \left(\frac {R}{C}\right) ^ {2} \boldsymbol {x} _ {t - 1} + \left(1 - \left(\frac {R}{C}\right) ^ {2}\right) \boldsymbol {y} _ {t}. \tag {20} +$$ + +Moreover, the convergence rate for this algorithm is asymptotically the same one as for the optimal algorithm in Theorem 4.2. Namely, $\lim_{t\to \infty}\mathbb{E}\left[\mathrm{dist}(\pmb{x}_t,\mathcal{X}^\star)\right]B_t = 1$ + +The condition on $\mu_R$ simply rules out cases in which the spectral density has exponentially small mass around 1. It is remarkable that in algorithm (20) the averaging coefficients can be expressed so simply in terms of the quantity $R / C$ . Notice also that while the convergence rate of the algorithm + +is slower than the convergence rate for the optimal algorithm by definition, both rates match in the limit, meaning that the asymptotically optimal algorithm also outperforms gradient descent by a constant factor $1 - \frac{R^2}{C^2}$ in the limit $t\to \infty$ + +# 6 EXPERIMENTS + +We compare some of the proposed methods on settings with varying degrees of mismatch with our assumptions. + +Bilinear Games. We consider min-max bilinear problems of the form (10), where the entries of $M$ are generated i.i.d. from a standard Gaussian distribution. We vary the ratio $r = d / n$ parameter for $d = 1000$ and compare the average-case optimal method of Theorems 3.1 and 5.1, the asymptotic worst-case optimal method of (Azizian et al., 2020) and extragradient (Korpelevich, 1976). In all cases, we use the convergence-rate optimal step-size assuming knowledge of the edges of the spectral distribution. + +The spectral density for these problems is displayed in the first row of Figure 1 and the benchmark results on the second row. Average-case optimal methods always outperform other methods, and the largest gain is in the ill-conditioned regime ( $r \approx 1$ ). + +Circular Distribution. For our second experiment we choose $A$ as a matrix with iid Gaussian random entries, therefore the support of the distribution of its eigenvalue is a disk. Note that $A$ does not satisfy the normality assumption of Assumption 2. Figure 1 (third row) compares the average-case optimal methods from Theorems 4.2 and 5.2 on two datasets with different levels of conditioning. Note that the methods converge despite the violation of Assumption 2, suggesting a broader applicability than the one proven in this paper. We leave this investigation for future work. + +# 7 DISCUSSION AND FUTURE RESEARCH DIRECTIONS + +In this paper, we presented a general framework for the design of optimal algorithms in the average-case for affine operators $F$ , whose underlying matrix is possibly non-symmetric. However, our approach presents some limitations, the major one being the restriction to normal matrices. Fortunately, the numerical experiments above suggests that this assumption can be relaxed. Developing a theory without that assumption is left for future work. Another avenue for future work is to analyze the nonlinear-case in which the non-symmetric operator $A$ is non-linear, as well as the case in which it is accessed through a stochastic estimator (as done by (Loizou et al., 2020) for the worst-case analysis). + +# ACKNOWLEDGEMENTS + +C. Domingo-Enrich has been partially funded by "la Caixa" Foundation (ID 100010434), under agreement LCF/BQ/AA18/11680094, and partially funded by the NYU Computer Science Department. + +![](images/92b054738669f3580bf73b96ead85508300536f2f82fc2c72c0f7155749651b8.jpg) +Bilinear Problems +Figure 1: Benchmarks and spectral density for different games. Top row: spectral density associated with bilinear games for varying values of the ratio parameter $r = n / d$ (the x-axis represents the imaginary line). Second row: Benchmarks. Average-case optimal methods always outperform other methods, and the largest gain is in the ill-conditioned regime ( $r \approx 1$ ). Third row. Benchmarks (columns 1 and 3) and eigenvalue distribution of a design matrix generated with iid entries for two different degrees of conditioning. Despite the normality assumption not being satisfied, we still observe an improvement of average-case optimal methods vs worst-case optimal ones. + +# REFERENCES + +Walter Van Assche. Orthogonal polynomials in the complex plane and on the real line. In Fields Institute Communications, volume 14, pp. 211-245, 1997. +Waiss Azizian, Damien Scieur, Ioannis Mitliagkas, Simon Lacoste-Julien, and Gauthier Gidel. Accelerating smooth games by manipulating spectral shapes. In Proceedings of Machine Learning Research, 2020. +David Balduzzi, Sébastien Racanière, James Martens, Jakob Foerster, Karl Tuyls, and Thore Graepel. The mechanics of $n$ -player differentiable games. In Proceedings of the International Conference on Machine Learning, 2018. +Raphael Berthier, Francis Bach, and Pierre Gaillard. Accelerated gossip in networks of given dimension using Jacobi polynomial iterations. SIAM Journal on Mathematics of Data Science, 2 (1):24-47, 2020. +Raghu Bollapragada, Damien Scieur, and Alexandre d'Aspremont. Nonlinear acceleration of momentum and primal-dual algorithms. arXiv preprint arXiv:1810.04539, 2018. +John Duchi, Elad Hazan, and Yoram Singer. Adaptive subgradient methods for online learning and stochastic optimization. Journal of Machine Learning Research, 12:2121-2159, 2011. +Bernd Fischer. *Polynomial Based Iteration Methods for Symmetric Linear Systems*. Vieweg+Teubner Verlag, 1996. +Magnus R Hestenes, Eduard Stiefel, et al. Methods of conjugate gradients for solving linear systems. Journal of research of the National Bureau of Standards, 1952. +Jonathan Katz and Yehuda Lindell. Introduction to modern cryptography. CRC press, 2014. +Diederik P. Kingma and Jimmy Ba. Adam: A method for stochastic optimization. In International Conference on Learning Representations, 2015. +Donald Knuth. The art of computer programming, volume 3. Pearson Education, 1997. +GM Korpelevich. The extragradient method for finding saddle points and other problems. Matecon, 12, 1976. +Jonathan Lacotte and Mert Pilanci. Optimal randomized first-order methods for least-squares problems. Proceedings of the 37th International Conference on Machine Learning, 2020. +Nicolas Loizou, Hugo Berard, Alexia Jolicoeur-Martineau, Pascal Vincent, Simon Lacoste-Julien, and Ioannis Mitliagkas. Stochastic Hamiltonian gradient methods for smooth games. arXiv preprint arXiv:2007.04202, 2020. +Arkadi Nemirovski. Information-based complexity of convex programming. Lecture Notes, 1995. +Yurii Nesterov. Introductory Lectures on Convex Optimization. Springer, 2004. +Courtney Paquette, Bart van Merrienboer, and Fabian Pedregosa. Halting time is predictable for large models: A universality property and average-case analysis. arXiv preprint arXiv:2006.04299, 2020. +Fabian Pedregosa and Damien Scieur. Average-case acceleration through spectral density estimation. In Proceedings of the 37th International Conference on Machine Learning, 2020. +Damien Scieur and Fabian Pedregosa. Universal average-case optimality of Polyak momentum. In Proceedings of the 37th International Conference on Machine Learning, 2020. + +# A PROOF OF THEOREM 2.1 + +# A.1 PRELIMINARIES + +Before proving Theorem 2.1, we quickly analyze the distance function (1), recalled below, + +$$ +\operatorname {d i s t} (\boldsymbol {x}, \mathcal {X} ^ {\star}) \stackrel {{\mathrm {d e f}}} {{=}} \min _ {\boldsymbol {v} \in \mathcal {X} ^ {\star}} \| \boldsymbol {x} - \boldsymbol {v} \| ^ {2}. +$$ + +The definition of the distance function is not practical for the theoretical analysis. Fortunately, it is possible to find a simple expression that uses the orthogonal projection matrix $\Pi$ to the kernel $\mathrm{Ker}(A)$ . Since $\Pi$ is an orthogonal projection matrix to the kernel of a linear transformation, it satisfies + +$$ +\Pi = \Pi^ {T}, \quad \Pi^ {2} = \Pi , \quad \text {a n d} \quad A \Pi = 0. \tag {21} +$$ + +The normality assumption on $\mathbf{A}$ implies also that + +$$ +\Pi \boldsymbol {A} = 0. \tag {22} +$$ + +Indeed, the spectral decomposition of $\mathbf{A}$ is + +$$ +\boldsymbol {A} = [ \boldsymbol {U} _ {1} | \boldsymbol {U} _ {2} ] \left[ \begin{array}{c c} \boldsymbol {\Lambda} & 0 \\ 0 & 0 \end{array} \right] [ \boldsymbol {U} _ {1} | \boldsymbol {U} _ {2} ] ^ {*}, +$$ + +and then $\Pi = U_2U_2^*$ . The next proposition uses $\Pi$ to derive the explicit solution of the (1). + +Proposition A.1. We have that + +$$ +\operatorname {d i s t} (\boldsymbol {y}, \mathcal {X} ^ {\star}) = \| (\boldsymbol {I} - \Pi) (\boldsymbol {y} - \boldsymbol {x} ^ {\star}) \| ^ {2} \quad \forall \boldsymbol {x} ^ {\star} \in \mathcal {X} ^ {\star}. +$$ + +Proof. We first parametrize the set of solution $\mathcal{X}^{\star}$ . By definition we have + +$$ +\mathcal {X} ^ {\star} = \left\{\boldsymbol {x}: \boldsymbol {A} \left(\boldsymbol {x} - \boldsymbol {x} ^ {\star}\right) = 0 \right\}. +$$ + +Which can be written in terms of the kernel of $A$ as + +$$ +\mathcal {X} ^ {\star} = \left\{\boldsymbol {x} ^ {\star} + \Pi \boldsymbol {w}: \boldsymbol {w} \in \mathbb {R} ^ {d} \right\}. +$$ + +From this, we can rewrite the distance function (1) as + +$$ +\operatorname {d i s t} (\boldsymbol {y}, \mathcal {X} ^ {\star}) = \min _ {\boldsymbol {w} \in \mathbb {R} ^ {d}} \| \boldsymbol {y} - (\boldsymbol {x} ^ {\star} + \Pi \boldsymbol {w}) \| ^ {2}. +$$ + +The minimum can be attained at different points, but in particular at $\pmb{w} = -(\pmb{y} - \pmb{x}^{\star})$ , which proves the statement. + +We now simplifies further the result of the previous proposition in the case where $\boldsymbol{x}_t$ is generated by a first order method. + +Proposition A.2. For every iterate $\pmb{x}_t$ of a first-order methods, i.e., $\pmb{x}_t$ satisfies + +$$ +\boldsymbol {x} _ {t} - \boldsymbol {x} ^ {\star} = P _ {t} (\boldsymbol {A}) (\boldsymbol {x} _ {0} - \boldsymbol {x} ^ {\star}), \quad \deg (P _ {t}) \leq t, \quad P (0) = \boldsymbol {I}, +$$ + +we have that + +$$ +\operatorname {d i s t} \left(\boldsymbol {x} _ {t}, \mathcal {X} ^ {\star}\right) = \left\| \boldsymbol {x} _ {t} - \boldsymbol {x} ^ {\star} \right\| ^ {2} - \left\| \Pi \left(\boldsymbol {x} _ {0} - \boldsymbol {x} ^ {\star}\right) \right\| ^ {2}. +$$ + +Proof. We start with the result of Proposition A.1, + +$$ +\operatorname {d i s t} \left(\boldsymbol {x} _ {t}, \mathcal {X} ^ {\star}\right) = \left\| (\boldsymbol {I} - \Pi) \left(\boldsymbol {x} _ {t} - \boldsymbol {x} ^ {\star}\right) \right\| ^ {2}. +$$ + +The norm can be split into + +$$ +\begin{array}{l} \| (\boldsymbol {I} - \Pi) (\boldsymbol {x} _ {t} - \boldsymbol {x} ^ {\star}) \| ^ {2} = \| \boldsymbol {x} _ {t} - \boldsymbol {x} ^ {\star} \| ^ {2} + \| \underbrace {\Pi^ {2}} _ {= \Pi \text {b y (2 1)}} (\boldsymbol {x} _ {t} - \boldsymbol {x} ^ {\star}) \| ^ {2} - 2 \| \Pi (\boldsymbol {x} _ {t} - \boldsymbol {x} ^ {\star}) \| ^ {2} \\ = \left\| \boldsymbol {x} _ {t} - \boldsymbol {x} ^ {\star} \right\| ^ {2} - \left\| \Pi \left(\boldsymbol {x} _ {t} - \boldsymbol {x} ^ {\star}\right) \right\| ^ {2}. \\ \end{array} +$$ + +Since $x_{t}$ is generated by a first order method, we have + +$$ +\boldsymbol {x} _ {t} - \boldsymbol {x} ^ {\star} = P _ {t} (\boldsymbol {A}) (\boldsymbol {x} _ {0} - \boldsymbol {x} ^ {\star}), \quad P _ {t} (0) = 1. +$$ + +Since $P(0) = 1$ , the polynomial can be factorized as $P(\mathbf{A}) = \mathbf{I} + \mathbf{A}\mathbf{Q}_{t - 1}(\mathbf{A}), \mathbf{Q}_{t - 1}$ being a polynomial of degree $t - 1$ . Therefore, $\| \Pi (\pmb{x}_t - \pmb{x}^\star)\|^2$ reads + +$$ +\begin{array}{l} \left\| \Pi (\boldsymbol {x} _ {t} - \boldsymbol {x} ^ {\star}) \right\| ^ {2} = \left\| \Pi \left(\boldsymbol {I} + \boldsymbol {A} \boldsymbol {Q} _ {t - 1} (\boldsymbol {A})\right) (\boldsymbol {x} _ {0} - \boldsymbol {x} ^ {\star}) \right\| ^ {2} \\ = \| \Pi (\boldsymbol {x} _ {0} - \boldsymbol {x} ^ {\star}) + \underbrace {\Pi A} _ {= 0 \text {b y (2 2)}} Q _ {t - 1} (\boldsymbol {A}) (\boldsymbol {x} _ {0} - \boldsymbol {x} ^ {\star}) \| ^ {2} \\ = \left\| \Pi \left(\boldsymbol {x} _ {0} - \boldsymbol {x} ^ {\star}\right) \right\| ^ {2}, \\ \end{array} +$$ + +which prove the statement. + +![](images/08c544e5dba4f818848d85726015039694724f159fe7e44d78bbc5eedf180ce4.jpg) + +# A.2 PROOF OF THE THEOREM + +We are now ready to prove the main result. + +Theorem 2.1. Consider the application of a first-order method associated to the sequence of polynomials $\{P_t\}$ (Proposition 2.1) on the problem (NSO). Let $\mu$ be the expected spectral distribution of $\mathbf{A}$ . Under Assumptions 1 and 2, we have + +$$ +\mathbb {E} \left[ \operatorname {d i s t} \left(\boldsymbol {x} _ {t}, \mathcal {X} ^ {\star}\right) \right] = R ^ {2} \int_ {\mathbb {C} \backslash \{0 \}} \left| P _ {t} \right| ^ {2} \mathrm {d} \mu , \tag {7} +$$ + +Proof. We start with the result of Proposition A.2, + +$$ +\operatorname {d i s t} \left(\boldsymbol {x} _ {t}, \mathcal {X} ^ {\star}\right) = \left\| \boldsymbol {x} _ {t} - \boldsymbol {x} ^ {\star} \right\| ^ {2} - \left\| \Pi \left(\boldsymbol {x} _ {0} - \boldsymbol {x} ^ {\star}\right) \right\| ^ {2}. +$$ + +We now write the expectation of the distance function, + +$$ +\begin{array}{l} \mathbb {E} \left[ \operatorname {d i s t} \left(\boldsymbol {x} _ {t}, \mathcal {X} ^ {\star}\right) \right] = \mathbb {E} \left[ \left\| \boldsymbol {x} _ {t} - \boldsymbol {x} ^ {\star} \right\| ^ {2} - \left\| \Pi \left(\boldsymbol {x} _ {0} - \boldsymbol {x} ^ {\star}\right) \right\| ^ {2} \right] \\ = \mathbb {E} \left[ \| P _ {t} (\boldsymbol {A}) \left(\boldsymbol {x} _ {0} - \boldsymbol {x} ^ {\star}\right) \| ^ {2} - \| \Pi \left(\boldsymbol {x} _ {0} - \boldsymbol {x} ^ {\star}\right) \| ^ {2} \right] \\ = \mathbb {E} \left[ \operatorname {t r} P _ {t} (\boldsymbol {A}) P _ {t} (\boldsymbol {A}) ^ {T} \left(\boldsymbol {x} _ {0} - \boldsymbol {x} ^ {\star}\right) \left(\boldsymbol {x} _ {0} - \boldsymbol {x} ^ {\star}\right) ^ {T} - \operatorname {t r} \Pi^ {2} (\boldsymbol {x} _ {0} - \boldsymbol {x} ^ {\star}) \left(\boldsymbol {x} _ {0} - \boldsymbol {x} ^ {\star}\right) ^ {T} \right] \\ = \mathbb {E} _ {A} \left[ \operatorname {t r} P _ {t} (\boldsymbol {A}) P _ {t} (\boldsymbol {A}) ^ {T} \mathbb {E} \left[ \left(\boldsymbol {x} _ {0} - \boldsymbol {x} ^ {\star}\right) \left(\boldsymbol {x} _ {0} - \boldsymbol {x} ^ {\star}\right) ^ {T} | \boldsymbol {A} \right] - \operatorname {t r} \Pi \mathbb {E} \left[ \left(\boldsymbol {x} _ {0} - \boldsymbol {x} ^ {\star}\right) \left(\boldsymbol {x} _ {0} - \boldsymbol {x} ^ {\star}\right) ^ {T} | \boldsymbol {A} \right] \right] \\ = R \mathbb {E} _ {A} \left[ \operatorname {t r} P _ {t} (\boldsymbol {A}) P _ {t} (\boldsymbol {A}) ^ {T} - \operatorname {t r} \Pi \right] \\ = R \mathbb {E} \left[ \sum_ {i = 1} ^ {d} | P (\lambda_ {i}) | ^ {2} - \operatorname {t r} \Pi \right] \\ = R \mathbb {E} \left[ \int_ {\mathbb {C} \backslash \{0 \}} | P (\lambda) | ^ {2} \delta_ {\lambda_ {i}} (\lambda) + | P (0) | ^ {2} \cdot [ \# \text {z e r o e i g e n v a l u e s} ] - \operatorname {t r} \Pi \right] \\ \end{array} +$$ + +However, $|P(0)|^2 = 1$ and $\operatorname{tr} \Pi$ corresponds to the number of zero eigenvalues of $A$ , therefore, + +$$ +E \left[ \operatorname {d i s t} \left(\boldsymbol {x} _ {t}, \mathcal {X} ^ {\star}\right) \right] = R \mathbb {E} \left[ \int_ {\mathbb {C} \backslash \{0 \}} | P (\lambda) | ^ {2} \delta_ {\lambda_ {i}} (\lambda) \right] = R \int_ {\mathbb {C} \backslash \{0 \}} P (\lambda) \mu (\lambda). +$$ + +![](images/e448e52c9f88f956b7bac2caf110d04168507fec8574ead5cb0fb4c4dd0cde5a.jpg) + +# B PROOFS OF THEOREM 3.1 AND PROPOSITION 3.1 + +Proposition B.1. [Block determinant formula] If $A, B, C, D$ are (not necessarily square) matrices, + +$$ +\det \left[ \begin{array}{l l} \boldsymbol {A} & \boldsymbol {B} \\ \boldsymbol {C} & \boldsymbol {D} \end{array} \right] = \det (\boldsymbol {D}) \det (\boldsymbol {A} - \boldsymbol {B} \boldsymbol {D} ^ {- 1} \boldsymbol {C}), \tag {23} +$$ + +if $D$ is invertible. + +Definition 6 (Pushforward of a measure). Recall that the pushforward $f_*\mu$ of a measure $\mu$ by a function $f$ is defined as the measure such that for all measurable $g$ , + +$$ +\int g (\lambda) \mathrm {d} (f _ {*} \mu) (\lambda) = \int g (f (\lambda)) \mathrm {d} \mu (\lambda). \tag {24} +$$ + +Equivalently, if $X$ is a random variable with distribution $\mu$ , then $f(X)$ has distribution $f_{*}\mu$ . + +Proposition B.2. Assume that the dimensions of $M \in \mathbb{R}^{d_x \times d_y}$ fulfill $d_x \leq d_y$ and let $r = d_x / d_y$ . Let $\mu_{MM^\top}$ be the expected spectral distribution of the random matrix $MM^\top \in \mathbb{R}^{d_x \times d_x}$ , and assume that it is absolutely continuous with respect to the Lebesgue measure. The expected spectral distribution of $A$ is contained in the imaginary line and is given by + +$$ +\mu_ {\mathbf {A}} (i \lambda) = \left(1 - \frac {2}{1 + \frac {1}{r}}\right) \delta_ {0} (\lambda) + \frac {2 | \lambda |}{1 + \frac {1}{r}} \mu_ {M M ^ {\top}} \left(\lambda^ {2}\right). \tag {25} +$$ + +for $\lambda \in \mathbb{R}$ . If $d_{x} \geq d_{y}$ , then (25) holds with $\mu_{M^{\top}M}$ in place of $\mu_{MM^{\top}}$ and $1 / r$ in place of $r$ . + +Proof. By the block determinant formula, we have that for $s \neq 0$ + +$$ +\begin{array}{l} \det \left(s I _ {d _ {1} + d _ {2}} - A\right) = \left| \begin{array}{l l} s I _ {d _ {1}} & - M \\ M ^ {\top} & s I _ {d _ {2}} \end{array} \right| = \det \left(s I _ {d _ {2}}\right) \det \left(s I _ {d _ {1}} + M s ^ {- 1} I _ {d _ {2}} M ^ {\top}\right) \tag {26} \\ = s ^ {d _ {2} - d _ {1}} \det \left(s ^ {2} \boldsymbol {I} _ {d _ {1}} + \boldsymbol {M} \boldsymbol {M} ^ {\top}\right) \\ \end{array} +$$ + +Thus, for every eigenvalue $-\lambda \leq 0$ of $-MM^{\top}$ , both $i\sqrt{\lambda}$ and $-i\sqrt{\lambda}$ are eigenvalues of $\mathbf{A}$ . Since $\mathrm{rank}(MM^{\top}) = \mathrm{rank}(M)$ , we have $\mathrm{rank}(\mathbf{A}) = 2\mathrm{rank}(M)$ . Thus, the rest of the eigenvalues of $\mathbf{A}$ are 0 and there is a total of $d - 2d_{1} = d_{2} - d_{1}$ of them. Notice that + +$$ +\frac {d _ {1}}{d _ {1} + d _ {2}} = \frac {1}{\frac {d _ {1} + d _ {2}}{d _ {1}}} = \frac {1}{1 + \frac {1}{r}} \tag {27} +$$ + +Let $f_{+}(\lambda) = i\sqrt{\lambda}, f_{-}(\lambda) = -i\sqrt{\lambda}$ , and let $(f_{+})_{*}\mu_{MM^{\top}}$ (resp., $(f_{-})_{*}\mu_{MM^{\top}}$ ) be the pushforward measure of $\mu_{MM^{\top}}$ by the function $f_{+}$ (resp., $f_{-}$ ). Thus, by the definition of the pushforward measure (Definition 6), + +$$ +\mu_ {\mathbf {A}} (i \lambda) = \left(1 - \frac {2}{1 + \frac {1}{r}}\right) \delta_ {0} (\lambda) + \frac {1}{1 + \frac {1}{r}} \left(f _ {+}\right) * \mu_ {M M ^ {\top}} (\lambda) + \frac {1}{1 + \frac {1}{r}} \left(f _ {-}\right) * \mu_ {M M ^ {\top}} (\lambda) \tag {28} +$$ + +We compute the pushforwards $(f_{+})_{*}\mu_{MM^{\top}}$ , $(f_{-})_{*}\mu_{MM^{\top}}$ performing the change of variables $y = \pm i\sqrt{\lambda}$ under the assumption that $\mu_{MM^{\top}}(\lambda) = \rho_{MM^{\top}}(\lambda)d\lambda$ : + +$$ +\int_ {\mathbb {R} _ {\geq 0}} g (\pm i \sqrt {\lambda}) \mathrm {d} \mu_ {M M ^ {\top}} (\lambda) = \int_ {\mathbb {R} _ {\geq 0}} g (\pm i \sqrt {\lambda}) \rho_ {M M ^ {\top}} (\lambda) d \lambda = \int_ {\pm i \mathbb {R} _ {\geq 0}} g (y) \rho_ {M M ^ {\top}} (| y | ^ {2}) 2 | y | \mathrm {d} | y |, \tag {29} +$$ + +which means that the density of $(f_{+})_{*}\mu_{MM^{\top}}$ at $y\in i\mathbb{R}_{\geq 0}$ is $2|y|\rho_{MM^{\top}}(|y|^{2})$ and the density of $(f_{-})_{*}\mu_{MM^{\top}}$ at $y\in -i\mathbb{R}_{\geq 0}$ is also $2|y|\rho_{MM^{\top}}(|y|^{2})$ . + +# Proposition B.3. The condition + +$$ +\forall P, Q \text {p o l y n o m i a l s} \langle P (\lambda), \lambda Q (\lambda) \rangle = 0 \Longrightarrow \langle \lambda P (\lambda), Q (\lambda) \rangle = 0 \tag {30} +$$ + +is sufficient for any sequence $(P_k)_{k\geq 0}$ of orthogonal polynomials of increasing degrees to satisfy a three-term recurrence of the form + +$$ +\gamma_ {k} P _ {k} (\lambda) = (\lambda - \alpha_ {k}) P _ {k - 1} (\lambda) - \beta_ {k} P _ {k - 2} (\lambda), \tag {31} +$$ + +where + +$$ +\gamma_ {k} = \frac {\left\langle \lambda P _ {k - 1} (\lambda) , P _ {k} (\lambda) \right\rangle}{\left\langle P _ {k} (\lambda) , P _ {k} (\lambda) \right\rangle}, \quad \alpha_ {k} = \frac {\left\langle \lambda P _ {k - 1} (\lambda) , P _ {k - 1} (\lambda) \right\rangle}{\left\langle P _ {k - 1} (\lambda) , P _ {k - 1} (\lambda) \right\rangle}, \quad \beta_ {k} = \frac {\left\langle \lambda P _ {k - 1} (\lambda) , P _ {k - 2} (\lambda) \right\rangle}{\left\langle P _ {k - 2} (\lambda) , P _ {k - 2} (\lambda) \right\rangle} \tag {32} +$$ + +Proof. Since $\lambda P_{k-1}(\lambda)$ is a polynomial of degree $k$ , and $(P_j)_{0 \leq j \leq k}$ is a basis of the polynomials of degree up to $k$ , we can write + +$$ +\lambda P _ {k - 1} (\lambda) = \sum_ {j = 0} ^ {k} \frac {\left\langle \lambda P _ {k - 1} , P _ {j} \right\rangle}{\left\langle P _ {j} , P _ {j} \right\rangle} P _ {j} (\lambda) \tag {33} +$$ + +Now, remark that for all $j < k - 2$ , $\langle P_{k-1}, \lambda P_j \rangle = 0$ because the inner product of $P_{k-1}$ with a polynomial of degree at most $k - 2$ . If we make use of the condition (30), this implies that $\langle \lambda P_{k-1}, P_j \rangle = 0$ for all $j < k - 2$ . Plugging this into (33), we obtain (31). + +Proposition B.4. Let $\Pi_t^\mathbb{R}$ be the set of polynomials with real coefficients and degree at most $t$ . For $t \geq 0$ even, the minimum of the problem + +$$ +\min _ {P _ {t} \in \Pi_ {t} ^ {\mathbb {R}}, P _ {t} (0) = 1} \int_ {i \mathbb {R} \backslash \{0 \}} | P _ {t} (\lambda) | ^ {2} | \lambda | \rho_ {\boldsymbol {M M} ^ {\top}} \left(| \lambda | ^ {2}\right) d | \lambda | \tag {34} +$$ + +is attained by an even polynomial with real coefficients. + +Proof. Since $\mathrm{d}\mu(i\lambda) \stackrel{\mathrm{def}}{=} |\lambda| \rho_{MM^{\top}}(|\lambda|^2) \mathrm{d}|\lambda|$ is supported in the imaginary axis and is symmetric with respect to 0, for all polynomials $P, Q$ , + +$$ +\langle \lambda P (\lambda), Q (\lambda) \rangle = \int_ {i \mathbb {R}} \lambda P (\lambda) Q (\lambda) ^ {*} d \mu (\lambda) = - \int_ {i \mathbb {R}} P (\lambda) \lambda^ {*} Q (\lambda) ^ {*} d \mu (\lambda) = - \langle P (\lambda), \lambda Q (\lambda) \rangle . \tag {35} +$$ + +Hence, $\langle P(\lambda),\lambda Q(\lambda)\rangle = 0$ implies $\langle \lambda P(\lambda),Q(\lambda)\rangle = 0$ . By Proposition B.3, a three-term recurrence (31) and (32) for the orthonormal sequence $(\phi_t)_{t\geq 0}$ of polynomials holds. + +By Proposition B.5, the orthonormal polynomials $(\phi_t)_{t\geq 0}$ of even (resp. odd) degree are even (resp. odd) and have real coefficients. Hence, for all $t\geq 0$ even + +$$ +\frac {\sum_ {k = 0} ^ {t} \phi_ {k} (\lambda) \phi_ {k} (0) ^ {*}}{\sum_ {k = 0} ^ {t} | \phi_ {k} (0) | ^ {2}} = \frac {\sum_ {k = 0} ^ {t / 2} \phi_ {2 k} (\lambda) \phi_ {2 k} (0) ^ {*}}{\sum_ {k = 0} ^ {t / 2} | \phi_ {2 k} (0) | ^ {2}} \tag {36} +$$ + +is an even polynomial with real coefficients. By Theorem 2.3, this polynomial attains the minimum of the problem + +$$ +\min _ {P _ {t} \in \Pi_ {t} ^ {\mathbb {C}}, P _ {t} (0) = 1} \int_ {i \mathbb {R} \backslash \{0 \}} | P _ {t} (\lambda) | ^ {2} | \lambda | \rho_ {M M ^ {\top}} \left(| \lambda | ^ {2}\right) d | \lambda | \tag {37} +$$ + +and, a fortiori, the minimum of the problem in (34), in which the minimization is restricted polynomials with real coefficients instead of complex coefficients. + +Proposition B.5. The polynomials $(\phi_t)_{t\geq 0}$ of the orthonormal sequence corresponding to the measure $\mu (i\lambda) = |\lambda |\rho_{MM^{\top}}(|\lambda |^{2})d|\lambda |$ have real coefficients and are even (resp. odd) for even (resp. odd) $k$ . + +Proof. The proof is by induction. The base case follows from the choice $\phi_0 = 1$ . Assuming that $\phi_{k - 1}\in \mathbb{R}[X]$ by the induction hypothesis, we show that $\alpha_{k} = 0$ (where $\alpha_{k}$ is the coefficient from (31) and (32)): + +$$ +\begin{array}{l} \langle \lambda \phi_ {k - 1} (\lambda), \phi_ {k - 1} (\lambda) \rangle = \int_ {i \mathbb {R}} \lambda | \phi_ {k - 1} (\lambda) | ^ {2} | \lambda | \rho_ {M M ^ {\top}} (| \lambda | ^ {2}) d | \lambda | \\ = \int_ {\mathbb {R} _ {\geq 0}} i \lambda \left(\left| \phi_ {k - 1} (i \lambda) \right| ^ {2} - \left| \phi_ {k - 1} (- i \lambda) \right| ^ {2}\right) \lambda \rho_ {M M ^ {\top}} \left(\lambda^ {2}\right) d \lambda = 0 \tag {38} \\ \end{array} +$$ + +The last equality follows from $|\phi_{k-1}(i\lambda)|^2 = |\phi_{k-1}(-i\lambda)|^2$ , which holds because $\phi_{k-1}(i\lambda)^* = \phi_{k-1}(-i\lambda)$ , and in turn this is true because $\phi_{k-1} \in \mathbb{R}[X]$ by the induction hypothesis. + +Once we have seen that $\alpha_{k} = 0$ , it is straightforward to apply the induction hypothesis once again to show that $\phi_{k}$ also satisfies the even/odd property. Namely, for $k$ even (resp. odd), $\gamma_{k}P_{k} = \lambda P_{k - 1} - \beta_{k}P_{k - 2}$ , and the two polynomials in the right-hand side have even (resp. odd) degrees. + +Finally, $\phi_{k}$ must have real coefficients because $\phi_{k - 1}$ and $\phi_{k - 2}$ have real coefficients by the induction hypothesis, and the recurrence coefficient $\beta_{k}$ is real, as + +$$ +\begin{array}{l} \langle \lambda P _ {k - 1} (\lambda), P _ {k - 2} (\lambda) \rangle = \int_ {i \mathbb {R}} \lambda \phi_ {k - 1} (\lambda) \phi_ {k - 2} (\lambda) ^ {*} | \lambda | \rho_ {M M ^ {\top}} (| \lambda | ^ {2}) d | \lambda | \\ = \int_ {\mathbb {R} _ {\geq 0}} i \lambda \left(\phi_ {k - 1} (i \lambda) \phi_ {k - 2} (i \lambda) ^ {*} - \phi_ {k - 1} (i \lambda) ^ {*} \phi_ {k - 2} (i \lambda)\right) \lambda \rho_ {M M ^ {\top}} \left(\lambda^ {2}\right) d \lambda \\ = - \int_ {\mathbb {R} _ {\geq 0}} 2 \lambda \operatorname {I m} \left(\phi_ {k - 1} (i \lambda) \phi_ {k - 2} (i \lambda) ^ {*}\right) \lambda \rho_ {M M ^ {\top}} \left(\lambda^ {2}\right) d \lambda \in \mathbb {R}. \tag {39} \\ \end{array} +$$ + +![](images/26b1ca0715cc2c88def55f9d15d7e5925c08a7e650c2d013b14d96c2531a4296.jpg) + +Proposition B.6. Let $t \geq 0$ even. Assume that on $\mathbb{R}_{>0}$ , the expected spectral density $\mu_{MM^{\top}}$ has Radon-Nikodym derivative $\rho_{MM^{\top}}$ with respect to the Lebesgue measure. If + +$$ +Q _ {t / 2} ^ {\star} \stackrel {\text {d e f}} {=} \underset { \begin{array}{c} P _ {t / 2} \in \Pi_ {t / 2} ^ {\mathbb {R}}, \\ P _ {t / 2} (0) = 1 \end{array} } {\arg \min } \int_ {\mathbb {R} > 0} P _ {t / 2} (\lambda) ^ {2} \mathrm {d} \mu_ {- \boldsymbol {A} ^ {2}} (\lambda), \tag {40} +$$ + +and + +$$ +P _ {t} ^ {\star} \stackrel {\text {d e f}} {=} \underset { \begin{array}{c} P _ {t} \in \Pi_ {t} ^ {\mathbb {R}}, \\ P _ {t} (0) = 1 \end{array} } {\arg \min } \int_ {i \mathbb {R} \backslash \{0 \}} | P _ {t} (\lambda) | ^ {2} | \lambda | \rho_ {M M ^ {\top}} (| \lambda | ^ {2}) d | \lambda |, \tag {41} +$$ + +then $P_{t}^{\star}(\lambda) = Q_{t / 2}^{\star}(-\lambda^{2})$ + +Proof. First, remark that the equalities in (40) and (41) are well defined because the arg min are unique by Theorem 2.3. Without loss of generality, assume that $d_x \leq d_y$ (otherwise switch the players), and let $r \stackrel{\mathrm{def}}{=} d_x / d_y < 1$ . Since, + +$$ +- \boldsymbol {A} ^ {2} = \left[ \begin{array}{c c} M M ^ {\top} & 0 \\ 0 & M ^ {\top} M \end{array} \right], \tag {42} +$$ + +each eigenvalue of $MM^{\top} \in \mathbb{R}^{d_x \times d_x}$ is an eigenvalue of $-A^2$ with doubled duplicity, and the rest of eigenvalues are zero. Hence, we have $\mu_{-A^2} = \left(1 - 2 / (1 + \frac{1}{r})\right)\delta_0 + 2\mu_{MM^{\top}} / (1 + \frac{1}{r})$ . Thus, for all $t \geq 0$ , + +$$ +Q _ {t} ^ {\star} = \arg \min _ { \begin{array}{c} P _ {t} \in \Pi_ {t} ^ {\mathbb {R}}, \\ P _ {t} (0) = 1 \end{array} } \int_ {\mathbb {R} _ {> 0}} P _ {t} (\lambda) ^ {2} \mathrm {d} \mu_ {- \boldsymbol {A} ^ {2}} (\lambda) = \underset { \begin{array}{c} P _ {t} \in \Pi_ {t} ^ {\mathbb {R}}, \\ P _ {t} (0) = 1 \end{array} } {\arg \min } \int_ {\mathbb {R} _ {> 0}} P _ {t} (\lambda) ^ {2} \rho_ {\boldsymbol {M M} ^ {\top}} (\lambda) \mathrm {d} \lambda \tag {43} +$$ + +By Proposition B.4, for an even $t \geq 0$ the minimum in (41) is attained by an even polynomial with real coefficients. Hence, + +$$ +\begin{array}{l} \min_{\substack{P_{t}\in \Pi_{t}^{\mathbb{R}},\\ P_{t}(0) = 1}}\int_{i\mathbb{R}\setminus \{0\}}|P_{t}(\lambda)|^{2}|\lambda |\rho_{\boldsymbol{M}\boldsymbol{M}^{\top}}(|\lambda |^{2}) \mathrm{d}|\lambda | = \min_{\substack{P_{t / 2}\in \Pi_{t / 2}^{\mathbb{R}},\\ P_{t / 2}(0) = 1}}\int_{i\mathbb{R}\setminus \{0\}}|P_{t / 2}(\lambda^{2})|^{2}|\lambda |\rho_{\boldsymbol{M}\boldsymbol{M}^{\top}}(|\lambda |^{2}) \mathrm{d}|\lambda | \\ = 2\min_{\substack{P_{t / 2}\in \Pi^{\mathbb{R}}_{t / 2},\\ P_{t / 2}(0) = 1}}\int_{\mathbb{R}_{>0}}|P_{t / 2}((i\lambda)^{2})|^{2}\lambda \rho_{MM^{\top}}(\lambda^{2}) \mathrm{d}\lambda \\ = 2\min_{\substack{P_{t / 2}\in \Pi^{\mathbb{R}}_{t / 2},\\ P_{t / 2}(0) = 1}}\int_{\mathbb{R}_{>0}}P_{t / 2}(\lambda^{2})^{2}\lambda \rho_{MM^{\top}}(\lambda^{2}) \mathrm{d}\lambda \\ = \min _ {\substack {P _ {t / 2} \in \Pi_ {t / 2} ^ {\mathbb {R}}, \\ P _ {t / 2} (0) = 1}} \int_ {\mathbb {R} > 0} P _ {t / 2} (\lambda) ^ {2} \rho_ {\boldsymbol {M M} ^ {\top}} (\lambda) \mathrm {d} \lambda \tag{44} \\ \end{array} +$$ + +Moreover, for any polynomial $Q_{t/2}$ that attains the minimum on the right-most term, the polynomial $P_t(\lambda) = Q_{t/2}(-\lambda^2)$ attains the minimum on the left-most term. In particular, using (43), $P_t^\star(\lambda) \stackrel{\mathrm{def}}{=} Q_{t/2}^\star(-\lambda^2)$ attains the minimum on the left-most term. + +Theorem 3.1. Suppose that Assumption 1 holds and that the expected spectral distribution of $MM^{\top}$ is absolutely continuous with respect to the Lebesgue measure. Then, the method (11) is average-case optimal for bilinear games when $h_t$ , $m_t$ are chosen to be the coefficients of the average-case optimal minimization of $\frac{1}{2}\| F(\pmb{x})\|^2$ . + +Proof. Making use of Theorem 2.1 and Proposition B.2, we obtain that for any first-order method using the vector field $F$ , + +$$ +\mathbb {E} \left[ \operatorname {d i s t} \left(\boldsymbol {x} _ {t}, \mathcal {X} ^ {\star}\right) \right] = R ^ {2} \int_ {\mathbb {C} \backslash \{0 \}} | P _ {t} (\lambda) | ^ {2} \mathrm {d} \mu_ {\boldsymbol {A}} (\lambda) = \frac {2 R ^ {2}}{1 + \frac {1}{r}} \int_ {i \mathbb {R} \backslash \{0 \}} | P _ {t} (\lambda) | ^ {2} | \lambda | \rho_ {M M ^ {\top}} (| \lambda | ^ {2}) \mathrm {d} | \lambda | \tag {45} +$$ + +Let $Q_{t/2}^{\star}, P_t^{\star}$ be as defined in (41) and (40). For $t \geq 0$ even the iteration $t$ of the average-case optimal method for the bilinear game must satisfy + +$$ +\boldsymbol {x} _ {t} - P _ {\mathcal {X} ^ {*}} \left(\boldsymbol {x} _ {0}\right) = P _ {t} ^ {*} (\boldsymbol {A}) \left(\boldsymbol {x} _ {0} - P _ {\mathcal {X} ^ {*}} \left(\boldsymbol {x} _ {0}\right)\right) = Q _ {t / 2} ^ {*} (- \boldsymbol {A} ^ {2}) \left(\boldsymbol {x} _ {0} - P _ {\mathcal {X} ^ {*}} \left(\boldsymbol {x} _ {0}\right)\right) \tag {46} +$$ + +On the other hand, the first-order methods for the minimization of the function $\frac{1}{2}\| F(\pmb{x})\|^2$ make use of the vector field $\nabla \left(\frac{1}{2}\| F(\pmb{x})\|^2\right) = \pmb{A}^\top (\pmb{A}\pmb{x} + \pmb{b}) = -\pmb{A}^2 (\pmb{x} - \pmb{x}^\star)$ . Let $\mu_{-\pmb{A}^2}$ be the spectral density of $-\pmb{A}^2$ . By Theorem 2.1, the average-case optimal first-order method for the minimization problem is the one for which the residual polynomial $P_t$ (Proposition 2.1) minimizes the functional $\int_{\mathbb{R}} P_t^2 \mathrm{d}\mu_{-\pmb{A}^2}$ . That is, the residual polynomial is $Q_t^\star$ . From (46), we see that the $t$ -th iterate of the average-case optimal method for $F$ is equal to the $t/2$ -th iterator of the average-case optimal method for $\nabla \left(\frac{1}{2}\| F(\pmb{x})\|^2\right)$ . + +# C PROOFS OF THEOREM 4.1 AND THEOREM 4.2 + +Theorem 4.1. Under Assumption 4 and the assumptions of Theorem 2.1, the following algorithm is optimal in the average case, with $\mathbf{y}_{-1} = \mathbf{y}_0 = \mathbf{x}_0$ : + +$$ +\boldsymbol {y} _ {t} = a _ {t} \boldsymbol {y} _ {t - 1} + (1 - a _ {t}) \boldsymbol {y} _ {t - 2} + b _ {t} F (\boldsymbol {y} _ {t - 1}) +$$ + +$$ +\boldsymbol {x} _ {t} = \frac {B _ {t}}{B _ {t} + \beta_ {t}} \boldsymbol {x} _ {t - 1} + \frac {\beta_ {t}}{B _ {t} + \beta_ {t}} \boldsymbol {y} _ {t}, \quad \beta_ {t} = \phi_ {t} ^ {2} (0), \quad B _ {t} = B _ {t - 1} + \beta_ {t - 1}, \quad B _ {0} = 0. \tag {16} +$$ + +where $(\phi_k(0))_{k\geq 0}$ can be computed using the three-term recurrence (upon normalization). Moreover, $\mathbb{E}_{(\pmb {A},\pmb{x}^{\star},\pmb{x}_0)}\mathrm{dist}(\pmb {x}_t,\mathcal{X}^\star)$ converges to zero at rate $1 / B_{t}$ + +Proof. We prove by induction that + +$$ +\boldsymbol {x} _ {t} - \boldsymbol {x} ^ {\star} = \frac {\sum_ {k = 0} ^ {t} \phi_ {k} (\boldsymbol {A}) \phi_ {k} (0) ^ {*}}{\sum_ {k = 0} ^ {t} \phi_ {k} (0) ^ {2}} \left(\boldsymbol {x} _ {0} - \boldsymbol {x} ^ {\star}\right) \tag {47} +$$ + +The base step $t = 0$ holds trivially because $\phi_0 = 1$ . Assume that (47) holds for $t - 1$ . Subtracting $x^{\star}$ from (16), we have + +$$ +\boldsymbol {x} _ {t} - \boldsymbol {x} ^ {\star} = \frac {\sum_ {k = 0} ^ {t - 1} \phi_ {k} (0) ^ {2}}{\sum_ {k = 0} ^ {t} \phi_ {k} (0) ^ {2}} \left(\boldsymbol {x} _ {t - 1} - \boldsymbol {x} ^ {\star}\right) + \frac {\phi_ {t} (0) ^ {2}}{\sum_ {k = 0} ^ {t} \phi_ {k} (0) ^ {2}} \left(\boldsymbol {y} _ {t} - \boldsymbol {x} ^ {\star}\right) \tag {48} +$$ + +If + +$$ +\phi_ {t} (0) ^ {2} \left(\boldsymbol {y} _ {t} - \boldsymbol {x} ^ {\star}\right) = \phi_ {t} (0) \phi_ {t} (\boldsymbol {A}) \left(\boldsymbol {x} _ {0} - \boldsymbol {x} ^ {\star}\right), \tag {49} +$$ + +by the induction hypothesis for $t - 1$ and (48), we have + +$$ +\begin{array}{l} \boldsymbol {x} _ {t} - \boldsymbol {x} ^ {\star} = \frac {\sum_ {k = 0} ^ {t - 1} \phi_ {t} (0) \phi_ {t} (\boldsymbol {A})}{\sum_ {k = 0} ^ {t} \phi_ {k} (0) ^ {2}} \left(\boldsymbol {x} _ {0} - \boldsymbol {x} ^ {\star}\right) + \frac {\phi_ {t} (0) \phi_ {t} (\boldsymbol {A})}{\sum_ {k = 0} ^ {t} \phi_ {k} (0) ^ {2}} \left(x _ {0} - x _ {*}\right) \tag {50} \\ = \frac {\sum_ {k = 0} ^ {t} \phi_ {t} (0) \phi_ {t} (\boldsymbol {A})}{\sum_ {k = 0} ^ {t} \phi_ {k} (0) ^ {2}} (x _ {0} - x _ {*}), \\ \end{array} +$$ + +which concludes the proof of (47). The only thing left is to show (49), again by induction. The base case follows readily from $\pmb{y}_0 = \pmb{x}_0$ in (16). Dividing by $\phi_t(0)^2$ , we rewrite (49) as + +$$ +\boldsymbol {y} _ {t} - \boldsymbol {x} ^ {\star} = \frac {\phi_ {t} (\boldsymbol {A})}{\phi_ {t} (0)} \left(\boldsymbol {x} _ {0} - \boldsymbol {x} ^ {\star}\right) = \psi_ {t} (\boldsymbol {A}) \left(\boldsymbol {x} _ {0} - \boldsymbol {x} ^ {\star}\right), \tag {51} +$$ + +where $\psi_t$ is the $t$ -th orthogonal residual polynomial of sequence. By Assumption 4, $\psi_t$ must satisfy the recurrence in (15). If we subtract $x_*$ from the second line of (16), we apply the induction hypothesis and then the recurrence in (15), we obtain + +$$ +\begin{array}{l} \boldsymbol {y} _ {t} - \boldsymbol {x} ^ {\star} = a _ {t} \left(\boldsymbol {y} _ {t - 1} - \boldsymbol {x} ^ {\star}\right) + \left(1 - a _ {t}\right) \left(\boldsymbol {y} _ {t - 2} - \boldsymbol {x} ^ {\star}\right) + b _ {t} F \left(\boldsymbol {y} _ {t - 1}\right) \\ = a _ {t} \left(\boldsymbol {y} _ {t - 1} - \boldsymbol {x} ^ {\star}\right) + \left(1 - a _ {t}\right) \left(\boldsymbol {y} _ {t - 2} - \boldsymbol {x} ^ {\star}\right) + b _ {t} \boldsymbol {A} \left(\boldsymbol {y} _ {t - 1} - \boldsymbol {x} _ {*}\right) \\ = a _ {t} \psi_ {t - 1} (\boldsymbol {A}) \left(\boldsymbol {x} _ {0} - \boldsymbol {x} ^ {\star}\right) + (1 - a _ {t}) \psi_ {t - 2} (\boldsymbol {A}) \left(\boldsymbol {x} _ {0} - \boldsymbol {x} ^ {\star}\right) + b _ {t} \boldsymbol {A} \psi_ {t - 1} (\boldsymbol {A}) \left(\boldsymbol {x} _ {0} - \boldsymbol {x} ^ {\star}\right) \tag {52} \\ = \psi_ {t} (\boldsymbol {A}) \left(\boldsymbol {x} _ {0} - \boldsymbol {x} ^ {\star}\right), \\ \end{array} +$$ + +thus concluding the proof of (49). + +![](images/ddbdf6b720a26c59661c0cb92463857343c989b33c8e74a3ffa20a551ab723ed.jpg) + +Proposition C.1. Suppose that Assumption 5 holds with $C = 0$ , that is, the circular support of $\mu$ is centered at 0. Then, the basis of orthonormal polynomials for the scalar product + +$$ +\langle P, Q \rangle = \int_ {D _ {R, 0}} P (\lambda) Q (\lambda) ^ {*} \mathrm {d} \mu (\lambda) \quad i s \quad \phi_ {k} (\lambda) = \frac {\lambda^ {k}}{D _ {k , R}}, \quad \forall k \geq 0, \tag {53} +$$ + +where $K_{k,R} = \sqrt{2\pi\int_0^Rr^{2k}d\mu_R(r)}$ + +Proof. First, we will show that if $\mu$ satisfies Assumption 5 with $C = 0$ , then $\langle \lambda^i, \lambda^j \rangle = 0$ if $j, k \geq 0$ with $j \neq k$ (without loss of generality, suppose that $j > k$ ). + +$$ +\begin{array}{l} \langle \lambda^ {j}, \lambda^ {k} \rangle = \int_ {D _ {R, 0}} \lambda^ {j} \left(\lambda^ {*}\right) ^ {k} d \mu (\lambda) = \int_ {D _ {R, 0}} \lambda^ {j - k} | \lambda | ^ {2 k} d \mu (\lambda) \\ = \int_ {0} ^ {R} \frac {1}{2 \pi} \int_ {0} ^ {2 \pi} (r e ^ {i \theta}) ^ {j - k} r ^ {2 k} \mathrm {d} \theta \mathrm {d} \mu_ {R} (r) = \frac {1}{2 \pi} \int_ {0} ^ {2 \pi} e ^ {i \theta (j - k)} \mathrm {d} \theta \int_ {0} ^ {R} r ^ {j + k} \mathrm {d} \mu_ {R} (r) \tag {54} \\ = \frac {e ^ {i 2 \pi} - 1}{2 \pi i (j - k)} \int_ {0} ^ {R} r ^ {j + k} \mathrm {d} \mu_ {R} (r) = 0 \\ \end{array} +$$ + +And for all $k\geq 0$ + +$$ +\langle \lambda^ {k}, \lambda^ {k} \rangle = \int_ {D _ {R, 0}} | \lambda^ {k} | ^ {2} \mathrm {d} \mu (\lambda) = \int_ {0} ^ {R} \frac {1}{2 \pi} \int_ {0} ^ {2 \pi} r ^ {2 k} \mathrm {d} \theta \mathrm {d} \mu_ {R} (r) = \int_ {0} ^ {2 \pi} r ^ {2 k} \mathrm {d} \mu_ {R} (r). \tag {55} +$$ + +![](images/3ff7dd55f0fd6f067ac71ded079425782f02e58e2e7cef5bb5c0ab98473f5924.jpg) + +Proposition 4.1. If $\mu$ satisfies Assumption 5, the sequence of orthonormal polynomials is $(\phi_t)_{t\geq 0}$ + +$$ +\phi_ {t} (\lambda) = \frac {(\lambda - C) ^ {t}}{K _ {t , R}}, \text {w h e r e} K _ {t, R} = \sqrt {\int_ {0} ^ {R} r ^ {2 t} \mathrm {d} \mu_ {R} (r)}. \tag {17} +$$ + +Proof. The result follows from Proposition C.1 using the change of variables $z \to z + C$ . To compute the measure $\mu_R$ for the uniform measure on $D_{C,R}$ , we perform a change of variables to circular coordinates: + +$$ +\begin{array}{l} \int_ {D _ {C, R}} f (\lambda) \mathrm {d} \mu (\lambda) = \frac {1}{\pi R ^ {2}} \int_ {0} ^ {R} \int_ {0} ^ {2 \pi} f (C + r e ^ {i \theta}) r \mathrm {d} \theta \mathrm {d} r = \int_ {0} ^ {R} \int_ {0} ^ {2 \pi} f (C + r e ^ {i \theta}) \mathrm {d} \theta \mathrm {d} \mu_ {R} (r). \\ \Rightarrow \mathrm {d} \mu_ {R} (r) = \frac {r}{\pi R ^ {2}} \mathrm {d} r \tag {56} \\ \end{array} +$$ + +And + +$$ +\int_ {0} ^ {R} r ^ {2 t} \mathrm {d} \mu_ {R} (r) = \frac {1}{\pi R ^ {2}} \int_ {0} ^ {R} r ^ {2 t + 1} \mathrm {d} r = \frac {1}{\pi} \frac {R ^ {2 t}}{2 t + 2} \Rightarrow K _ {t, R} = R ^ {t} / \sqrt {t + 1}. \tag {57} +$$ + +![](images/2c6b973f979e018eab001056596cccd6456f2712fd507689d8c23fcb4294950d.jpg) + +Theorem 4.2. Given an initialization $\pmb{x}_0(\pmb{y}_0 = \pmb{x}_0)$ , if Assumption 5 is fulfilled with $R < C$ and the assumptions of Theorem 2.1 hold, then the average-case optimal first-order method is + +$$ +\boldsymbol {y} _ {t} = \boldsymbol {y} _ {t - 1} - \frac {1}{C} F (\boldsymbol {y} _ {t - 1}), \quad \beta_ {t} = C ^ {2 t} / K _ {t, R} ^ {2}, \quad B _ {t} = B _ {t - 1} + \beta_ {t - 1}, +$$ + +$$ +\boldsymbol {x} _ {t} = \frac {B _ {t}}{B _ {t} + \beta_ {t}} \boldsymbol {x} _ {t - 1} + \frac {\beta_ {t}}{B _ {t} + \beta_ {t}} \boldsymbol {y} _ {t}. \tag {18} +$$ + +Moreover, $\mathbb{E}_{(A,\pmb{x}^{\star},\pmb{x}_0)}\mathrm{dist}(\pmb{x}_t,\mathcal{X}^\star)$ converges to zero at rate $1 / B_{t}$ . + +Proof. By Proposition 4.1, the sequence of residual orthogonal polynomials is given by $\psi_t(\lambda) = \phi_t(\lambda) / \phi_t(0) = \left(1 - \frac{\lambda}{C}\right)^t$ . Hence, Assumption 4 is fulfilled with $a_t = 1, b_t = -\frac{1}{C}$ , as $\psi_t(\lambda) = \psi_{t-1}(\lambda) - \frac{\lambda}{C} \psi_{t-1}(\lambda)$ . We apply Theorem 4.1 and make use of the fact that $\phi_k(0)^2 = \frac{C^{2k}}{K_{t,R}^2}$ . See Proposition D.3 for the rate on $\mathrm{dist}(\boldsymbol{x}_t, \mathcal{X}^\star)$ . + +# D PROOF OF PROPOSITION 5.2 + +Proposition D.1. Suppose that the assumptions of Theorem 4.2 hold with the probability measure $\mu_R$ fulfilling $\mu_R([r,R]) = \Omega((R - r)^\kappa)$ for $r$ in $[r_0,R]$ for some $r_0 \in [0,R)$ and for some $\kappa \in \mathbb{Z}$ . Then, + +$$ +\lim _ {t \rightarrow \infty} \frac {\frac {C ^ {2 t}}{K _ {t , R} ^ {2}}}{\sum_ {k = 0} ^ {t} \frac {C ^ {2 k}}{K _ {k , R} ^ {2}}} = 1 - \frac {R ^ {2}}{C ^ {2}}. \tag {58} +$$ + +Proof. Given $\epsilon > 0$ , let $c_{\epsilon} \in \mathbb{Z}_{\geq 0}$ be the minimum such that + +$$ +\frac {1}{\sum_ {i = 0} ^ {c _ {\epsilon}} \left(\frac {R ^ {2}}{C ^ {2}}\right) ^ {i}} \leq (1 + \epsilon) \frac {1}{\sum_ {i = 0} ^ {\infty} \left(\frac {R ^ {2}}{C ^ {2}}\right) ^ {i}} = (1 + \epsilon) \left(1 - \frac {R ^ {2}}{C ^ {2}}\right) \tag {59} +$$ + +Define $Q_{t,R} \stackrel{\mathrm{def}}{=} \frac{R^{2t}}{K_{t,R}^2}$ . Then, + +$$ +\frac {\frac {C ^ {2 t}}{K _ {t , R} ^ {2}}}{\sum_ {k = 0} ^ {t} \frac {C ^ {2 k}}{K _ {k , R} ^ {2}}} = \frac {\frac {C ^ {2 t}}{R ^ {2 t}} Q _ {t , R}}{\sum_ {k = 0} ^ {t} \frac {C ^ {2 k}}{R ^ {2 k}} Q _ {k , R}} = \frac {Q _ {t , R}}{\sum_ {k = 0} ^ {t} \left(\frac {R ^ {2}}{C ^ {2}}\right) ^ {t - k} Q _ {k , R}} \tag {60} +$$ + +Now, on one hand, using that $Q_{t,R}$ is an increasing sequence on $t$ , + +$$ +\frac {Q _ {t , R}}{\sum_ {k = 0} ^ {t} \left(\frac {R ^ {2}}{C ^ {2}}\right) ^ {t - k} Q _ {k , R}} \geq \frac {1}{\sum_ {k = 0} ^ {t} \left(\frac {R ^ {2}}{C ^ {2}}\right) ^ {t - k}} \geq \frac {1}{\sum_ {k = 0} ^ {\infty} \left(\frac {R ^ {2}}{C ^ {2}}\right) ^ {k}} = 1 - \frac {R ^ {2}}{C ^ {2}} \tag {61} +$$ + +On the other hand, for $t \geq c_{\epsilon}$ , + +$$ +\frac {Q _ {t , R}}{\sum_ {k = 0} ^ {t} \left(\frac {R ^ {2}}{C ^ {2}}\right) ^ {t - k} Q _ {k , R}} \leq \frac {Q _ {t , R}}{\sum_ {k = t - c _ {\epsilon}} ^ {t} \left(\frac {R ^ {2}}{C ^ {2}}\right) ^ {t - k} Q _ {k , R}} = \frac {Q _ {t , R}}{\sum_ {k = t - c _ {\epsilon}} ^ {t} \left(\frac {R ^ {2}}{C ^ {2}}\right) ^ {t - k} \left(Q _ {t , R} - \int_ {k} ^ {t} \frac {d}{d s} Q _ {s , R} d s\right)} \tag {62} +$$ + +Thus, we want to upper-bound $\int_{k}^{t}\frac{d}{ds} Q_{s,R}\mathrm{d}s$ . First, notice that + +$$ +\frac {d}{d s} Q _ {s, R} = \frac {d}{d s} \left(\int_ {0} ^ {R} \left(\frac {r}{R}\right) ^ {2 s} \mathrm {d} \mu_ {R} (r)\right) ^ {- 1} = \frac {\int_ {0} ^ {R} \left(\frac {r}{R}\right) ^ {2 s} \left(- \log \left(\frac {r}{R}\right)\right) \mathrm {d} \mu_ {R} (r)}{\left(\int_ {0} ^ {R} \left(\frac {r}{R}\right) ^ {2 s} \mathrm {d} \mu_ {R} (r)\right) ^ {2}} \tag {63} +$$ + +By concavity of the logarithm function we obtain $\log \left(\frac{R}{r}\right) \leq \frac{R}{r_0} - 1$ for $r \in [r_0, R]$ . Choose $r_0$ close enough to $R$ so that $\frac{R}{r_0} - 1 \leq \epsilon / c_{\epsilon}$ . We obtain that + +$$ +\int_ {0} ^ {R} \left(\frac {r}{R}\right) ^ {2 s} \log \left(\frac {R}{r}\right) d \mu_ {R} (r) \leq \int_ {0} ^ {r _ {0}} \left(\frac {r}{R}\right) ^ {2 s} \log \left(\frac {R}{r}\right) d \mu_ {R} (r) + \int_ {r _ {0}} ^ {R} \left(\frac {r}{R}\right) ^ {2 s} \left(\frac {R}{r _ {0}} - 1\right) d \mu_ {R} (r). \tag {64} +$$ + +Thus, + +$$ +\int_ {k} ^ {t} \frac {d}{d s} Q _ {s, R} \mathrm {d} s \leq \int_ {k} ^ {t} \frac {\int_ {0} ^ {r _ {0}} \left(\frac {r}{R}\right) ^ {2 s} \log \left(\frac {R}{r}\right) \mathrm {d} \mu_ {R} (r)}{\left(\int_ {0} ^ {R} \left(\frac {r}{R}\right) ^ {2 s} \mathrm {d} \mu_ {R} (r)\right) ^ {2}} \mathrm {d} s + \int_ {k} ^ {t} \frac {\int_ {r _ {0}} ^ {R} \left(\frac {r}{R}\right) ^ {2 s} \left(\frac {R}{r _ {0}} - 1\right) \mathrm {d} \mu_ {R} (r)}{\left(\int_ {0} ^ {R} \left(\frac {r}{R}\right) ^ {2 s} \mathrm {d} \mu_ {R} (r)\right) ^ {2}} \mathrm {d} s. \tag {65} +$$ + +Using that $\log x\leq x$ , for $k\in [t - c_{\epsilon},t]$ we can bound the first term of (65) as + +$$ +\begin{array}{l} \int_ {k} ^ {t} \frac {\int_ {0} ^ {r _ {0}} \left(\frac {r}{R}\right) ^ {2 s} \log \left(\frac {R}{r}\right) \mathrm {d} \mu_ {R} (r)}{\left(\int_ {0} ^ {R} \left(\frac {r}{R}\right) ^ {2 s} \mathrm {d} \mu_ {R} (r)\right) ^ {2}} \mathrm {d} s \leq \int_ {k} ^ {t} \frac {\int_ {0} ^ {r _ {0}} \left(\frac {r}{R}\right) ^ {2 s - 1} \mathrm {d} \mu_ {R} (r)}{\left(\int_ {0} ^ {R} \left(\frac {r}{R}\right) ^ {2 s} \mathrm {d} \mu_ {R} (r)\right) ^ {2}} \mathrm {d} s \\ \leq (t - k) \frac {\left(\frac {r _ {0}}{R}\right) ^ {2 k - 1}}{\left(\int_ {0} ^ {R} \left(\frac {r}{R}\right) ^ {2 t} \mathrm {d} \mu_ {R} (r)\right) ^ {2}} \tag {66} \\ \leq c _ {\epsilon} \left(\frac {r _ {0}}{R}\right) ^ {2 (t - c _ {\epsilon}) - 1} Q _ {t, R} ^ {2} \\ \leq c _ {\epsilon} \left(\frac {r _ {0}}{R}\right) ^ {2 (t - c _ {\epsilon}) - 1} \frac {1}{(c _ {1}) ^ {2}} (2 t + 1) ^ {2 \kappa} \xrightarrow {t \to \infty} 0. \\ \end{array} +$$ + +In the last inequality we use that by Proposition D.2, for $t$ large enough, $Q_{t,R} = \frac{R^{2t}}{K_{t,R}^2} \leq (2t + 1)^k / c_1$ . For $k \in [t - c_\epsilon, t]$ , the second term of (65) can be bounded as + +$$ +\begin{array}{l} \int_ {k} ^ {t} \frac {\int_ {r _ {0}} ^ {R} \left(\frac {r}{R}\right) ^ {2 s} \frac {R}{r _ {0}} \mathrm {d} \mu_ {R} (r)}{\left(\int_ {0} ^ {R} \left(\frac {r}{R}\right) ^ {2 s} \mathrm {d} \mu_ {R} (r)\right) ^ {2}} \mathrm {d} s \leq (t - k) \left(\frac {R}{r _ {0}} - 1\right) \frac {1}{\int_ {0} ^ {R} \left(\frac {r}{R}\right) ^ {2 t} \mathrm {d} \mu_ {R} (r)} \\ \leq c _ {\epsilon} \left(\frac {R}{r _ {0}} - 1\right) \frac {1}{\int_ {0} ^ {R} \left(\frac {r}{R}\right) ^ {2 t} \mathrm {d} \mu_ {R} (r)} \tag {67} \\ \le \epsilon Q _ {t, R}. \\ \end{array} +$$ + +From (65), (66) and (67), we obtain that for $t$ large enough, for $k \in [t - c_{\epsilon}, t]$ , + +$$ +\int_ {k} ^ {t} \frac {d}{d s} Q _ {s, R} d s \leq 2 \epsilon Q _ {t, R}. \tag {68} +$$ + +Hence, we can bound the right-hand side of (62): + +$$ +\begin{array}{l} \frac {Q _ {t , R}}{\sum_ {k = t - c _ {\epsilon}} ^ {t} \left(\frac {R ^ {2}}{C ^ {2}}\right) ^ {t - k} \left(Q _ {t , R} - \int_ {k} ^ {t} \frac {d}{d s} Q _ {s , R} d s\right)} \leq \frac {Q _ {t , R}}{\sum_ {k = t - c _ {\epsilon}} ^ {t} \left(\frac {R ^ {2}}{C ^ {2}}\right) ^ {t - k} \left(Q _ {t , R} - 2 \epsilon Q _ {t , R}\right)} \tag {69} \\ = \frac {1}{(1 - 2 \epsilon) \sum_ {k = t - c _ {\epsilon}} ^ {t} \left(\frac {R ^ {2}}{C ^ {2}}\right) ^ {t - k}} = \frac {1}{(1 - 2 \epsilon) \sum_ {k = 0} ^ {c _ {\epsilon}} \left(\frac {R ^ {2}}{C ^ {2}}\right) ^ {k}} \leq \frac {1 + \epsilon}{1 - 2 \epsilon} \left(1 - \frac {R ^ {2}}{C ^ {2}}\right). \\ \end{array} +$$ + +The last inequality follows from the definition of $c_{\epsilon}$ in (59). Since $\epsilon$ is arbitrary, by the sandwich theorem applied on (60), (61) and (69), + +$$ +\lim _ {t \rightarrow \infty} \frac {\frac {C ^ {2 t}}{K _ {t , R} ^ {2}}}{\sum_ {k = 0} ^ {t} \frac {C ^ {2 k}}{K _ {k , R} ^ {2}}} = 1 - \frac {R ^ {2}}{C ^ {2}}. \tag {70} +$$ + +![](images/7e9d653274ae9687fd6ab6de2600da77f75481df669b1aebec5bd3f497d40c56.jpg) + +Proposition D.2. Under the assumptions of Theorem 4.2, we have that there exists $c_{1} > 0$ such that for $t$ large enough, + +$$ +K _ {t, R} ^ {- 2} \geq c _ {1} R ^ {2 t} (2 t + 1) ^ {- \kappa}. \tag {71} +$$ + +Proof. By the assumption on $\mu_R$ , there exist $r_0, c_1, \kappa > 0$ such that + +$$ +\begin{array}{l} K _ {t, R} ^ {2} \stackrel {\mathrm {d e f}} {=} 2 \pi \int_ {0} ^ {R} r ^ {2 t} \mathrm {d} \mu_ {R} (r) = 2 \pi \int_ {0} ^ {r _ {0}} r ^ {2 t} \mathrm {d} \mu_ {R} (r) + 2 \pi \int_ {r _ {0}} ^ {R} r ^ {2 t} \mathrm {d} \mu_ {R} (r) \\ \geq 2 \pi c _ {1} \int_ {r _ {0}} ^ {R} r ^ {2 t} (R - r) ^ {\kappa - 1} \mathrm {d} r = - 2 \pi c _ {1} \int_ {0} ^ {r _ {0}} r ^ {2 t} (R - r) ^ {\kappa - 1} \mathrm {d} r + 2 \pi c _ {1} \int_ {0} ^ {R} r ^ {2 t} (R - r) ^ {\kappa - 1} \mathrm {d} r \\ \geq - 2 \pi c _ {1} R r _ {0} ^ {2 t} + 2 \pi c _ {1} R ^ {2 t + \kappa} B (2 t + 1, \kappa). \tag {72} \\ \end{array} +$$ + +where the beta function $B(x,y)$ is defined as + +$$ +B (x, y) \stackrel {\text {d e f}} {=} \int_ {0} ^ {1} r ^ {x + 1} (1 - r) ^ {y + 1} \mathrm {d} r. \tag {73} +$$ + +Using the link between the beta function and the gamma function $B(x,y) = \Gamma (x)\Gamma (y) / \Gamma (x + y)$ , and Stirling's approximation, we obtain that for fixed $y$ and large $x$ , + +$$ +B (x, y) \sim \Gamma (y) x ^ {- y}. \tag {74} +$$ + +Hence, for $t$ large enough, $B(2t + 1,\kappa)\sim \Gamma (\kappa)(2t + 1)^{-\kappa} = (\kappa -1)!(2t + 1)^{-\kappa}$ . Hence, from (72) we obtain that there exist $c_{1}^{\prime}$ depending only on $\kappa$ and $r_0$ such that for $t$ large enough + +$$ +K _ {t, R} ^ {2} \geq - 2 \pi c _ {1} R r _ {0} ^ {2 t} + 2 \pi c _ {1} R ^ {2 t + \kappa} (k - 1)! (2 t + 1) ^ {- \kappa} \geq c _ {1} ^ {\prime} R ^ {2 t} (2 t + 1) ^ {- \kappa}. \tag {75} +$$ + +![](images/7bfe370b70dcd593b78602bdf21d5d6ed327de7142bf4a99982d9a9a261068f5.jpg) + +Proposition 5.2. Suppose that the assumptions of Theorem 4.2 hold with $\mu_R \in \mathcal{P}([0, R])$ fulfilling $\mu_R([r, R]) = \Omega((R - r)^\kappa)$ for $r$ in $[r_0, R]$ for some $r_0 \in [0, R)$ and for some $\kappa \in \mathbb{Z}$ . Then, the average-case asymptotically optimal algorithm is, with $\pmb{y}_0 = \pmb{x}_0$ : + +$$ +\boldsymbol {y} _ {t} = \boldsymbol {y} _ {t - 1} - \frac {1}{C} F (\boldsymbol {y} _ {t - 1}), +$$ + +$$ +\boldsymbol {x} _ {t} = \left(\frac {R}{C}\right) ^ {2} \boldsymbol {x} _ {t - 1} + \left(1 - \left(\frac {R}{C}\right) ^ {2}\right) \boldsymbol {y} _ {t}. \tag {20} +$$ + +Moreover, the convergence rate for this algorithm is asymptotically the same one as for the optimal algorithm in Theorem 4.2. Namely, $\lim_{t\to \infty}\mathbb{E}\left[\mathrm{dist}(\pmb{x}_t,\mathcal{X}^\star)\right]B_t = 1$ + +Proof. The proof follows directly from Theorem 4.2 and Proposition D.1. See (77) and (79) in Proposition D.3 for the statement regarding the convergence rate. + +Proposition D.3. For the average-case optimal algorithm (18), + +$$ +\mathbb {E} \operatorname {d i s t} \left(\boldsymbol {x} _ {t}, \boldsymbol {\chi} ^ {\star}\right) = \xi_ {o p t} (t) \stackrel {\text {d e f}} {=} \frac {1}{\sum_ {k = 0} ^ {t} \frac {C ^ {2 k}}{K _ {k , R} ^ {2}}} \tag {76} +$$ + +For the average-case asymptotically optimal algorithm (20), + +$$ +\mathbb {E} \operatorname {d i s t} \left(\boldsymbol {x} _ {t}, \boldsymbol {\chi} ^ {\star}\right) = \xi_ {\text {a s y m p}} (t) \stackrel {\text {d e f}} {=} \left(1 - \left(\frac {R}{C}\right) ^ {2}\right) ^ {2} \sum_ {k = 1} ^ {t} \frac {K _ {k , R} ^ {2}}{C ^ {2 k}} \left(\frac {R}{C}\right) ^ {4 (t - k)} + \left(\frac {R}{C}\right) ^ {4 t} \tag {77} +$$ + +For the iterates $\mathbf{y}_t$ in (18), i.e. gradient descent with stepsize $1 / C$ , we have + +$$ +\mathbb {E} \operatorname {d i s t} \left(\boldsymbol {y} _ {t}, \mathcal {X} ^ {\star}\right) = \xi_ {G D} (t) \stackrel {\text {d e f}} {=} \frac {K _ {t , R} ^ {2}}{C ^ {2 t}} \tag {78} +$$ + +Moreover, for all $t \geq 0$ , we have $\xi_{opt}(t) \leq \xi_{asymp}(t)$ , and under the assumptions of (5.1), + +$$ +\lim _ {t \rightarrow \infty} \frac {\xi_ {o p t} (t)}{\xi_ {a s y m p} (t)} = 1, \quad \lim _ {t \rightarrow \infty} \frac {\xi_ {o p t} (t)}{\xi_ {G D} (t)} = \frac {\xi_ {a s y m p} (t)}{\xi_ {G D} (t)} = 1 - \left(\frac {R}{C}\right) ^ {2} \tag {79} +$$ + +Proof. To show (76), (77), (78), we use the expression $\pmb{x}_t - \pmb{x}^\star = P_t(\pmb{A})(\pmb{x}_0 - \pmb{x}^\star)$ (Proposition 2.1) and then evaluate $\| P_t\|_\mu^2 = \int_{\mathbb{C}\setminus \{0\}}|P_t|^2 \, \mathrm{d}\mu$ (Theorem 2.1). + +For (76), the value of $\| P_t\|_\mu^2$ follows directly from Theorem 2.3, which states that the value for the optimal residual polynomial $P_{t}$ is + +$$ +\frac {1}{\sum_ {k = 0} ^ {t} | \phi_ {k} (0) | ^ {2}} = \frac {1}{\sum_ {k = 0} ^ {t} \frac {C ^ {2 k}}{K _ {k , R} ^ {2}}}. \tag {80} +$$ + +A simple proof by induction shows that for the asymptotically optimal algorithm (20), the following expression holds for all $t \geq 0$ : + +$$ +\boldsymbol {x} _ {t} - \boldsymbol {x} ^ {\star} = \left(\left(\frac {R}{C}\right) ^ {2 t} + \left(1 - \left(\frac {R}{C}\right) ^ {2}\right) \sum_ {k = 1} ^ {t} \left(1 - \frac {\boldsymbol {A}}{C}\right) ^ {k} \left(\frac {R}{C}\right) ^ {2 (t - k)}\right) \left(\boldsymbol {x} _ {0} - \boldsymbol {x} ^ {\star}\right) \tag {81} +$$ + +Thus, + +$$ +\begin{array}{l} P _ {t} (\lambda) = \left(\frac {R}{C}\right) ^ {2 t} + \left(1 - \left(\frac {R}{C}\right) ^ {2}\right) \sum_ {k = 1} ^ {t} \left(1 - \frac {\lambda}{C}\right) ^ {k} \left(\frac {R}{C}\right) ^ {2 (t - k)} \tag {82} \\ = \left(\frac {R}{C}\right) ^ {2 t} \phi_ {0} (\lambda) + \left(1 - \left(\frac {R}{C}\right) ^ {2}\right) \sum_ {k = 1} ^ {t} \frac {K _ {k , R}}{C ^ {k}} \phi_ {k} (\lambda) \left(\frac {R}{C}\right) ^ {2 (t - k)}, \\ \end{array} +$$ + +which concludes the proof of (77), as + +$$ +\left\| P _ {t} \right\| _ {\mu} ^ {2} = \left(1 - \left(\frac {R}{C}\right) ^ {2}\right) ^ {2} \sum_ {k = 1} ^ {t} \frac {K _ {k , R} ^ {2}}{C ^ {2 k}} \left(\frac {R}{C}\right) ^ {4 (t - k)} + \left(\frac {R}{C}\right) ^ {4 t}. \tag {83} +$$ + +By equation (52), + +$$ +\boldsymbol {y} _ {t} - \boldsymbol {x} ^ {\star} = \left(1 - \frac {\boldsymbol {A}}{C}\right) ^ {t} \left(\boldsymbol {y} _ {0} - \boldsymbol {x} ^ {\star}\right) = \frac {K _ {t , R}}{C ^ {t}} \phi_ {k} (\boldsymbol {A}) \left(\boldsymbol {y} _ {0} - \boldsymbol {x} ^ {\star}\right) \tag {84} +$$ + +Thus, for the $\mathbf{y}_t$ iterates, $\| P_t\|_\mu^2 = \frac{K_{t,R}^2}{C^{2t}}$ , and (78) follows. + +Now, $\xi_{\mathrm{opt}}(t) \leq \xi_{\mathrm{asymp}}(t), \forall t \geq 0$ is a consequence of $\xi_{\mathrm{opt}}(t)$ being the rate of the optimal algorithm. And + +$$ +\lim _ {t \rightarrow \infty} \frac {\xi_ {\mathrm {o p t}} (t)}{\xi_ {\mathrm {G D}} (t)} = \lim _ {t \rightarrow \infty} \frac {\frac {C ^ {2 t}}{K _ {t , R} ^ {2}}}{\sum_ {k = 0} ^ {t} \frac {C ^ {2 k}}{K _ {k , R} ^ {2}}} = 1 - \frac {R ^ {2}}{C ^ {2}} \tag {85} +$$ + +follows from Proposition D.1. To show $\lim_{t\to \infty}\frac{\xi_{\mathrm{opt}}(t)}{\xi_{\mathrm{GD}}(t)} = 1 - \frac{R^2}{C^2}$ , which concludes the proof, we rewrite + +$$ +\xi_ {\text {a s y m p}} (t) = \left(\frac {R}{C}\right) ^ {2 t} \left(\left(1 - \left(\frac {R}{C}\right) ^ {2}\right) ^ {2} \sum_ {k = 1} ^ {t} \frac {1}{Q _ {k , R}} \left(\frac {R}{C}\right) ^ {2 (t - k)} + \left(\frac {R}{C}\right) ^ {2 t}\right), \tag {86} +$$ + +using that by definition, $Q_{k,R} = R^{2k} / K_{k,R}^2$ . Now, let $c_{\epsilon} \in \mathbb{Z}_{\geq 0}$ such that + +$$ +\sum_ {k = c _ {\epsilon}} ^ {\infty} \left(\frac {R}{C}\right) ^ {2 k} \leq \epsilon . \tag {87} +$$ + +Using the same argument as in Proposition D.1 (see (68)), for $t$ large enough and $k \in [t - c_{\epsilon}, t]$ , + +$$ +\int_ {k} ^ {t} \frac {d}{d s} Q _ {s, R} d s \leq 2 \epsilon Q _ {t, R}. \tag {88} +$$ + +Hence, for $t$ large enough, + +$$ +\begin{array}{l} \left(1 - \left(\frac {R}{C}\right) ^ {2}\right) ^ {2} \sum_ {k = 1} ^ {t} \frac {1}{Q _ {k , R}} \left(\frac {R}{C}\right) ^ {2 (t - k)} + \left(\frac {R}{C}\right) ^ {2 t} \\ = \left(1 - \left(\frac {R}{C}\right) ^ {2}\right) ^ {2} \left(\sum_ {k = t - c _ {\epsilon}} ^ {t} \frac {1}{Q _ {t , R} - \int_ {k} ^ {t} \frac {d}{d s} Q _ {s , R}} \left(\frac {R}{C}\right) ^ {2 (t - k)} + \sum_ {k = 1} ^ {t - c _ {\epsilon}} \frac {1}{Q _ {k , R}} \left(\frac {R}{C}\right) ^ {2 (t - k)}\right) + \left(\frac {R}{C}\right) ^ {2 t} \\ \leq \left(1 - \left(\frac {R}{C}\right) ^ {2}\right) ^ {2} \left(\frac {1}{(1 - 2 \epsilon) Q _ {t , R}} \sum_ {k = t - c _ {\epsilon}} ^ {t} \left(\frac {R}{C}\right) ^ {2 (t - k)} + \sum_ {k = 1} ^ {t - c _ {\epsilon}} \left(\frac {R}{C}\right) ^ {2 (t - k)}\right) + \epsilon \\ \leq \left(1 - \left(\frac {R}{C}\right) ^ {2}\right) \left(\frac {1}{(1 - 2 \epsilon) Q _ {t , R}} + \left(1 - \left(\frac {R}{C}\right) ^ {2}\right) \epsilon\right) + \epsilon , \tag {89} \\ \end{array} +$$ + +which can be made arbitrarily close to $\left(1 - \left(\frac{R}{C}\right)^2\right)\frac{1}{Q_{t,R}}$ by taking $\epsilon > 0$ small enough. Plugging this into (86), we obtain that we can make $\xi_{\mathrm{asymp}}(t)$ arbitrarily close to $\left(1 - \left(\frac{R}{C}\right)^2\right)\left(\frac{R}{C}\right)^{2t}\frac{1}{Q_{t,R}} = \left(1 - \left(\frac{R}{C}\right)^2\right)\xi_{\mathrm{GD}}(t)$ by taking $t$ large enough. \ No newline at end of file diff --git a/averagecaseaccelerationforbilineargamesandnormalmatrices/images.zip b/averagecaseaccelerationforbilineargamesandnormalmatrices/images.zip new file mode 100644 index 0000000000000000000000000000000000000000..f5eb2c8028d91e1bbe04238cc9ba0180cea8ea4b --- /dev/null +++ b/averagecaseaccelerationforbilineargamesandnormalmatrices/images.zip @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c62bd8349adbc9d9d35ad10c830aad5d11c26ffe8fe3c0d2edd7c6870a670adf +size 1321387 diff --git a/averagecaseaccelerationforbilineargamesandnormalmatrices/layout.json b/averagecaseaccelerationforbilineargamesandnormalmatrices/layout.json new file mode 100644 index 0000000000000000000000000000000000000000..7b756ce1527f964063a59020bf87f93c58ebcb97 --- /dev/null +++ b/averagecaseaccelerationforbilineargamesandnormalmatrices/layout.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:395f072646c7eb93d055c99c57c69e24abe6207ad45f7170dc8b1a68ff7b8775 +size 1015280 diff --git a/bagoftricksforadversarialtraining/0e009d16-83be-41b1-8610-beb69bfecf8e_content_list.json b/bagoftricksforadversarialtraining/0e009d16-83be-41b1-8610-beb69bfecf8e_content_list.json new file mode 100644 index 0000000000000000000000000000000000000000..ae23f7ed581e1e784f36cc0e88d0865c6e3e4648 --- /dev/null +++ b/bagoftricksforadversarialtraining/0e009d16-83be-41b1-8610-beb69bfecf8e_content_list.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:bba8ff54b6646d8bba05dd67b75e002898d92de3a061710022b2c7352230d899 +size 119972 diff --git a/bagoftricksforadversarialtraining/0e009d16-83be-41b1-8610-beb69bfecf8e_model.json b/bagoftricksforadversarialtraining/0e009d16-83be-41b1-8610-beb69bfecf8e_model.json new file mode 100644 index 0000000000000000000000000000000000000000..d876d0af13bac6271175adffe3770df5242dd5e1 --- /dev/null +++ b/bagoftricksforadversarialtraining/0e009d16-83be-41b1-8610-beb69bfecf8e_model.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:abbd115ef5e78121f9f7798d521fd487c54b84136cd3a62fc352df1a8fb6f563 +size 152380 diff --git a/bagoftricksforadversarialtraining/0e009d16-83be-41b1-8610-beb69bfecf8e_origin.pdf b/bagoftricksforadversarialtraining/0e009d16-83be-41b1-8610-beb69bfecf8e_origin.pdf new file mode 100644 index 0000000000000000000000000000000000000000..71f21c8f5251818a9bab2d6fb5d367c0522d8150 --- /dev/null +++ b/bagoftricksforadversarialtraining/0e009d16-83be-41b1-8610-beb69bfecf8e_origin.pdf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8f637c42abf474215b0325aca5dd646756b5f5fba666f89a51508eefc83438bd +size 1046442 diff --git a/bagoftricksforadversarialtraining/full.md b/bagoftricksforadversarialtraining/full.md new file mode 100644 index 0000000000000000000000000000000000000000..f959b95cb368eab98f9010924b8c017db9662acb --- /dev/null +++ b/bagoftricksforadversarialtraining/full.md @@ -0,0 +1,397 @@ +# BAG OF TRICKS FOR ADVERSARIAL TRAINING + +Tianyu Pang, Xiao Yang, Yinpeng Dong, Hang Su, Jun Zhu* + +Department of Computer Science & Technology, Institute for AI, BNRist Center + +Tsinghua-Bosch Joint ML Center, THBI Lab, Tsinghua University, Beijing, 100084 China + +{pty17, yangxiaol9, dyp17}@mails.tsinghua.edu.cn, {suhangss, dcszj}@tsinghua.edu.cn + +# ABSTRACT + +Adversarial training (AT) is one of the most effective strategies for promoting model robustness. However, recent benchmarks show that most of the proposed improvements on AT are less effective than simply early stopping the training procedure. This counter-intuitive fact motivates us to investigate the implementation details of tens of AT methods. Surprisingly, we find that the basic settings (e.g., weight decay, training schedule, etc.) used in these methods are highly inconsistent. In this work, we provide comprehensive evaluations on CIFAR-10, focusing on the effects of mostly overlooked training tricks and hyperparameters for adversially trained models. Our empirical observations suggest that adversarial robustness is much more sensitive to some basic training settings than we thought. For example, a slightly different value of weight decay can reduce the model robust accuracy by more than $7\%$ , which is probable to override the potential promotion induced by the proposed methods. We conclude a baseline training setting and re-implement previous defenses to achieve new state-of-the-art results1. These facts also appeal to more concerns on the overlooked confounders when benchmarking defenses. + +# 1 INTRODUCTION + +Adversarial training (AT) has been one of the most effective defense strategies against adversarial attacks (Biggio et al., 2013; Szegedy et al., 2014; Goodfellow et al., 2015). Based on the primary AT frameworks like PGD-AT (Madry et al., 2018), many improvements have been proposed from different perspectives, and demonstrate promising results (detailed in Sec. 2). However, the recent benchmarks (Croce & Hein, 2020b; Chen & Gu, 2020) find that simply early stopping the training procedure of PGD-AT (Rice et al., 2020) can attain the gains from almost all the previously proposed improvements, including the state-of-the-art TRADES (Zhang et al., 2019b). + +This fact is somewhat striking since TRADES also executes early stopping (one epoch after decaying the learning rate) in their code implementation. Besides, the reported robustness of PGD-AT in Rice et al. (2020) is much higher than in Madry et al. (2018), even without early-stopping. This paradox motivates us to check the implementation details of these seminal works. We find that TRADES uses weight decay of $2 \times 10^{-4}$ , Gaussian PGD initialization as $\delta_0 \sim \mathcal{N}(0, \alpha I)$ , and eval mode of batch normalization (BN) when crafting adversarial examples, while Rice et al. (2020) use weight decay of $5 \times 10^{-4}$ , uniform PGD initialization as $\delta_0 \sim \mathcal{U}(-\epsilon, \epsilon)$ , and train mode of BN to generate adversarial examples. In our experiments on CIFAR-10 (e.g., Table 8), the two slightly different settings can differ the robust accuracy by $\sim 5\%$ , which is significant according to the reported benchmarks. + +To have a comprehensive study, we further investigate the implementation details of tens of papers working on the AT methods, some of which are summarized in Table 1. We find that even using the same model architectures, the basic hyperparameter settings (e.g., weight decay, learning rate schedule, etc.) used in these papers are highly inconsistent and customized, which could affect the model performance and may override the gains from the methods themselves. Under this situation, if we directly benchmark these methods using their released code or checkpoints, some actually effective improvements would be under-estimated due to the improper hyperparameter settings. + +Our contributions. We evaluate the effects of a wide range of basic training tricks (e.g., warmup, early stopping, weight decay, batch size, BN mode, etc.) on the adversarially trained models. Our empirical results suggest that improper training settings can largely degenerate the model performance, + +Table 1: Hyperparameter settings and tricks used to implement different AT methods on CIFAR-10. We convert the training steps into epochs, and provide code links for reference in Table 11. Compared to the model architectures, the listed settings are easy to be neglected and paid less attention to unify. + +
Methodl.r.Total epoch (l.r. decay)Batch sizeWeight decayEarly stop (train / attack)Warm-up (l.r. / pertub.)
Madry et al. (2018)0.1200 (100, 150)128\( 2 \times 10^{-4} \)No / NoNo / No
Cai et al. (2018)0.1300 (150, 250)200\( 5 \times 10^{-4} \)No / NoNo / Yes
Zhang et al. (2019b)0.176 (75)128\( 2 \times 10^{-4} \)Yes / NoNo / No
Wang et al. (2019)0.01120 (60, 100)128\( 1 \times 10^{-4} \)No / YesNo / No
Qin et al. (2019)0.1110 (100, 105)256\( 2 \times 10^{-4} \)No / NoNo / Yes
Mao et al. (2019)0.180 (50, 60)50\( 2 \times 10^{-4} \)No / NoNo / No
Carmon et al. (2019)0.1100 (cosine anneal)256\( 5 \times 10^{-4} \)No / NoNo / No
Alayrac et al. (2019)0.264 (38, 46, 51)128\( 5 \times 10^{-4} \)No / NoNo / No
Shafahi et al. (2019b)0.1200 (100, 150)128\( 2 \times 10^{-4} \)No / NoNo / No
Zhang et al. (2019a)0.05105 (79, 90, 100)256\( 5 \times 10^{-4} \)No / NoNo / No
Zhang & Wang (2019)0.1200 (60, 90)60\( 2 \times 10^{-4} \)No / NoNo / No
Atzmon et al. (2019)0.01100 (50)32\( 1 \times 10^{-4} \)No / NoNo / No
Wong et al. (2020)0~0.230 (one cycle)128\( 5 \times 10^{-4} \)No / NoYes / No
Rice et al. (2020)0.1200 (100, 150)128\( 5 \times 10^{-4} \)Yes / NoNo / No
Ding et al. (2020)0.3128 (51, 77, 102)128\( 2 \times 10^{-4} \)No / NoNo / No
Pang et al. (2020a)0.01200 (100, 150)50\( 1 \times 10^{-4} \)No / NoNo / No
Zhang et al. (2020)0.1120 (60, 90, 110)128\( 2 \times 10^{-4} \)No / YesNo / No
Huang et al. (2020)0.1200 (cosine anneal)256\( 5 \times 10^{-4} \)No / NoYes / No
Cheng et al. (2020)0.1200 (80, 140, 180)128\( 5 \times 10^{-4} \)No / NoNo / No
Lee et al. (2020)0.1200 (100, 150)128\( 2 \times 10^{-4} \)No / NoNo / No
Xu et al. (2020)0.1120 (60, 90)256\( 1 \times 10^{-4} \)No / NoNo / No
+ +while this degeneration may be mistakenly ascribed to the methods themselves. We provide a baseline recipe for PGD-AT on CIFAR-10 as an example, and demonstrate the generality of the recipe on training other frameworks like TRADES. As seen in Table 16, the retrained TRADES achieve new state-of-the-art performance on the AutoAttack benchmark (Croce & Hein, 2020b). + +Although our empirical conclusions may not generalize to other datasets or tasks, we reveal the facts that adversarially trained models could be sensitive to certain training settings, which are usually neglected in previous work. These results also encourage the community to re-implement the previously proposed defenses with fine-tuned training settings to better explore their potentials. + +# 2 RELATED WORK + +In this section, we introduce related work on the adversarial defenses and recent benchmarks. We detail on the adversarial attacks in Appendix A.1. + +# 2.1 ADVERSARIAL DEFENSES + +To alleviate the adversarial vulnerability of deep learning models, many defense strategies have been proposed, but most of them can eventually be evaded by adaptive attacks (Carlini & Wagner, 2017b; Athalye et al., 2018). Other more theoretically guaranteed routines include training provably robust networks (Dvijotham et al., 2018a;b; Hein & Andriushchenko, 2017; Wong & Kolter, 2018) and obtaining certified models via randomized smoothing (Cohen et al., 2019). While these methods are promising, they currently do not match the state-of-the-art robustness under empirical evaluations. + +The idea of adversarial training (AT) stems from the seminal work of Goodfellow et al. (2015), while other AT frameworks like PGD-AT (Madry et al., 2018) and TRADES (Zhang et al., 2019b) occupied the winner solutions in the adversarial competitions (Kurakin et al., 2018; Brendel et al., 2020). Based on these primary AT frameworks, many improvements have been proposed via encoding the mechanisms inspired from other domains, including ensemble learning (Tramér et al., 2018; Pang et al., 2019), metric learning (Mao et al., 2019; Li et al., 2019; Pang et al., 2020c), generative modeling (Jiang et al., 2018; Pang et al., 2018b; Wang & Yu, 2019; Deng et al., 2020), semi-supervised learning (Carmon et al., 2019; Alayrac et al., 2019; Zhai et al., 2019), and self-supervised + +Table 2: Test accuracy (\%) under different early stopping and warmup on CIFAR-10. The model is ResNet-18 (results on WRN-34-10 is in Table 14). For early stopping attack iter., we denote, e.g., 40 / 70 as the epochs to increase the tolerance step by one (Zhang et al., 2020). For warmup, the learning rate and the maximal perturbation linearly increase from zero to preset values in $10/15/20$ epochs. + +
BaseEarly stopping attack iter.Warmup on l.r.Warmup on perturb.
40 / 7040 / 10060 / 100101520101520
Clean82.5286.5286.5685.6782.4582.6482.3182.6482.7582.78
PGD-1053.5852.6553.2252.9053.4353.2953.3553.6553.2753.62
AA48.5146.646.0445.9648.2648.1248.3748.4448.1748.48
+ +learning (Hendrycks et al., 2019; Chen et al., 2020a;b; Naseer et al., 2020). On the other hand, due to the high computational cost of AT, many efforts are devoted to accelerating the training procedure via reusing the computations (Shafahi et al., 2019b; Zhang et al., 2019a), adaptive adversarial steps (Wang et al., 2019; Zhang et al., 2020) or one-step training (Wong et al., 2020; Liu et al., 2020; Vivek B & Venkatesh Babu, 2020). The following works try to solve the side effects (e.g., catastrophic overfitting) caused by these fast AT methods (Andriushchenko & Flammarion, 2020; Li et al., 2020). + +# 2.2 ADVERSARIAL BENCHMARKS + +Due to the large number of proposed defenses, several benchmarks have been developed to rank the adversarial robustness of existing methods. Dong et al. (2020) perform large-scale experiments to generate robustness curves, which are used for evaluating typical defenses. Croce & Hein (2020b) propose AutoAttack, which is an ensemble of four selected attacks. They apply AutoAttack on tens of previous defenses and provide a comprehensive leader board. Chen & Gu (2020) propose the black-box RayS attack, and establish a similar leader board for defenses. In this paper, we mainly apply PGD attack and AutoAttack as two common ways to evaluate the models. + +Except for the adversarial robustness, there are other efforts that introduce augmented datasets for accessing the robustness against general corruptions or perturbations. Mu & Gilmer (2019) introduce MNIST-C with a suite of 15 corruptions applied to the MNIST test set, while Hendrycks & Dietterich (2019) introduce ImageNet-C and ImageNet-P with common corruptions and perturbations on natural images. Evaluating robustness on these datasets can reflect the generality of the proposed defenses, and avoid overfitting to certain attacking patterns (Engstrom et al., 2019; Tramér & Boneh, 2019). + +# 3 BAG OF TRICKS + +Our overarching goal is to investigate how the usually overlooked implementation details affect the performance of the adversarially trained models. Our experiments are done on CIFAR-10 (Krizhevsky & Hinton, 2009) under the $\ell_{\infty}$ threat model of maximal perturbation $\epsilon = 8 / 255$ , without accessibility to additional data. We evaluate the models under 10-steps PGD attack (PGD-10) (Madry et al., 2018) and AutoAttack (AA) (Croce & Hein, 2020b). For the PGD attack, we apply untargeted mode using ground truth labels, step size of $2 / 255$ , and 5 restarts for evaluation / no restart for training. For the AutoAttack2, we apply the standard version, with no restart for AutoPGD and FAB, compared to 5 restarts for plus version. We consider some basic training tricks and perform ablation studies on each of them, based on the default training setting as described below: + +Default setting. Following Rice et al. (2020), in the default setting, we apply the primary PGD-AT framework and the hyperparameters including batch size 128; SGD momentum optimizer with the initial learning rate of 0.1; weight decay $5 \times 10^{-4}$ ; ReLU activation function and no label smoothing; train mode for batch normalization when crafting adversarial examples. All the models are trained for 110 epochs with the learning rate decaying by a factor of 0.1 at 100 and 105 epochs, respectively. We report the results on the checkpoint with the best PGD-10 accuracy. + +Note that our empirical observations and conclusions may not always generalize to other datasets or AT frameworks, but we emphasize the importance of using consistent implementation details (not only the same model architectures) to enable fair comparisons among different AT methods. + +Table 3: Test accuracy $(\%)$ under different batch size and learning rate (l.r.) on CIFAR-10. The basic l.r. is 0.1, while the scaled l.r. is, e.g., 0.2 for batch size 256, and 0.05 for batch size 64. + +
ResNet-18
Batch sizeBasic l.r.Scaled l.r.
CleanPGD-10CleanPGD-10
6480.0851.3182.4452.48
12882.5253.58--
25683.3352.2082.2452.52
51283.4050.6982.1653.36
+ +
WRN-34-10
Batch sizeBasic l.r.Scaled l.r.
CleanPGD-10CleanPGD-10
6484.2054.6985.4054.86
12886.0756.60--
25686.2152.9085.8956.09
51286.2950.1786.4755.49
+ +Table 4: Test accuracy $(\%)$ under different degrees of label smoothing (LS) on CIFAR-10. More evaluation results under, e.g., PGD-1000 can be found in Table 17. + +
ResNet-18
LSCleanPGD-10AARayS
082.5253.5848.5153.34
0.182.6954.0448.7653.71
0.282.7354.2249.2053.66
0.382.5154.3449.2453.59
0.482.3954.1348.8353.40
+ +
LSCleanPGD-10AARayS
086.0756.6052.1960.07
0.185.9656.8852.7459.99
0.286.0957.3153.0060.28
0.385.9957.5552.7061.00
0.486.1957.6352.7160.64
+ +Table 5: Test accuracy (\%) using different optimizers on CIFAR-10. The model is ResNet-18 (results on WRN-34-10 is in Table 15). The initial learning rate for Adam and AdamW is 0.0001. + +
MomNesterovAdamAdamWSGD-GCSGD-GCC
Clean82.5282.8383.2081.6882.7782.93
PGD-1053.5853.7848.8746.5853.6253.40
AA48.5148.2244.0442.3948.3348.51
+ +# 3.1 EARLY STOPPING AND WARMUP + +Early stopping training epoch. The trick of early stopping w.r.t. the training epoch was first applied in the implementation of TRADES (Zhang et al., 2019b), where the learning rate decays at the 75th epoch and the training is stopped at the 76th epoch. Later Rice et al. (2020) provide a comprehensive study on the overfitting phenomenon in AT, and advocate early stopping the training epoch as a general strategy for preventing adversarial overfitting, which could be triggered according to the PGD accuracy on a split validation set. Due to its effectiveness, we regard this trick as a default choice. + +Early stopping adversarial intensity. Another level of early stopping happens on the adversarial intensity, e.g., early stopping PGD steps when crafting adversarial examples for training. This trick was first applied by the runner-up of the defense track in NeurIPS 2018 adversarial vision challenge (Brendel et al., 2020). Later efforts are devoted to formalizing this early stopping mechanism with different trigger rules (Wang et al., 2019; Zhang et al., 2020). Balaji et al. (2019) early stop the adversarial perturbation, which has a similar effect on the adversarial intensity. In the left part of Table 2, we evaluate the method proposed by Zhang et al. (2020) due to its simplicity. As seen, this kind of early stopping can improve the performance on clean data while keeping comparable accuracy under PGD-10. However, the performance under the stronger AutoAttack is degraded. + +Warmup w.r.t. learning rate. Warmup w.r.t. learning rate is a general trick for training deep learning models (Goodfellow et al., 2016). In the adversarial setting, Wong et al. (2020) show that the one cycle learning rate schedule is one of the critical ingredients for the success of FastAT. Thus, we evaluate the effect of this trick for the piecewise learning rate schedule and PGD-AT framework. We linearly increase the learning rate from zero to the preset value in the first $10 / 15 / 20$ epochs. As shown in the middle part of Table 2, the effect of warming up learning rate is marginal. + +Warmup w.r.t. adversarial intensity. In the AT procedure, warmup can also be executed w.r.t. the adversarial intensity. Cai et al. (2018) propose the curriculum AT process to gradually increase the adversarial intensity and monitor the overfitting trend. Qin et al. (2019) increase the maximal + +Table 6: Test accuracy (\%) under different non-linear activation function on CIFAR-10. The model is ResNet-18. We apply the hyperparameters recommended by Xie et al. (2020) on ImageNet for the activation function. Here the notation $\ddagger$ indicates using weight decay of $5 \times 10^{-5}$ , where applying weight decay of $5 \times 10^{-4}$ with these activations will lead to much worse model performance. + +
ReLULeaky.ELU‡CELU‡SELU‡GELUSoftplusTanh‡
Clean82.5282.1182.1781.3778.8880.4282.8080.13
PGD-1053.5853.2552.0851.3749.5352.2154.3049.12
+ +![](images/ad84207258442ecab4aa27a415a6cddde09c258a19b4f8bf7abfd7789b08edbd.jpg) + +![](images/e6d439e1ac6912a17959f0eb0cb18877b91b5a598fa874cdeeb8cf307603e892.jpg) + +![](images/5dc5a2f9c40beebc47204b4c503d9e60fb21d8de897f762e6611d6ff5dd3f780.jpg) +Figure 1: (a) Test accuracy w.r.t. different values of weight decay. The reported checkpoints correspond to the best PGD-10 accuracy (Rice et al., 2020). We test on two model architectures, and highlight (with red circles) three most commonly used weight decays in previous work; (b) Curves of test accuracy w.r.t. training epochs, where the model is WRN-34-10. We set weight decay be $1 \times 10^{-4}$ , $2 \times 10^{-4}$ , and $5 \times 10^{-4}$ , respectively. We can observe that smaller weight decay can learn faster but also more tend to overfit w.r.t. the robust accuracy. In Fig. 4, we early decay the learning rate before the models overfitting, but weight decay of $5 \times 10^{-4}$ still achieve better robustness. + +![](images/84b69f529a013e3fa5810e8617ec2b15e02eced78ee9641f4b6e4b199cf8637e.jpg) + +perturbation $\epsilon$ from zero to $8 / 255$ in the first 15 epochs. In the right part of Table 2, we linearly increase the maximal perturbation in the first $10 / 15 / 20$ epochs, while the effect is still limited. + +# 3.2 TRAINING HYPERPARAMETERS + +Batch size. On the large-scale datasets like ImageNet (Deng et al., 2009), it has been recognized that the mini-batch size is an important factor influencing the model performance (Goyal et al., 2017), where larger batch size traverses the dataset faster but requires more memory usage. In the adversarial setting, Xie et al. (2019) use a batch size of 4096 to train a robust model on ImageNet, which achieves state-of-the-art performance under adversarial attacks. As to the defenses reported on the CIFAR-10 dataset, the mini-batch sizes are usually chosen between 128 and 256, as shown in Table 1. To evaluate the effect, we test on two model architectures and four values of batch size in Table 3. Since the number of training epochs is fixed to 110, we also consider applying the linear scaling rule introduced in Goyal et al. (2017), i.e., when the mini-batch size is multiplied by $k$ , multiply the learning rate by $k$ . We treat the batch size of 128 and the learning rate of 0.1 as a basic setting to obtain the factor $k$ . We can observe that the batch size of 128 works well on CIFAR-10, while the linear scaling rule can benefit the cases with other batch sizes. + +Table 7: Test accuracy (\%) under different BN modes on CIFAR-10. We evaluate across several model architectures, since the BN layers have different positions in different models. + +
BN modeModel architecture
ResNet-18SENet-18DenseNet-121GoogleNetDPN26WRN-34-10
Cleantrain82.5282.2085.3883.9783.6786.07
eval83.4884.1186.3385.2684.5687.38
-+0.96+1.91+0.95+1.29+0.89+1.31
PGD-10train53.5854.0156.2253.7653.8856.60
eval53.6453.9056.1153.7753.4156.04
-+0.06-0.11-0.11+0.01-0.47-0.56
AAtrain48.5148.7251.5848.7348.5052.19
eval48.7548.9551.2448.8348.3051.93
-+0.24+0.23-0.34+0.10-0.20-0.26
+ +![](images/eb746a629ae3851fd591059ace7412c54c0e95c9088d7fdd5dd95ea7146664ba.jpg) +Figure 2: Clean accuracy vs. PGD-10 accuracy for different model architectures. The circle sizes are proportional to the number of parameters that specified in Table 12. + +Label smoothing (LS). Shafahi et al. (2019a) propose to utilize LS to mimic adversarial training. Pang et al. (2019) also find that imposing LS on the ensemble prediction can alleviate the adversarial transferability among individual members. Unfortunately, combing LS with standard training cannot prevent the models from evaded by adaptive attacks (Tramer et al., 2020) or larger iteration steps (Summers & Dinneen, 2018). Beyond previous observations, we further evaluate the effect of LS on adversarial training. As shown in Table 4 and Table 17, mild LS can improve $0.5 \sim 1\%$ robust accuracy under the strong attacks we evaluated, including AutoAttack and PGD-1000, without affecting the clean performance. This can be regarded as the effect induced by calibrating the confidence (Stutz et al., 2020) of adversarily trained models ( $80\% \sim 85\%$ accuracy on clean data). In contrast, excessive LS could degrade the robustness (e.g., $\mathrm{LS} = 0.3$ vs. $\mathrm{LS} = 0.4$ on ResNet-18), which is consistent with the recent observations in Jiang et al. (2020) (they use $\mathrm{LS} = 0.5$ ). However, since LS is known for its potential gradient masking effect, we advocate careful evaluations when applying this trick on the proposed defenses, following the suggestions in Carlini et al. (2019). + +Optimizer. Most of the AT methods apply SGD with momentum as the optimizer. The momentum factor is usually set to be 0.9 with zero dampening. In other cases, Carmon et al. (2019) apply SGD with Nesterov, and Rice et al. (2020) apply Adam for cyclic learning rate schedule. We test some commonly used optimizers in Table 5, as well as the decoupled AdamW (Loshchilov & Hutter, 2019) and the recently proposed gradient centralization trick SGD-GC / SGD-GCC (Yong et al., 2020). We can find that SGD-based optimizers (e.g., Mom, Nesterov, SGD-GC / SGD-GCC) have similar performance, while Adam / AdamW performs worse for piecewise learning rate schedule. + +Weight decay. As observed in Table 1, three different values of weight decay are used in previous defenses, including $1 \times 10^{-4}$ , $2 \times 10^{-4}$ , and $5 \times 10^{-4}$ . While $5 \times 10^{-4}$ is a fairly widely used value for weight decay in deep learning, the prevalence of the value $2 \times 10^{-4}$ should stem from Madry et al. (2018) in the adversarial setting. In Fig. 1(a), we report the best test accuracy under different values of weight decay $^3$ . We can see that the gap of robust accuracy can be significant due to slightly + +Table 8: The default hyperparameters include batch size 128 and SGD momentum optimizer. The AT framework is PGD-AT. We highlight the setting used by the implementation in Rice et al. (2020). + +
ArchitectureLabel smoothWeight decayActivation functionBN modeCleanAccuracy PGD-10AA
WRN-34-1001 × 10-4ReLUtrain85.8749.4546.43
02 × 10-4ReLUtrain86.1452.0848.72
05 × 10-4ReLUtrain86.0756.6052.19
05 × 10-4ReLUeval87.3856.0451.93
05 × 10-4Softplustrain86.6056.4452.70
0.15 × 10-4Softplustrain86.4257.2253.01
0.15 × 10-4Softpluseval86.3456.3852.21
0.25 × 10-4Softplustrain86.1056.5552.91
0.25 × 10-4Softpluseval86.9856.2152.10
WRN-34-2001 × 10-4ReLUtrain86.2149.7447.58
02 × 10-4ReLUtrain86.7351.3949.03
05 × 10-4ReLUtrain86.9757.5753.26
05 × 10-4ReLUeval87.6257.0453.14
05 × 10-4Softplustrain85.8057.8453.64
0.15 × 10-4Softplustrain85.6957.8653.66
0.15 × 10-4Softpluseval87.8657.3353.23
0.25 × 10-4Softplustrain84.8257.9353.39
0.25 × 10-4Softpluseval87.5857.1953.26
+ +![](images/529ffca965ee1317d656c33f89c13895f0ce9c720abf1b1b5f9d5cc6e5fe94c0.jpg) +Figure 3: Random normal cross-sections of the decision boundary for PGD-AT with different weight decay. The model architecture is WRN-34-10. Following the examples in Moosavi-Dezfooli et al. (2019), we craft PGD-10 perturbation as the normal direction $v$ , and $r$ be a random direction, under the $\ell_{\infty}$ constraint of $8/255$ . The values of x-axis and y-axis represent the multiplied scale factors. + +different values of weight decay (e.g., up to $\sim 7\%$ for $1\times 10^{-4}$ vs. $5\times 10^{-4}$ ). Besides, in Fig. 1(b) we plot the learning curves of test accuracy w.r.t. training epochs. Note that smaller values of weight decay make the model learn faster in the initial phase, but the overfitting phenomenon also appears earlier. In Fig. 3, we visualize the cross sections of the decision boundary. We can see that proper values of weight decay (e.g., $5\times 10^{-4}$ ) can enlarge margins from decision boundary and improve robustness. Nevertheless, as shown in the left two columns, this effect is less significant on promoting clean accuracy. As a result, weight decay is a critical and usually neglected ingredient that largely influences the robust accuracy of adversarially trained models. In contrast, the clean accuracy is much less sensitive to weight decay, for both adversarially and standardly (shown in Fig. 5) trained models. + +Activation function. Most of the previous AT methods apply ReLU as the non-linear activation function in their models, while Xie et al. (2020) empirically demonstrate that smooth activation functions can better improve model robustness on ImageNet. Following their settings, we test if a similar conclusion holds on CIFAR-10. By comparing the results on ReLU and Softplus in Table 6 (for PGD-AT) and Table 13 (for TRADES), we confirm that smooth activation indeed benefits model robustness for ResNet-18. However, as shown in Table 8 (for PGD-AT) and Table 9 (for TRADES), this benefit is less significant on larger models like WRN. Thus we deduce that smaller model capacity can benefit more from the smoothness of activation function. Besides, as shown in Table 6, models trained on CIFAR-10 seem to prefer activation function $\sigma(x)$ with zero truncation, i.e., $\sigma(x) \geq 0$ . Those with negative return values like ELU, LeakyReLU, Tanh have worse performance than ReLU. + +Table 9: Test accuracy (%). The AT framework is TRADES. We highlight the setting used by the original implementation in Zhang et al. (2019b). As listed in Table 16, our retrained TRADES models can achieve state-of-the-art performance in the AutoAttack benchmark. + +
Threat model: ℓ∞ constraint, ε = 0.031
ArchitectureWeight decayBN modeActivationCleanPGD-10AA
WRN-34-102 × 10-4trainReLU83.8654.9651.52
2 × 10-4evalReLU85.1755.1051.85
5 × 10-4trainReLU84.1757.3453.51
5 × 10-4evalReLU85.3458.5454.64
5 × 10-4evalSoftplus84.6658.0554.20
WRN-34-205 × 10-4evalReLU86.9357.9354.42
5 × 10-4evalSoftplus85.4357.9454.32
Threat model: ℓ∞ constraint, ε = 8/255
ArchitectureWeight decayBN modeActivationCleanPGD-10AA
WRN-34-102 × 10-4trainReLU84.5054.6050.94
2 × 10-4evalReLU85.1754.5851.54
5 × 10-4trainReLU84.0457.4153.83
5 × 10-4evalReLU85.4857.4553.80
5 × 10-4evalSoftplus84.2457.5953.88
WRN-34-202 × 10-4trainReLU84.5053.8651.18
2 × 10-4evalReLU85.4853.2150.59
5 × 10-4trainReLU85.8757.4054.22
5 × 10-4evalReLU86.4357.9154.39
5 × 10-4evalSoftplus85.5157.5054.21
+ +Model architecture. Su et al. (2018) provide a comprehensive study on the robustness of standardly trained models, using different model architectures. For the adversarially trained models, it has been generally recognized that larger model capacity can usually lead to better robustness (Madry et al., 2018). Recently, Guo et al. (2020) blend in the technique of AutoML to explore robust architectures. In Fig. 2, we perform similar experiments on more hand-crafted model architectures. The selected models have comparable numbers of parameters. We can observe that DenseNet can achieve both the best clean and robust accuracy, while being memory-efficient (but may require longer inference time). This is consistent with the observation in Guo et al. (2020) that residual connections can benefit the AT procedure. Interestingly, Wu et al. (2020) demonstrate that residual connections allow easier generation of highly transferable adversarial examples, while in our case this weakness for the standardly trained models may turn out to strengthen the adversarially trained models. + +Batch normalization (BN) mode. When crafting adversarial examples in the training procedure, Zhang et al. (2019b) use eval mode for BN, while Rice et al. (2020) and Madry et al. (2018) use train mode for BN. Since the parameters in the BN layers are not updated in this progress, the difference between these two modes is mainly on the recorded moving average BN mean and variance used in the test phase. As pointed out in Xie & Yuille (2020), properly dealing with BN layers is critical to obtain a well-performed adversarily trained model. Thus in Table 7, we employ the train or eval mode of BN for crafting adversarial examples during training, and report the results on different model architectures to dig out general rules. As seen, using eval mode for BN can increase clean accuracy, while keeping comparable robustness. We also advocate for the eval mode, because if we apply train mode for multi-step PGD attack, the BN mean and variance will be recorded for every intermediate step, which could blur the adversarial distribution used by BN layers during inference. + +# Takeaways: + +(i) Slightly different values of weight decay could largely affect the robustness of trained models; +(ii) Moderate label smoothing and linear scaling rule on l.r. for different batch sizes are beneficial; +(iii) Applying eval BN mode to craft training adversarial examples can avoid blurring the distribution; +(iv) Early stopping the adversarial steps or perturbation may degenerate worst-case robustness; +(v) Smooth activation benefits more when the model capacity is not enough for adversarial training. + +Table 10: Test accuracy (\%). The considered AT frameworks are FastAT and FreeAT. The model architecture is WRN-34-10. Detailed settings used for these defenses are described in Sec. 3.5. + +
DefenseLabel smoothWeight decayBN modeCleanAccuracy PGD-10AA
FastAT (Wong et al., 2020)0\( 2 \times 10^{-4} \)train82.1947.4742.99
0\( 5 \times 10^{-4} \)train82.9348.4844.06
0\( 5 \times 10^{-4} \)eval84.0048.1643.66
0.1\( 5 \times 10^{-4} \)train82.8348.7644.50
FreeAT (Shafahi et al., 2019b)0\( 2 \times 10^{-4} \)train87.4247.6644.24
0\( 5 \times 10^{-4} \)train88.1748.9045.66
0\( 5 \times 10^{-4} \)eval88.2648.5045.49
0.1\( 5 \times 10^{-4} \)train88.0749.2645.91
+ +# 3.3 COMBINATION OF TRICKS + +In the above, we separately evaluate the effect of each training trick in the AT procedure. Now we investigate combining the selected useful tricks, which involve label smoothing, weight decay, activation function and BN mode. As demonstrated in Table 8, the improvements are not ideally additive by combining different tricks, while label smoothing and smooth activation function are helpful, but not significant, especially when we apply model architectures with a larger capacity. + +We also find that the high performance of the models trained by Rice et al. (2020) partially comes from its reasonable training settings, compared to previous work. Based on these, we provide a trick list for training robust models on CIFAR-10 for reference. + +# Baseline setting (CIFAR-10): + +Batch size 128; SGD momentum optimizer; weight decay $5 \times 10^{-4}$ ; eval mode BN for generating adversarial examples; warmups are not necessary; moderate label smoothing $(0.1 \sim 0.2)$ and smooth activation function could be beneficial; model architecture with residual connections. + +# 3.4 RE-IMPLEMENTATION OF TRADES + +As a sanity check, we re-implement TRADES to see if our conclusions derived from PGD-AT can generalize and provide the results in Table 9. We can observe that after simply changing the weight decay from $2 \times 10^{-4}$ to $5 \times 10^{-4}$ , the clean accuracy of TRADES improves by $\sim 1\%$ and the AA accuracy improves by $\sim 4\%$ , which make the trained model surpass the previously state-of-the-art models reported by the AutoAttack benchmark, as listed in Table 16. This fact highlights the importance of employing a standardized training setting for fair comparisons of different AT methods. + +# 3.5 EVALUATIONS ON OTHER AT FRAMEWORKS + +To examine the universality of our observations on PGD-AT and TRADES, we further evaluate on other AT frameworks, including FastAT (Wong et al., 2020) and FreeAT (Shafahi et al., 2019b). We base on the FastAT code4 to implement the methods. Specifically, for FastAT, we use cyclic learning rate schedule with $l_{\mathrm{min}} = 0$ and $l_{\mathrm{max}} = 0.2$ , training for 15 epochs. For FreeAT, we also use cyclic learning rate schedule with $l_{\mathrm{min}} = 0$ and $l_{\mathrm{max}} = 0.04$ , training for 24 epochs with mini-batch replays be 4. The results are provided in Table 10. We can find that our observations generalize well to other AT frameworks, which verifies that the proposed baseline setting could be a decent default choice for adversarial training on CIFAR-10. + +# 4 CONCLUSION + +In this work, we take a step in examining how the usually neglected implementation details impact the performance of adversarially trained models. Our empirical results suggest that compared to clean accuracy, robustness is more sensitive to some seemingly unimportant differences in training settings. Thus when building AT methods, we should more carefully fine-tune the training settings (on validation sets), or follow certain long-tested setup in the adversarial setting. + +# ACKNOWLEDGEMENTS + +This work was supported by the National Key Research and Development Program of China (Nos. 2020AAA0104304, 2017YFA0700904), NSFC Projects (Nos. 61620106010, 62076147, U19B2034, U19A2081), Beijing Academy of Artificial Intelligence (BAAI), Tsinghua-Huawei Joint Research Program, a grant from Tsinghua Institute for Guo Qiang, Tiangong Institute for Intelligent Computing, and the NVIDIA NVAIL Program with GPU/DGX Acceleration. Tianyu Pang was supported by MSRA Fellowship and Baidu Scholarship. + +# REFERENCES + +Jean-Baptiste Alayrac, Jonathan Uesato, Po-Sen Huang, Alhussein Fawzi, Robert Stanforth, and Pushmeet Kohli. Are labels required for improving adversarial robustness? In Advances in Neural Information Processing Systems (NeurIPS), pp. 12192-12202, 2019. +Maksym Andriushchenko and Nicolas Flammarion. Understanding and improving fast adversarial training. In Advances in neural information processing systems (NeurIPS), 2020. +Maksym Andriushchenko, Francesco Croce, Nicolas Flammarion, and Matthias Hein. Square attack: a query-efficient black-box adversarial attack via random search. In European Conference on Computer Vision (ECCV), 2020. +Anish Athalye, Nicholas Carlini, and David Wagner. Obfuscated gradients give a false sense of security: Circumventing defenses to adversarial examples. In International Conference on Machine Learning (ICML), 2018. +Matan Atzmon, Niv Haim, Lior Yariv, Ofer Israelov, Haggai Maron, and Yaron Lipman. Controlling neural level sets. In Advances in Neural Information Processing Systems (NeurIPS), pp. 2034-2043, 2019. +Yogesh Balaji, Tom Goldstein, and Judy Hoffman. Instance adaptive adversarial training: Improved accuracy tradeoffs in neural nets. arXiv preprint arXiv:1910.08051, 2019. +Battista Biggio, Igino Corona, Davide Maiorca, Blaine Nelson, Nedim Šrndić, Pavel Laskov, Giorgio Giacinto, and Fabio Roli. Evasion attacks against machine learning at test time. In Joint European Conference on Machine Learning and Knowledge Discovery in Databases, pp. 387-402. Springer, 2013. +Wieland Brendel, Jonas Rauber, and Matthias Bethge. Decision-based adversarial attacks: Reliable attacks against black-box machine learning models. In International Conference on Learning Representations (ICLR), 2018. +Wieland Brendel, Jonas Rauber, Alexey Kurakin, Nicolas Papernot, Behar Veliqi, Sharada P Mohanty, Florian Laurent, Marcel Salathé, Matthias Bethge, Yaodong Yu, et al. Adversarial vision challenge. In The NeurIPS'18 Competition, pp. 129-153. Springer, 2020. +Qi-Zhi Cai, Chang Liu, and Dawn Song. Curriculum adversarial training. In International Joint Conference on Artificial Intelligence (IJCAI), pp. 3740-3747, 2018. +Nicholas Carlini and David Wagner. Towards evaluating the robustness of neural networks. In IEEE Symposium on Security and Privacy (S&P), 2017a. +Nicholas Carlini and David Wagner. Adversarial examples are not easily detected: Bypassing ten detection methods. In ACM Workshop on Artificial Intelligence and Security (AISec), 2017b. +Nicholas Carlini, Anish Athalye, Nicolas Papernot, Wieland Brendel, Jonas Rauber, Dimitris Tsipras, Ian Goodfellow, Aleksander Madry, and Alexey Kurakin. On evaluating adversarial robustness. arXiv preprint arXiv:1902.06705, 2019. +Yair Carmon, Aditi Raghunathan, Ludwig Schmidt, Percy Liang, and John C Duchi. Unlabeled data improves adversarial robustness. In Advances in Neural Information Processing Systems (NeurIPS), 2019. + +Jinghui Chen and Quanquan Gu. Rays: A ray searching method for hard-label adversarial attack. arXiv preprint arXiv:2006.12792, 2020. +Kejiang Chen, Yuefeng Chen, Hang Zhou, Xiaofeng Mao, Yuhong Li, Yuan He, Hui Xue, Weiming Zhang, and Nenghai Yu. Self-supervised adversarial training. In IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP), pp. 2218-2222. IEEE, 2020a. +Pin-Yu Chen, Huan Zhang, Yash Sharma, Jinfeng Yi, and Cho-Jui Hsieh. Zoo: Zeroth order optimization based black-box attacks to deep neural networks without training substitute models. In ACM Workshop on Artificial Intelligence and Security (AISec). ACM, 2017a. +Pin-Yu Chen, Yash Sharma, Huan Zhang, Jinfeng Yi, and Cho-Jui Hsieh. Ead: elastic-net attacks to deep neural networks via adversarial examples. In AAAI Conference on Artificial Intelligence (AAAIA), 2018. +Tianlong Chen, Sijia Liu, Shiyu Chang, Yu Cheng, Lisa Amini, and Zhangyang Wang. Adversarial robustness: From self-supervised pre-training to fine-tuning. In Conference on Computer Vision and Pattern Recognition (CVPR), pp. 699-708, 2020b. +Yunpeng Chen, Jianan Li, Huaxin Xiao, Xiaojie Jin, Shuicheng Yan, and Jiashi Feng. Dual path networks. In Advances in Neural Information Processing Systems (NeurIPS), pp. 4467-4475, 2017b. +Minhao Cheng, Thong Le, Pin-Yu Chen, Jinfeng Yi, Huan Zhang, and Cho-Jui Hsieh. Query-efficient hard-label black-box attack: An optimization-based approach. In International Conference on Learning Representations (ICLR), 2019a. +Minhao Cheng, Qi Lei, Pin-Yu Chen, Inderjit Dhillon, and Cho-Jui Hsieh. Cat: Customized adversarial training for improved robustness. arXiv preprint arXiv:2002.06789, 2020. +Shuyu Cheng, Yinpeng Dong, Tianyu Pang, Hang Su, and Jun Zhu. Improving black-box adversarial attacks with a transfer-based prior. In Advances in Neural Information Processing Systems (NeurIPS), 2019b. +Jeremy M Cohen, Elan Rosenfeld, and J Zico Kolter. Certified adversarial robustness via randomized smoothing. In International Conference on Machine Learning (ICML), 2019. +Francesco Croce and Matthias Hein. Minimally distorted adversarial examples with a fast adaptive boundary attack. In International Conference on Machine Learning (ICML), 2020a. +Francesco Croce and Matthias Hein. Reliable evaluation of adversarial robustness with an ensemble of diverse parameter-free attacks. In International Conference on Machine Learning (ICML), 2020b. +Jia Deng, Wei Dong, Richard Socher, Li-Jia Li, Kai Li, and Li Fei-Fei. Imagenet: A large-scale hierarchical image database. In IEEE Conference on Computer Vision and Pattern Recognition (CVPR), 2009. +Zhijie Deng, Yinpeng Dong, Tianyu Pang, Hang Su, and Jun Zhu. Adversarial distributional training for robust deep learning. arXiv preprint arXiv:2002.05999, 2020. +Gavin Weiguang Ding, Yash Sharma, Kry Yik Chau Lui, and Ruitong Huang. Mma training: Direct input space margin maximization through adversarial training. In International Conference on Learning Representations (ICLR), 2020. +Yinpeng Dong, Fangzhou Liao, Tianyu Pang, Hang Su, Jun Zhu, Xiaolin Hu, and Jianguo Li. Boosting adversarial attacks with momentum. In IEEE Conference on Computer Vision and Pattern Recognition (CVPR), 2018. +Yinpeng Dong, Tianyu Pang, Hang Su, and Jun Zhu. Evading defenses to transferable adversarial examples by translation-invariant attacks. In IEEE Conference on Computer Vision and Pattern Recognition (CVPR), 2019. + +Yinpeng Dong, Qi-An Fu, Xiao Yang, Tianyu Pang, Hang Su, Zihao Xiao, and Jun Zhu. Benchmarking adversarial robustness on image classification. In IEEE Conference on Computer Vision and Pattern Recognition (CVPR), 2020. +Krishnamurthy Dvijotham, Sven Gowal, Robert Stanforth, Relja Arandjelovic, Brendan O'Donoghue, Jonathan Uesato, and Pushmeet Kohli. Training verified learners with learned verifiers. arXiv preprint arXiv:1805.10265, 2018a. +Krishnamurthy Dvijotham, Robert Stanforth, Sven Gowal, Timothy Mann, and Pushmeet Kohli. A dual approach to scalable verification of deep networks. In Annual Conference on Uncertainty in Artificial Intelligence (UAI), 2018b. +Logan Engstrom, Brandon Tran, Dimitris Tsipras, Ludwig Schmidt, and Aleksander Madry. A rotation and a translation suffice: Fooling cnns with simple transformations. In International Conference on Machine Learning (ICML), 2019. +Reuben Feinman, Ryan R Curtin, Saurabh Shintre, and Andrew B Gardner. Detecting adversarial samples from artifacts. arXiv preprint arXiv:1703.00410, 2017. +Ian Goodfellow, Yoshua Bengio, and Aaron Courville. Deep Learning. MIT Press, 2016. http://www.deeplearningbook.org. +Ian J Goodfellow, Jonathon Shlens, and Christian Szegedy. Explaining and harnessing adversarial examples. In International Conference on Learning Representations (ICLR), 2015. +Sven Gowal, Chongli Qin, Jonathan Uesato, Timothy Mann, and Pushmeet Kohli. Uncovering the limits of adversarial training against norm-bounded adversarial examples. arXiv preprint arXiv:2010.03593, 2020. +Priya Goyal, Piotr Dólar, Ross Girshick, Pieter Noordhuis, Lukasz Wesolowski, Aapo Kyrola, Andrew Tulloch, Yangqing Jia, and Kaiming He. Accurate, large minibatch sgd: Training imagenet in 1 hour. arXiv preprint arXiv:1706.02677, 2017. +Chuan Guo, Mayank Rana, Moustapha Cisse, and Laurens Van Der Maaten. Countering adversarial images using input transformations. In International Conference on Learning Representations (ICLR), 2018. +Minghao Guo, Yuzhe Yang, Rui Xu, Ziwei Liu, and Dahua Lin. When nas meets robustness: In search of robust architectures against adversarial attacks. In IEEE Conference on Computer Vision and Pattern Recognition (CVPR), pp. 631-640, 2020. +Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Identity mappings in deep residual networks. In European Conference on Computer Vision (ECCV), pp. 630-645. Springer, 2016. +Matthias Hein and Maksym Andriushchenko. Formal guarantees on the robustness of a classifier against adversarial manipulation. In Advances in Neural Information Processing Systems (NeurIPS), pp. 2266-2276, 2017. +Dan Hendrycks and Thomas Dietterich. Benchmarking neural network robustness to common corruptions and perturbations. In International Conference on Learning Representations (ICLR), 2019. +Dan Hendrycks, Kimin Lee, and Mantas Mazeika. Using pre-training can improve model robustness and uncertainty. In International Conference on Machine Learning (ICML), 2019. +Jie Hu, Li Shen, and Gang Sun. Squeeze-and-excitation networks. In IEEE Conference on Computer Vision and Pattern Recognition (CVPR), pp. 7132-7141, 2018. +Gao Huang, Zhuang Liu, Laurens Van Der Maaten, and Kilian Q Weinberger. Densely connected convolutional networks. In IEEE Conference on Computer Vision and Pattern Recognition (CVPR), pp. 4700-4708, 2017. +Lang Huang, Chao Zhang, and Hongyang Zhang. Self-adaptive training: beyond empirical risk minimization. arXiv preprint arXiv:2002.10319, 2020. + +Andrew Ilyas, Logan Engstrom, Anish Athalye, and Jessy Lin. Black-box adversarial attacks with limited queries and information. In International Conference on Machine Learning (ICML), 2018. +Haoming Jiang, Zhehui Chen, Yuyang Shi, Bo Dai, and Tuo Zhao. Learning to defense by learning to attack. arXiv preprint arXiv:1811.01213, 2018. +Linxi Jiang, Xingjun Ma, Zejia Weng, James Bailey, and Yu-Gang Jiang. Imbalanced gradients: A new cause of overestimated adversarial robustness. arXiv preprint arXiv:2006.13726, 2020. +Alex Krizhevsky and Geoffrey Hinton. Learning multiple layers of features from tiny images. Technical report, Citeseer, 2009. +Alexey Kurakin, Ian Goodfellow, and Samy Bengio. Adversarial examples in the physical world. In The International Conference on Learning Representations (ICLR) Workshops, 2017. +Alexey Kurakin, Ian Goodfellow, Samy Bengio, Yinpeng Dong, Fangzhou Liao, Ming Liang, Tianyu Pang, Jun Zhu, Xiaolin Hu, Cihang Xie, et al. Adversarial attacks and defences competition. arXiv preprint arXiv:1804.00097, 2018. +Saehyung Lee, Hyungyu Lee, and Sungroh Yoon. Adversarial vertex mixup: Toward better adversarially robust generalization. In IEEE Conference on Computer Vision and Pattern Recognition (CVPR), pp. 272-281, 2020. +Bai Li, Shiqi Wang, Suman Jana, and Lawrence Carin. Towards understanding fast adversarial training. arXiv preprint arXiv:2006.03089, 2020. +Pengcheng Li, Jinfeng Yi, Bowen Zhou, and Lijun Zhang. Improving the robustness of deep neural networks via adversarial training with triplet loss. In International Joint Conference on Artificial Intelligence (IJCAI), 2019. +Guanxiong Liu, Issa Khalil, and Abdallah Khreishah. Using single-step adversarial training to defend iterative adversarial examples. arXiv preprint arXiv:2002.09632, 2020. +Ilya Loshchilov and Frank Hutter. Decoupled weight decay regularization. In International Conference on Learning Representations (ICLR), 2019. +Xingjun Ma, Bo Li, Yisen Wang, Sarah M Erfani, Sudanthi Wijewickrema, Michael E Houle, Grant Schoenebeck, Dawn Song, and James Bailey. Characterizing adversarial subspaces using local intrinsic dimensionality. arXiv preprint arXiv:1801.02613, 2018. +Aleksander Madry, Aleksandar Makelov, Ludwig Schmidt, Dimitris Tsipras, and Adrian Vladu. Towards deep learning models resistant to adversarial attacks. In International Conference on Learning Representations (ICLR), 2018. +Chengzhi Mao, Ziyuan Zhong, Junfeng Yang, Carl Vondrick, and Baishakhi Ray. Metric learning for adversarial robustness. In Advances in Neural Information Processing Systems (NeurIPS), pp. 478-489, 2019. +Jan Hendrik Metzen, Tim Genewein, Volker Fischer, and Bastian Bischoff. On detecting adversarial perturbations. In International Conference on Learning Representations (ICLR), 2017. +Seyed-Mohsen Moosavi-Dezfooli, Alhussein Fawzi, Jonathan Uesato, and Pascal Frossard. Robustness via curvature regularization, and vice versa. In IEEE Conference on Computer Vision and Pattern Recognition (CVPR), 2019. +Norman Mu and Justin Gilmer. Mnist-c: A robustness benchmark for computer vision. arXiv preprint arXiv:1906.02337, 2019. +Muzammal Naseer, Salman Khan, Munawar Hayat, Fahad Shahbaz Khan, and Fatih Porikli. A self-supervised approach for adversarial robustness. In Conference on Computer Vision and Pattern Recognition (CVPR), pp. 262-271, 2020. +Anh Nguyen, Jason Yosinski, and Jeff Clune. Deep neural networks are easily fooled: High confidence predictions for unrecognizable images. In IEEE Conference on Computer Vision and Pattern Recognition (CVPR), pp. 427-436, 2015. + +Tianyu Pang, Chao Du, Yinpeng Dong, and Jun Zhu. Towards robust detection of adversarial examples. In Advances in Neural Information Processing Systems (NeurIPS), pp. 4579-4589, 2018a. +Tianyu Pang, Chao Du, and Jun Zhu. Max-mahalanobis linear discriminant analysis networks. In International Conference on Machine Learning (ICML), 2018b. +Tianyu Pang, Kun Xu, Chao Du, Ning Chen, and Jun Zhu. Improving adversarial robustness via promoting ensemble diversity. In International Conference on Machine Learning (ICML), 2019. +Tianyu Pang, Kun Xu, Yinpeng Dong, Chao Du, Ning Chen, and Jun Zhu. Rethinking softmax cross-entropy loss for adversarial robustness. In International Conference on Learning Representations (ICLR), 2020a. +Tianyu Pang, Kun Xu, and Jun Zhu. Mixup inference: Better exploiting mixup to defend adversarial attacks. In International Conference on Learning Representations (ICLR), 2020b. +Tianyu Pang, Xiao Yang, Yinpeng Dong, Kun Xu, Hang Su, and Jun Zhu. Boosting adversarial training with hypersphere embedding. In Advances in Neural Information Processing Systems (NeurIPS), 2020c. +Nicolas Papernot, Patrick McDaniel, Somesh Jha, Matt Fredrikson, Z Berkay Celik, and Ananthram Swami. The limitations of deep learning in adversarial settings. In IEEE European Symposium on Security and Privacy (EuroS&P), pp. 372-387. IEEE, 2016. +Chongli Qin, James Martens, Sven Gowal, Dilip Krishnan, Krishnamurthy Dvijotham, Alhussein Fawzi, Soham De, Robert Stanforth, and Pushmeet Kohli. Adversarial robustness through local linearization. In Advances in Neural Information Processing Systems (NeurIPS), pp. 13824-13833, 2019. +Ilija Radosavovic, Raj Prateek Kosaraju, Ross Girshick, Kaiming He, and Piotr Dólár. Designing network design spaces. In IEEE Conference on Computer Vision and Pattern Recognition (CVPR), pp. 10428-10436, 2020. +Edward Raff, Jared Sylvester, Steven Forsyth, and Mark McLean. Barrage of random transforms for adversarially robust defense. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition (CVPR), pp. 6528-6537, 2019. +Leslie Rice, Eric Wong, and J Zico Kolter. Overfitting in adversarially robust deep learning. In International Conference on Machine Learning (ICML), 2020. +Ali Shafahi, Amin Ghiasi, Furong Huang, and Tom Goldstein. Label smoothing and logit squeezing: A replacement for adversarial training? arXiv preprint arXiv:1910.11585, 2019a. +Ali Shafahi, Mahyar Najibi, Amin Ghiasi, Zheng Xu, John Dickerson, Christoph Studer, Larry S Davis, Gavin Taylor, and Tom Goldstein. Adversarial training for free! In Advances in Neural Information Processing Systems (NeurIPS), 2019b. +Dawn Song, Kevin Eykholt, Ivan Evtimov, Earlence Fernandes, Bo Li, Amir Rahmati, Florian Tramer, Atul Prakash, and Tadayoshi Kohno. Physical adversarial examples for object detectors. In USENIX Workshop on Offensive Technologies, 2018a. +Yang Song, Taesup Kim, Sebastian Nowozin, Stefano Ermon, and Nate Kushman. Pixeldefend: Leveraging generative models to understand and defend against adversarial examples. In International Conference on Learning Representations (ICLR), 2018b. +David Stutz, Matthias Hein, and Bernt Schiele. Confidence-calibrated adversarial training: Generalizing to unseen attacks. In International Conference on Machine Learning (ICML), 2020. +Dong Su, Huan Zhang, Hongge Chen, Jinfeng Yi, Pin-Yu Chen, and Yupeng Gao. Is robustness the cost of accuracy? - a comprehensive study on the robustness of 18 deep image classification models. In European Conference on Computer Vision (ECCV), 2018. + +Cecilia Summers and Michael J Dinneen. Logit regularization methods for adversarial robustness. ICLR submission, 2018. https://openreview.net/forum?id=BJlr0j0ctX. +Christian Szegedy, Wojciech Zaremba, Ilya Sutskever, Joan Bruna, Dumitru Erhan, Ian Goodfellow, and Rob Fergus. Intriguing properties of neural networks. In International Conference on Learning Representations (ICLR), 2014. +Christian Szegedy, Wei Liu, Yangqing Jia, Pierre Sermanet, Scott Reed, Dragomir Anguelov, Dumitru Erhan, Vincent Vanhoucke, and Andrew Rabinovich. Going deeper with convolutions. In IEEE Conference on Computer Vision and Pattern Recognition (CVPR), pp. 1-9, 2015. +Pedro Tabacof and Eduardo Valle. Exploring the space of adversarial images. In 2016 International Joint Conference on Neural Networks (IJCNN), pp. 426-433. IEEE, 2016. +Florian Tramér and Dan Boneh. Adversarial training and robustness for multiple perturbations. In Advances in Neural Information Processing Systems (NeurIPS), pp. 5858-5868, 2019. +Florian Tramér, Alexey Kurakin, Nicolas Papernot, Dan Boneh, and Patrick McDaniel. Ensemble adversarial training: Attacks and defenses. In International Conference on Learning Representations (ICLR), 2018. +Florian Tramer, Nicholas Carlini, Wieland Brendel, and Aleksander Madry. On adaptive attacks to adversarial example defenses. In Advances in Neural Information Processing Systems (NeurIPS), 2020. +Jonathan Uesato, Brendan O'Donoghue, Aaron van den Oord, and Pushmeet Kohli. Adversarial risk and the dangers of evaluating against weak attacks. In International Conference on Machine Learning (ICML), 2018. +S Vivek B and R Venkatesh Babu. Single-step adversarial training with dropout scheduling. In IEEE Conference on Computer Vision and Pattern Recognition (CVPR), 2020. +Huaxia Wang and Chun-Nam Yu. A direct approach to robust deep learning using adversarial networks. In International Conference on Learning Representations (ICLR), 2019. +Yisen Wang, Xingjun Ma, James Bailey, Jinfeng Yi, Bowen Zhou, and Quanquan Gu. On the convergence and robustness of adversarial training. In International Conference on Machine Learning (ICML), pp. 6586-6595, 2019. +Eric Wong and Zico Kolter. Provable defenses against adversarial examples via the convex outer adversarial polytope. In International Conference on Machine Learning (ICML), pp. 5283-5292, 2018. +Eric Wong, Leslie Rice, and J. Zico Kolter. Fast is better than free: Revisiting adversarial training. In International Conference on Learning Representations (ICLR), 2020. +Dongxian Wu, Yisen Wang, Shu-Tao Xia, James Bailey, and Xingjun Ma. Skip connections matter: On the transferability of adversarial examples generated with resnets. In International Conference on Learning Representations (ICLR), 2020. +Cihang Xie and Alan Yuille. Intriguing properties of adversarial training at scale. In International Conference on Learning Representations (ICLR), 2020. +Cihang Xie, Jianyu Wang, Zhishuai Zhang, Zhou Ren, and Alan Yuille. Mitigating adversarial effects through randomization. In International Conference on Learning Representations (ICLR), 2018. +Cihang Xie, Yuxin Wu, Laurens van der Maaten, Alan Yuille, and Kaiming He. Feature denoising for improving adversarial robustness. In IEEE Conference on Computer Vision and Pattern Recognition (CVPR), 2019. +Cihang Xie, Mingxing Tan, Boqing Gong, Alan Yuille, and Quoc V Le. Smooth adversarial training. arXiv preprint arXiv:2006.14536, 2020. + +Saining Xie, Ross Girshick, Piotr Dolkar, Zhuowen Tu, and Kaiming He. Aggregated residual transformations for deep neural networks. In IEEE Conference on Computer Vision and Pattern Recognition (CVPR), pp. 1492-1500, 2017. +Zheng Xu, Ali Shafahi, and Tom Goldstein. Exploring model robustness with adaptive networks and improved adversarial training. arXiv preprint arXiv:2006.00387, 2020. +Hongwei Yong, Jianqiang Huang, Xiansheng Hua, and Lei Zhang. Gradient centralization: A new optimization technique for deep neural networks. In European Conference on Computer Vision (ECCV), 2020. +Sergey Zagoruyko and Nikos Komodakis. Wide residual networks. In The British Machine Vision Conference (BMVC), 2016. +Runtian Zhai, Tianle Cai, Di He, Chen Dan, Kun He, John Hopcroft, and Liwei Wang. Adversarily robust generalization just requires more unlabeled data. arXiv preprint arXiv:1906.00555, 2019. +Dinghuai Zhang, Tianyuan Zhang, Yiping Lu, Zhanxing Zhu, and Bin Dong. You only propagate once: Accelerating adversarial training via maximal principle. In Advances in Neural Information Processing Systems (NeurIPS), 2019a. +Haichao Zhang and Jianyu Wang. Defense against adversarial attacks using feature scattering-based adversarial training. In Advances in Neural Information Processing Systems (NeurIPS), pp. 1829-1839, 2019. +Hongyang Zhang, Yaodong Yu, Jiantao Jiao, Eric P Xing, Laurent El Ghaoui, and Michael I Jordan. Theoretically principled trade-off between robustness and accuracy. In International Conference on Machine Learning (ICML), 2019b. +Jingfeng Zhang, Xilie Xu, Bo Han, Gang Niu, Lizhen Cui, Masashi Sugiyama, and Mohan Kankanhalli. Attacks which do not kill training make adversarial learning stronger. In International Conference on Machine Learning (ICML), 2020. + +# A TECHNICAL DETAILS + +In this section we introduce more related backgrounds and technical details for reference. + +# A.1 ADVERSARIAL ATTACKS + +Since the seminal L-BFGS and FGSM attacks (Szegedy et al., 2014; Goodfellow et al., 2015), a large amount of attacking methods on generating adversarial examples have been introduced. In the white-box setting, gradient-based methods are popular and powerful, which span in the $\ell_{\infty}$ threat model (Nguyen et al., 2015; Madry et al., 2018), $\ell_2$ threat model (Carlini & Wagner, 2017a), $\ell_1$ threat model (Chen et al., 2018), and $\ell_0$ threat model (Papernot et al., 2016). In the black-box setting, the attack strategies are much more diverse. These include transfer-based attacks (Dong et al., 2018; 2019; Cheng et al., 2019b), quasi-gradient attacks (Chen et al., 2017a; Uesato et al., 2018; Ilyas et al., 2018), and decision-based attacks (Brendel et al., 2018; Cheng et al., 2019a). Adversarial attacks can be also realized in the physical world (Kurakin et al., 2017; Song et al., 2018a). Below we formulate the PGD attack and AutoAttack that we used in our evaluations. + +PGD attack. One of the most commonly studied adversarial attack is the projected gradient descent (PGD) method (Madry et al., 2018). Let $x_0$ be a randomly perturbed sample in the neighborhood of the clean input $x$ , then PGD iteratively crafts the adversarial example as + +$$ +x _ {i} = \operatorname {c l i p} _ {x, \epsilon} \left(x _ {i - 1} + \epsilon_ {i} \cdot \operatorname {s i g n} \left(\nabla_ {x _ {i - 1}} \mathcal {L} \left(x _ {i - 1}, y\right)\right)\right), \tag {1} +$$ + +where $\mathrm{clip}_{x,\epsilon}(\cdot)$ is the clipping function and $\mathcal{L}$ is the adversarial objective. The accuracy under PGD attack has been a standard metric to evaluate the model robustness. + +AutoAttack. Croce & Hein (2020b) first propose the Auto-PGD (APGD) algorithm, where the main idea is to automatically tune the adversarial step sizes according to the optimization trend. As to the adversarial objective, except for the traditional cross-entropy (CE) loss, they develop a new difference of logits ratio (DLR) loss as + +$$ +\mathrm {D L R} (x, y) = - \frac {z _ {y} - \operatorname* {m a x} _ {i \neq y} z _ {i}}{z _ {\pi_ {1}} - z _ {\pi_ {3}}}, \tag {2} +$$ + +where $z$ is the logits and $\pi$ is the ordering which sorts the components of $z$ . Finally, the authors propose to group $\mathrm{APGD}_{\mathrm{CE}}$ and $\mathrm{APGD}_{\mathrm{DLR}}$ with FAB (Croce & Hein, 2020a) and square attack (Andriushchenko et al., 2020) to form the AutoAttack (AA). + +# A.2 REFERENCE CODES + +In Table 11, we provide the code links for the referred defenses. The summarized training settings are either described in their papers or manually retrieved by us in their code implementations. + +Table 11: We summarize the code links for the referred defense methods in Table 1. + +
MethodCode link
Madry et al. (2018)github.com/MadryLab/cifar10_challenge
Cai et al. (2018)github.com/sun Blaze-ucb/curriculum-adversarial-training-CAT
Zhang et al. (2019b)github.com/yaodongyu/TRADES
Wang et al. (2019)github.com/YisenWang/dynamic_adv_training
Mao et al. (2019)github.com/columbia/Metric_Learning_Adversarial_Robustness
Carmon et al. (2019)github.com/yaircarmon/semisup-adv
Alayrac et al. (2019)github.com/deepmind/deepmind-research/unsupervised_adversarial_training
Shafahi et al. (2019b)github.com/ashafahi/free_adv_train
Zhang et al. (2019a)github.com/a1600012888/YOPO-You-Only-Propagate-Once
Zhang & Wang (2019)github.com/Haichao-Zhang/FeatureScatter
Atzmon et al. (2019)github.com/matanatz/ControllingNeuralLevelsets
Wong et al. (2020)github.com/locuslab/fast_adversarial
Rice et al. (2020)github.com/locuslab/robust_overfitting
Ding et al. (2020)github.com/BorealisAI/mma_training
Pang et al. (2020a)github.com/P2333/Max-Mahalanobis-Training
Zhang et al. (2020)github.com/zjfheart/Friendly-Adversarial-Training
Huang et al. (2020)github.com/LayneH/self-adaptive-training
Lee et al. (2020)github.com/Saehyung-Lee/cifar10_challenge
+ +# A.3 MODEL ARCHITECTURES + +We select some typical hand-crafted model architectures as the objects of study, involving DenseNet (Huang et al., 2017), GoogleNet (Szegedy et al., 2015), (PreAct) ResNet (He et al., 2016), SENet (Hu et al., 2018), WRN (Zagoruyko & Komodakis, 2016), DPN (Chen et al., 2017b), ResNeXt (Xie et al., 2017), and RegNetX (Radosavovic et al., 2020). The models are implemented by https://github.com/kuangliu/pytorch-cifar. + +Table 12: Number of parameters for different model architectures. + +
Architecture# of param.Architecture# of param.Architecture# of param.
DenseNet-12128.29 MDPN2646.47 MGoogleNet24.81 M
DenseNet-20173.55 MDPN92137.50 MResNeXt-2936.65 M
RegNetX (200MF)9.42 MResNet-1844.70 MSENet-1845.09 M
RegNetX (400MF)19.34 MResNet-5094.28 MWRN-34-10193.20 M
+ +# A.4 INFERENCE-PHASE ADVERSARIAL DEFENSES + +Except for enhancing the models in the training phase, there are other methods that intend to improve robustness in the inference phase. These attempts include performing local linear transformation like adding Gaussian noise (Tabacof & Valle, 2016), different operations of image processing (Guo et al., 2018; Xie et al., 2018; Raff et al., 2019) or specified inference principle (Pang et al., 2020b). On the other hand, detection-based methods aim to filter out adversarial examples and resort to higher-level intervention. Although detection is a suboptimal strategy compared to classification, it can avoid over-confident wrong decisions. These efforts include training auxiliary classifiers to detect adversarial inputs (Metzen et al., 2017), designing detection statistics (Feinman et al., 2017; Ma et al., 2018; Pang et al., 2018a), or basing on additional probabilistic models (Song et al., 2018b). + +# A.5 CONCURRENT WORK + +Gowal et al. (2020) also provide a comprehensive study on different training tricks of AT, and push forward the state-of-the-art performance of adversarially trained models on MNIST, CIFAR-10 and CIFAR-100. While they analyze some properties that we also analyze in this paper (such as training batch size, label smoothing, weight decay, activation functions), they also complement our analyses with experiments on, e.g., weight moving average and data quality. Both of our works reveal the importance of training details in the process of AT, and contribute to establishing more justified perspectives for evaluating AT methods. + +# B ADDITIONAL RESULTS + +In this section, we provide additional results to further support the conclusions in the main text. + +# B.1 EARLY DECAYS LEARNING RATE + +As shown in Fig. 1, smaller values of weight decay make the training faster but also more tend to overfit. So in Fig. 4, we early decay the learning rate at 40 and 45 epochs, rather than 100 and 105 epochs. We can see that the models can achieve the same clean accuracy, but the weight decay of $5 \times 10^{-4}$ can still achieve better robustness. Besides, in Fig. 5, we use different values of weight decay for standard training, where the models can also achieve similar clean accuracy. These results demonstrate that adversarial robustness is a more difficult target than clean performance, and is more sensitive to the training hyperparameters, both for standardly and adversarily trained models. + +![](images/5e4f8d2a418b9ff463447af89ce91bba605127d289e2109e5fd900cba5320d38.jpg) +Figure 4: Curves of test accuracy w.r.t. training epochs, where the model is WRN-34-10. Here we early decay the learning rate at 40 and 45 epochs for the cases of weight decay $1 \times 10^{-4}$ and $2 \times 10^{-4}$ , just before they overfitting. We can see that the models can achieve the same clean accuracy as weight decay $5 \times 10^{-4}$ , but still worse robustness. + +![](images/e832d977e942957f5dc39bb991b89869077e33e7a92d071fa25aa5d3c3cac869.jpg) + +![](images/8c818325ce60dc37e2f0478402035aa102900dc4766f5180cf8ea30803a7a1df.jpg) +Figure 5: Curves of test accuracy w.r.t. training epochs. The model architecture is WRN-34-10, and is standardly trained on CIFAR-10. We can observe that the final performance of each model is comparable, which means that clean accuracy is less sensitive to different values of weight decay. This observation also holds for the adversarially trained models as shown in Fig. 1. + +# B.2 THE EFFECT OF SMOOTH ACTIVATION FUNCTION + +In Table 13 we test the effect of Softplus and BN mode on ResNet-18. + +Table 13: Test accuracy $(\%)$ of TRADES. We compare with the results in Table 6 to check the effect of smooth activation function on TRADES, as well as the compatibility of it with eval BN mode. + +
Threat model: ℓ∞ constraint, ε = 8/255
ArchitectureWeight decayBN modeActivationCleanPGD-10AA
ResNet-185 × 10-4trainReLU80.2353.6048.96
5 × 10-4trainSoftplus81.2654.5850.35
5 × 10-4evalReLU81.4553.5149.06
5 × 10-4evalSoftplus82.3754.3750.51
+ +# B.3 RESULTS OF EARLY STOPPING, WARMUP, AND OPTIMIZERS ON WRN-34-10 + +In Table 14 and Table 15, we provide the results on WRN-34-10. + +Table 14: Test accuracy (\%) under different early stopping and warmup on CIFAR-10. The model is WRN-34-10. For early stopping attack iterations, we denote, e.g., $40 / 70$ as the epochs to increase the tolerance step by one (Zhang et al., 2020). For warmup, the learning rate (l.r.) and the maximal perturbation (perturb.) linearly increase from zero to the preset value in the first $10 / 15 / 20$ epochs. + +
BaseEarly stopping attack iter.Warmup on l.r.Warmup on perturb.
40 / 7040 / 10060 / 100101520101520
Clean86.0788.2988.2588.8186.3586.6386.4186.6686.4386.73
PGD-1056.6056.0655.4956.4156.3156.6056.2856.2556.3755.65
AA52.1950.1949.4449.8151.9652.1351.7551.8852.0651.70
+ +Table 15: Test accuracy $(\%)$ using different optimizers on CIFAR-10. The model is WRN-34-10. The initial learning rate for Adam and AdamW is 0.0001, while for other optimizers is 0.1. + +
MomNesterovAdamAdamWSGD-GCSGD-GCC
Clean86.0786.8081.0080.7286.7086.67
PGD-1056.6056.3452.5450.3256.0656.14
AA52.1951.9346.5245.7951.7551.65
+ +# B.4 RANK IN THE AUTOATTACK BENCHMARK + +The models evaluated in this paper are all retrained based on the released codes (Zhang et al., 2019b; Rice et al., 2020). Now we compare our trained models with the AutoAttack public benchmark, where the results of previous work are based on the released pretrained models. In Table 16, we retrieve our results in Table 9 on the TRADES model where we simply change the weight decay from $2 \times 10^{-4}$ to $5 \times 10^{-4}$ . We can see that this seemingly unimportant difference sends the TRADES model back to the state-of-the-art position in the benchmark. + +Table 16: We retrieve the results of top-rank methods from https://github.com/fra31/auto-attack. All the methods listed below do not require additional training data on CIFAR-10. Here the model of Ours (TRADES) corresponds to lines of weight decay $5 \times 10^{-4}$ , eval BN mode and ReLU activation in Table 9, which only differs from the original TRADES in weight decay. We run our methods 5 times with different random seeds, and report the mean and standard deviation. + +
Threat model: ℓ∞ constraint, ε = 8/255
MethodArchitectureCleanAA
Ours (TRADES)WRN-34-2086.4354.39
Ours (TRADES)WRN-34-1085.49 ± 0.2453.94 ± 0.10
Pang et al. (2020c)WRN-34-2085.1453.74
Zhang et al. (2020)WRN-34-1084.5253.51
Rice et al. (2020)WRN-34-2085.3453.42
Qin et al. (2019)WRN-40-886.2852.84
Threat model: ℓ∞ constraint, ε = 0.031
MethodArchitectureCleanAA
Ours (TRADES)WRN-34-1085.45 ± 0.0954.28 ± 0.24
Huang et al. (2020)WRN-34-1083.4853.34
Zhang et al. (2019b)WRN-34-1084.9253.08
+ +# B.5 MORE EVALUATIONS ON LABEL SMOOTHING + +In Table 17 we further investigate the effect of label smoothing on adversarial training. + +Table 17: Test accuracy (\%) under different label smoothing on CIFAR-10. The model is ResNet-18 trained by PGD-AT. We evaluate under PGD-1000 with different number of restarts and step sizes. Here we use the cross-entropy (CE) objective and C&W objective (Carlini & Wagner, 2017a), respectively. We also evaluate under the SPSA attack (Uesato et al., 2018) for 10,000 iteration steps, with batch size 128, perturbation size 0.001 and learning rate of $\frac{1}{255}$ . + +
Evaluation methodLabel smoothing
AttackRestartStep size00.10.20.30.4
PGD-1000 (CE objective)12/25552.4552.9553.0853.1053.14
52/25552.4152.8953.0153.0453.03
102/25552.3152.8552.9253.0252.96
100.5/25552.6352.9453.3353.3053.25
PGD-1000 (C&W objective)12/25550.6450.7651.0750.9650.54
52/25550.5850.6650.9350.8650.44
102/25550.5550.5950.9050.8550.44
100.5/25550.6350.7351.0351.0450.52
SPSA-1000011/25561.6961.9261.9361.7961.53
\ No newline at end of file diff --git a/bagoftricksforadversarialtraining/images.zip b/bagoftricksforadversarialtraining/images.zip new file mode 100644 index 0000000000000000000000000000000000000000..46fc9508651398253459660441eee11271349afa --- /dev/null +++ b/bagoftricksforadversarialtraining/images.zip @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c0a0d5299ca3763ad808a7c5c95013d6151ff6cdf9a44a41bbbc71e9c35f4bc8 +size 1313040 diff --git a/bagoftricksforadversarialtraining/layout.json b/bagoftricksforadversarialtraining/layout.json new file mode 100644 index 0000000000000000000000000000000000000000..912aff01c951429878f83a86c9c6d2a078458fcf --- /dev/null +++ b/bagoftricksforadversarialtraining/layout.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b0263f6be831e301d2e0ecb8626b1cc71a89067b49d602ff20c65d604e5c90e6 +size 559715 diff --git a/balancingconstraintsandrewardswithmetagradientd4pg/9dfee37f-53ff-4353-b1ef-ea06be2a64b1_content_list.json b/balancingconstraintsandrewardswithmetagradientd4pg/9dfee37f-53ff-4353-b1ef-ea06be2a64b1_content_list.json new file mode 100644 index 0000000000000000000000000000000000000000..bc54ffd1060dfafee7ce21b131300066f6cbdce7 --- /dev/null +++ b/balancingconstraintsandrewardswithmetagradientd4pg/9dfee37f-53ff-4353-b1ef-ea06be2a64b1_content_list.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:67e62b4cf5882176318a8a175cd1671dd4b13d2b512ca4a50b127d1865011047 +size 64725 diff --git a/balancingconstraintsandrewardswithmetagradientd4pg/9dfee37f-53ff-4353-b1ef-ea06be2a64b1_model.json b/balancingconstraintsandrewardswithmetagradientd4pg/9dfee37f-53ff-4353-b1ef-ea06be2a64b1_model.json new file mode 100644 index 0000000000000000000000000000000000000000..0ae19508610abe409488a683240b2beb46a710ec --- /dev/null +++ b/balancingconstraintsandrewardswithmetagradientd4pg/9dfee37f-53ff-4353-b1ef-ea06be2a64b1_model.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:169755e1e95ebe08d9675cced73c64617db2aa4f24080658344c9b6b3aba5416 +size 80259 diff --git a/balancingconstraintsandrewardswithmetagradientd4pg/9dfee37f-53ff-4353-b1ef-ea06be2a64b1_origin.pdf b/balancingconstraintsandrewardswithmetagradientd4pg/9dfee37f-53ff-4353-b1ef-ea06be2a64b1_origin.pdf new file mode 100644 index 0000000000000000000000000000000000000000..ee7438e508edbcfe6b83877653a594b9118e1216 --- /dev/null +++ b/balancingconstraintsandrewardswithmetagradientd4pg/9dfee37f-53ff-4353-b1ef-ea06be2a64b1_origin.pdf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:884d79c9aede110c436663f292772b6e9f801c58d1ed08e95855f22138bf0068 +size 905110 diff --git a/balancingconstraintsandrewardswithmetagradientd4pg/full.md b/balancingconstraintsandrewardswithmetagradientd4pg/full.md new file mode 100644 index 0000000000000000000000000000000000000000..026e37227f21011ab348635d4ba753909458df70 --- /dev/null +++ b/balancingconstraintsandrewardswithmetagradientd4pg/full.md @@ -0,0 +1,196 @@ +# BALANCING CONSTRAINTS AND REWARDS WITH META-GRADIENT D4PG + +Dan A. Calian*, Daniel J. Mankowitz*, Tom Zahavy, Zhongwen Xu, Junhyuk Oh, Nir Levine & Timothy Mann + +DeepMind + +London, United Kingdom + +{dancalian, dmankowitz}@google.com + +# ABSTRACT + +Deploying Reinforcement Learning (RL) agents to solve real-world applications often requires satisfying complex system constraints. Often the constraint thresholds are incorrectly set due to the complex nature of a system or the inability to verify the thresholds offline (e.g., no simulator or reasonable offline evaluation procedure exists). This results in solutions where a task cannot be solved without violating the constraints. However, in many real-world cases, constraint violations are undesirable yet they are not catastrophic, motivating the need for soft-constrained RL approaches. We present a soft-constrained RL approach that utilizes meta-gradients to find a good trade-off between expected return and minimizing constraint violations. We demonstrate the effectiveness of this approach by showing that it consistently outperforms the baselines across four different Mujoco domains. + +# 1 INTRODUCTION + +Reinforcement Learning (RL) algorithms typically try to maximize an expected return objective (Sutton & Barto, 2018). This approach has led to numerous successes in a variety of domains which include board-games (Silver et al., 2017), computer games (Mnih et al., 2015; Tessler et al., 2017) and robotics (Abdolmaleki et al., 2018). However, formulating real-world problems with only an expected return objective is often sub-optimal when tackling many applied problems ranging from recommendation systems to physical control systems which may include robots, self-driving cars and even aerospace technologies. In many of these domains there are a variety of challenges preventing RL from being utilized as the algorithmic solution framework. Recently, Dulac-Arnold et al. (2019) presented nine challenges that need to be solved to enable RL algorithms to be utilized in real-world products and systems. One of those challenges is handling constraints. All of the above domains may include one or more constraints related to cost, wear-and-tear, or safety, to name a few. + +Hard and Soft Constraints: There are two types of constraints that are encountered in constrained optimization problems; namely hard-constraints and soft-constraints (Boyd & Vandenberghe, 2004). Hard constraints are pairs of pre-specified functions and thresholds that require the functions, when evaluated on the solution, to respect the thresholds. As such, these constraints may limit the feasible solution set. Soft constraints are similar to hard constraints in the sense that they are defined by pairs of pre-specified functions and thresholds, however, a soft constraint does not require the solution to hold the constraint; instead, it penalizes the objective function (according to a specified rule) if the solution violates the constraint (Boyd & Vandenberghe, 2004; Thomas et al., 2017). + +Motivating Soft-Constraints: In real-world products and systems, there are many examples of soft-constraints; that is, constraints that can be violated, where the violated behaviour is undesirable but not catastrophic (Thomas et al. 2017; Dulac-Arnold et al. 2020b). One concrete example is that of energy minimization in physical control systems. Here, the system may wish to reduce the amount of energy used by setting a soft-constraint. Violating the constraint is inefficient, but not catastrophic to the system completing the task. In fact, there may be desirable characteristics that can only be attained if there are some constraint violations (e.g., a smoother/faster control policy). Another common setting is where it is unclear how to set a threshold. In many instances, a product + +manager may desire to increase the level of performance on a particular product metric $A$ , while ensuring that another metric $B$ on the same product does not drop by 'approximately $X\%$ '. The value 'X' is often inaccurate and may not be feasible in many cases. In both of these settings, violating the threshold is undesirable, yet does not have catastrophic consequences. + +Lagrange Optimization: In the RL paradigm, a number of approaches have been developed to incorporate hard constraints into the overall problem formulation (Altman 1999; Tessler et al. 2018; Efroni et al. 2020; Achiam et al. 2017; Bohez et al. 2019; Chow et al. 2018; Paternain et al. 2019; Zhang et al. 2020; Efroni et al. 2020). One popular approach is to model the problem as a Constrained Markov Decision Process (CMDP) (Altman 1999). In this case, one method is to solve the following problem formulation: $\max_{\pi} J_R^{\pi}$ s.t. $J_C^\pi \leq \beta$ , where $\pi$ is a policy, $J_R^\pi$ is the expected return, $J_C^\pi$ is the expected cost and $\beta$ is a constraint violation threshold. This is often solved by performing alternating optimization on the unconstrained Lagrangian relaxation of the original problem (e.g. Tessler et al. (2018)), defined as: $\min_{\lambda \geq 0} \max_{\pi} J_R^\pi + \lambda (\beta - J_C^\pi)$ . The updates alternate between learning the policy and the Lagrange multiplier $\lambda$ . + +In many previous constrained RL works (Achiam et al., 2017; Tessler et al., 2018; Ray et al., 2019; Satija et al., 2020), because the problem is formulated with hard constraints, there are some domains in each case where a feasible solution is not found. This could be due to approximation errors, noise, or the constraints themselves being infeasible. The real-world applications, along with empirical constrained RL research results, further motivates the need to develop a soft-constrained RL optimization approach. Ideally, in this setup, we would like an algorithm that satisfies the constraints while solving the task by maximizing the objective. If the constraints cannot be satisfied, then this algorithm finds a good trade-off (that is, minimizing constraint violations while solving the task by maximizing the objective). + +In this paper, we extend the constrained RL Lagrange formulation to perform soft-constrained optimization by formulating the constrained RL objective as a nested optimization problem (Sinha et al., 2017) using meta-gradients. We propose MetaL that utilizes meta-gradients (Xu et al., 2018; Zahavy et al., 2020) to improve upon the trade-off between reducing constraint violations and improving expected return. We focus on Distributed Distributional Deterministic Policy Gradients (D4PG) (Barth-Maron et al., 2018) as the underlying algorithmic framework, a state-of-the-art continuous control RL algorithm. We show that MetaL can capture an improved trade-off between expected return and constraint violations compared to the baseline approaches. We also introduce a second approach called MeSh that utilizes meta-gradients by adding additional representation power to the reward shaping function. Our main contributions are as follows: (1) We extend D4PG to handle constraints by adapting it to Reward Constrained Policy Optimization (RCPO) (Tessler et al., 2018) yielding Reward Constrained D4PG (RC-D4PG); (2) We present a soft constrained meta-gradient technique: Meta-Gradients for the Lagrange multiplier learning rate (MetaL)1; (3) We derive the meta-gradient update for MetaL (Theorem 1); (4) We perform extensive experiments and investigative studies to showcase the properties of this algorithm. MetaL outperforms the baseline algorithms across domains, safety coefficients and thresholds from the Real World RL suite (Dulac-Arnold et al., 2020b). + +# 2 BACKGROUND + +A Constrained Markov Decision Process (CMDP) is an extension to an MDP (Sutton & Barto, 2018) and consists of the tuple $\langle S, A, P, R, C, \gamma \rangle$ where $S$ is the state space; $A$ is the action space; $P: S \times A \to S$ is a function mapping states and actions to a distribution over next states; $R: S \times A \to \mathbb{R}$ is a bounded reward function and $C: S \times A \to \mathbb{R}^K$ is a $K$ dimensional function representing immediate penalties (or costs) relating to $K$ constraints. The solution to a CMDP is a policy $\pi: S \to \Delta_A$ which is a mapping from states to a probability distribution over actions. This policy aims to maximize the expected return $J_R^\pi = \mathbb{E}[\sum_{t=0}^\infty \gamma^t r_t]$ and satisfy the constraints $J_{C_i}^\pi = \mathbb{E}[\sum_{t=0}^\infty \gamma^t c_{i,t}] \leq \beta_i, i = 1 \dots K$ . For the purpose of the paper, we consider a single constraint; that is, $K = 1$ , but this can easily be extended to multiple constraints. + +Meta-Gradients is an approach to optimizing hyperparameters such as the discount factor, learning rates, etc. by performing online cross validation while simultaneously optimizing for the overall RL optimization objective such as the expected return (Xu et al., 2018; Zahavy et al., 2020). The goal is to optimize both an inner loss and an outer loss. The update of the $\theta$ parameters on the inner + +loss is defined as $\theta' = \theta + f(\tau, \theta, \eta)$ , where $\theta \in \mathbb{R}^d$ corresponds to the parameters of the policy $\pi_\theta(a|s)$ and the value function $v_\theta(s)$ (if applicable). The function $f: \mathbb{R}^k \to \mathbb{R}^d$ is the gradient of the policy and/or value function with respect to the parameters $\theta$ and is a function of an n-step trajectory $\tau = \langle s_1, a_1, r_2, s_2 \ldots s_n \rangle$ , meta-parameters $\eta$ and is weighted by a learning rate $\alpha$ and is defined as $f(\tau, \theta, \eta) = \alpha \frac{\mathrm{d}J_{obj}^{\pi_\theta}(\theta, \tau, \eta)}{\mathrm{d}\theta}$ where $J_{obj}^{\pi_\theta}(\theta, \tau, \eta)$ is the objective being optimized with respect to $\theta$ . The idea is to then evaluate the performance of this new parameter value $\theta'$ on an outer loss - the meta-gradient objective. We define this objective as $J'(\tau', \theta', \bar{\eta})$ where $\tau'$ is a new trajectory, $\theta'$ are the updated parameters and $\bar{\eta}$ is a fixed meta-parameter (which needs to be selected/tuned in practice). We then need to take the gradient of the objective $J'$ with respect to the meta-parameters $\eta$ to yield the outer loss update $\eta' = \eta + \alpha_\eta \frac{\partial J'(\tau', \theta', \bar{\eta})}{\partial\eta}$ . This gradient is computed as follows: $\frac{\partial J'(\tau', \theta', \bar{\eta})}{\partial\eta} = \frac{\partial J'(\tau', \theta', \bar{\eta})}{\partial\theta'} \frac{\partial\theta'}{\partial\eta}$ . The outer loss is essentially the objective we are trying to optimize. This could be a policy gradient loss, a temporal difference loss, a combination of the two etc (Xu et al., 2018; Zahavy et al., 2020). Meta-gradients have been previously used to learn intrinsic rewards for policy gradient (Zheng et al., 2018) and auxiliary tasks (Veeriah et al., 2019). Meta-gradients have also been used to adapt optimizer parameters (Young et al., 2018; Franceschi et al., 2017). In our setup, we consider the continuous control setting, provide the first implementation of meta-gradients for an algorithm that uses an experience replay, and focus on adapting meta-parameters that encourage soft constraint satisfaction while maximizing expected return. + +D4PG is a state-of-the-art continuous control RL algorithm with a deterministic policy (Barth-Maron et al., 2018). It is an incremental improvement to DDPG (Lillicrap et al., 2015). The overall objective of DDPG is to maximize $J(\theta_{a}, \theta_{c}) = \mathbb{E}[Q_{\theta_{c}}(s, a) | s = s_{t}, a = \pi_{\theta_{a}}(s_{t})]$ where $\pi_{\theta_{a}}(s_{t})$ is a deterministic policy with parameters $\theta_{a}$ and $Q_{\theta_{c}}(s, a)$ is an action value function with parameters $\theta_{c}$ . The actor loss is defined as: $L_{\text{actor}} = \| \mathrm{SG}(\nabla_{a} Q_{\theta_{c}}(s_{t}, a_{t})|_{a_{t} = \pi_{\theta_{a}}(s)} + a_{\theta_{a}, t}) - a_{\theta_{a}, t} \|_{2}$ where SG is a stop gradient. The corresponding gradient update is defined as $\nabla_{\theta_{a}} J(\theta_{a}) = \mathbb{E}[\nabla_{a} Q_{\theta_{c}}(s, a) \nabla_{\theta_{a}} \pi_{\theta_{a}}(s_{t})]$ . The critic is updated using the standard temporal difference error loss: $L_{\text{critic}} = (r(s, a) + \gamma Q_{T}(s', \pi_{T}(s')) - Q_{\theta_{c}}(s, a))^{2}$ where $Q_{T}, \pi_{T}$ are the target critic and actor networks respectively. In D4PG, the critic is a distributional critic based on the C51 algorithm (Bellemare et al., 2017) and the agent is run in a distributed setup with multiple actors executed in parallel, n-step returns and with prioritized experience replay. We will use the non-distributional critic update in our notation for ease of visualization and clarity for the reader. + +# 3 REWARD CONSTRAINED D4PG (RC-D4PG) + +This section describes our modifications required to transform D4PG into Reward Constrained D4PG (RC-D4PG) such that it maximizes the expected return and satisfies constraints. + +The constrained optimisation objective is defined as: $\max_{\pi_{\theta}}J_{R}^{\pi_{\theta}}$ subject to $J_C^{\pi_\theta}\leq \beta$ where $J_R^{\pi_\theta} = \mathbb{E}[Q(s,a)|s = s_t,a = \pi_\theta (s_t)]$ and $J_{C}^{\pi_{\theta}} = \mathbb{E}[C(s,a)|s = s_{t},a = \pi_{\theta}(s_{t})]$ ; the parameter $\theta = \langle \theta_{a},\theta_{c}\rangle$ from here on in; $C(s,a)$ is a long-term penalty value function (e.g., sum of discounted immediate penalties) corresponding to constraint violations. The Lagrangian relaxation objective is defined as $J_{R}^{\pi_{\theta}} + \lambda (\beta -J_{C}^{\pi_{\theta}})$ . As in RCPO, a proxy objective $J_{R}^{\pi_{\theta}} - \lambda J_{C}^{\pi_{\theta}}$ is used that converges to the same set of locally optimal solutions as the relaxed objective (Tessler et al., 2018). Note that the constant $\beta$ does not affect the policy improvement step and is only used for the Lagrange multiplier loss update. To optimize the proxy objective with D4PG, reward shaping of the form $r(s,a) - \lambda c(s,a)$ is required to yield the reward shaped critic loss defined as: $L_{critic}(\theta_c,\lambda) = (r(s,a) - \lambda c(s,a) + \gamma Q_T(s,\pi_T(s')) - Q_{\theta_c}(s,a))^2$ . The actor loss is defined as before. The Lagrange loss is defined as: $L_{lagrange}(\lambda) = \lambda (\beta -J_C^{\pi_\theta})$ where $\lambda \geq 0$ . Since RC-D4PG is off-policy, it requires storing the per time-step penalties, $c$ , inside the transitions stored in the experience replay buffer (ER). For training the Lagrange multiplier an additional penalty buffer is used to store the per-episode penalties $J_C^{\pi_\theta}$ . The learner then reads from this penalty buffer for updating the Lagrange multiplier. RC-D4PG updates the actor/critic parameters and the Lagrange multipliers using alternating optimization. The full algorithm for this setup can be found in the Appendix, Algorithm 3. + +# 4 META-GRADIENTS FOR THE LAGRANGE LEARNING RATE (METAL) + +In this section, we introduce the MetaL algorithm which extends RC-D4PG to use meta-gradients for adapting the learning rate of the Lagrangian multiplier. The idea is to update the learning rate such that the outer loss (as defined in the next subsection) is minimized. Our intuition is that a learning rate gradient that takes into account the overall task objective and constraint thresholds will lead to improved overall performance. + +# Algorithm 1 MetaL + +1: Input: penalty $c(\cdot)$ , constraint $C(\cdot)$ , threshold $\beta$ , learning rates $\alpha_{1}, \alpha_{\theta_{a}}, \alpha_{\theta_{c}}, \alpha_{\eta}$ , max. number of episodes $M$ +2: Initialize actor, critic parameters $\theta_{a}$ and $\theta_{c}$ , Lagrange multiplier $\lambda = 0$ , meta-parameter $\eta = \alpha_{\lambda}$ +3: for $1 \ldots M$ do +4: Inner loss: +5: Sample episode penalty $J_{C}^{\pi}$ from the penalty replay buffer +6: $\lambda^{\prime}\gets [\lambda -\alpha_{1}\exp (\alpha_{\lambda})(\beta -J_{C}^{\pi})]_{+}$ ▷ Lagrange multiplier update +7: Sample a batch with tuples $\langle s_t, a_t, r_t, c_t \rangle_{t=1}^T$ from ER and split into training/validation sets +8: Accumulate and apply actor and critic updates over training batch $T_{train}$ by: +9: $\nabla \theta_{c} = 0, \nabla \theta_{a} = 0$ +10: for $t = 1\ldots T_{train}$ do +11: $\hat{R}_t = r_t - \lambda' c_t + \gamma \hat{Q}(\lambda, s_{t+1}, a_{t+1} \sim \pi_T(s_{t+1}); \theta_c)$ +12: $\nabla \theta_{c} + = \alpha_{\theta_{c}}\partial (\hat{R}_{t} - \hat{Q} (\lambda ,s_{t},a_{t};\theta_{c}))^{2} / \partial \theta_{c}$ +13: $\nabla \theta_{a} + = \alpha_{\theta_{a}}\mathbb{E}\big[\nabla_{a}Q(s_{t},a_{t})\nabla_{\theta_{a}}\pi_{\theta_{a}}(s_{t})|_{a_{t} = \pi (s_{t})}\big]$ +14: $\theta_c^{\prime}\gets \theta_c - \frac{1}{T_{train}}\sum \nabla \theta_c$ +15: $\theta_{a}^{\prime}\gets \theta_{a} + \frac{1}{T_{train}}\sum \nabla \theta_{a}$ +16: Outer loss: Compute outer loss and meta-gradient update using validation set $T_{\text{validate}}$ : +17: $\alpha_{\lambda}^{\prime}\gets \alpha_{\lambda} - \alpha_{\eta}\frac{\partial J^{\prime}(\theta_{c}^{\prime}(\alpha_{\lambda}),\lambda^{\prime}(\alpha_{\lambda}))}{\partial\alpha_{\lambda}}$ +18: $\lambda \leftarrow \lambda^{\prime},\theta_{a}\leftarrow \theta_{a}^{\prime},\theta_{c}\leftarrow \dot{\theta}_{c}^{\prime},\alpha_{\lambda}\leftarrow \alpha_{\lambda}^{\prime}$ +19: return $\theta_{a},\theta_{c},\lambda$ + +Meta-parameters, inner and outer losses: The meta-parameter is defined as $\eta = \alpha_{\lambda}$ . The inner loss is composed of three losses, the actor, critic and Lagrange loss respectively. The actor and critic losses are the same as in RC-D4PG. The Lagrange multiplier loss is defined as: $L_{lagrange}(\lambda) = \exp (\alpha_{\lambda})\lambda (\beta -J_C^\pi)$ where $\alpha_{\lambda}$ is the meta-parameter as defined above. The meta-parameter is wrapped inside an exponential function to magnify the effect of $\alpha_{\lambda}$ while also ensuring non-negativity of the effective learning rate. The inner loss updates are + +$$ +\left[ \begin{array}{c} \theta_ {a} ^ {\prime} \\ \theta_ {c} ^ {\prime} \\ \lambda^ {\prime} \end{array} \right] = \left[ \begin{array}{c} \theta_ {a} \\ \theta_ {c} \\ \lambda \end{array} \right] - \left[ \begin{array}{c} f (\tau , \theta_ {a}, \eta) \\ f (\tau , \theta_ {c}, \eta) \\ f (\tau , \lambda , \eta) \end{array} \right] = \left[ \begin{array}{c} \theta_ {a} \\ \theta_ {c} \\ \lambda \end{array} \right] - \left[ \begin{array}{c} \alpha_ {\theta_ {a}} \frac {d L _ {\text {a c t o r}} (\theta_ {a})}{d \theta_ {a}} \\ \alpha_ {\theta_ {c}} \frac {d L _ {\text {c r i t i c}} (\theta_ {c} , \lambda)}{d \theta_ {c}} \\ \alpha_ {1} \frac {d L _ {\text {l a g r a n g e}} (\lambda)}{d \lambda} \end{array} \right] +$$ + +tor critic and Lagrange multiplier learning rates respectively. The outer loss is defined as $J^{\prime}(\theta_c^\prime (\alpha_\lambda),\lambda^\prime (\alpha_\lambda)) = L_{outer} = L_{critic}(\theta_c^\prime (\alpha_\lambda),\lambda^\prime (\alpha_\lambda))$ . We tried different variants of outer losses and found that this loss empirically yielded the best performance; we discuss this in more detail in the experiments section. This is analogous to formulating MetaL as the following nested optimization problem: $\min_{\alpha_{\lambda}}J^{\prime}(\theta (\alpha_{\lambda}),\lambda (\alpha_{\lambda}))$ , s.t. $\theta ,\lambda \in \arg \min_{\theta ,\lambda \geq 0}\{-J_R^{\pi_\theta} - \lambda (\alpha_\lambda)(\beta -J_C^{\pi_\theta})\}$ . We treat the lower level optimization problem as the Lagrange relaxation objective (inner loss). We then treat the upper level optimization as the meta-gradient objective $J^{\prime}(\theta (\alpha_{\lambda}),\lambda (\alpha_{\lambda}))$ (outer loss). This transforms the optimization problem into soft-constrained optimization since the meta-parameter $\alpha_{\lambda}$ guides the learning of the Lagrange multiplier $\lambda$ to minimize the outer loss while attempting to find a good trade-off between minimizing constraint violations and maximizing return (inner loss). + +As shown in Algorithm [1], the inner loss gradients are computed for $\lambda$ (line 6), $\theta_{c}$ (line 12) and $\theta_{a}$ (line 13) corresponding to the Lagrange multiplier, critic and actor parameters respectively. The Lagrange multiplier is updated by sampling episode penalties which is an empirical estimate of $J_C^\pi$ from a separate penalty replay buffer (line 5) to compute the gradient update. The updated multiplier + +is then utilized in the critic inner update (lines 11 and 12) to ensure that the critic parameters are a function of this new updated Lagrange multiplier. The actor and critic parameters are updated using the training batch, and these updated parameters along with a validation batch are used to compute the outer loss (line 17). The meta-parameter $\alpha_{\lambda}$ is then updated along the gradient of this outer loss with respect to $\eta = \alpha_{\lambda}$ . We next derive the meta-gradient update for $\alpha_{\lambda}$ , and present it in the following theorem (see the Appendix, Section A for the full derivation). Intuition for this meta-gradient update is provided in the experiments section. + +Theorem 1. MetaL gradient update: Let $\beta \geq 0$ be a pre-defined constraint violation threshold, meta-parameter $\eta = \alpha_{\lambda}$ and $J_C^{\pi_\theta} = \mathbb{E}\Big[C(s,a)|s = s_t,a = \pi_\theta (s_t)\Big]$ is the discounted constraint violation function, then, the meta-gradient update is: + +$$ +\alpha_ {\lambda} ^ {\prime} \leftarrow \alpha_ {\lambda} - \alpha_ {\eta} \bigg (- 2 \delta \cdot c (s, a) \cdot \alpha_ {1} \exp (\alpha_ {\lambda}) \cdot \bigg (J _ {C} ^ {\pi_ {\theta}} - \beta \bigg) \bigg (- 2 \alpha_ {\theta_ {c}} (\nabla_ {\theta_ {c} ^ {\prime}} Q _ {\theta_ {c} ^ {\prime}} (s, a)) ^ {T} \nabla_ {\theta_ {c}} Q _ {\theta_ {c}} (s, a) + 1 \bigg) \bigg), +$$ + +where $\delta$ is the TD error; $\alpha_{\theta_c}$ is the critic learning rate and $\alpha_{\eta}$ is the meta-parameter learning rate. + +# 5 EXPERIMENTS + +The experiments were performed using domains from the Real-World Reinforcement Learning (RWRL) suite4, namely cartpole:swingup, walker:walk, quadruped:walk and humanoid:walk. We will refer to these domains as cartpole, walker, quadruped and humanoid from here on in. + +We focus on two types of tasks with constraints: (1) solvable constraint tasks - where the task is solved and the constraints can be satisfied; (2) unsolvable constraint tasks - where the task can be solved but the constraints cannot be satisfied. Unsolvable constraint tasks correspond to tasks where the constraint thresholds are incorrectly set and cannot be satisfied, situations which occur in many real-world problems as motivated in the introduction. The specific constraints we focused on for each domain can be found in the Appendix (Section). The goal is to showcase the soft-constrained performance of MetaL, with respect to reducing constraint violations and maximizing the return in both of these scenarios (solvable and unsolvable constraint tasks) with respect to the baselines. + +The baseline algorithms we focused on for each experiment are D4PG without any constraints, RC-D4PG (i.e., hard constraint satisfaction) and Reward Shaping D4PG (RS-D4PG) (i.e., soft constraint satisfaction). RS-D4PG uses a fixed $\lambda$ for the duration of training. We compare these baselines to MetaL. Note that D4PG, RC-D4PG and MetaL have no prior information regarding the Lagrange multiplier. RC-D4PG and MetaL attempt to learn a suitable multiplier value from scratch, i.e. the initial Lagrange multiplier value is set to 0.0. In contrast, RS-D4PG has prior information (i.e. it uses a pre-selected fixed Lagrange multiplier). + +Experimental Setup: For each domain, the action and observation dimensions are shown in the Appendix, Table 4. The episode length is 1000 steps, the base reward function is computed within the dm_control suite (Tassa et al., 2018). The upper bound reward for each task is 1000. Each task was trained for 20000 episodes. Each variant of D4PG uses the same network architecture (see the Appendix, Table 5 for more details). + +We use different performance metrics to compare overall performance. We track the average episode return $(R)$ , but we also define the penalized return: $R_{\text{penalized}} = R - \kappa \cdot \psi_{\beta, C}$ , which captures the trade-off between achieving optimal performance and satisfying the constraints. Here, $R$ is the average return for the algorithm upon convergence (computed as an average over the previous 100 episodes); $\kappa$ is a fixed constant that determines how much to weight the constraint violation penalty. For the purposes of evaluation, we want to penalize algorithms that consistently violate the constraints and therefore set $\kappa = 1000$ . Since the upper bound of rewards for each domain is 1000, we are essentially weighing equally attaining high performance and satisfying constraints. Finally, $\psi_{\beta, C} = \max(0, J_C^\pi - \beta)$ is defined as the overshoot. Here $\beta$ is the constraint violation threshold and defines the allowable average constraint violations per episode; $J_C^\pi$ is the average constraint violation value per episode upon convergence for a policy $\pi$ . The overshoot, $\psi_{\beta, C}$ , tracks the average constraint violations that are above the allowed constraint violation threshold $\beta$ . + +We investigate each algorithm's performance along a variety of dimensions which include different constraint violation thresholds (see the Appendix, Table 3 for a list of thresholds used), safety + +coefficients and domains. The safety coefficient is a flag in the RWRL suite (Dulac-Arnold et al., 2020a). This flag contains values between 0.0 and 1.0. Reducing the value of the flag ensures that more constraint violations occur per domain per episode. As such, we searched over the values \{0.05, 0.1, 0.2, 0.3\}. These values vary from solvable constraint tasks (e.g., 0.3) to unsolvable constraint tasks (e.g., 0.05). We wanted to see how the algorithms behaved in these extreme scenarios. In addition, we analysed the performance across a variety of different constraint violation thresholds (see Appendix, Table 6). All experiments are averaged across 8 seeds. + +# 5.1 MAIN RESULTS + +We begin by analyzing the performance of our best variant, MetaL, with different outer losses. Then we analyse the overall performance of all methods, followed by dissecting performance along the dimensions of safety coefficient and domain respectively. Finally, we investigate the derived gradient update for MetaL from Theorem 1 and provide intuition for the algorithm's behaviour. + +![](images/dabeab421df99269cf1b0b4c816b84ed3afd2b786a25e34a9e5d5720e2d022b2.jpg) +Figure 1: MetaL performance using different outer losses (left) and comparison with D4PG and RC-D4PG (right). + +![](images/8098013e2224c297e740236b0f806e2a53d5f47deda485395b1cd07da1f8d231.jpg) + +MetaL outer loss: We wanted to determine whether different outer losses would result in improved overall performance. We used the actor loss ( $L_{\text{actor}}$ ) and the combination of the actor and critic losses as the outer loss ( $L_{\text{actor}} + L_{\text{critic}}$ ) and compared them with the original MetaL outer loss ( $L_{\text{critic}}$ ) as well as the other baselines. Figure [1] shows that using just the actor loss results in the worst performance; while using the critic loss always results in better performance. The best performance is achieved by the original critic-only MetaL outer loss. + +There is some intuition for choosing a critic-only outer loss. In MetaL, the critic loss is a function of lambda. As a result, the value of lambda affects the agents ability to minimize this loss and therefore learn an accurate value function. In D4PG, an accurate value function (i.e., the critic) is crucial for learning a good policy (i.e., the actor). This is because the policy relies on an accurate estimate of the value function to learn good actions that maximize the return (see D4PG actor loss). This would explain why adding the actor loss to the outer loss does not have much effect on the final quality of the solution. However, removing the critic loss has a significant effect on the overall solution. + +Overall performance: We averaged the performance of MetaL across all safety coefficients, thresholds and domains and compared this with the relevant baselines. As seen in Table 1, MetaL outperforms all of the baseline approaches by achieving the best trade-off of minimizing constraint violations and maximizing return. This includes all of the soft-constrained optimization baselines (i.e., RS-D4PG variants), D4PG as well as the hard-constrained optimization algorithm RC-D4PG. It is interesting to analyze this table to see that the best reward shaping variants are (1) $RS - 0.1$ which achieves comparable return, but higher overshoot and therefore lower penalized return; (2) $RS - 1.0$ which attains significantly lower return but lower overshoot resulting in lower penalized return. D4PG has the highest return, but this results in significantly higher overshoot. While RC-D4PG attains lower overshoot, it also yields significantly lower overall return. We now investigate this performance in more detail by looking at the performance per safety coefficient and per domain. + +Performance as a function of safety coefficient: We analyzed the average performance per safety coefficient, while averaging across all domains and thresholds. As seen in Figure [right], MetaL achieves comparable average return to that of D4PG. In addition, it significantly outperforms both + +
AlgorithmRpenalizedRmax(0, Jcπ - β)
D4PG432.70 ± 11.99927.660.49
MetaL677.93 ± 25.78921.160.24
RC-D4PG478.60 ± 89.26648.420.17
RS-0.1641.41 ± 26.67906.760.27
RS-1.0511.70 ± 15.50684.300.17
RS-10.0208.57 ± 61.46385.420.18
RS-100.0118.50 ± 62.54314.930.20
+ +Table 1: Overall performance across domains, safety coefficients and thresholds. + +D4PG and RC-D4PG in terms of penalized return. Figure 2 includes the reward shaping baselines. As can be seen in this figure, choosing a different reward shaping value can lead to drastically different performance. This is one of the drawbacks of the RS-D4PG variants. It is possible however, to find comparable RS variants (e.g., $RS - 0.1$ for the lowest safety coefficient of 0.05). However, as can be seen in Figure 3 for the highest safety coefficient and largest threshold, this RS variant fails completely at the humanoid task, further highlighting the instability of the RS approach. Figure 3 which presents the performance of MetaL and the baselines on the highest safety coefficient and largest threshold (to ensure that the constraint task is solvable), shows that MetaL has comparable performance to RC-D4PG (a hard constrained optimization algorithm). This further highlights the power of MetaL whereby it can achieve comparable performance when the constraint task is solvable compared to hard constrained optimization algorithms and state-of-the-art performance when the constraint task is not solvable. + +Performance per domain: When analyzing the performance per domain, averaging across safety coefficients and constraint thresholds, we found that MetaL has significantly better penalized return compared to D4PG and RC-D4PG across the domains. A table of the results can be seen in the Appendix, Figure 7. Note that, as mentioned previously, the RS-D4PG variants fluctuate drastically in performance across domains. + +![](images/2ca6d449980b2fbe4c049823e57c445caa3234044a96391e921f8d1cbdfbc058.jpg) +Figure 2: Performance as a function of safety coefficient. + +![](images/833128195d3e87835fad93f2d14945467dcb57c664d227c489b01006b8b68b48.jpg) +Figure 3: Performance per domain. MetaL compared to baselines in terms of average reward and penalized reward across the highest safety coefficient and largest thresholds for each domain. + +Algorithm behaviour analysis: Since MetaL is a soft-constrained adaptation of RC-D4PG, we next analyze MetaL's gradient update in Theorem 1 to understand why the performance of MetaL differs + +from that of RC-D4PG in two types of scenarios: (1) solvable and (2) unsolvable constraint tasks. For both scenarios, we investigate the performance on cartpole for a constraint threshold of $0.115^{6}$ . + +For (1), we set the safety coefficient to a value of 0.3. The learning curve for this converged setting can be seen in Figure 4 (left). We track 4 different parameters here: the Lagrangian multiplier $\lambda$ (red curve), the mean penalty value $J_{C}^{\pi}$ (orange curve), the meta-parameter $\alpha_{\lambda}$ (black curve) and the scaled Lagrangian learning rate $\alpha_{1} \cdot \exp(\alpha_{\lambda})$ (green curve). The threshold $\beta$ is shown as the blue dotted line. Initially there are many constraint violations. This corresponds to a large difference for $J_{C}^{\pi} - \beta$ (orange curve minus blue dotted line) which appears in the gradient in Theorem 1. As a result, the meta-parameter $\alpha_{\lambda}$ increases in value as seen in the figure, and therefore increases the scaled learning rate to modify the value of $\lambda$ such that an improved solution can be found. Once $J_{C}^{\pi}$ is satisfying the constraint in expectation ( $J_{C}^{\pi} - \beta \approx 0$ ), the scaled learning rate drops in value due to $J_{C}^{\pi} - \beta$ being small. This is an attempt by the algorithm to slow down the change in $\lambda$ since a reasonable solution has been found (see the return for MetaL (green curve) in Figure 4 (right)). + +For (2), we set the safety coefficient to a value of 0.05 making the constraint task unsolvable in this domain. The learning curves can be seen in Figure 4 (middle). Even though the constraint task is unsolvable, MetaL still manages to yield a reasonable expected return as seen in Figure 4 (right). This is compared to RC-D4PG that overfits to satisfying the constraint and, in doing so, results in poor average reward performance. This can be seen in Figure 4 (middle) where RC-D4PG has lower overshoot than MetaL for low safety coefficients. However, this is at the expense of poor expected return and penalized return performance as seen in Figure 4 (left). We will now provide some intuition for MetaL performance and relate it to the $\alpha_{\lambda}$ gradient update. + +In this setting, there are consistent constraint violations leading to a large value for $J_C^\pi - \beta$ . At this point an interesting effect occurs. The value of $\alpha_\lambda$ decreases, as seen in the figure, while it tries to adapt the value of $\lambda$ to satisfy the constraint. However, as seen in the gradient update, there is an exponential term $\exp(\alpha_\lambda)$ which scales the Lagrange multiplier learning rate. This quickly drives the gradient down to 0, and consequently the scaled Lagrange multiplier learning rate too, as seen in Figure 4 (middle). This causes $\lambda$ to settle on a value as seen in the figure. At this point the algorithm optimizes for a stable fixed $\lambda$ and as a result finds the best trade-off for expected return at this $\lambda$ value. In summary, MetaL will maximize the expected return for an 'almost' fixed $\lambda$ , whereas RC-D4PG will attempt to overfit to satisfying the constraint resulting in a poor overall solution. + +![](images/ef92ba3bf5960a7b91707d090282ff20a75c9d77ee26ea3627944ebdd2544fa5.jpg) +Figure 4: The learning progress of MetaL for solvable (left) and unsolvable (middle) constraint tasks. In both cases, MetaL attempts to try and maximize the return (right). + +![](images/0f821e395840cfe3f0378c15b0ee20f36f01900c891bb684740b7b7174f8a630.jpg) + +![](images/70e4c76f51ff6686b0efdaba0f4e63de7e887db0671f60bf2467127d1df7e122.jpg) + +# 6 DISCUSSION + +In this paper, we presented a soft-constrained RL technique called MetaL that combines metagratings and constrained RL to find a good trade-off between minimizing constraint violations and maximizing returns. This approach (1) matches the return and constraint performance of a hard-constrained optimization algorithm (RC-D4PG) on "solvable constraint tasks"; and (2) obtains an improved trade-off between maximizing return and minimizing constraint overshoot on "unsolvable constraint tasks" compared to the baselines. (This includes a hard-constrained RL algorithm where the return simply collapses in such a case). MetaL achieves this by adapting the learning rate for the Lagrange multiplier update. This acts as a proxy for adapting the lagrangian multiplier. By amplifying/dampening the gradient updates to the lagrangian during training, the agent is able to influence the tradeoff between maximizing return and satisfying the constraints to yield the behavior of (1) and (2). We also implemented a meta-gradient approach called MeSh that scales and offsets the + +shaped rewards. This approach did not outperform MetaL but is a direction of future work. The algorithm, derived meta-gradient update and a comparison to MetaL can be found in the Appendix, Section B. We show that across safety coefficients, domains and constraint thresholds, MetaL outperforms all of the baseline algorithms. We also derive the meta-gradient updates for MetaL and perform an investigative study where we provide empirical intuition for the derived gradient update that helps explain this meta-gradient variant's performance. We believe the proposed techniques will generalize to other policy gradient algorithms but leave this for future work. + +# REFERENCES + +Abbas Abdelmaleki, Jost Tobias Springenberg, Jonas Degrave, Steven Bohez, Yuval Tassa, Dan Belov, Nicolas Heess, and Martin A. Riedmiller. Relative entropy regularized policy iteration. CoRR, abs/1812.02256, 2018. +Joshua Achiam, David Held, Aviv Tamar, and Pieter Abbeel. Constrained policy optimization. In Proceedings of the 34th International Conference on Machine Learning-Volume 70, pp. 22-31. JMLR.org, 2017. +Eitan Altman. Constrained Markov decision processes, volume 7. CRC Press, 1999. +Gabriel Barth-Maron, Matthew W Hoffman, David Budden, Will Dabney, Dan Horgan, Dhruva Tb, Alistair Muldal, Nicolas Heess, and Timothy Lillicrap. Distributed distributional deterministic policy gradients. arXiv preprint arXiv:1804.08617, 2018. +Marc G Bellemare, Will Dabney, and Rémi Munos. A distributional perspective on reinforcement learning. In Proceedings of the 34th International Conference on Machine Learning-Volume 70, pp. 449-458. JMLR.org, 2017. +Steven Bohez, Abbas Abdelmaleki, Michael Neunert, Jonas Buchli, Nicolas Heess, and Raia Haddell. Value constrained model-free continuous control. arXiv preprint arXiv:1902.04623, 2019. +Stephen Boyd and Lieven Vandenberghe. Convex optimization. Cambridge university press, 2004. +Yinlam Chow, Ofir Nachum, Edgar Duenez-Guzman, and Mohammad Ghavamzadeh. A lyapunov-based approach to safe reinforcement learning, 2018. +Gabriel Dulac-Arnold, Daniel J. Mankowitz, and Todd Hester. Challenges of real-world reinforcement learning. CoRR, abs/1904.12901, 2019. +Gabriel Dulac-Arnold, Nir Levine, Daniel J Mankowitz, Jerry Li, Cosmin Paduraru, Sven Gowal, and Todd Hester. An empirical investigation of the challenges of real-world reinforcement learning. arXiv preprint arXiv:2003.11881, 2020a. +Gabriel Dulac-Arnold, Nir Levine, Daniel J. Mankowitz, Jerry Li, Cosmin Paduraru, Sven Gowal, and Todd Hester. An empirical investigation of the challenges of real-world reinforcement learning, 2020b. +Yonathan Efroni, Shie Mannor, and Matteo Pirotta. Exploration-exploitation in constrained mdps, 2020. +Luca Franceschi, Michele Donini, Paolo Frasconi, and Massimiliano Pontil. Forward and reverse gradient-based hyperparameter optimization, 2017. +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. +Volodymyr Mnih, Koray Kavukcuoglu, David Silver, Andrei A. Rusu, Joel Veness, Marc G. Bellemare, Alex Graves, Martin Riedmiller, Andreas K. Fidjeland, Georg Ostrovski, Stig Petersen, Charles Beattie, Amir Sadik, Ioannis Antonoglou, Helen King, Dharshan Kumaran, Daan Wierstra, Shane Legg, and Demis Hassabis. Human-level control through deep reinforcement learning. Nature, 518(7540):529-533, 2015. +Santiago Patermain, Luiz Chamon, Miguel Calvo-Fullana, and Alejandro Ribeiro. Constrained reinforcement learning has zero duality gap. In Advances in Neural Information Processing Systems, pp. 7555-7565, 2019. + +Alex Ray, Joshua Achiam, and Dario Amodei. Benchmarking safe exploration in deep reinforcement learning. arXiv preprint arXiv:1910.01708, 2019. +Harsh Satija, Philip Amortila, and Joelle Pineau. Constrained markov decision processes via backward value functions. arXiv preprint arXiv:2008.11811, 2020. +David Silver, Julian Schrittwieser, Karen Simonyan, Ioannis Antonoglou, Aja Huang, Arthur Guez, Thomas Hubert, Lucas Baker, Matthew Lai, Adrian Bolton, Yutian Chen, Timothy Lillicrap, Fan Hui, Laurent Sifre, George van den Driessche, Thore Graepel, and Demis Hassabis. Mastering the game of Go without human knowledge. Nature, 550, 2017. +Ankur Sinha, Pekka Malo, and Kalyanmoy Deb. A review on bilevel optimization: from classical to evolutionary approaches and applications. IEEE Transactions on Evolutionary Computation, 22 (2):276-295, 2017. +Richard S Sutton and Andrew G Barto. Reinforcement learning: An introduction. MIT press, 2018. +Yuval Tassa, Yotam Doron, Alistair Muldal, Tom Erez, Yazhe Li, Diego de Las Casas, David Budden, Abbas Abdelmaleki, Josh Merel, Andrew Lefrancq, Timothy P. Lillicrap, and Martin A. Riedmiller. Deepmind control suite. CoRR, abs/1801.00690, 2018. +Chen Tessler, Shahar Givony, Tom Zahavy, Daniel J Mankowitz, and Shie Mannor. A deep hierarchical approach to lifelong learning in apacheft. In AAAI, volume 3, pp. 6, 2017. +Chen Tessler, Daniel J Mankowitz, and Shie Mannor. Reward constrained policy optimization. arXiv preprint arXiv:1805.11074, 2018. +Philip S Thomas, Bruno Castro da Silva, Andrew G Barto, and Emma Brunskill. On ensuring that intelligent machines are well-behaved. arXiv preprint arXiv:1708.05448, 2017. +Vivek Veeriah, Matteo Hessel, Zhongwen Xu, Richard Lewis, Janarthanan Rajendran, Junhyuk Oh, Hado van Hasselt, David Silver, and Satinder Singh. Discovery of useful questions as auxiliary tasks. NeurIPS, 2019. +Zhongwen Xu, Hado van Hasselt, and David Silver. Meta-Gradient Reinforcement Learning. NeurIPS, 2018. +Kenny Young, Baoxiang Wang, and Matthew E. Taylor. Metatrace actor-critic: Online step-size tuning by meta-gradient descent for reinforcement learning control, 2018. +Tom Zahavy, Zhongwen Xu, Vivek Veeriah, Matteo Hessel, Junhyuk Oh, Hado van Hasselt, David Silver, and Satinder Singh. Self-Tuning Deep Reinforcement Learning. 2020. +Ruiyi Zhang, Tong Yu, Yilin Shen, Hongxia Jin, Changyou Chen, and Lawrence Carin. Reward constrained interactive recommendation with natural language feedback, 2020. +Zeyu Zheng, Junhyuk Oh, and Satinder Singh. On learning intrinsic rewards for policy gradient methods. NeurIPS, 2018. \ No newline at end of file diff --git a/balancingconstraintsandrewardswithmetagradientd4pg/images.zip b/balancingconstraintsandrewardswithmetagradientd4pg/images.zip new file mode 100644 index 0000000000000000000000000000000000000000..a1d7b52cef12e0266a2acfa6c77a374b86f71cdb --- /dev/null +++ b/balancingconstraintsandrewardswithmetagradientd4pg/images.zip @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c31e45df6731b78f7756e6740f150af3c55a12ef47f83b54e25b9e8e1e9f2c7e +size 196422 diff --git a/balancingconstraintsandrewardswithmetagradientd4pg/layout.json b/balancingconstraintsandrewardswithmetagradientd4pg/layout.json new file mode 100644 index 0000000000000000000000000000000000000000..53dc8fc495071fa256a94603f6cde9af52e888d9 --- /dev/null +++ b/balancingconstraintsandrewardswithmetagradientd4pg/layout.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6cf027039ea58b1b20aa08507b44f183765c805205ba5200e522f81332974916 +size 374595 diff --git a/batchreinforcementlearningthroughcontinuationmethod/e8a933dc-225e-4a31-8e23-de6a3dce1bdd_content_list.json b/batchreinforcementlearningthroughcontinuationmethod/e8a933dc-225e-4a31-8e23-de6a3dce1bdd_content_list.json new file mode 100644 index 0000000000000000000000000000000000000000..830b4ff487e0aa1a03aefa1b9f62925540d82efe --- /dev/null +++ b/batchreinforcementlearningthroughcontinuationmethod/e8a933dc-225e-4a31-8e23-de6a3dce1bdd_content_list.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:62fb88164f63fc0ffec7de05ef385e7c83184e954bce7d4746371359dfa99f68 +size 71536 diff --git a/batchreinforcementlearningthroughcontinuationmethod/e8a933dc-225e-4a31-8e23-de6a3dce1bdd_model.json b/batchreinforcementlearningthroughcontinuationmethod/e8a933dc-225e-4a31-8e23-de6a3dce1bdd_model.json new file mode 100644 index 0000000000000000000000000000000000000000..eb6203e5d00fc086a1c9d4c2f279e03e5326bd8a --- /dev/null +++ b/batchreinforcementlearningthroughcontinuationmethod/e8a933dc-225e-4a31-8e23-de6a3dce1bdd_model.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:30083cacade4451dd3e02fa2a92a9e5a52f31b24bc804832d76dfae7a0745ba7 +size 84657 diff --git a/batchreinforcementlearningthroughcontinuationmethod/e8a933dc-225e-4a31-8e23-de6a3dce1bdd_origin.pdf b/batchreinforcementlearningthroughcontinuationmethod/e8a933dc-225e-4a31-8e23-de6a3dce1bdd_origin.pdf new file mode 100644 index 0000000000000000000000000000000000000000..7210100da1fd7917727d1f4116e51bb8b4285609 --- /dev/null +++ b/batchreinforcementlearningthroughcontinuationmethod/e8a933dc-225e-4a31-8e23-de6a3dce1bdd_origin.pdf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:481325d5c477f8b7b0eede3a141699b69e9216266f1c4fcb614a7cd057340bcf +size 2147426 diff --git a/batchreinforcementlearningthroughcontinuationmethod/full.md b/batchreinforcementlearningthroughcontinuationmethod/full.md new file mode 100644 index 0000000000000000000000000000000000000000..a16ab2e42afc9f7bd14e81f2a2e8a80f94693c22 --- /dev/null +++ b/batchreinforcementlearningthroughcontinuationmethod/full.md @@ -0,0 +1,239 @@ +# BATCH REINFORCEMENT LEARNING THROUGH CONTINUATION METHOD + +Yijie Guo1 Shengyu Feng1 Nicolas Le Roux2 Ed Chi2 Honglak Lee1,2 Minmin Chen2 + +1University of Michigan 2Google AI + +{guoyijie,shengyuf}@umich.edu {nlr,edchi,honglak,minminc}@google.com + +# ABSTRACT + +Many real-world applications of reinforcement learning (RL) require the agent to learn from a fixed set of trajectories, without collecting new interactions. Policy optimization under this setting is extremely challenging as: 1) the geometry of the objective function is hard to optimize efficiently; 2) the shift of data distributions causes high noise in the value estimation. In this work, we propose a simple yet effective policy iteration approach to batch RL using global optimization techniques known as continuation. By constraining the difference between the learned policy and the behavior policy that generates the fixed trajectories, and continuously relaxing the constraint, our method 1) helps the agent escape local optima; 2) reduces the error in policy evaluation in the optimization procedure. We present results on a variety of control tasks, game environments and a recommendation task to empirically demonstrate the efficacy of our proposed method. + +# 1 INTRODUCTION + +While RL is fundamentally an online learning paradigm, many practical applications of RL algorithms, e.g., recommender systems [5, 7] or autonomous driving [36], fall under the batch RL setup. Under this setting, the agent is asked to learn its policy from a fixed set of interactions collected by a different (and possibly unknown) policy commonly referred to as the behavior policy, without the flexibility to gather new interactions. Realizing the interactive nature of online RL has been hindering its wider adoptions, researchers strive to bring these techniques offline [24, 11, 20, 23, 31, 12, 21, 2, 32, 8]. We focus on policy optimization under batch RL setup. As pointed out in [3, 26], even with access to the exact gradient, the loss surface of the objective function maximizing the expected return is difficult to optimize, leading to slow convergence. Chen et al. [8] show that the objective function of expected return exhibits sub-optimal plateaus and exponentially many local optima in the worst case. Batch setup makes the learning even harder as it adds large variance to the gradient estimate, especially when the learned policy differs from the behavior policy used to generate the fixed trajectories. Recent works propose to constrain the size of the policy update [27, 28] or the distance between the learned policy and the behavior policy [14, 21]. The strength of that constraint is a critical hyperparameter that can be hard to tune [28], as a loose constraint does not alleviate the distribution shift while a strict one results in conservative updates. + +Here we propose to address the challenges using continuation methods [35, 6, 17]. Continuation methods attempt to solve the global optimization problem by progressively solving a sequence of new objectives that can be optimized more efficiently and then trace back the solutions to the original one. We change the objective function of policy optimization by including an additional term penalizing the KL divergence between the parameterized policy $\pi_{\theta}$ and the behavior policy. We then gradually decrease the weight of that penalty, eventually converging to optimizing the expected return. With this additional constraint, we benefit from more accurate policy evaluation in the early stage of training as the target policy is constrained to be close to the behavior policy. As training continues, we relax the constraint and allow for more aggressive improvement over the behavior policy as long as the policy evaluation is still stable and relatively reliable, i.e. with a small enough variance. By doing so, the proposed method exhaustively exploits the information in the collected trajectories while avoiding the overestimation of state-action pairs that lack support. + +The contributions of this paper are as follows: (1) We propose a soft policy iteration approach to batch RL through the continuation method. (2) We theoretically verify that in the tabular setting with exact gradients, maximizing KL regularized expected return leads to faster convergence than optimizing the expected return alone. Also, our method converges to the globally optimal policy if there are sufficient data samples for accurate value estimation. (3) We demonstrate the effectiveness of our method in reducing errors in value estimation using visualization; (4) We empirically verify the advantages of our method over existing batch RL methods on various complex tasks. + +# 2 RELATED WORK + +Batch Reinforcement Learning. Off-policy reinforcement learning has been extensively studied [11, 20, 30, 23, 31], with many works [12, 21, 2] focusing on variants of Q-learning. Fujimoto et al. [12], Kumar et al. [21] investigated the extrapolation error in batch RL resulting from the mismatch of state-action visitation distribution between the fixed dataset and the current policy, and proposed to address it by constraining the action distribution of the current policy from deviating much from the training dataset distribution. Recent works [29, 33] studied policy iteration under batch RL. The Q function is estimated in the policy evaluation step without special treatment while the policy updates are regularized to remain close to the prior policy with a fixed constraint. To further reduce uncertainty in Q learning, an ensemble of Q networks [21, 29] and distributional Q-function [2, 33] are introduced for the value estimation. [34, 18] use the KL divergence between the target policy and the behavior policy as a regularization term in the policy update and/or value estimation. The constraint is controlled by a fixed weight of the KL regularization or a fixed threshold for the KL divergence. While all of these works apply a fixed constraint determined by a sensitive hyperparameter to control the distance between the behavior/prior policy and the target policy, we focus on gradually relaxed constraints. + +Constrained Policy Updates. Several works [27, 1, 15] studied constrained policy updates in online settings. Kakade & Langford [19] show that large policy updates can be destructive, and propose a conservative policy iteration algorithm to find an approximately optimal policy. Schulman et al. [27] constrain the KL divergence between the old policy and new policy to guarantee policy improvement in each update. Grau-Moya et al. [15] force the policy to stay close to a learned prior distribution over actions, deriving a mutual-information regularization between state and action. Cheng et al. [9] propose to regularize in the function space. Again these methods focused on a fixed constraint while we are interested in continuing relaxing the constraint to maximize the expected return eventually. Also none of these methods have been extensively tested for batch RL with fixed training data. + +Continuation Method. Continuation method [35] is a global optimization technique. The main idea is to transform a nonlinear and highly non-convex objective function to a series of smoother and easier to optimize objective functions. The optimization procedure is successively applied to the new functions that are progressively more complex and closer to the original non-context problem, to trace their solutions back to the original objective function. Chapelle et al. [6] use the continuation method to optimize the objective function of semi-supervised SVMs and reach lower test error compared with algorithms directly minimizing the original objective. Hale et al. [17] apply the continuation method to 11-regularized problems and demonstrate better performance for compressed sensing problems. Inspired by prior works, we employ the continuation method to transform the objective of batch RL problems by adding regularization. We gradually decrease the regularization weight to trace the solution back to the original problem. + +# 3 METHOD + +In classical RL, an agent interacts with the environment while updating its policy. At each step $t$ , the agent observes a state $s_t \in S$ , selects an action $a_t \in \mathcal{A}$ according to its policy to receive a reward $r_t = r(s_t, a_t) : S \times \mathcal{A} \to \mathbb{R}$ and transitions to the next state $s_{t+1} \sim \mathcal{P}(\cdot | s_t, a_t)$ . The state value of a policy $\pi$ at a state $s$ is $V^{\pi}(s) = \mathbb{E}_{s_0 = s, a_t \sim \pi(\cdot | s_t), s_{t+1} \sim \mathcal{P}(\cdot | s_t, a_t)} [\sum_{t=0}^{\infty} \gamma^t r(s_t, a_t)]$ . $\gamma \in [0,1]$ is the discounting factor. At each step, the agent updates the policy $\pi$ so that the expected return $V^{\pi}(\rho) = \mathbb{E}_{s \sim \rho} [V^{\pi}(s)]$ (where $\rho$ is the initial state distribution) is maximized. + +In batch RL, the agent is not allowed to interact with the environment during policy learning. Instead it has access to a fixed set of trajectories sampled from the environment according to a behavior policy1. A trajectory $\{(s_0, a_0, r_0), (s_1, a_1, r_1), \dots, (s_T, a_T, r_T)\}$ is generated by sampling $s_0$ from the initial state distribution $\rho$ , sampling the action $a_t \sim \beta(\cdot | s_t)$ at the state $s_t$ and moving to $s_{t+1} \sim \mathcal{P}(\cdot | s_t, a_t)$ for each step $t \in [0, 1, \dots, T]$ . The length $T$ can vary among trajectories. We then convert the generated trajectories to a dataset $\mathcal{D} = \{(s_i, a_i, r_i, s_i')\}_{i=1}^N$ , where $s_i'$ is the next state after $s_i$ in a trajectory. + +The goal of batch RL is to learn a parameterized policy $\pi_{\theta}$ with the provided dataset to maximize the expected return $V^{\pi}(\rho)$ . In Sec. 3.1, we will first introduce a new objective function $\tilde{V}^{\pi,\tau}(\rho)$ , i.e. the expected return of policy $\pi$ with KL regularization term and the regularization weight $\tau$ . With exact gradients, $\tilde{V}^{\pi,\tau}(\rho)$ can be optimized more efficiently than the original objective $V^{\pi}(\rho)$ . With the + +continuation method, solving a sequence of optimization problems for $\tilde{V}^{\pi,\tau}(\rho)$ with decaying value of $\tau$ converges toward optimizing $V^{\pi}(\rho)$ and makes the optimization easier. In Sec. 3.2, we derive soft policy iteration with KL regularization to optimize $\tilde{V}^{\pi,\tau}(\rho)$ , without the assumption of exact gradients. Finally, in Sec. 3.3, we propose a practical batch RL algorithm with value estimation for target policy based on this theory. + +# 3.1 OPTIMIZING EXPECTED RETURN WITH KL REGULARIZATION + +In batch RL, the distribution of the trajectories generated by the behavior policy can be very different from that of the learned policy. We thus restrict the learned policy to stay close to the behavior policy via the regularization of KL divergence. Define the soft state value of a policy $\pi$ at a state $s$ as + +$$ +\tilde {V} ^ {\pi , \tau} (s) = \mathbb {E} _ {s _ {0} = s, a _ {t} \sim \pi (\cdot | s _ {t}), s _ {t + 1} \sim \mathcal {P} (\cdot | s _ {t}, a _ {t})} \left[ \sum_ {t = 0} ^ {\infty} \gamma^ {t} \left(r \left(s _ {t}, a _ {t}\right) - \tau \log \frac {\pi \left(a _ {t} \mid s _ {t}\right)}{\beta \left(a _ {t} \mid s _ {t}\right)}\right) \right], \tag {1} +$$ + +where the temperature parameter $\tau$ controls the deviation from $\beta$ . The new objective function becomes $\tilde{V}^{\pi, \tau}(\rho) = \mathbb{E}_{s \sim \rho}[\tilde{V}^{\pi, \tau}(s)]$ . This KL regularized objective differs from the original objective $V^{\pi}(\rho)$ , which however can be recovered as $\tau \to 0$ . + +As pointed out in [3], even with exact gradients, the objective function $V^{\pi}(\rho)$ is still difficult to optimize due to its highly non-smooth landscape. Mei et al. [26] further prove that, in a tabular setting with softmax parameterized policy and exact gradients, the vanilla policy gradient method (i.e. directly updating the parameters of policy $\pi$ to maximize $V^{\pi}(\rho)$ with gradient descent) converges to the global optimal policy at a convergence rate $\mathcal{O}(1 / t)$ , while the entropy-regularized policy gradient enjoys a significantly faster linear convergence rate $O(e^{-t})$ . Motivated by this line of work, we investigate the convergence rate of optimizing $\tilde{V}^{\pi,\tau}(\rho)$ with the exact gradient descent and compare it with the vanilla policy gradient method. We study the smoothness and Łojasiewicz inequality for the function $\tilde{V}^{\pi,\tau}(\rho)$ to prove the convergence rate, similar to [26]. The detailed proofs of all following theorems are provided in the appendix. + +Theorem 1. In the tabular setting with softmax parameterized policy $\pi_{\theta}$ , maximizing $\tilde{V}^{\pi,\tau}(\rho)$ using policy gradient with the learning rate $\eta = \frac{(1 - \gamma)^3}{(8M + \tau(4 + 8\log A))}$ , for all $t > 1$ , we have + +$$ +\tilde {V} ^ {\pi_ {\tau} ^ {*}, \tau} (\rho) - \tilde {V} ^ {\pi_ {\theta_ {t}}, \tau} (\rho) \leq C \cdot e ^ {- C _ {\tau} (t - 1)} \cdot \frac {M + \tau \log A}{(1 - \gamma) ^ {2}} +$$ + +where $\pi_{\tau}^{*}$ is the optimal policy maximizing $\tilde{V}^{\pi, \tau}(\rho)$ , $M$ is the bound of the absolute value of $r(s, a) + \tau \log \beta(a|s)$ , $A$ is the size of action space, $S$ is the size of state space, $C_{\tau} \propto \frac{(1 - \gamma)^4}{(8M / \tau + 4 + 8\log A)\cdot S}$ , and $C$ is a constant independent with $t$ and $\tau$ . + +Theorem 1 states that KL regularized expected return $\tilde{V}^{\pi, \tau}(\rho)$ can be optimized with a convergence rate $\mathcal{O}(e^{-t})$ rather than the $\mathcal{O}(1/t)$ , the convergence rate of vanilla policy gradient for expected return alone. The faster convergence inspires us to optimize $\tilde{V}^{\pi, \tau}(\rho)$ to reach policy $\pi_{\tau}^{*}$ , then use $\pi_{\tau}^{*}$ as initialization, gradually decrease the temperature $\tau$ towards 0, and eventually move from $\pi_{\tau}^{*}$ to $\pi^{*} = \arg \max_{\pi} V^{\pi}(\rho)$ . With a reasonable value of $\tau$ , we enjoy a linear convergence rate toward $\pi_{\tau}^{*}$ from the randomly initialized policy $\pi_{\theta}$ . As $\tau$ decreases, $\pi_{\tau}^{*}$ gets closer to $\pi^{*}$ . The final optimization of $V^{\pi_{\theta}}(\rho)$ from $\pi_{\tau}^{*}$ can be much faster than from a randomly initialized $\pi_{\theta}$ . + +We construct a toy example to illustrate this motivation. In the grid world (Fig. 1a), the start state, annotated with 'S', is in the center and the terminal states are marked in yellow. There are only two states with positive rewards (0.9 and 1). There are four actions {up, down, left, right}. A badly initialized policy $\pi_{\theta_0}$ is shown as arrows in Fig. 1a). The initialization results in a poor policy, having high tendency to go right toward a terminal state with zero reward. The vanilla policy gradient method (i.e. maximizing $V^{\pi}(\rho)$ with true gradient) starting from this initial point takes more than 7000 iterations to escape a sub-optimal solution (Fig. 1b). In contrast, we escape the sub-optimal solution much faster when ap + +plying the continuation method to update the policy havior policy $\beta (\cdot |s) = [u_{1},u_{2},u_{3},u_{4}]$ with $u_{i},i =$ + +![](images/1bd81b01fc190950c566b050f6b90810389ab114ab5eb98e3c41422047189af3.jpg) +(a) + +![](images/41403df970b82800d65e109fa63e7e0b84491f7f53cfab0a4fa37b69327f7375.jpg) +(b) +Figure 1: (a) A grid world with sparse rewards. (b) Learning curve of the value of learned policy $\pi_{\theta_i}$ . We conduct a hyper-parameter search for the learning rate 5,1,0.5,0.1,0.05,0.01,0.005,0.001 and report the best performance for each method. + +Algorithm 1 Soft Policy Iteration through Continuation Method +1: Initialize: actor network $\pi_{\theta}$ , ensemble critic network $\{Q_{\phi^{(1)}}, Q_{\phi^{(2)}}, \dots, Q_{\phi^{(K)}}\}$ , behavior policy network $\beta_{\psi}$ , penalty coefficient $\tau$ , decay rate $\lambda$ , number of iterations $I$ for each $\tau$ +2: Input: training dataset $D = \{(s_i, a_i, r_i, s_i')\}_{i=0}^N$ +3: for update $j = 0, 1, \dots$ do +4: Sample batch of data $\{(s_i, a_i, r_i)\}_{i=1}^B$ from $D$ +5: # Learn the behavior policy with behavior cloning objective +6: Update $\psi$ to maximize $\frac{1}{B} \sum_{i=1}^B \log \beta_{\psi}(a_i | s_i)$ +7: # Train the critic network +8: Update $\phi^{(k)}$ to minimize the temporal difference $\frac{1}{B} \sum_{i=1}^B (r_i + \gamma V(s_i')) - Q_{\phi^{(k)}}(s_i, a_i)^2$ +9: where $V(s) = \frac{1}{K} \sum_{k=1}^K \mathbb{E}_{a \sim \pi_{\theta}(\cdot | s)} (Q_{\phi^{(k)}}(s, a)) - \tau KL(\pi_{\theta}(\cdot | s) | \beta_{\psi}(\cdot | s))$ +10: # Train the actor network +11: Update $\theta$ to maximize $\frac{1}{B} \sum_{i=1}^B \left[ \frac{1}{K} \sum_{k=1}^K \mathbb{E}_{a \sim \pi_{\theta}(\cdot | s_i)} (Q_{\phi^{(k)}}(s_i, a)) - \tau KL(\pi_{\theta}(\cdot | s_i) | \beta_{\psi}(\cdot | s_i) \right]$ +12: # Decay the weight of KL regularization $\tau$ for every $I$ updates +13: if $j \mod I = 0$ then +14: $\tau \gets \tau * \lambda$ +15: end if +16: end for + +normalized for each state $s$ . In Fig. 1b, as we decrease $\tau$ , the value of learned policy $\pi_{\theta_i}$ for each iteration $i$ quickly converges to the optimal value. In other words, optimizing a sequence of objective functions $\tilde{V}^{\pi ,\tau}(\rho)$ can reach the optimal solution for $V^{\pi}(\rho)$ significantly faster. + +# 3.2 SOFT POLICY ITERATION WITH KL REGULARIZATION + +As explained in the previous section, we focus on the new objective function $\tilde{V}^{\pi,\tau}(\rho)$ , which can be optimized more efficiently, and use continuation method to relax toward optimizing $V^{\pi}(\rho)$ . Batch RL adds the complexity of estimating the gradient of $\tilde{V}^{\pi,\tau}(\rho)$ with respect to $\pi$ from a fixed set of trajectories. We propose to adapt soft actor-critic[16], a general algorithm to learn optimal maximum entropy policies in batch RL for our use case. We change the entropy regularization to KL regularization and derive the soft policy iteration to learn KL regularized optimal policy. For a policy $\pi$ and temperature $\tau$ , the soft state value is defined in Eq. 1 and soft Q function is defined as: + +$$ +\tilde {Q} ^ {\pi , \tau} (s, a) = r (s, a) + \gamma \mathbb {E} _ {s ^ {\prime} \sim \mathcal {P} (\cdot | s, a)} \tilde {V} ^ {\pi , \tau} \left(s ^ {\prime}\right) \tag {2} +$$ + +In the step of soft policy evaluation, we aim to compute the value of policy $\pi$ according to the minimum KL divergence objective $\tilde{V}^{\pi,\tau}(\rho) = \mathbb{E}_{s\sim \rho}[\tilde{V}^{\pi,\tau}(s)]$ . According to Lemma 1 in Appendix, the soft Q value can be computed by repeatedly applying the soft bellman backup operator. + +$$ +\mathcal {T} ^ {\pi , \tau} Q (s, a) = r (s, a) + \gamma \mathbb {E} _ {s ^ {\prime} \sim \mathcal {P} (\cdot | s, a)} (V (s ^ {\prime})), \text {w h e r e} V (s) = \mathbb {E} _ {a \sim \pi (\cdot | s)} \left[ Q (s, a) - \tau \log \frac {\pi (a | s)}{\beta (a | s)} \right]. +$$ + +In the step of policy improvement, we maximize the expected return based on Q-value evaluation with the KL divergence regularization. The following policy update can be guaranteed to result in an improved policy in terms of its soft value (Lemma 2 in Appendix). + +$$ +\pi_ {n e w} (\cdot | s) = \arg \max _ {\pi \in \Pi} \left[ \mathbb {E} _ {a \sim \pi (\cdot | s)} \left(\tilde {Q} ^ {\pi_ {o l d}, \tau} (s, a)\right) - \tau K L (\pi (\cdot | s) | \beta (\cdot | s)) \right] \tag {3} +$$ + +$$ +\mathrm {w h e r e} \qquad K L (\pi (\cdot | s) | \beta (\cdot | s)) = \mathbb {E} _ {a \sim \pi (\cdot | s)} \left[ \log \frac {\pi (a | s)}{\beta (a | s)} \right] +$$ + +The soft policy iteration algorithm alternates between the soft policy evaluation and soft policy improvement, and it will provably converge to the optimal policy maximizing the objective $\hat{V}^{\pi ,\tau}(\rho)$ . + +Theorem 2. Repeated application of soft policy evaluation and soft policy improvement converges to a policy $\pi_{\tau}^{*}$ such that $\tilde{Q}^{\pi_{\tau}^{*},\tau}(s,a)\geq \tilde{Q}^{\pi ,\tau}(s,a)$ for any $\pi \in \Pi$ and $(s,a)\in S\times \mathcal{A}$ . + +The soft policy iteration finds a policy $\pi_{\tau}^{*}$ with optimal soft Q value for each state-action pair and hence gets the optimal value of $V^{\pi, \tau}(\rho)$ . Here we propose to use the soft policy iteration to solve objectives $\tilde{V}^{\pi, \tau}(\rho)$ with decreasing value of $\tau$ and move back to the objective $V^{\pi}(\rho)$ as $\tau = 0$ . The method is guaranteed to asymptotically converge to the optimal policy $\pi^{*}$ for the objective $V^{\pi}(\rho)$ . + +![](images/313ca6fe8270625ec10c0f587af1b5e0ccbad4545d26cb1ddf41ae49c26a45c0.jpg) +Figure 2: Visualization of the error in soft Q value estimation and quality of the learned policy. In the first four columns, triangles represent the error for actions that move in different directions. Darker color indicates higher error. To investigate the performance of the learned policy $\pi_{\theta_{1000}}$ , the length of arrows represents the probability of taking each action in each states. We run $\pi_{\theta_{1000}}$ in the grid world and visualize the visitation count in the last column (heatmap). Darker color means more visitation. + +Theorem 3. Let $\pi_{\tau}^{*}(a|s)$ be the optimal policy from soft policy iteration with fixed temperature $\tau$ . We have $\pi_{\tau}^{*}(a|s) \propto \exp \left(\frac{\tilde{Q}^{\pi_{\tau}^{*},\tau}(s,a)}{\tau}\right)\beta(a|s)$ . As $\tau \to 0$ , $\pi_{\tau}^{*}(a|s)$ will take the optimal action $a^{*}$ with optimal $Q$ value for state $s$ . + +# 3.3 ERROR IN VALUE ESTIMATE + +In the previous section, we show that the soft policy iteration with the continuation method provably converges to the global optimal policy maximizing expected return. However, in batch RL with a fixed dataset and limited samples, we cannot perform the soft policy iteration with KL regularization in its exact form. Specifically, in the policy evaluation step, when the learned policy $\pi$ deviates for the behavior policy $\beta$ , and chooses the state-action pair $(s,a)$ rarely visited by $\beta$ , the estimation of target $r(s,a) + \gamma \mathbb{E}_{s' \sim \mathcal{P}(\cdot | s,a)}(V(s'))$ can be very noisy. The error in the value estimate $Q(s,a)$ will be further propagated to other state-action pairs through the bellman update. Finally, inaccurate value estimation will cause errors in the policy improvement step, resulting in a worse policy. On the other hand, if we constrain the learned policy $\pi$ to be very close to the behavior policy $\beta$ , we can expect the policy evaluation to be reliable and safely update the learned policy. The tight constraint however prevents $\pi$ to be much better than $\beta$ due to the conservative update. + +On the grid world, we study this problem of value estimation with different values of $\tau$ . Figure 2 visualizes the propagation of Q value estimation errors and the learned policies. We assume a mediocre behavior policy tending to move left and down. For the rarely visited states in the upper right part of the grid, there are errors in the value estimation of $\tilde{Q}^{\pi,\tau}(s,a)$ , i.e. $|Q(s,a) - \tilde{Q}^{\pi,\tau}(s,a)| > 0$ where $Q(s,a)$ is the Q value we learn during training and $\tilde{Q}^{\pi,\tau}(s,a)$ is the ground truth soft Q value. Because the bad initial policy (Fig. 1a) tends to move towards the right part, without a strong KL regularization, the policy evaluation can be problematic due to the errors of value estimation in the right part of the grid world. In Fig. 2, with a small KL regularization weight $\tau = 0.001$ , the first row shows that errors even propagate to the frequently visited states by the behavior policy. On the other hand, when we set a large value of $\tau = 1$ (second row), the error $|Q(s,a) - \tilde{Q}^{\pi,\tau}(s,a)|$ is smaller. Yet the performance of the learned policy is not much better than the behavior policy. Our continuation method gradually moves the policy update between these two spectra. The value estimation benefits from the gradually relaxed KL regularization and the errors remain small. The last column of Fig. 2 visualizes the learned policy in these methods. With constant $\tau = 0.001$ , the wrong value estimates in some states mislead the agent. It fails to visit any terminal state and gets stuck at the state in dark orange. With constant $\tau = 1$ , the tight constraint of KL divergence makes the learned policy close to the behavior policy, mostly visiting the left bottom part of the environment. With continuation method, the agent learns to always take the optimal path moving left directly and obtains the highest expected return. More details of this example are provided in the appendix. + +In the toy example, gradually relaxing KL regularization towards zero alleviates the propagation of errors in the soft Q estimate and helps the agent converge to the optimal policy. In more complicated domains, we find that as $\tau$ decays close to 0, the policy evaluation is still erroneous. To mitigate this issue, we introduce an ensemble of critic networks $\{Q_{\phi^{(1)}},Q_{\phi^{(2)}},\dots ,Q_{\phi^{(K)}}\}$ to approximate the soft Q value, and monitor the variance of value estimation in different critic networks to measure the uncertainty. Given a batch of data samples $\{s_i\}_{i = 1}^B\subset \mathcal{D}$ , $var(Q^{\pi}) = \frac{1}{B}\sum_{i = 1}^{B}\mathbb{E}_{a\sim \pi (\cdot |s_i)}var(Q_{\phi^{(1)}}(s_i,a),Q_{\phi^{(2)}}(s_i,a),\dots ,Q_{\phi^{(k)}}(s_i,a))$ indicates whether the current policy $\pi$ tends to take actions with highly noisy value estimation. + +Our method is summarized in Algorithm 1. Instead of running the soft policy evaluation and policy improvement until convergence, we alternate between optimizing the critic network and actor network with stochastic gradient descent. We set $\tau$ to large value initially and let the KL divergence term dominate the objective, thus performing behavior cloning. We record a moving average of the Q value estimation variance $var(Q^{\pi ,\tau_0})$ over 1000 updates at the end of the phase. After that, we decay the temperature gradually with $\lambda = 0.9$ every $I$ steps. When the moving average of the Q value estimation variance $var(Q^{\pi ,\tau})$ is large compared with the initial value $var(Q^{\pi ,\tau_0})$ (i.e. at the end of behavior cloning), we no longer trust the value estimate under the current temperature $\tau$ and take the policy checkpointed before the temperature decays to this $\tau$ as our solution. + +# 4 EXPERIMENTS + +# 4.1 MUJOCO + +We evaluate our method with several baselines on continuous control tasks. We train a Proximal Policy Optimization agent [28] with entropy regularization for 1000 million steps in the environments. We parameterize the policy using Gaussian policies where the mean is a linear function of the agent's state $\theta^T s$ and variance is an identity matrix to keep the policy simple as introduced in [3]. To generate training datasets $\mathcal{D}$ with varying quality, we construct the behavior policy by mixing the well-trained policy $\mathcal{N}(\theta_{opt}^T s, 0.5\mathbb{I})$ , i.e. checkpoint with the highest score during training, and a poor policy $\mathcal{N}(\theta_0^T s, 0.5\mathbb{I})$ , i.e. checkpoint at the beginning of the training, with the weight $\alpha$ . Then the behavior policy $\beta(\cdot|s)$ is $\mathcal{N}((1 - \alpha)\theta_{opt} + \alpha \theta_0)^T s, 0.5\mathbb{I})$ . We generate trajectories and store a total of one million data samples from the mixed behavior for different values of the coefficient $\alpha$ . + +The architecture of the target policy is the same as the behavior policy. We consider six baseline approaches: BCQ [14], BEAR [21], ABM+SVG [29], CRR [33], CQL [22], BRAC [34]. For a fair comparison, the architectures of the ensemble critic network and the policy network are the same in the baselines and our method, except BCQ which has no policy network. To evaluate and compare the methods, we run the learned policy in the environments for 100 episodes and report the average episode reward in Fig 3. As for the continuation method, we report the score of policy checkpointed last with reasonable value estimation variance, as explained in Section 3.3. For the baselines, we report the score of the final policy when we terminate the training at 1.5M updates. + +
αBCQBEARABMCRRCQLBRACOurs
Hopper0.21908.0 ±327.01661.2 ± 163.31814.2 ±176.91861.5 ±112.81962.6 ±194.12375.4 ± 181.32085.8 ±204.8
0.4876.0 ±462.21028.9 ± 49.01113.0 ±201.31281.0 ±218.21262.0±116.7991.0 ± 39.51463.7 ±195.0
0.6429.9 ±198.1898.6 ± 28.21402.6 ±350.5791.1 ±87.0609.1 ±35.1573.7 ± 41.61524.3 ±511.4
0.8450.3 ±174.23.3 ± 4.33.6 ±0.0304.2 ±36.3295.7 ±41.983.6 ± 113.1234.8 ±26.4
Half Cheetah0.21765.8 ±41.22143.4 ± 18.32168.3 ±26.12154.1 ±6.62105.7 ±37.21649.3 ± 64.32149.3 ±32.9
0.41336.4 ±35.61809.3 ± 18.11914.7 ±13.21860.1 ±38.21811.9 ±60.71744.5 ± 15.11839.9 ±16.9
0.6513.6 ±35.61149.9 ± 39.31457.9 ±36.41161.7 ±11.71156.6 ±43.31245.1 ± 67.21524.8±37.6
0.8179.0 ±14.1700.6 ± 11.4600.4 ±8.6572.8 ±14.3605.8 ±44.5499.1 ± 11.0595.4± 19.1
Walker0.21400.2 ±30.91414.6 ± 19.41405.2 ±57.31442.9 ±19.51385.2 ±73.4437.5 ± 638.91467.3 ±45.2
0.4965.9 ±69.01179.5 ± 21.21259.3 ±27.71233.5 ±35.8979.6 ±83.51311.5 ± 29.71223.5±15.7
0.6266.3 ±56.9486.3 ± 43.3664.9 ±37.5529.9 ±46.8218.8 ±16.9559.1 ± 37.6872.9 ±228.7
0.83.5 ±5.010.9 ± 0.95.9 ±0.610.7 ±0.33.3 ±6.55.6 ± 0.97.0± 6.3
+ +Table 1: Results on Mujoco. We show the average and standard deviation of the scores in 5 independent runs. +Tab. 1 shows that our method outperforms all the baselines on 5 settings. On the dataset with relatively reasonable quality (i.e. $\alpha = 0.2, 0.4, 0.6$ ), ours performs comparable or better than the baselines. With $\alpha = 0.2$ , i.e., close to optimal behavior policy, all the methods perform similarly and + +![](images/699d7ce586b9d067ba5ac665694fce7047ec73da2ea5088c9126b1de469eef53.jpg) +Figure 3: Learning curves of average reward over 5 runs on Mujoco tasks with $\alpha = 0.6$ . The shaded area with light color indicates the standard deviation of the reward. The gray vertical lines on the yellow curves indicate where we take the checkpointed policy, according to the measure of Q value variance, as our final solution. + +![](images/37012ff1d5d7aad47b576352b23d28d968f6bc3b6984366555a82014a41cbc81.jpg) + +![](images/c4ef7c950df502931ee595bc4027aca1cd4d768f907109a9c31550f8182c3f4d.jpg) + +
AmidarAsterixBreakoutEnduroMsPacmanQbertSeaquestSpaceInvaders
BCQ154.4 ±11.02466.7 ±273.4203.8 ±19.6604.7 ±39.72299.7 ±150.24088.3 ±332.84420.0 ±548.7726.5 ±58.7
REM32.0 ±3.5741.4 ±236.73.1 ±0.0244.2 ±19.81997.4 ±6.42062.9 ±511.5474.0 ±61.9678.4 ±41.3
CQL145.0 ±1.62618.7 ±102.1253.7 ±14.4206.6 ±5.82234.6 ±203.24094.7 ±74.14652.6 ±2017.1493.5 ±11.4
Ours174.5 ±7.13476.7 ±229.0199.0 ±32.0922.9 ±31.72494.0 ±301.34732.5 ±172.59935.0 ±1175.91070.3 ±137.1
+ +Table 2: Results on Atari, the mean and standard deviation of scores achieved in 3 independent runs. + +one can achieve a good return by simply cloning the behavior policy. With $\alpha = 0.8$ , i.e., low-quality behavior policy, there are few good trajectories in the dataset for any methods to learn. The advantage of our method is most obvious when $\alpha = 0.6$ (Fig. 3), as the dataset contains trajectories of both high and low cumulative rewards. Our method can learn from the relatively large number of good trajectories and at the same time deviate from the behavior policy to avoid those bad trajectories and achieve higher rewards. In Fig. 3, 'Constant' is the method of optimizing KL regularized expected reward with constant value of $\tau$ . We search several values of $\tau$ and report the best result. We can see that gradually relaxing constraint performs better than the fixed constraint. In Fig. 3(left), as $\tau$ decays to close to 0, the learned policy can degrade due to errors in the Q estimation, the stopping condition explained in Section 3.3 is however able to identify a good policy before the degenerating point. More experimental details are in the Appendix. + +# 4.2 ATARI + +We further study our method on several Atari games from the Arcade Learning Environment (ALE) [4]. The rich observation space requires more complicated policies and makes policy optimization even more challenging. We focus on eight games and generate the datasets as discussed in Fujimoto et al. [13]. We use a mediocre DQN agent, trained online for 10 million timesteps (40 million frames). The performance of the DQN agent is shown as 'Online DQN' in Fig. 4. We add exploratory noise on the DQN agent (at 10 million timesteps) to gather a new set of 10 million transitions, similar to [13]. The line "Behavior" in Fig. 4 shows the average of trajectory reward in the dataset $\mathcal{D}$ . The dataset $\mathcal{D}$ is used to train each offline RL agent. We compare with BCQ [13], REM [2] and CQL [22] because they are recently proposed offline RL algorithms and work well on Atari domain. For evaluation, we run 10 episodes on the Atari games with the learned policies and record the average episode reward (Fig. 4). Tab. 2 summarizes the performance of BCQ, REM and CQL after 6M updates. For our method, we report the score before the variance of Q estimate becomes too high. + +Our approach achieves higher scores than the baselines on 7 out of 8 games, and perform comparably on the other one. Agarwal et al. [2] reports that REM performs well in the dataset consisting of the entire replay experiences collected in the online training of the DQN agent for 50M timesteps (200M frames). We hypothesize that learning on the entire replay experience makes the setup easier as the training dataset contains more exploratory and higher quality trajectories. With the dataset of much smaller size and worse quality, REM performs poorly in this single behavioral policy setting. We use the same architecture of the critic network for both our method and BCQ with ensemble of 4 Q networks. As mentioned in [13], BCQ only matches the performance of the online DQN on most games. In contrast, ours is able to outperform online DQN significantly on several games. As presented in [22], on the Atari dataset, CQL performs better than REM, while our method outperforms CQL in 7 out of 8 datasets. + +![](images/e2b44829fff56f9f42d098317d7a38f886d3b0b896b6ab518e030eed94709c2d.jpg) + +![](images/7631e12f66bb6b44879baf6ed2dcf0659b363e9051e6c502051013f2b097148d.jpg) + +![](images/676b47cd9b4cc5f6e33aa5bca64f292a1282f3e0783b2184dcff684ba9753806.jpg) + +![](images/020795762657aeb161fc0ff8c0a0b1da45f077e1fd38c108101150ed6ff9ffc5.jpg) + +![](images/ff815c7b31565da8bc0c0741cc8011ed8952568de6224b3127be7028012039f7.jpg) +Figure 4: Learning curves of average reward over 3 runs on Atari games. + +![](images/f8bee7ba84197d48fd476fc1dfb70b438b7e723c31b27bd91e648feae3c53a26.jpg) + +![](images/c09adfc7f74902df9e43f577f4057ddaf41cd5ccbfeaf89a65ac1b3cb7fb2d91.jpg) + +![](images/16865ef6145b62734f3a7cf4291208b86aed2cde927e832517c1f171f3e66723.jpg) + +
data with avg. reward 0.49data with avg. reward 0.63data avg. reward 0.81
sample size30,00060,00030,00060,00030,00060,000
Cross-Entropy74.3±0.0173.5±0.0182.0±0.0181.3±0.0186.7±0.0085.6±0.00
IPS80.5±0.0382.1±0.0286.4±0.0288.0±0.0187.2 ± 0.0290.0 ± 0.01
Ours83.0±0.0185.8±0.0088.7±0.0190.1±0.0089.4±0.0090.5±0.00
+ +Table 3: Results on MovieLens dataset. The number is precision at 10, i.e., the percent of recommended movies getting positive feedback when we use the well-trained policy to recommend top-10 movies to the test users. We report the mean and standard deviation of the precision over 20 independent runs, + +# 4.3 RECOMMENDER + +We also showcase our proposed method for building a softmax recommender agent. We use a publicly available dataset MovieLens-1M, a popular benchmark for recommender system. There are 1 million ratings of 3,900 movies (with the title and genre features) from 6,040 users (with demographic features). The problem of recommending movies for each user can be converted to a contextual bandit problem, where we aim to learn a target policy $\pi_{\theta}(a|s)$ selecting the proper action (movie) $a$ for each state (user) $s$ to get a high reward (rating) $r$ in a single step. The ratings of 5-score are converted to binary rewards using a cutoff of 4. To evaluate whether a learned target policy works well, ideally we should run the learned policy in real recommendation environments. However, such environments for online test are rarely publicly available. Thus, we use the online simulation method. We train a simulator to predict the immediate binary feedback from user and movie features, and the well-trained simulator can serve as a proxy of the real online environments, because it outputs the feedback for any user-movie pair. Similar to [25], we train the simulator with all records of logged feedback in MovieLens-1M dataset. The behavior policy is trained with partial data in MovieLens-1M. We then construct the bandit datasets $\mathcal{D} = \{s_i,a_i,r_i,\beta (a_i|s_i)\}_{i = 1}^N$ of different size and quality, by using different behavior policies $\beta$ to select movies $a_i$ for users $s_i$ and getting the binary feedback $r_i$ from the well-trained simulator. We train offline RL agents on the generated dataset $\mathcal{D}$ and use the simulator to evaluate the learned policies on a held-out test set of users. + +We compare our method with two baselines, as they are commonly used in current industrial recommender systems [10, 7]. (1) Cross-Entropy: a supervised learning method for the softmax recommender where the learning objective is the cross-entropy loss $J_{CE}(\theta) = -\frac{1}{N}\sum_{i=1}^{N}r_i\log \pi_\theta(a_i|s_i)$ (2) IPS: the off-policy policy gradient method introduced in [7] with the learning objective $J_{IPS}(\theta) = -\frac{1}{N}\sum_{i=1}^{N}\frac{sg(\pi_\theta(a_i|s_i))}{\beta(s_i,a_i)}r_i\log \pi_\theta(a_i|s_i)$ where $sg$ indicates a stop-gradient operation. $J_{IPS}(\theta)$ produces the same gradient as that of the function $-\frac{1}{N}\sum_{i=1}^{N}r_i\frac{\pi_\theta(a_i|s_i)}{\beta(a_i|s_i)}$ . Thus, minimizing the loss $J_{IPS}(\theta)$ is to maximizing the expected return with importance sampling. (3) Ours: in the bandit setting, we simply perform IPS with gradually decaying KL regularization since estimating the soft Q from bellman update is not needed. Tab. 3 clearly demonstrates the advantage of our proposed method over the baselines. IPS can be viewed as vanilla policy gradient with importance sampling to correct the distribution shift. Our method clearly outperforms it across datasets collected using different behavior policies. + +# 5 CONCLUSION + +We propose a simple yet effective approach, soft policy iteration algorithm through continuation method to alleviate two challenges in policy optimization under batch reinforcement learning: (1) highly non-smooth objective function which is difficult to optimize (2) high variance in value estimates. We provide theoretical ground and visualization tools to help understand this technique. We demonstrate its efficacy on multiple complex tasks. + +# REFERENCES + +[1] Joshua Achiam, David Held, Aviv Tamar, and Pieter Abbeel. Constrained policy optimization. In Proceedings of the 34th International Conference on Machine Learning-Volume 70, pp. 22–31. JMLR.org, 2017. +[2] Rishabh Agarwal, Dale Schuurmans, and Mohammad Norouzi. Striving for simplicity in off-policy deep reinforcement learning. arXiv preprint arXiv:1907.04543, 2019. +[3] Zafarali Ahmed, Nicolas Le Roux, Mohammad Norouzi, and Dale Schuurmans. Understanding the impact of entropy on policy optimization. In International Conference on Machine Learning, pp. 151-160. PMLR, 2019. +[4] Marc G Bellemare, Yavar Naddaf, Joel Veness, and Michael Bowling. The arcade learning environment: An evaluation platform for general agents. Journal of Artificial Intelligence Research, 47:253-279, 2013. +[5] James Bennett, Stan Lanning, et al. The netflix prize. Citeseer, 2007. +[6] Olivier Chapelle, Mingmin Chi, and Alexander Zien. A continuation method for semi-supervised svms. In Proceedings of the 23rd international conference on Machine learning, pp. 185-192, 2006. +[7] Minmin Chen, Alex Beutel, Paul Covington, Sagar Jain, Francois Belletti, and Ed H Chi. Top- $k$ off-policy correction for a reinforce recommender system. In Proceedings of the Twelfth ACM International Conference on Web Search and Data Mining, pp. 456-464, 2019. +[8] Minmin Chen, Ramki Gummadi, Chris Harris, and Dale Schuurmans. Surrogate objectives for batch policy optimization in one-step decision making. In Advances in Neural Information Processing Systems, pp. 8825-8835, 2019. +[9] Richard Cheng, Abhinav Verma, Gabor Orosz, Swarat Chaudhuri, Yisong Yue, and Joel W Burdick. Control regularization for reduced variance reinforcement learning. arXiv preprint arXiv:1905.05380, 2019. +[10] Paul Covington, Jay Adams, and Emre Sargin. Deep neural networks for youtube recommendations. In Proceedings of the 10th ACM conference on recommender systems, pp. 191-198, 2016. +[11] Damien Ernst, Pierre Geurts, and Louis Wehenkel. Tree-based batch mode reinforcement learning. Journal of Machine Learning Research, 6(Apr):503-556, 2005. +[12] Scott Fujimoto, David Meger, and Doina Precup. Off-policy deep reinforcement learning without exploration. arXiv preprint arXiv:1812.02900, 2018. +[13] Scott Fujimoto, Edoardo Conti, Mohammad Ghavamzadeh, and Joelle Pineau. Benchmarking batch deep reinforcement learning algorithms. arXiv preprint arXiv:1910.01708, 2019. +[14] Scott Fujimoto, David Meger, and Doina Precup. Off-policy deep reinforcement learning without exploration. In International Conference on Machine Learning, pp. 2052-2062, 2019. +[15] Jordi Grau-Moya, Felix Leibfried, and Peter Vrancx. Soft q-learning with mutual-information regularization. 2018. + +[16] 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. +[17] Elaine T Hale, Wotao Yin, and Yin Zhang. A fixed-point continuation method for 11-regularized minimization with applications to compressed sensing. CAAM TR07-07, Rice University, 43:44, 2007. +[18] Natasha Jaques, Asma Ghandeharioun, Judy Hanwen Shen, Craig Ferguson, Agata Lapedriza, Noah Jones, Shixiang Gu, and Rosalind Picard. Way off-policy batch deep reinforcement learning of implicit human preferences in dialog. arXiv preprint arXiv:1907.00456, 2019. +[19] Sham Kakade and John Langford. Approximately optimal approximate reinforcement learning. In ICML, volume 2, pp. 267-274, 2002. +[20] Shivaram Kalyanakrishnan and Peter Stone. Batch reinforcement learning in a complex domain. In Proceedings of the 6th international joint conference on Autonomous agents and multiagent systems, pp. 94. ACM, 2007. +[21] Aviral Kumar, Justin Fu, Matthew Soh, George Tucker, and Sergey Levine. Stabilizing off-policy q-learning via bootstrapping error reduction. In Advances in Neural Information Processing Systems, pp. 11784-11794, 2019. +[22] Aviral Kumar, Aurick Zhou, George Tucker, and Sergey Levine. Conservative q-learning for offline reinforcement learning. arXiv preprint arXiv:2006.04779, 2020. +[23] Sascha Lange, Thomas Gabel, and Martin Riedmiller. Batch reinforcement learning. In Reinforcement learning, pp. 45-73. Springer, 2012. +[24] 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. +[25] Jiaqi Ma, Zhe Zhao, Xinyang Yi, Ji Yang, Minmin Chen, Jiaxi Tang, Lichan Hong, and Ed H Chi. Off-policy learning in two-stage recommender systems. In Proceedings of The Web Conference 2020, pp. 463-473, 2020. +[26] Jincheng Mei, Chenjun Xiao, Csaba Szepesvari, and Dale Schuurmans. On the global convergence rates of softmax policy gradient methods. arXiv preprint arXiv:2005.06392, 2020. +[27] John Schulman, Sergey Levine, Pieter Abbeel, Michael Jordan, and Philipp Moritz. Trust region policy optimization. In International conference on machine learning, pp. 1889-1897, 2015. +[28] John Schulman, Filip Wolski, Prafulla Dhariwal, Alec Radford, and Oleg Klimov. Proximal policy optimization algorithms. arXiv preprint arXiv:1707.06347, 2017. +[29] Noah Y Siegel, Jost Tobias Springenberg, Felix Berkenkamp, Abbas Abdelmaleki, Michael Neunert, Thomas Lampe, Roland Hafner, and Martin Riedmiller. Keep doing what worked: Behavioral modelling priors for offline reinforcement learning. arXiv preprint arXiv:2002.08396, 2020. +[30] Alex Strehl, John Langford, Lihong Li, and Sham M Kakade. Learning from logged implicit exploration data. In Advances in Neural Information Processing Systems, pp. 2217-2225, 2010. +[31] Adith Swaminathan and Thorsten Joachims. Batch learning from logged bandit feedback through counterfactual risk minimization. Journal of Machine Learning Research, 16(1):1731-1755, 2015. +[32] Philip Thomas and Emma Brunskill. Data-efficient off-policy policy evaluation for reinforcement learning. In International Conference on Machine Learning, pp. 2139-2148, 2016. +[33] Ziyu Wang, Alexander Novikov, Konrad Žolna, Jost Tobias Springenberg, Scott Reed, Bobak Shahrriari, Noah Siegel, Josh Merel, Caglar Gulcehre, Nicolas Heess, et al. Critic regularized regression. arXiv preprint arXiv:2006.15134, 2020. + +[34] Yifan Wu, George Tucker, and Ofir Nachum. Behavior regularized offline reinforcement learning. arXiv preprint arXiv:1911.11361, 2019. +[35] Zhijun Wu. The effective energy transformation scheme as a special continuation approach to global optimization with application to molecular conformation. SIAM Journal on Optimization, 6(3):748-768, 1996. +[36] Fisher Yu, Wenqi Xian, Yingying Chen, Fangchen Liu, Mike Liao, Vashisht Madhavan, and Trevor Darrell. Bdd100k: A diverse driving video database with scalable annotation tooling. arXiv preprint arXiv:1805.04687, 2018. \ No newline at end of file diff --git a/batchreinforcementlearningthroughcontinuationmethod/images.zip b/batchreinforcementlearningthroughcontinuationmethod/images.zip new file mode 100644 index 0000000000000000000000000000000000000000..f6c6ae44adebd96d3aa5a082e313fa1750f1da12 --- /dev/null +++ b/batchreinforcementlearningthroughcontinuationmethod/images.zip @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:cb3a11cd396aaf46448e23f13855f2678da97ce8280b97788d49e371887d6cb3 +size 576220 diff --git a/batchreinforcementlearningthroughcontinuationmethod/layout.json b/batchreinforcementlearningthroughcontinuationmethod/layout.json new file mode 100644 index 0000000000000000000000000000000000000000..c173586260517926808055662b8ab488fed7e4b4 --- /dev/null +++ b/batchreinforcementlearningthroughcontinuationmethod/layout.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:939a9062c7bdb09efbac7ee35cd3311c34638dc30526d96cbb08c042652b44a6 +size 438143 diff --git a/bayesiancontextaggregationforneuralprocesses/e9ed5707-401b-44ea-b04c-3e4637bb35d2_content_list.json b/bayesiancontextaggregationforneuralprocesses/e9ed5707-401b-44ea-b04c-3e4637bb35d2_content_list.json new file mode 100644 index 0000000000000000000000000000000000000000..befa413baa098bcce3f532d1d17b18b2dde4c8b6 --- /dev/null +++ b/bayesiancontextaggregationforneuralprocesses/e9ed5707-401b-44ea-b04c-3e4637bb35d2_content_list.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f5a4bb689ddcfd8e4cf81bf7980b159bb59459f161e4b213e4746a371edc56a9 +size 168688 diff --git a/bayesiancontextaggregationforneuralprocesses/e9ed5707-401b-44ea-b04c-3e4637bb35d2_model.json b/bayesiancontextaggregationforneuralprocesses/e9ed5707-401b-44ea-b04c-3e4637bb35d2_model.json new file mode 100644 index 0000000000000000000000000000000000000000..5ade2c12eff0bd5a6e25fbc23b4111443152ce7e --- /dev/null +++ b/bayesiancontextaggregationforneuralprocesses/e9ed5707-401b-44ea-b04c-3e4637bb35d2_model.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:80529ba56af806e91cd5bc3995768870fe01901a972d8ac96d3901d2d0b3d603 +size 206306 diff --git a/bayesiancontextaggregationforneuralprocesses/e9ed5707-401b-44ea-b04c-3e4637bb35d2_origin.pdf b/bayesiancontextaggregationforneuralprocesses/e9ed5707-401b-44ea-b04c-3e4637bb35d2_origin.pdf new file mode 100644 index 0000000000000000000000000000000000000000..8fb3d9bda0487228e36d4308f678cf9d5c347f57 --- /dev/null +++ b/bayesiancontextaggregationforneuralprocesses/e9ed5707-401b-44ea-b04c-3e4637bb35d2_origin.pdf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2dadc16c85f86730ab685ca75391c934af64d806178943118fba7d367b8c1bdb +size 1924448 diff --git a/bayesiancontextaggregationforneuralprocesses/full.md b/bayesiancontextaggregationforneuralprocesses/full.md new file mode 100644 index 0000000000000000000000000000000000000000..79a851d6bf0ff32f56bb3560e54db0e8dac62bb0 --- /dev/null +++ b/bayesiancontextaggregationforneuralprocesses/full.md @@ -0,0 +1,734 @@ +# BAYESIAN CONTEXT AGGREGATION FOR NEURAL PROCESSES + +Michael Volpp1,2* + +Fabian Flürenbrock1 + +Lukas Grossberger1 + +Christian Daniel + +Gerhard Neumann2,3 + +1Bosch Center for Artificial Intelligence, Renningen, Germany +$^{2}$ Karlsruhe Institute of Technology, Karlsruhe, Germany +3University of Tübingen, Tübingen, Germany + +# ABSTRACT + +Formulating scalable probabilistic regression models with reliable uncertainty estimates has been a long-standing challenge in machine learning research. Recently, casting probabilistic regression as a multi-task learning problem in terms of conditional latent variable (CLV) models such as the Neural Process (NP) has shown promising results. In this paper, we focus on context aggregation, a central component of such architectures, which fuses information from multiple context data points. So far, this aggregation operation has been treated separately from the inference of a latent representation of the target function in CLV models. Our key contribution is to combine these steps into one holistic mechanism by phrasing context aggregation as a Bayesian inference problem. The resulting Bayesian Aggregation (BA) mechanism enables principled handling of task ambiguity, which is key for efficiently processing context information. We demonstrate on a range of challenging experiments that BA consistently improves upon the performance of traditional mean aggregation while remaining computationally efficient and fully compatible with existing NP-based models. + +# 1 INTRODUCTION + +Estimating statistical relationships between physical quantities from measured data is of central importance in all branches of science and engineering and devising powerful regression models for this purpose forms a major field of study in statistics and machine learning. When judging representative power, neural networks (NNs) are arguably the most prominent member of the regression toolbox. NNs cope well with large amounts of training data and are computationally efficient at test time. On the downside, standard NN variants do not provide uncertainty estimates over their predictions and tend to overfit on small datasets. Gaussian processes (GPs) may be viewed as complementary to NNs as they provide reliable uncertainty estimates but their cubic (quadratic) scaling with the number of context data points at training (test) time in their basic formulation affects the application on tasks with large amounts of data or on high-dimensional problems. + +Recently, a lot of interest in the scientific community is drawn to combinations of aspects of NNs and GPs. Indeed, a prominent formulation of probabilistic regression is as a multi-task learning problem formalized in terms of amortized inference in conditional latent variable (CLV) models, which results in NN-based architectures which learn a distribution over target functions. Notable variants are given by the Neural Process (NP) (Garnelo et al., 2018b) and the work of Gordon et al. (2019), which presents a unifying view on a range of related approaches in the language of CLV models. + +Inspired by this research, we study context aggregation, a central component of such models, and propose a new, fully Bayesian, aggregation mechanism for CLV-based probabilistic regression models. + +To transform the information contained in the context data into a latent representation of the target function, current approaches typically employ a mean aggregator and feed the output of this aggregator into a NN to predict a distribution over global latent parameters of the function. Hence, aggregation and latent parameter inference have so far been treated as separate parts of the learning pipeline. Moreover, when using a mean aggregator, every context sample is assumed to carry the same amount of information. Yet, in practice, different input locations have different task ambiguity and, therefore, samples should be assigned different importance in the aggregation process. In contrast, our Bayesian aggregation mechanism treats context aggregation and latent parameter inference as one holistic mechanism, i.e., the aggregation directly yields the distribution over the latent parameters of the target function. Indeed, we formulate context aggregation as Bayesian inference of latent parameters using Gaussian conditioning in the latent space. Compared to existing methods, the resulting aggregator improves the handling of task ambiguity, as it can assign different variance levels to the context samples. This mechanism improves predictive performance, while it remains conceptually simple and introduces only negligible computational overhead. Moreover, our Bayesian aggregator can also be applied to deterministic model variants like the Conditional NP (CNP) (Garnelo et al., 2018a). + +In summary, our contributions are (i) a novel Bayesian Aggregation (BA) mechanism for context aggregation in NP-based models for probabilistic regression, (ii) its application to existing CLV architectures as well as to deterministic variants like the CNP, and (iii) an exhaustive experimental evaluation, demonstrating BA's superiority over traditional mean aggregation. + +# 2 RELATED WORK + +Prominent approaches to probabilistic regression are Bayesian linear regression and its kernelized counterpart, the Gaussian process (GP) (Rasmussen and Williams, 2005). The formal correspondence of GPs with infinite-width Bayesian NNs (BNNs) has been established in Neal (1996) and Williams (1996). A broad range of research aims to overcome the cubic scaling behaviour of GPs with the number of context points, e.g., through sparse GP approximations (Smola and Bartlett, 2001; Lawrence et al., 2002; Snelson and Ghahramani, 2005; Quinonero-Candela and Rasmussen, 2005), by deep kernel learning (Wilson et al., 2016), by approximating the posterior distribution of BNNs (MacKay, 1992; Hinton and van Camp, 1993; Gal and Ghahramani, 2016; Louizos and Welling, 2017), or, by adaptive Bayesian linear regression, i.e., by performing inference over the last layer of a NN which introduces sparsity through linear combinations of finitely many learned basis functions (Lazaro-Gredilla and Figueiras-Vidal, 2010; Hinton and Salakhutdinov, 2008; Snoek et al., 2012; Calandra et al., 2016). An in a sense complementary approach aims to increase the data-efficiency of deep architectures by a fully Bayesian treatment of hierarchical latent variable models ("DeepGPs") (Damianou and Lawrence, 2013). + +A parallel line of research studies probabilistic regression in the multi-task setting. Here, the goal is to formulate models which are data-efficient on an unseen target task by training them on data from a set of related source tasks. Bardenet et al. (2013); Yogatama and Mann (2014), and Golovin et al. (2017) study multi-task formulations of GP-based models. More general approaches of this kind employ the meta-learning framework (Schmidhuber, 1987; Thrun and Pratt, 1998; Vilalta and Drissi, 2005), where a model's training procedure is formulated in a way which incentivizes it to learn how to solve unseen tasks rapidly with only a few context examples ("learning to learn", "few-shot learning" (Fei-Fei et al., 2006; Lake et al., 2011)). A range of such methods trains a meta-learner to learn how to adjust the parameters of the learner's model (Bengio et al., 1991; Schmidhuber, 1992), an approach which has recently been applied to few-shot image classification (Ravi and Larochelle, 2017), or to learning data-efficient optimization algorithms (Hochreiter et al., 2001; Li and Malik, 2016; Andrychowicz et al., 2016; Chen et al., 2017; Perrone et al., 2018; Volpp et al., 2019). Other branches of meta-learning research aim to learn similarity metrics to determine the relevance of context samples for the target task (Koch et al., 2015; Vinyals et al., 2016; Snell et al., 2017; Sung et al., 2017), or explore the application of memory-augmented neural networks for meta-learning (Santoro et al., 2016). Finn et al. (2017) propose model-agnostic meta-learning (MAML), a general framework for fast parameter adaptation in gradient-based learning methods. + +A successful formulation of probabilistic regression as a few-shot learning problem in a multi-task setting is enabled by recent advances in the area of probabilistic meta-learning methods which allow a quantitative treatment of the uncertainty arising due to task ambiguity, a feature particularly + +relevant for few-shot learning problems. One line of work specifically studies probabilistic extensions of MAML (Grant et al., 2018; Ravi and Larochelle, 2017; Rusu et al., 2018; Finn et al., 2018; Kim et al., 2018). Further important approaches are based on amortized inference in multi-task CLV models (Heskes, 2000; Bakker and Heskes, 2003; Kingma and Welling, 2013; Rezende et al., 2014; Sohn et al., 2015), which forms the basis of the Neural Statistician proposed by Edwards and Storkey (2017) and of the NP model family (Garnelo et al., 2018b; Kim et al., 2019; Louizos et al., 2019). Gordon et al. (2019) present a unifying view on many of the aforementioned probabilistic architectures. Building on the conditional NPs (CNPs) proposed by Garnelo et al. (2018a), a range of NP-based architectures, such as Garnelo et al. (2018b) and Kim et al. (2019), consider combinations of deterministic and CLV model architectures. Recently, Gordon et al. (2020) extended CNPs to include translation equivariance in the input space, yielding state-of-the-art predictive performance. + +In this paper, we also employ a formulation of probabilistic regression in terms of a multi-task CLV model. However, while in previous work the context aggregation mechanism (Zaheer et al., 2017; Wagstaff et al., 2019) was merely viewed as a necessity to consume context sets of variable size, we take inspiration from Becker et al. (2019) and emphasize the fundamental connection of latent parameter inference with context aggregation and, hence, base our model on a novel Bayesian aggregation mechanism. + +# 3 PRELIMINARIES + +We present the standard multi-task CLV model which forms the basis for our discussion and present traditional mean context aggregation (MA) and the variational inference (VI) likelihood approximation as employed by the NP model family (Garnelo et al., 2018a; Kim et al., 2019), as well as an alternative Monte Carlo (MC)-based approximation. + +Problem Statement. We frame probabilistic regression as a multi-task learning problem. Let $\mathcal{F}$ denote a family of functions $f_{\ell}:\mathbb{R}^{d_x}\to \mathbb{R}^{d_y}$ with some form of shared statistical structure. + +We assume to have available data sets $\mathcal{D}_{\ell} \equiv \{(x_{\ell,i}, y_{\ell,i})\}_i$ of evaluations $y_{\ell,i} \equiv f_{\ell}(x_{\ell,i}) + \varepsilon$ from a subset of functions ("tasks") $\{f_{\ell}\}_{\ell=1}^{L} \subset \mathcal{F}$ with additive Gaussian noise $\varepsilon \sim \mathcal{N}\left(0, \sigma_n^2\right)$ . From this data, we aim to learn the posterior predictive distribution $p(y_{\ell}|x_{\ell}, \mathcal{D}_{\ell}^{c})$ over a (set of) $y_{\ell}$ , given the corresponding (set of) inputs $x_{\ell}$ as well as a context set $\mathcal{D}_{\ell}^{c} \subset \mathcal{D}_{\ell}$ . + +The Multi-Task CLV Model. We formalize the multi-task learning problem in terms of a CLV model (Heskes, 2000; Gordon et al., 2019) as shown in Fig. 1. The model employs task-specific global latent variables $z_{\ell} \in \mathbb{R}^{d_z}$ , as well as a task-independent latent variable $\theta$ , capturing the statistical structure shared between tasks. To learn $\theta$ , we split the data into context sets $\mathcal{D}_{\ell}^{c} \equiv \{(x_{\ell,n}^{c}, y_{\ell,n}^{c})\}_{n=1}^{N_{\ell}}$ and target sets $\mathcal{D}_{\ell}^{t} \equiv \{(x_{\ell,m}^{t}, y_{\ell,m}^{t})\}_{m=1}^{M_{\ell}}$ and maximize the posterior predictive likelihood function + +![](images/49679a4f32ae3872d41ae492ed682e769beffd23828c23b973ab2be6f9f3559f.jpg) +Figure 1: Multi-task CLV model with task-specific global latent variables $z_{\ell}$ and a task-independent variable $\theta$ describing statistical structure shared between tasks. + +$$ +\prod_ {\ell = 1} ^ {L} p \left(y _ {\ell , 1: M _ {\ell}} ^ {t} \mid x _ {\ell , 1: M _ {\ell}} ^ {t}, \mathcal {D} _ {\ell} ^ {c}, \theta\right) = \prod_ {\ell = 1} ^ {L} \int p \left(z _ {\ell} \mid \mathcal {D} _ {\ell} ^ {c}, \theta\right) \prod_ {m = 1} ^ {M _ {\ell}} p \left(y _ {\ell , m} ^ {t} \mid z _ {\ell}, x _ {\ell , m} ^ {t}, \theta\right) d z _ {\ell} \tag {1} +$$ + +w.r.t. $\theta$ . In what follows, we omit task indices $\ell$ to avoid clutter. + +Likelihood Approximation. Marginalizing over the task-specific latent variables $z$ is intractable for reasonably complex models, so one has to employ some form of approximation. The NP-family of models (Garnelo et al., 2018b; Kim et al., 2019) uses an approximation of the form + +$$ +\log p \left(y _ {1: M} ^ {t} \mid x _ {1: M} ^ {t}, \mathcal {D} ^ {c}, \theta\right) \gtrsim \mathbb {E} _ {q _ {\phi} (z | \mathcal {D} ^ {c} \cup \mathcal {D} ^ {t})} \left[ \sum_ {m = 1} ^ {M} \log p \left(y _ {m} ^ {t} \mid z, x _ {m} ^ {t}, \theta\right) + \log \frac {q _ {\phi} (z | \mathcal {D} ^ {c})}{q _ {\phi} (z | \mathcal {D} ^ {c} \cup \mathcal {D} ^ {t})} \right]. \tag {2} +$$ + +Being derived using a variational approach, this approximation utilizes an approximate posterior distribution $q_{\phi}(z|\mathcal{D}^c) \approx p(z|\mathcal{D}^c,\theta)$ . Note, however, that it does not constitute a proper evidence lower bound for the posterior predictive likelihood since the intractable latent posterior $p(z|\mathcal{D}^c,\theta)$ has been replaced by $q_{\phi}(z|\mathcal{D}^c)$ in the nominator of the rightmost term (Le et al., 2018). An alternative approximation, employed for instance in Gordon et al. (2019), also replaces the intractable latent posterior distribution by an approximate distribution $q_{\phi}(z|\mathcal{D}^c) \approx p(z|\mathcal{D}^c,\theta)$ and uses a Monte-Carlo (MC) approximation of the resulting integral based on $K$ latent samples, i.e., + +$$ +\log p \left(y _ {1: M} ^ {t} \mid x _ {1: M} ^ {t}, \mathcal {D} ^ {c}, \theta\right) \approx - \log K + \log \sum_ {k = 1} ^ {K} \prod_ {m = 1} ^ {M} p \left(y _ {m} ^ {t} \mid z _ {k}, x _ {m} ^ {t}, \theta\right), \quad z _ {k} \sim q _ {\phi} (z | \mathcal {D} ^ {c}). \tag {3} +$$ + +Note that both approaches employ approximations $q_{\phi}(z|\mathcal{D}^c)$ of the latent posterior distribution $p(z|\mathcal{D}^c,\theta)$ and, as indicated by the notation, amortize inference in the sense that one single set of parameters $\phi$ is shared between all context data points. This enables efficient inference at test time, as no per-data-point optimization loops are required. As is standard in the literature (Garnelo et al., 2018b; Kim et al., 2019), we represent $q_{\phi}(z|\mathcal{D}^c)$ and $p(y_m^t |z,x_m^t,\theta)$ by NNs and refer to them as the encoder (enc, parameters $\phi$ ) and decoder (dec, parameters $\theta$ ) networks, respectively. These networks set the means and variances of factorized Gaussian distributions, i.e., + +$$ +q _ {\phi} (z | \mathcal {D} ^ {c}) = \mathcal {N} (z | \mu_ {z}, \operatorname {d i a g} (\sigma_ {z} ^ {2})) , \quad \mu_ {z} = \operatorname {e n c} _ {\mu_ {z}, \phi} (\mathcal {D} ^ {c}), \quad \sigma_ {z} ^ {2} = \operatorname {e n c} _ {\sigma_ {z} ^ {2}, \phi} (\mathcal {D} ^ {c}) , \tag {4} +$$ + +$$ +p \left(y _ {m} ^ {t} \mid z, x _ {m} ^ {t}, \theta\right) = \mathcal {N} \left(y _ {m} ^ {t} \mid \mu_ {y}, \operatorname {d i a g} \left(\sigma_ {y} ^ {2}\right)\right), \mu_ {y} = \det _ {\mu_ {y}, \theta} \left(z, x _ {m} ^ {t}\right), \sigma_ {y} ^ {2} = \det _ {\sigma_ {y} ^ {2}, \theta} \left(z, x _ {m} ^ {t}\right). \tag {5} +$$ + +Context Aggregation. The latent variable $z$ is global in the sense that it depends on the whole context set $\mathcal{D}^c$ . Therefore, some form of aggregation mechanism is required to enable the encoder to consume context sets $\mathcal{D}^c$ of variable size. To represent a meaningful operation on sets, such an aggregation mechanism has to be invariant to permutations of the context data points. Zaheer et al. (2017) characterize possible aggregation mechanisms w.r.t. this permutation invariance condition, resulting in the structure of traditional aggregation mechanisms depicted in Fig. 2(a). Each context data tuple $(x_n^c, y_n^c)$ is first mapped onto a latent observation $r_n = \mathrm{enc}_{r,\phi}(x_n^c, y_n^c) \in \mathbb{R}^{d_r}$ . Then, a permutation-invariant operation is applied to the set $\{r_n\}_{n=1}^N$ to obtain an aggregated latent observation $\bar{r}$ . One prominent choice, employed for instance in Garnelo et al. (2018a), Kim et al. (2019), and Gordon et al. (2019), is to take the mean, i.e., + +$$ +\bar {r} = \frac {1}{N} \sum_ {n = 1} ^ {N} r _ {n}. \tag {6} +$$ + +Subsequently, $\bar{r}$ is mapped onto the parameters $\mu_z$ and $\sigma_z^2$ of the approximate posterior distribution $q_{\phi}(z|\mathcal{D}^c)$ using additional encoder networks, i.e., $\mu_z = \mathrm{enc}_{\mu_z,\phi}(\bar{r})$ and $\sigma_z^2 = \mathrm{enc}_{\sigma_z^2,\phi}(\bar{r})$ . Note that three encoder networks are employed here: (i) $\mathrm{enc}_{r,\phi}$ to map from the context pairs to $r_n$ , (ii) $\mathrm{enc}_{\mu_z,\phi}$ to compute $\mu_z$ from the aggregated mean $\bar{r}$ and (iii) $\mathrm{enc}_{\sigma_z^2,\phi}$ to compute the variance $\sigma_z^2$ from $\bar{r}$ . In what follows, we refer to this aggregation mechanism as mean aggregation (MA) and to the networks $\mathrm{enc}_{\mu_z,\phi}$ and $\mathrm{enc}_{\sigma_z^2,\phi}$ collectively as “ $\bar{r}$ -to- $z$ -networks”. + +# 4 BAYESIAN CONTEXT AGGREGATION + +We propose Bayesian Aggregation (BA), a novel context data aggregation technique for CLV models which avoids the detour via an aggregated latent observation $\bar{r}$ and directly treats the object of interest, namely the latent variable $z$ , as the aggregated quantity. This reflects a central observation for CLV models with global latent variables: context data aggregation and hidden parameter inference are fundamentally the same mechanism. Our key insight is to define a probabilistic observation model $p(r|z)$ for $r$ which depends on $z$ . Given a new latent observation $r_n = \mathrm{enc}_{r,\phi}(x_n^c, y_n^c)$ , we can update $p(z)$ by computing the posterior $p(z|r_n) = p(r_n|z)p(z)/p(r_n)$ . Hence, by formulating context data aggregation as a Bayesian inference problem, we aggregate the information contained in $\mathcal{D}^c$ directly into the statistical description of $z$ based on first principles. + +# 4.1 BAYESIAN CONTEXT AGGREGATION VIA GAUSSIAN CONDITIONING + +BA can easily be implemented using a factorized Gaussian observation model of the form + +$$ +p \left(r _ {n} \mid z\right) = \mathcal {N} \left(r _ {n} \mid z, \operatorname {d i a g} \left(\sigma_ {r _ {n}} ^ {2}\right)\right), \quad r _ {n} = \operatorname {e n c} _ {r, \phi} \left(x _ {n} ^ {c}, y _ {n} ^ {c}\right), \quad \sigma_ {r _ {n}} ^ {2} = \operatorname {e n c} _ {\sigma_ {r} ^ {2}, \phi} \left(x _ {n} ^ {c}, y _ {n} ^ {c}\right). \tag {7} +$$ + +![](images/f8e2aefc62432500df1fc09ce015ed3f2dbf77bbb1897dec0766075d72a26727.jpg) +(a) Traditional mean aggregation (MA). + +![](images/d392b75edce504359d92451ae5d2e42e6cd6ca8c3014f5109f52e7b1e2b684c2.jpg) +(b) Our Bayesian aggregation (BA). +Figure 2: Comparison of aggregation mechanisms in CLV models. Dashed lines correspond to learned components of the posterior approximation $q_{\phi}(z|\mathcal{D}^{c})$ . BA avoids the detour via a mean-aggregated latent observation $\bar{r}$ and aggregates $\mathcal{D}^c$ directly in the statistical description of $z$ . This allows to incorporate a quantification of the information content of each context tuple $(x_n^c, y_n^c)$ as well as of $z$ into the inference in a principled manner, while MA assigns the same weight to each context tuple. + +Note that, in contrast to standard variational auto-encoders (VAEs) (Kingma and Welling, 2013), we do not learn the mean and variance of a Gaussian distribution, but we learn the latent observation $r_n$ (which can be considered as a sample of $p(z)$ ) together with the variance $\sigma_{r_n}^2$ of this observation. This architecture allows the application of Gaussian conditioning while this is difficult for VAEs. Indeed, we impose a factorized Gaussian prior $p_0(z) \equiv \mathcal{N}(z|\mu_{z,0},\mathrm{diag}(\sigma_{z,0}^2))$ and arrive at a Gaussian aggregation model which allows to derive the parameters of the posterior distribution $q_{\phi}(z|\mathcal{D}^{c})$ in closed form1 (cf. App. 7.1): + +$$ +\sigma_ {z} ^ {2} = \left[ \left(\sigma_ {z, 0} ^ {2}\right) ^ {\ominus} + \sum_ {n = 1} ^ {N} \left(\sigma_ {r _ {n}} ^ {2}\right) ^ {\ominus} \right] ^ {\ominus}, \quad \mu_ {z} = \mu_ {z, 0} + \sigma_ {z} ^ {2} \odot \sum_ {n = 1} ^ {N} \left(r _ {n} - \mu_ {z, 0}\right) \oslash \left(\sigma_ {r _ {n}} ^ {2}\right). \tag {8} +$$ + +Here $\ominus$ , $\odot$ and $\oslash$ denote element-wise inversion, product, and division, respectively. These equations naturally lend themselves to efficient incremental updates as new context data $(x_{n}^{c},y_{n}^{c})$ arrives by using the current posterior parameters $\mu_{z,\mathrm{old}}$ and $\sigma_{z,\mathrm{old}}^2$ in place of the prior parameters, i.e., + +$$ +\sigma_ {z, \text {n e w}} ^ {2} = \left[ \left(\sigma_ {z, \text {o l d}} ^ {2}\right) ^ {\ominus} + \left(\sigma_ {r _ {n}} ^ {2}\right) ^ {\ominus} \right] ^ {\ominus}, \quad \mu_ {z} = \mu_ {z, \text {o l d}} + \sigma_ {z, \text {n e w}} ^ {2} \odot (r _ {n} - \mu_ {z, \text {o l d}}) \otimes (\sigma_ {r _ {n}} ^ {2}). \tag {9} +$$ + +BA employs two encoder networks, $\mathrm{enc}_{r,\phi}$ and $\mathrm{enc}_{\sigma_r^2,\phi}$ , mapping context tuples to latent observations and their variances, respectively. In contrast to MA, it does not require $\bar{r}$ -to- $z$ -networks, because the set $\{r_n\}_{n=1}^N$ is aggregated directly into the statistical description of $z$ by means of Eq. (8), cf. Fig. 2(b). Note that our factorization assumptions avoid the expensive matrix inversions that typically occur in Gaussian conditioning and which are difficult to backpropagate. Using factorized distributions renders BA cheap to evaluate with only marginal computational overhead in comparison to MA. Furthermore, we can easily backpropagate through BA to compute gradients to optimize the parameters of the encoder and decoder networks. As the latent space $z$ is shaped by the encoder network, the factorization assumptions are valid because the network will find a space where these assumptions work well. Note further that BA represents a permutation-invariant operation on $\mathcal{D}^c$ . + +Discussion. BA includes MA as a special case. Indeed, Eq. (8) reduces to the mean-aggregated latent observation Eq. (6) if we impose a non-informative prior and uniform observation variances $\sigma_{r_n}^2 \equiv 1$ . This observation sheds light on the benefits of a Bayesian treatment of aggregation. MA assigns the same weight $1/N$ to each latent observation $r_n$ , independent of the amount of information contained in the corresponding context data tuple $(x_n^c, y_n^c)$ , as well as independent of the uncertainty about the current estimation of $z$ . Bayesian aggregation remedies both of these limitations: the influence of $r_n$ on the parameters $\mu_{z,\mathrm{old}}$ and $\sigma_{z,\mathrm{old}}^2$ describing the current aggregated state is determined by the relative magnitude of the observation variance $\sigma_{r_n}^2$ and the latent variance + +$\sigma_{z,\mathrm{old}}^2$ , cf. Eq. (9). This emphasizes the central role of the learned observation variances $\sigma_{r_n}^2$ : they allow to quantify the amount of information contained in each latent observation $r_n$ . BA can therefore handle task ambiguity more efficiently than MA, as the architecture can learn to assign little weight (by predicting high observation variances $\sigma_{r_n}^2$ ) to context points $(x_n^c, y_n^c)$ located in areas with high task ambiguity, i.e., to points which could have been generated by many of the functions in $\mathcal{F}$ . Conversely, in areas with little task ambiguity, i.e., if $(x_n^c, y_n^c)$ contains a lot of information about the underlying function, BA can induce a strong influence on the posterior latent distribution. In contrast, MA has to find ways to propagate such information through the aggregation mechanism by encoding it in the mean-aggregated latent observation $\bar{r}$ . + +# 4.2 LIKELIHOOD APPROXIMATION WITH BAYESIAN CONTEXT AGGREGATION + +We show that BA is versatile in the sense that it can replace traditional MA in various CLV-based NP architectures as proposed, e.g., in Garnelo et al. (2018b) and Gordon et al. (2019), which employ samples from the approximate latent posterior $q_{\phi}(z|\mathcal{D}^c)$ to approximate the likelihood (as discussed in Sec. 3), as well as in deterministic variants like the CNP (Garnelo et al., 2018a). + +Sampling-Based Likelihood Approximations. BA is naturally compatible with both the VI and MC likelihood approximations for CLV models. Indeed, BA defines a Gaussian latent distribution from which we can easily obtain samples $z$ in order to evaluate Eq. (2) or Eq. (3) using the decoder parametrization Eq. (5). + +Bayesian Context Aggregation for Conditional Neural Processes. BA motivates a novel, alternative, method to approximate the posterior predictive likelihood Eq. (1), resulting in a deterministic loss function which can be efficiently optimized for $\theta$ and $\phi$ in an end-to-end fashion. To this end, we employ a Gaussian approximation of the posterior predictive likelihood of the form + +$$ +p \left(y _ {1: M} ^ {t} \mid x _ {1: M} ^ {t}, \mathcal {D} ^ {c}, \theta\right) \approx \mathcal {N} \left(y _ {1: M} ^ {t} \mid \mu_ {y}, \Sigma_ {y}\right). \tag {10} +$$ + +This is inspired by GPs which also define a Gaussian likelihood. Maximizing this expression yields the optimal solution $\mu_y = \tilde{\mu}_y$ , $\Sigma_y = \tilde{\Sigma}_y$ , with $\tilde{\mu}_y$ and $\tilde{\Sigma}_y$ being the first and second moments of the true posterior predictive distribution. This is a well-known result known as moment matching, a popular variant of deterministic approximate inference used, e.g., in Deisenroth and Rasmussen (2011) and Becker et al. (2019). $\tilde{\mu}_y$ and $\tilde{\Sigma}_y$ are functions of the moments $\mu_z$ and $\sigma_z^2$ of the latent posterior $p(z|\mathcal{D}^c,\theta)$ which motivates the following decoder parametrization: + +$$ +\mu_ {y} = \det _ {\mu_ {y}, \theta} \left(\mu_ {z}, \sigma_ {z} ^ {2}, x _ {m} ^ {t}\right), \quad \sigma_ {y} ^ {2} = \det _ {\sigma_ {y} ^ {2}, \theta} \left(\mu_ {z}, \sigma_ {z} ^ {2}, x _ {m} ^ {t}\right), \quad \Sigma_ {y} = \operatorname {d i a g} \left(\sigma_ {y} ^ {2}\right). \tag {11} +$$ + +Here, $\mu_z$ and $\sigma_z^2$ are given by the BA Eqs. (8). Note that we define the Gaussian approximation to be factorized w.r.t. individual $y_{m}^{t}$ , an assumption which simplifies the architecture but could be dropped if a more expressive model was required. This decoder can be interpreted as a "moment matching network", computing the moments of $y$ given the moments of $z$ . Indeed, in contrast to decoder networks of CLV-based NP architectures as defined in Eq. (5), it operates on the moments $\mu_z$ and $\sigma_z^2$ of the latent distribution instead of on samples $z$ which allows to evaluate this approximation in a deterministic manner. In this sense, the resulting model is akin to the CNP which defines a deterministic, conditional model with a decoder operating on the mean-aggregated latent observation $\bar{r}$ . However, BA-based models trained in this deterministic manner still benefit from BA's ability to accurately quantify latent parameter uncertainty which yields significantly improved predictive likelihoods. In what follows, we refer to this approximation scheme as direct parameter-based (PB) likelihood optimization. + +Discussion. The concrete choice of likelihood approximation or, equivalently, model architecture depends mainly on the intended use-case. Sampling-based models are generally more expressive as they can represent complex, i.e., structured, non-Gaussian, posterior predictive distributions. Moreover, they yield true function samples while deterministic models only allow approximate function samples through auto-regressive (AR) sampling schemes. Nevertheless, deterministic models exhibit several computational advantages. They yield direct probabilistic predictions in a single forward pass, while the predictions of sampling-based methods are only defined through averages over multiple function samples and hence require multiple forward passes. Likewise, evaluating the MC-based likelihood approximation Eq. (3) during training requires to draw multiple + +Table 1: Posterior predictive log-likelihood on functions drawn from GP priors with RBF, weakly periodic, and Matern-5/2 kernels, averaged over context sets with $N \in \{0,1,\dots,64\}$ points (table) and in dependence of $N$ (figure). BA consistently outperforms MA, independent of the likelihood approximation, with MC being the most expressive choice. PB represents an efficient, deterministic alternative, while the VI approximation tends to perform worst, in particular for small $N$ . + +
PB/det.VIMCANP
BAMA (CNP)BAMA (LP-NP)BAMAMA + Attention
RBF GP1.37 ± 0.150.94 ± 0.041.40 ± 0.040.45 ± 0.121.62 ± 0.051.07 ± 0.050.98 ± 0.02
Weakly Periodic GP1.13 ± 0.080.76 ± 0.020.89 ± 0.030.07 ± 0.141.30 ± 0.060.85 ± 0.041.02 ± 0.02
Matern-5/2 GP-0.50 ± 0.07-0.68 ± 0.01-0.79 ± 0.01-1.09 ± 0.10-0.33 ± 0.01-0.90 ± 0.150.25 ± 0.02
+ +![](images/eb7d09c4166d258345c8a069b6a24e56649b1137bfec03c78efdd9748fb233e7.jpg) + +![](images/e495b548c12abe2adbdacdb7f26391e5c6cd16393cc43bd3e616ed2bbc85a36f.jpg) + +![](images/315feb418c8f9865bcaf740ce43f3bf8a1366c7f676a98dbb9f7df23126a3629.jpg) + +$(K)$ latent samples $z$ . While the VI likelihood approximation Eq. (2) can be optimized on a single function sample per training step through stochastic gradient descent (Bishop, 2006), it has the disadvantage that it requires to feed target sets $\mathcal{D}^t$ through the encoder which can impede the training for small context sets $\mathcal{D}^c$ as discussed in detail in App. 7.2. + +# 5 EXPERIMENTS + +We present experiments to compare the performances of BA and of MA in NP-based models. To provide a complete picture, we evaluate all combinations of likelihood approximations (PB/deterministic Eq. (10), VI Eq. (2), MC Eq. (3)) and aggregation methods (BA Eq. (8), MA Eq. (6)), resulting in six different model architectures, cf. Fig. 4 in App. 7.5.2. Two of these architectures correspond to existing members of the NP family: MA + deterministic is equivalent to the CNP (Garnelo et al., 2018a), and MA + VI corresponds to the Latent-Path NP (LP-NP) (Garnelo et al., 2018b), i.e., the NP without a deterministic path. We further evaluate the Attentive Neural Process (ANP) (Kim et al., 2019), which employs a hybrid approach, combining LP-NP with a cross-attention mechanism in a parallel deterministic path3, as well as an NP-architecture using MA with a self-attentive (SA) encoder network. Note that BA can also be used in hybrid models like ANP or in combination with SA, an idea we leave for future research. In App. 7.4 we discuss NP-based regression in relation to other methods for (scalable) probabilistic regression. + +The performance of NP-based models depends heavily on the encoder and decoder network architectures as well as on the latent space dimensionality $d_{z}$ . To assess the influence of the aggregation mechanism independently from all other confounding factors, we consistently optimize the encoder and decoder network architectures, the latent-space dimensionality $d_{z}$ , as well as the learning rate of the Adam optimizer (Kingma and Ba, 2015), independently for all model architectures and for all experiments using the Optuna (Akiba et al., 2019) framework, cf. App. 7.5.3. If not stated differently, we report performance in terms of the mean posterior predictive log-likelihood over 256 test tasks with 256 data points each, conditioned on context sets containing $N \in \{0,1,\dots,N_{\mathrm{max}}\}$ data points (cf. App. 7.5.4). For sampling-based methods (VI, MC, ANP), we report the joint log-likelihood over the test sets using a Monte-Carlo approximation with 25 latent samples, cf. App. 7.5.4. We average the resulting log-likelihood values over 10 training runs with different random seeds and report $95\%$ confidence intervals. We publish source code to reproduce the experimental results online. $^4$ + +GP Samples. We evaluate the architectures on synthetic functions drawn from GP priors with different kernels (RBF, weakly periodic, Matern-5/2), as proposed by Gordon et al. (2020), cf. App. 7.5.1. We generate a new batch of functions for each training epoch. The results (Tab. 1) show that BA consistently outperforms MA, independent of the model architecture. In + +Table 3: Posterior predictive log-likelihood on 1D and 3D quadratic functions with limited numbers $L$ of training tasks,averaged over context sets with $N \in \{ 0,1,\ldots ,{20}\}$ data points. BA outperforms MA by considerable margins in this regime of little training data. + +
PB/det.VIMCANP
BAMA (CNP)BAMA (LP-NP)BAMAMA + Attention
Quadratic 1D, L = 641.42 ± 0.200.47 ± 0.251.48 ± 0.05-0.32 ± 0.551.71 ± 0.231.27 ± 0.060.69 ± 0.08
Quadratic 3D, L = 128-2.46 ± 0.12-2.73 ± 0.10-2.53 ± 0.07-3.45 ± 0.12-1.79 ± 0.07-2.14 ± 0.05-3.08 ± 0.02
+ +![](images/7033c49643938b117808341e137b0665ce1d69cffdd03d2fc6cc4af4a2e5de41.jpg) +Figure 3: Predictions on two instances (dashed lines) of the 1D quadratic function class, given $N = 3$ context data points (circles). We show mean and standard deviation predictions (solid line, shaded area), and 10 function samples (AR samples for deterministic methods). Cf. also App. 7.6. + +![](images/084718309877e7d89b7cb8fb05fa8555a794aba1de89d0b08d23c015525c0a43.jpg) + +![](images/c502868940eba0869c89eb0a78a89243b08dd5baab1f6ac5a0163193f29ee739.jpg) + +![](images/78de1034496b0241ed82fce452b24dc8e2d5ecee97c5edd12b4559f6321dbea1.jpg) + +![](images/61384d67434a9b052244e50f7049972ff7f844a6ebc96188cacc4311eb5ea983.jpg) + +![](images/1c348d14e0acb0902a65101d84e01bb7032801eefcbf44b74a073aa566ec27fc.jpg) + +![](images/4e802df171c85faf02c8654a579ea359ee696650df856e55ecfb831802aa359e.jpg) + +terestingly, despite employing a factorized Gaussian approximation, our deterministic PB approximation performs at least on-par with the traditional VI approximation which tends to perform + +particularly poorly for small context sets, reflecting the intricacies discussed in Sec. 4.2. As expected, the MC approximation yields the best results in terms of predictive performance, as it is more expressive than the deterministic approaches and does not share the problems of the VI approach. As shown in Tab. 2 and Tab. 9, App. 7.6, our proposed PB likelihood approximation is + +Table 2: Relative evaluation runtimes and #parameters of the optimized network architectures on RBF GP. Also cf. Tab. 9. + +
PB/det.VIMC
BAMA (CNP)BAMA (LP-NP)BAMA
Runtime11.418253227
#Parameters72k96k63k77k122k153k
+ +much cheaper to evaluate compared to both sampling-based approaches which require multiple forward passes per prediction. We further observe that BA tends to require smaller encoder and decoder networks as it is more efficient at propagating context information to the latent state as discussed in Sec. 4.1. The hybrid ANP approach is competitive only on the Matern-5/2 function class. Yet, we refer the reader to Tab. 10, App. 7.6, demonstrating that the attention mechanism greatly improves performance in terms of MSE. + +Quadratic Functions. We further seek to study the performance of BA with very limited amounts of training data. To this end, we consider two quadratic function classes, each parametrized by three real parameters from which we generate limited numbers $L$ of training tasks. The first function class is defined on a one-dimensional domain, i.e., $x \in \mathbb{R}$ , and we choose $L = 64$ , while the second function class, as proposed by Perrone et al. (2018), is defined on $x \in \mathbb{R}^3$ with $L = 128$ , cf. App. 7.5.1. As shown in Tab. 3, BA again consistently outperforms MA, often by considerably large margins, underlining the efficiency of our Bayesian approach to aggregation in the regime of little training data. On the 1D task, all likelihood approximations perform approximately on-par in combination with BA, while MC outperforms both on the more complex 3D task. Fig. 3 compares prediction qualities. + +Dynamics of a Furuta Pendulum. We study BA on a realistic dataset given by the simulated dynamics of a rotary inverted pendulum, better known as the Furuta pendulum (Furuta et al., 1992), which is a highly non-linear dynamical system, consisting of an actuated arm rotating in the horizontal + +plane with an attached pendulum rotating freely in the vertical plane, parametrized by two masses, three lengths, and two damping constants. The regression task is defined as the one-step-ahead prediction of the four-dimensional system state with a step-size of $\Delta t = 0.1\mathrm{s}$ , as detailed in App. 7.5.1. The results (Tab. 4) show that BA improves predictive performance also on complex, non-synthetic regression tasks with higher-dimensional input- and output spaces. Further, they are consistent + +![](images/da7b48fd0605e5a9de1878ab7b01a5496490721c18c5cb242f8e556565b0ce76.jpg) + +with our previous findings regarding the likelihood approximations, with MC being strongest in terms of predictive likelihood, followed by our efficient deterministic alternative PB. + +2D Image Completion. We consider a 2D image completion experiment where the inputs $x$ are pixel locations in images showing handwritten digits, and we regress onto the corresponding pixel intensities $y$ , cf. App. 7.6. Interestingly, we found that architectures without deterministic paths were not able to solve this task reliably which is why we only report results for deterministic models. + +Table 4: Posterior predictive log-likelihood on the dynamics of a Furuta pendulum, averaged over context sets with $N \in \{ 0,1,\ldots ,{20}\}$ state transitions. BA performs favorably on this real-world task. + +
PB/det.VIMCANP
BAMA (CNP)BAMA (LP-NP)BAMAMA + Attention
Furuta Dynamics7.50 ± 0.277.06 ± 0.127.32 ± 0.185.57 ± 0.218.25 ± 0.337.55 ± 0.244.74 ± 0.16
+ +Table 6: Comparison of the posterior predictive log-likelihood of our BA with traditional MA, combined with a self-attention (SA) mechanism in the encoder (BA does not use an SA mechanism), using the PB and MC likelihood approximations. We provide results for Laplace SA (L-SA), dot-product SA (DP-SA), and mulhead SA (MH-SA) and repeat the results for BA and MA without SA ("no SA"). While L-SA and DP-SA do not increase predictive performance compared to MA without SA, MH-SA results in significant improvements. Nevertheless, vanilla BA still performs better or at least on-par, while being computationally more efficient. + +
BA + PB +no SAMA + PBBA + MC +no SAMA + MC
no SAL-SADP-SAMH-SAno SAL-SADP-SAMH-SA
RBF GP1.37 ± 0.150.94 ± 0.040.74 ± 0.060.89 ± 0.041.46 ± 0.141.62 ± 0.051.07 ± 0.050.93 ± 0.050.98 ± 0.031.44 ± 0.09
Weakly Periodic GP1.13 ± 0.080.76 ± 0.020.59 ± 0.020.71 ± 0.021.13 ± 0.151.30 ± 0.060.85 ± 0.040.77 ± 0.030.82 ± 0.031.29 ± 0.04
Matern-5/2 GP-0.50 ± 0.07-0.68 ± 0.01-1.03 ± 0.01-0.76 ± 0.01-0.64 ± 0.01-0.33 ± 0.01-0.90 ± 0.15-0.80 ± 0.02-0.86 ± 0.01-0.59 ± 0.03
Quadratic 1D, L = 641.42 ± 0.200.47 ± 0.250.15 ± 0.320.47 ± 0.241.49 ± 0.111.71 ± 0.231.27 ± 0.061.19 ± 0.091.32 ± 0.141.66 ± 0.12
Quadratic 3D, L = 128-2.46 ± 0.12-2.73 ± 0.10-2.94 ± 0.41-2.95 ± 0.13-2.13 ± 0.25-1.79 ± 0.07-2.14 ± 0.05-2.19 ± 0.11-2.18 ± 0.07-1.71 ± 0.05
Furuta Dynamics7.50 ± 0.277.06 ± 0.127.13 ± 0.127.04 ± 0.207.40 ± 0.468.25 ± 0.337.55 ± 0.247.80 ± 0.137.67 ± 0.148.39 ± 0.20
+ +As shown in Tab. 5, BA improves performance in comparison to MA by a large margin. This highlights that BA's ability to quantify the information content of a context tuple is particularly beneficial on this task, as, e.g., pixels in the middle area of the images typically convey more information about the identity of the digit than pixels located near the borders. + +Table 5: Predictive log-likelihood on a 2D image completion task on MNIST, averaged over $N\in \{0,1,\dots ,392\}$ context pixels. + +
PB/det.ANP
BAMA (CNP)MA + Attention
2D Image Completion2.75 ± 0.202.05 ± 0.361.62 ± 0.03
+ +Self-attentive Encoders. Another interesting baseline for BA is MA, combined with a self-attention (SA) mechanism in the encoder. Indeed, similar to BA, SA yields non-uniform weights for the latent observations $r_n$ , where a given weight is computed from some form of pairwise spatial relationship with all other latent observations in the context set (cf. App. 7.3 for a detailed discussion). As BA's weight for $r_n$ only depends on $(x_n, y_n)$ itself, BA is computationally more efficient: SA scales like $\mathcal{O}(N^2)$ in the number $N$ of context tuples while BA scales like $\mathcal{O}(N)$ , and, furthermore, SA does not allow for efficient incremental updates while this is possible for BA, cf. Eq. (9). Tab. 6 shows a comparison of BA with MA in combination with various different SA mechanisms in the encoder. We emphasize that we compare against BA in its vanilla form, i.e., BA does not use SA in the encoder. The results show that Laplace SA and dot-product SA do not improve predictive performance compared to vanilla MA, while multihead SA yields significantly better results. Nevertheless, vanilla BA still performs better or at least on-par and is computationally more efficient. While being out of the scope of this work, according to these results, a combination of BA with SA seems promising if computational disadvantages can be accepted in favour of increased predictive performance, cf. App. 7.3. + +# 6 CONCLUSION AND OUTLOOK + +We proposed a novel Bayesian Aggregation (BA) method for NP-based models, combining context aggregation and hidden parameter inference in one holistic mechanism which enables efficient handling of task ambiguity. BA is conceptually simple, compatible with existing NP-based model architectures, and consistently improves performance compared to traditional mean aggregation. It introduces only marginal computational overhead, simplifies the architectures in comparison to existing CLV models (no $\bar{r}$ -to- $z$ -networks), and tends to require less complex encoder and decoder network architectures. Our experiments further demonstrate that the VI likelihood approximation traditionally used to train NP-based models should be abandoned in favor of a MC-based approach, and that our proposed PB likelihood approximation represents an efficient deterministic alternative with strong predictive performance. We believe that a range of existing models, e.g., the ANP or NPs with self-attentive encoders, can benefit from BA, especially when a reliable quantification of uncertainty is crucial. Also, more complex Bayesian aggregation models are conceivable, opening interesting avenues for future research. + +# ACKNOWLEDGMENTS + +We thank Philipp Becker, Stefan Falkner, and the anonymous reviewers for valuable remarks and discussions which greatly improved this paper. + +# REFERENCES + +Takuya Akiba, Shotaro Sano, Toshihiko Yanase, Takeru Ohta, and Masanori Koyama. Optuna: A Next-generation Hyperparameter Optimization Framework. 2019. +Marcin Andrychowicz, Misha Denil, Sergio Gomez Colmenarejo, Matthew W. Hoffman, David Pfau, Tom Schaul, and Nando de Freitas. Learning to Learn by Gradient Descent by Gradient Descent. Advances in Neural Information Processing Systems, 2016. +Bart Bakker and Tom Heskes. Task Clustering and Gating for Bayesian Multitask Learning. Journal of Machine Learning Research, 2003. +Rémi Bardenet, Mátyás Brendel, Balázs Kégl, and Michèle Sebag. Collaborative Hyperparameter Tuning. International Conference on Machine Learning, 2013. +Philipp Becker, Harit Pandya, Gregor H. W. Gebhardt, Cheng Zhao, C. James Taylor, and Gerhard Neumann. Recurrent Kalman Networks: Factorized Inference in High-Dimensional Deep Feature Spaces. International Conference on Machine Learning, 2019. +Yoshua Bengio, Samy Bengio, and Jocelyn Cloutier. Learning a Synaptic Learning Rule. International Joint Conference on Neural Networks, 1991. +Christopher M. Bishop. Pattern Recognition and Machine Learning. Springer, 2006. +R. Calandra, J. Peters, C. E. Rasmussen, and M. P. Deisenroth. Manifold Gaussian Processes for Regression. International Joint Conference on Neural Networks, 2016. +Benjamin Seth Cazzolato and Zebb Prime. On the Dynamics of the Furuta Pendulum. Journal of Control Science and Engineering, 2011. +Yutian Chen, Matthew W. Hoffman, Sergio Gómez Colmenarejo, Misha Denil, Timothy P. Lillicrap, Matt Botvinick, and Nando de Freitas. Learning to Learn without Gradient Descent by Gradient Descent. International Conference on Machine Learning, 2017. +Andreas Damianou and Neil Lawrence. Deep Gaussian Processes. International Conference on Artificial Intelligence and Statistics, 2013. +MP. Deisenroth and CE. Rasmussen. PILCO: A Model-Based and Data-Efficient Approach to Policy Search. International Conference on Machine Learning, 2011. +Harrison A. Edwards and Amos J. Storkey. Towards a Neural Statistician. International Conference on Learning Representations, 2017. +Li Fei-Fei, R. Fergus, and P. Perona. One-shot Learning of Object Categories. IEEE Transactions on Pattern Analysis and Machine Intelligence, 2006. +Chelsea Finn, Pieter Abbeel, and Sergey Levine. Model-Agnostic Meta-Learning for Fast Adaptation of Deep Networks. International Conference on Machine Learning, 2017. +Chelsea Finn, Kelvin Xu, and Sergey Levine. Probabilistic Model-Agnostic Meta-Learning. Advances in Neural Information Processing Systems, 2018. +K. Furuta, M. Yamakita, and S. Kobayashi. Swing-up Control of Inverted Pendulum Using Pseudo-State Feedback. Journal of Systems and Control Engineering, 1992. +Yarin Gal and Zoubin Ghahramani. Dropout as a Bayesian Approximation: Representing Model Uncertainty in Deep Learning. International Conference on Machine Learning, 2016. + +Marta Garnelo, Dan Rosenbaum, Christopher Maddison, Tiago Ramalho, David Saxton, Murray Shanahan, Yee Whye Teh, Danilo Rezende, and S. M. Ali Eslami. Conditional Neural Processes. International Conference on Machine Learning, 2018a. +Marta Garnelo, Jonathan Schwarz, Dan Rosenbaum, Fabio Viola, Danilo Jimenez Rezende, S. M. Ali Eslami, and Yee Whye Teh. Neural Processes. arXiv abs/1807.01622, 2018b. +Daniel Golovin, Benjamin Solnik, Subhodeep Moitra, Greg Kochanski, John Karro, and D. Sculley. Google Vizier: A Service for Black-Box Optimization. International Conference on Knowledge Discovery and Data Mining, 2017. +Jonathan Gordon, John Bronskill, Matthias Bauer, Sebastian Nowozin, and Richard E. Turner. Meta-Learning Probabilistic Inference for Prediction. International Conference on Learning Representations, 2019. +Jonathan Gordon, Wessel P. Bruinsma, Andrew Y. K. Foong, James Requeima, Yann Dubois, and Richard E. Turner. Convolutional Conditional Neural Processes. International Conference on Learning Representations, 2020. +Erin Grant, Chelsea Finn, Sergey Levine, Trevor Darrell, and Thomas L. Griffiths. Recasting Gradient-Based Meta-Learning as Hierarchical Bayes. International Conference on Learning Representations, 2018. +Tom Heskes. Empirical Bayes for Learning to Learn. International Conference on Machine Learning, 2000. +Geoffrey E. Hinton and Russ R. Salakhutdinov. Using Deep Belief Nets to Learn Covariance Kernels for Gaussian Processes. Advances in Neural Information Processing Systems, 2008. +Geoffrey E. Hinton and Drew van Camp. Keeping the Neural Networks Simple by Minimizing the Description Length of the Weights. Annual Conference on Computational Learning Theory, 1993. +Sepp Hochreiter, A. Steven Younger, and Peter R. Conwell. Learning to Learn Using Gradient Descent. International Conference on Artificial Neural Networks, 2001. +Hyunjik Kim, Andriy Mnih, Jonathan Schwarz, Marta Garnelo, S. M. Ali Eslami, Dan Rosenbaum, Oriol Vinyals, and Yee Whye Teh. Attentive Neural Processes. International Conference on Learning Representations, 2019. +Taesup Kim, Jaesik Yoon, Ousmane Dia, Sungwoong Kim, Yoshua Bengio, and Sungjin Ahn. Bayesian Model-Agnostic Meta-Learning. Advances in Neural Information Processing Systems, 2018. +Diederik P. Kingma and Jimmy Ba. Adam: A Method for Stochastic Optimization. International Conference on Learning Representations, 2015. +Diederik P. Kingma and Max Welling. Auto-Encoding Variational Bayes. International Conference on Learning Representations, 2013. +Gregory Koch, Richard Zemel, and Ruslan Salakhutdinov. Siamese Neural Networks for One-shot Image Recognition. International Conference on Machine Learning, 2015. +Brenden M. Lake, Ruslan Salakhutdinov, Jason Gross, and Joshua B. Tenenbaum. One Shot Learning of Simple Visual Concepts. Cognitive Science, 2011. +Neil Lawrence, Matthias Seeger, and Ralf Herbrich. Fast Sparse Gaussian Process Methods: The Informative Vector Machine. Advances in Neural Information Processing Systems, 2002. +M. Lazaro-Gredilla and A. R. Figueiras-Vidal. Marginalized Neural Network Mixtures for Large-Scale Regression. IEEE Transactions on Neural Networks, 2010. +Tuan Anh Le, Hyunjik Kim, and Marta Garnelo. Empirical Evaluation of Neural Process Objectives. Third Workshop on Bayesian Deep Learning, 2018. +Yann LeCun and Corinna Cortes. MNIST Handwritten Digit Database. 2010. + +Ke Li and Jitendra Malik. Learning to Optimize. International Conference on Machine Learning, 2016. +Lisha Li, Kevin Jamieson, Giulia DeSalvo, Afshin Rostamizadeh, and Ameet Talwalkar. Hyperband: A Novel Bandit-Based Approach to Hyperparameter Optimization. Journal of Machine Learning Research, 2017. +Christos Louizos and Max Welling. Multiplicative Normalizing Flows for Variational Bayesian Neural Networks. International Conference on Machine Learning, 2017. +Christos Louizos, Xiahan Shi, Klamer Schutte, and M. Welling. The Functional Neural Process. Advances in Neural Information Processing Systems, 2019. +David J. C. MacKay. A Practical Bayesian Framework for Backpropagation Networks. Neural Computation, 1992. +Radford M. Neal. Bayesian Learning for Neural Networks. Springer-Verlag, 1996. +Valerio Perrone, Rodolphe Jenatton, Matthias W Seeger, and Cedric Archambeau. Scalable Hyperparameter Transfer Learning. Advances in Neural Information Processing Systems, 2018. +Joaquin Quñonero-Candela and Carl Edward Rasmussen. A Unifying View of Sparse Approximate Gaussian Process Regression. Journal of Machine Learning Research, 2005. +Carl Edward Rasmussen and Christopher K. I. Williams. Gaussian Processes for Machine Learning. The MIT Press, 2005. +Sachin Ravi and Hugo Larochelle. Optimization as a Model for Few-Shot Learning. International Conference on Learning Representations, 2017. +Danilo Jimenez Rezende, Shakir Mohamed, and Daan Wierstra. Stochastic Backpropagation and Approximate Inference in Deep Generative Models. International Conference on Machine Learning, 2014. +Andrei A. Rusu, Dushyant Rao, Jakub Sygnowski, Oriol Vinyals, Razvan Pascanu, Simon Osindero, and Raia Hadsell. Meta-Learning with Latent Embedding Optimization. International Conference on Learning Representations, 2018. +Adam Santoro, Sergey Bartunov, Matthew M. Botvinick, Daan Wierstra, and Timothy P. Lillicrap. Meta-Learning with Memory-Augmented Neural Networks. International Conference on Machine Learning, 2016. +Jürgen Schmidhuber. Evolutionary Principles in Self-Referential Learning. On Learning how to Learn: The Meta-Meta-Meta...-Hook. Diploma Thesis, Technische Universität München, Germany, 1987. +Jürgen Schmidhuber. Learning to Control Fast-Weight Memories: An Alternative to Dynamic Recurrent Networks. Neural Computation, 1992. +Alex J. Smola and Peter L. Bartlett. Sparse Greedy Gaussian Process Regression. Advances in Neural Information Processing Systems, 2001. +Jake Snell, Kevin Swersky, and Richard S. Zemel. Prototypical Networks for Few-shot Learning. Advances in Neural Information Processing Systems, 2017. +Edward Snelson and Zoubin Ghahramani. Sparse Gaussian Processes Using Pseudo-Inputs. International Conference on Neural Information Processing Systems, 2005. +Jasper Snoek, Hugo Larochelle, and Ryan P. Adams. Practical Bayesian Optimization of Machine Learning Algorithms. Advances in Neural Information Processing Systems, 2012. +Kihyuk Sohn, Honglak Lee, and Xinchen Yan. Learning Structured Output Representation using Deep Conditional Generative Models. Advances in Neural Information Processing Systems, 2015. + +Flood Sung, Yongxin Yang, Li Zhang, Tao Xiang, Philip H. S. Torr, and Timothy M. Hospedales. Learning to Compare: Relation Network for Few-Shot Learning. Conference on Computer Vision and Pattern Recognition, 2017. +Sebastian Thrun and Lorien Pratt. Learning to Learn. Kluwer Academic Publishers, 1998. +Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N Gomez, Lukasz Kaiser, and Illia Polosukhin. Attention is All you Need. Advances in Neural Information Processing Systems, 2017. +Ricardo Vilalta and Youssef Drissi. A Perspective View and Survey of Meta-Learning. Artificial Intelligence Review, 2005. +Oriol Vinyals, Charles Blundell, Timothy Lillicrap, Koray Kavukcuoglu, and Daan Wierstra. Matching Networks for One Shot Learning. Advances in Neural Information Processing Systems, 2016. +Michael Volpp, Lukas P. Fröhlich, Kirsten Fischer, Andreas Doerr, Stefan Falkner, Frank Hutter, and Christian Daniel. Meta-Learning Acquisition Functions for Transfer Learning in Bayesian Optimization. International Conference on Learning Representations, 2019. +Edward Wagstaff, Fabian B. Fuchs, Martin Engelcke, Ingmar Posner, and Michael A. Osborne. On the Limitations of Representing Functions on Sets. International Conference on Machine Learning, 2019. +Christopher K. I. Williams. Computing with Infinite Networks. Advances in Neural Information Processing Systems, 1996. +Andrew Gordon Wilson, Zhiting Hu, Ruslan Salakhutdinov, and Eric P. Xing. Deep Kernel Learning. International Conference on Artificial Intelligence and Statistics, 2016. +Dani Yogatama and Gideon Mann. Efficient Transfer Learning Method for Automatic Hyperparameter Tuning. International Conference on Artificial Intelligence and Statistics, 2014. +Manzil Zaheer, Satwik Kottur, Siamak Ravanbakhsh, Barnabás Póczos, Ruslan Salakhutdinov, and Alexander J. Smola. Deep Sets. Advances in Neural Information Processing Systems, 2017. + +# 7 APPENDIX + +We present the derivation of the Bayesian aggregation update equations (Eqs. (8), (9)) in more detail. To foster reproducibility, we describe all experimental settings as well as the hyperparameter optimization procedure used to obtain the results reported in Sec. 5, and publish the source code online. We further provide additional experimental results and visualizations of the predictions of the compared architectures. + +# 7.1 DERIVATION OF THE BAYESIAN AGGREGATION UPDATE EQUATIONS + +We derive the full Bayesian aggregation update equations without making any factorization assumptions. We start from a Gaussian observation model of the form + +$$ +p \left(r _ {n} \mid z\right) \equiv \mathcal {N} \left(r _ {n} \mid z, \Sigma_ {r _ {n}}\right), \quad r _ {n} = \operatorname {e n c} _ {r, \phi} \left(x _ {n} ^ {c}, y _ {n} ^ {c}\right), \quad \Sigma_ {r _ {n}} = \operatorname {e n c} _ {\Sigma_ {r}, \phi} \left(x _ {n} ^ {c}, y _ {n} ^ {c}\right), \tag {12} +$$ + +where $r_n$ and $\Sigma_{r_n}$ are learned by the encoder network. If we impose a Gaussian prior in the latent space, i.e., + +$$ +p (z) \equiv \mathcal {N} (z | \mu_ {z, 0}, \Sigma_ {z, 0}), \tag {13} +$$ + +we arrive at a Gaussian aggregation model which allows to derive the parameters of the posterior distribution, i.e., of + +$$ +q _ {\phi} (z | \mathcal {D} ^ {c}) = \mathcal {N} (z | \mu_ {z}, \Sigma_ {z}) \tag {14} +$$ + +in closed form using standard Gaussian conditioning (Bishop, 2006): + +$$ +\Sigma_ {z} = \left[ \left(\Sigma_ {z, 0}\right) ^ {- 1} + \sum_ {n = 1} ^ {N} \left(\Sigma_ {r _ {n}}\right) ^ {- 1} \right] ^ {- 1}, \tag {15a} +$$ + +$$ +\mu_ {z} = \mu_ {z, 0} + \Sigma_ {z} \sum_ {n = 1} ^ {N} \left(\Sigma_ {r _ {n}}\right) ^ {- 1} \left(r _ {n} - \mu_ {z, 0}\right). \tag {15b} +$$ + +As the latent space $z$ is shaped by the encoder network, it will find a space where the following factorization assumptions work well (given $d_{z}$ is large enough): + +$$ +\Sigma_ {r _ {n}} = \operatorname {d i a g} \left(\sigma_ {r _ {n}} ^ {2}\right), \quad \sigma_ {r _ {n}} ^ {2} = \operatorname {e n c} _ {\sigma_ {r} ^ {2}, \phi} \left(x _ {n} ^ {c}, y _ {n} ^ {c}\right), \quad \Sigma_ {z, 0} = \operatorname {d i a g} \left(\sigma_ {z, 0} ^ {2}\right). \tag {16} +$$ + +This yields a factorized posterior, i.e., + +$$ +q _ {\phi} (z | \mathcal {D} ^ {c}) = \mathcal {N} (z | \mu_ {z}, \operatorname {d i a g} (\sigma_ {z} ^ {2})) , \tag {17} +$$ + +with + +$$ +\sigma_ {z} ^ {2} = \left[ \left(\sigma_ {z, 0} ^ {2}\right) ^ {\ominus} + \sum_ {n = 1} ^ {N} \left(\sigma_ {r _ {n}} ^ {2}\right) ^ {\ominus} \right] ^ {\ominus}, \tag {18a} +$$ + +$$ +\mu_ {z} = \mu_ {z, 0} + \sigma_ {z} ^ {2} \odot \sum_ {n = 1} ^ {N} \left(r _ {n} - \mu_ {z, 0}\right) \otimes \left(\sigma_ {r _ {n}} ^ {2}\right). \tag {18b} +$$ + +Here $\ominus$ , $\odot$ and $\oslash$ denote element-wise inversion, product, and division, respectively. This is the result Eq. (8) from the main part of this paper. + +# 7.2 DISCUSSION OF VI LIKELIHOOD APPROXIMATION + +To highlight the limitations of the VI approximation, we note that decoder networks of models employing the PB or the MC likelihood approximation are provided with the same context information at training and test time: the latent variable (which is passed on to the decoder in the form of latent samples $z$ (for MC) or in the form of parameters $\mu_z$ , $\sigma_z^2$ describing the latent distribution (for PB)) is in both cases conditioned only on the context set $\mathcal{D}^c$ . In contrast, in the variational approximation Eq. (2), the expectation is w.r.t. $q_{\phi}$ , conditioned on the union of the context set $\mathcal{D}^c$ and the target set $\mathcal{D}^t$ . As $\mathcal{D}^t$ is not available at test time, this introduces a mismatch between how the model is trained + +and how it is used at test time. Indeed, the decoder is trained on samples from $q_{\phi}(z|\mathcal{D}^c \cup \mathcal{D}^t)$ but evaluated on samples from $q_{\phi}(z|\mathcal{D}^c)$ . This is not a serious problem when the model is evaluated on context sets with sizes large enough to allow accurate approximations of the true latent posterior distribution. Small context sets, however, usually contain too little information to infer $z$ reliably. Consequently, the distributions $q_{\phi}(z|\mathcal{D}^c)$ and $q_{\phi}(z|\mathcal{D}^c \cup \mathcal{D}^t)$ typically differ significantly in this regime. Hence, incentivizing the decoder to yield meaningful predictions on small context sets requires intricate and potentially expensive additional sampling procedures to choose suitable target sets $\mathcal{D}^t$ during training. As a corner case, we point out that it is not possible to train the decoder on samples from the latent prior, because the right hand side of Eq. (2) vanishes for $\mathcal{D}^c = \mathcal{D}^t = \varnothing$ . + +# 7.3 SELF-ATTENTIVE ENCODER ARCHITECTURES + +Kim et al. (2019) propose to use attention-mechanisms to improve the quality of NP-based regression. In general, given a set of key-value pairs $\{(x_n,y_n)\}_{n = 1}^N$ , $x_{n}\in \mathbb{R}^{d_{x}}$ , $y_{n}\in \mathbb{R}^{d_{y}}$ , and a query $x^{*}\in \mathbb{R}^{d_{x}}$ , an attention mechanism $\mathcal{A}$ produces a weighted sum of the values, with the weights being computed from the keys and the query: + +$$ +\mathcal {A} \left(\left\{\left(x _ {n}, y _ {n}\right) \right\} _ {n = 1} ^ {N}, x ^ {*}\right) = \sum_ {n = 1} ^ {N} w \left(x _ {n}, x ^ {*}\right) y _ {n}. \tag {19} +$$ + +There are several types of attention mechanisms proposed in the literature (Vaswani et al., 2017), each defining a specific form of the weights. Laplace attention adjusts the weights according to the spatial distance of keys and query: + +$$ +w _ {\mathrm {L}} \left(x _ {n}, x ^ {*}\right) \propto \exp \left(- \| x _ {n} - x ^ {*} \| _ {1}\right). \tag {20} +$$ + +Similarly, dot-product attention computes + +$$ +w _ {\mathrm {D P}} \left(x _ {n}, x ^ {*}\right) \propto \exp \left(x _ {n} ^ {T} x ^ {*} / \sqrt {d _ {x}}\right). \tag {21} +$$ + +A more complex mechanism is multihead attention, which employs a set of $3H$ learned linear mappings $\{\mathcal{L}_h^K\}_{h=1}^H$ , $\{\mathcal{L}_h^V\}_{h=1}^H$ , $\{\mathcal{L}_h^Q\}_{h=1}^H$ , where $H$ is a hyperparameter. For each $h$ , these mappings are applied to keys, values, and queries, respectively. Subsequently, dot-product attention is applied to the set of transformed key-value pairs and the transformed query. The resulting $H$ values are then again combined by a further learned linear mapping $\mathcal{L}^O$ to obtain the final result. + +Self-attention (SA) is defined by setting the set of queries equal to the set of keys. Therefore, SA produces again a set of $N$ weighted values. Combining SA with an NP-encoder, i.e., applying SA to the set $\{f_x(x_n), r_n\}_{n=1}^N$ of inputs $x_n$ and corresponding latent observations $r_n$ (where we also consider a possible nonlinear transformation $f_x$ of the inputs) and subsequently applying MA yields an interesting baseline for our proposed BA. Indeed, similar to BA, SA computes a weighted sum of the latent observations $r_n$ . Note, however, that SA weighs each latent observation according to some form of spatial relationship of the corresponding input with all other latent observations in the context set. In contrast, BA's weight for a given latent observation is based only on features computed from the context tuple corresponding to this very latent observation and allows to incorporate an estimation of the amount of information contained in the context tuple into the aggregation (cf. Sec. 4.1). This leads to several computational advantages of BA over SA: (i) SA scales quadratically in the number $N$ of context tuples, as it has to be evaluated on all $N^2$ pairs of context tuples. In contrast, BA scales linearly with $N$ . (ii) BA allows for efficient incremental updates when context data arrives sequentially (cf. Eq. (9)), while using SA does not provide this possibility: it requires to store and encode the whole context set $\mathcal{D}^c$ at once and to subsequently aggregate the whole set of resulting (SA-weighted) latent observations. + +The results in Tab. 6, Sec. 5 show that multihead SA leads to significant improvements in predictive performance compared to vanilla MA. Therefore, a combination of BA with self-attentive encoders seems promising in situations where computational disadvantages can be accepted in favour of increased predictive performance. Note that BA relies on a second encoder output $\sigma_{r_n}^2$ (in addition to the latent observation $r_n$ ) which assesses the information content in each context tuple $(x_n, y_n)$ . As each SA-weighted $r_n$ is informed by the other latent observations in the context set, obviously, one would have to also process the set of $\sigma_{r_n}^2$ in a manner consistent with the SA-weighting. We leave such a combination of SA and BA for future research. + +Table 7: Comparison of the predictive log-likelihood of NP-based architectures with two simple GP-based baselines, (i) Vanilla GP (optimizes the hyperparameters individually on each target task and ignores the source data) (ii) Multi-task GP (optimizes one set of hyperparameters on all source tasks and uses them without further adaptation on the target tasks). Both GP implementations use RBF-kernels. As in the main text, we average performance over context sets with sizes $N \in \{0, \dots, 64\}$ for RBF GP and $N \in \{0, \dots, 20\}$ for the other experiments. Multi-task GP constitutes the optimal model (assuming it fits the hyperparameters perfectly) for the RBF GP experiment, which explains its superior performance. On the Quadratic 1D experiment, Multi-task GP still performs better than the other methods as this function class shows a relatively low degree of variability. In contrast, on more complex experiments like Quadratic 3D and the Furuta dynamics, none of the GP variants is able to produce meaningful results given the small budget of at most 20 context points, while NP-based methods produce predictions of high quality as they incorporate the source data more efficiently. + +
NPs with MC-lossGP
BAMAVanillaMulti-task
RBF GP1.62 ± 0.051.07 ± 0.051.962.99
Quadratic 1D, L = 641.71 ± 0.231.27 ± 0.06-1.562.11
Quadratic 3D, L = 128-1.79 ± 0.07-2.14 ± 0.05-472.76-173.78
Furuta Dynamics8.25 ± 0.337.55 ± 0.24-6.16-2.47
+ +# 7.4 NEURAL PROCESS-BASED MODELS IN THE CONTEXT OF SCALABLE PROBABILISTIC REGRESSION + +We discuss in more detail how NP-based models relate to other existing methods for (scalable) probabilistic regression, such as (multi-task) GPs (Rasmussen and Williams, 2005; Bardenet et al., 2013; Yogatama and Mann, 2014; Golovin et al., 2017), Bayesian neural networks (BNNs) (MacKay, 1992; Gal and Ghahramani, 2016), and DeepGPs (Damianou and Lawrence, 2013). + +NPs are motivated in Garnelo et al. (2018a;b), Kim et al. (2019), as well as in our Sec. 1, as models which combine the computational efficiency of neural networks with well-calibrated uncertainty estimates (like those of GPs). Indeed, NPs scale linearly in the number $N$ of context and $M$ of target data points, i.e., like $\mathcal{O}(N + M)$ , while GPs scale like $\mathcal{O}(N^3 + M^2)$ . Furthermore, NPs are shown to exhibit well-calibrated uncertainty estimates. In this sense, NPs can be counted as members of the family of scalable probabilistic regression methods. + +A central aspect of NP training which distinguishes NPs from a range of standard methods is that they are trained in a multi-task fashion (cf. Sec. 3). This means that NPs rely on data from a set of related source tasks from which they automatically learn powerful priors and the ability to adapt quickly to unseen target tasks. This multi-task training procedure of NPs scales linearly in the number $L$ of source tasks, which makes it possible to train these architectures on large amounts of source data. Applying GPs in such a multi-task setting can be challenging, especially for large numbers of source tasks. Similarly, BNNs as well as DeepGPs are in their vanilla forms specifically designed for the single-task setting. Therefore, GPs, BNNs, and DeepGPs are not directly applicable in the NP multi-task setting, which is why they are typically not considered as baselines for NP-based models, as discussed in (Kim et al., 2019). + +The experiments presented in Garnelo et al. (2018a;b) and Kim et al. (2019) focus mainly on evaluating NPs in the context of few-shot probabilistic regression, i.e., on demonstrating the data-efficiency of NPs on the target task after training on data from a range of source tasks. In contrast, the application of NPs in situations with large (> 1000) numbers of context/target points per task has to the best of our knowledge not yet been investigated in detail in the literature. Furthermore, it has not been studied how to apply NPs in situations where only a single or very few source tasks are available. The focus of our paper is a clear-cut comparison of the performance of our BA with traditional MA in the context of NP-based models. Therefore, we also consider experiments similar to those presented in (Garnelo et al., 2018a;b; Kim et al., 2019) and leave further comparisons with existing methods for (multi-task) probabilistic regressions for future work. + +Nevertheless, to illustrate this discussion, we provide two simple GP-based baseline methods: (i) a vanilla GP, which optimizes the hyperparameters on each target task individually and does not use + +the source data, and (ii) a naive but easily interpretable example of a multi-task GP, which optimizes one set of hyperparameters on all source tasks and uses it for predictions on the target tasks without further adaptation. The results in Tab. 7 show that those GP-based models can only compete with NPs on function classes where either the inductive bias as given by the kernel functions fits the data well (RBF GP), or on function classes which exhibit a relatively low degree of variability (Quadratic 1D). On more complex function classes, NPs produce predictions of much better quality, as they incorporate the source data more efficiently. + +# 7.5 EXPERIMENTAL DETAILS + +We provide details about the data sets as well as about the experimental setup used in our experiments in Sec. 5. + +# 7.5.1 DATA GENERATION + +In our experiments, we use several classes of functions to evaluate the architectures under consideration. To generate training data from these function classes, we sample $L$ random tasks (as described in Sec. 5), and $N_{\mathrm{tot}}$ random input locations $x$ for each task. For each minibatch of training tasks, we uniformly sample a context set size $N \in \{n_{\mathrm{min}}, \dots, n_{\mathrm{max}}\}$ and use a random subset of $N$ data points from each task as context sets $\mathcal{D}^c$ . The remaining $M = N_{\mathrm{tot}} - N$ data points are used as the target sets $\mathcal{D}^t$ (cf. App. 7.5.3 for the special case of the VI likelihood approximation). Tab. 8 provides details about the data generation process. + +GP Samples. We sample one-dimensional functions $f: \mathbb{R} \to \mathbb{R}$ from GP priors with three different stationary kernel functions as proposed by Gordon et al. (2020). + +A radial basis functions (RBF) kernel with lenghtscale $l = 1.0$ .. + +$$ +k _ {\mathrm {R B F}} (r) \equiv \exp (- 0. 5 r ^ {2}). \tag {22} +$$ + +A weakly periodic kernel: + +$$ +k _ {\mathrm {W P}} (r) \equiv \exp \left(- 2 \sin (0. 5 r) ^ {2} - 0. 1 2 5 r ^ {2}\right). \tag {23} +$$ + +A Matern-5/2 kernel with lengthscale $l = 0.25$ + +$$ +k _ {\mathrm {M} 5 / 2} (r) \equiv \left(1 + \frac {\sqrt {5} r}{0 . 2 5} + \frac {5 r ^ {2}}{3 \cdot 0 . 2 5 ^ {2}}\right) \exp \left(- \frac {\sqrt {5} r}{0 . 2 5}\right). \tag {24} +$$ + +Quadratic Functions. We consider two classes of quadratic functions. The first class $f^{Q,1D} : \mathbb{R} \to \mathbb{R}$ is defined on a one-dimensional domain and parametrized by three parameters $a, b, c \in \mathbb{R}$ : + +$$ +f ^ {Q, 1 \mathrm {D}} (x) \equiv a ^ {2} (x + b) ^ {2} + c. \tag {25} +$$ + +The second class $f^{Q,3\mathrm{D}}: \mathbb{R}^3 \to \mathbb{R}$ is defined on a three-dimensional domain and also parametrized by three parameters $a, b, c \in \mathbb{R}$ : + +$$ +f ^ {Q, 3 \mathrm {D}} \left(x _ {1}, x _ {2}, x _ {3}\right) \equiv 0. 5 a \left(x _ {1} ^ {2} + x _ {2} ^ {2} + x _ {3} ^ {2}\right) + b \left(x _ {1} + x _ {2} + x _ {3}\right) + 3 c. \tag {26} +$$ + +This function class was proposed in Perrone et al. (2018). + +For both function classes we add Gaussian noise with standard deviation $\sigma_{n}$ to the evaluations, cf. Tab. 8. + +Furuta Pendulum Dynamics. We consider a function class obtained by integrating the non-linear equations of motion governing the dynamics of a Furuta pendulum (Furuta et al., 1992; Cazzolato and Prime, 2011) for a time span of $\Delta t = 0.1$ s. More concretely, we consider the mapping + +$$ +\Theta (t) \rightarrow \Theta (t + \Delta t) - \Theta (t), \tag {27} +$$ + +Table 8: Input spaces and parameters used to generate data for training and testing the architectures discussed in the main part of this paper. $\mathrm{U}\left( {a,b}\right)$ denotes the uniform distribution on the interval $\left\lbrack {a,b}\right\rbrack$ , and, likewise $\mathrm{U}\left\{ {a,a + n}\right\}$ denotes the uniform distribution on the set $\{ a,a + 1,\ldots ,a + n\}$ . + +
SymbolDescriptionValue/Sampling distribution
GP Samples
xInputU(-2.0,+2.0)
NtotNumber of data points per task128
{nmin,...}Context set sizes during training{3,...,50}
1D Quadratic Functions
xInputU(-1.0,+1.0)
aParameterU(-0.5,+1.5)
bParameterU(-0.9,+0.9)
cParameterU(-1.0,+1.0)
σnNoise standard deviation0.01
NtotNumber of data points per task128
{nmin,...}Context set sizes during trainingU{0,...,20}
3D Quadratic Functions
x1,x2,x3InputsU(-1.0,+1.0)
a,b,cParametersU(+0.1,+10.0)
σnNoise standard deviation0.01
NtotNumber of data points per task128
{nmin,...}Context set sizes during trainingU{0,...,20}
Furuta Dynamics
θarm, θpendInput anglesU(0.0,2π rad)
θarm, θpendInput angular velocitiesU(-2π rad/0.5s, 2π rad/0.5s)
marmMass armU(6.0·10-2kg, 6.0·10-1kg)
mpendMass pendulumU(1.5·10-2kg, 1.5·10-1kg)
larmLength armU(5.6·10-2m, 5.6·10-1m)
LarmDistance joint arm — mass armU(1.0·10-1m, 3.0·10-1m)
LpendDistance joint pend. — mass pend.U(1.0·10-1m, 3.0·10-1m)
barmDamping constant armU(2.0·10-5Nms, 2.0·10-3Nms)
bpendDamping constant pendulumU(5.6·10-5Nms, 5.6·10-3Nms)
στ,armAction noise standard dev. arm0.5Nm
στ,pendAction noise standard dev. pend.0.5Nm
NtotNumber of data points per task256
{nmin,...}Context set sizes during trainingU{0,...,20}
2D Image Completion MNIST
x1,x2Input pixel locationsU{0,27} (scaled to [0,1])
NtotNumber of data points per task28·28
{nmin,...}Context set sizes during trainingU{0,...,28·28/2}
+ +where $\Theta = \left[\theta_{\mathrm{arm}}(t),\theta_{\mathrm{pend}}(t),\dot{\theta}_{\mathrm{arm}}(t),\dot{\theta}_{\mathrm{pend}}(t)\right]^T$ denotes the four-dimensional vector describing the dynamical state of the Furuta pendulum. The Furuta pendulum is parametrized by seven parameters (two masses, three lengths, two damping constants) as detailed in Tab. 8. During training, we provide $L = 64$ tasks, corresponding to 64 different parameter configurations. We consider the free system and generate noise by applying random torques at each integration time step $(\Delta t_{\mathrm{Euler}} = 0.001\mathrm{s})$ to the joints of the arm and pendulum drawn from Gaussian distributions with standard deviations $\sigma_{\tau,\mathrm{pend}},\sigma_{\tau,\mathrm{arm}}$ , respectively. + +![](images/8a270a0026ad1b54971488cac80ac4036e52cae5a3e4474f733899e3bda6d4c4.jpg) +(a) $\mathrm{BA} + \mathrm{PB}$ + +![](images/faa1d136973241711d17f7933d7bcd3c43095af99ab94f81cd904b70bacb24fe.jpg) +(b) $\mathrm{MA} + \mathrm{det}$ . (CNP). + +![](images/1db89b703d54c1fc6ea4fb69c63852543eaf7b991043746a52093b3e5e246af1.jpg) +(c) $\mathrm{BA} + \mathrm{VI}$ , $\mathrm{BA} + \mathrm{MC}$ . + +![](images/f0e88ec1517410297cf98dd5722da6d6be0dc5e567210297db60dfd3b50f9e8e.jpg) +(d) MA + VI (LP-NP), MA + MC. +Figure 4: Model architectures used for our experiments in Sec. 5. For the ANP architecture we refer the reader to Kim et al. (2019). Orange rectangles denote MLPs. Blue rectangles denote aggregation operations. Variables in green rectangles are sampled from normal distributions with parameters given by the incoming nodes. To arrive at a fair comparison, we optimize all MLP architectures, the latent space dimensionality $d_{z}$ , as well as the Adam learning rate, individually for all model architectures and all experiments, cf. App. 7.5.3. + +2D Image Completion. For this task, we use the MNIST database of $28 \times 28$ images of handwritten digits (LeCun and Cortes, 2010), and define 2D functions mapping pixel locations $x_{1}, x_{2} \in \{0, \dots, 27\}$ (scaled to the unit square) to the corresponding pixel intensities $y \in \{0, \dots, 255\}$ (scaled to the unit interval), cf. Tab. 8. One training task corresponds to one image drawn randomly from the training set (consisting of 60000 images) and for evaluation we use a subset of the test set (consisting of 10000 images). + +# 7.5.2 MODEL ARCHITECTURES + +We provide the detailed architectures used for the experiments in Sec. 5 in Fig. 4. For ANP we use multihead cross attention and refer the reader to Kim et al. (2019) for details about the architecture. + +# 7.5.3 HYPERPARAMETERS AND HYPERPARAMETER OPTIMIZATION + +To arrive at a fair comparison of our BA with MA, it is imperative to use optimal model architectures for each aggregation method and likelihood approximation under consideration. Therefore, we optimize the number of hidden layers and the number of hidden units per layer of each encoder and decoder MLP (as shown in Fig. 4), individually for each model architecture and each experiment. For the ANP, we also optimize the multihead attention MLPs. We further optimize the latent space dimensionality $d_{z}$ and the learning rate of the Adam optimizer. For this hyperparameter optimization, we use the Optuna framework (Akiba et al., 2019) with TPE Sampler and Hyperband pruner (Li et al., 2017). We consistently use a minibatch size of 16. Further, we use $S = 10$ latent samples to evaluate + +the MC likelihood approximation during training. To evaluate the VI likelihood approximation, we sample target set sizes between $N_{\mathrm{tot}}$ and $N$ in each training epoch, cf. Tab. 8. + +# 7.5.4 EVALUATION PROCEDURE + +To evaluate the performance of the various model architectures we generate $L = 256$ unseen test tasks with target sets $\mathcal{D}_{\ell}^{t}$ consisting of $M = 256$ data points each and compute the average posterior predictive log-likelihood $\frac{1}{L}\frac{1}{M}\sum_{\ell = 1}^{L}\log p\left(y_{\ell ,1:M}^{t}\Bigg{|}x_{\ell ,1:M}^{t},\mathcal{D}_{\ell}^{c},\theta\right)$ , given context sets $\mathcal{D}_{\ell}^{c}$ of size $N$ . + +Depending on the architecture, we approximate the posterior predictive log-likelihood according to: + +- For BA + PB likelihood approximation: + +$$ +\frac {1}{L} \frac {1}{M} \sum_ {\ell = 1} ^ {L} \sum_ {m = 1} ^ {M} \log p \left(y _ {\ell , m} ^ {t} \mid x _ {\ell , m} ^ {t}, \mu_ {z, \ell}, \sigma_ {z, \ell} ^ {2}, \theta\right). \tag {28} +$$ + +- For MA + deterministic loss (= CNP): + +$$ +\frac {1}{L} \frac {1}{M} \sum_ {\ell = 1} ^ {L} \sum_ {m = 1} ^ {M} \log p \left(y _ {\ell , m} ^ {t} \mid x _ {\ell , m} ^ {t}, \bar {r} _ {\ell}, \theta\right). \tag {29} +$$ + +- For architectures employing sampling-based likelihood approximations (VI, MC-LL) we report the joint log-likelihood over all data points in a test set, i.e. + +$$ +\begin{array}{l} \frac {1}{L} \frac {1}{M} \sum_ {\ell = 1} ^ {L} \log \int q _ {\phi} (z _ {\ell} | \mathcal {D} _ {\ell} ^ {c}) \prod_ {m = 1} ^ {M} p \left(y _ {\ell , m} ^ {t} \mid x _ {\ell , m} ^ {t}, z _ {\ell}, \theta\right) d z _ {\ell} (30) \\ \approx \frac {1}{L} \frac {1}{M} \sum_ {\ell = 1} ^ {L} \log \frac {1}{S} \sum_ {s = 1} ^ {S} \prod_ {m = 1} ^ {M} p \left(y _ {\ell , m} ^ {t} \mid x _ {\ell , m} ^ {t}, z _ {\ell , s}, \theta\right) (31) \\ = - \frac {1}{M} \log S + \frac {1}{L} \frac {1}{M} \sum_ {l = 1} ^ {L} \operatorname {l o g s u m e x p} _ {s = 1} ^ {S} \left(\sum_ {m = 1} ^ {M} \log p \left(y _ {\ell , m} ^ {t} \mid x _ {\ell , m} ^ {t}, z _ {\ell , s}, \theta\right)\right), (32) \\ \end{array} +$$ + +where $z_{\ell ,s}\sim q_{\phi}(z|\mathcal{D}_{\ell})$ . We employ $S = 25$ latent samples. + +To compute the log-likelihood values given in tables, we additionally average over various context set sizes $N$ as detailed in the main part of this paper. + +We report the mean posterior predictive log-likelihood computed in this way w.r.t. 10 training runs with different random seeds together with $95\%$ confidence intervals + +Table 9: Relative evaluation runtimes and numbers of parameters of the optimized network architectures on the GP tasks. The deterministic methods (PB, det.) are much more efficient regarding evaluation runtime, as they require only on forward pass per prediction, while the sampling-based approaches (VI, MC) require multiple forward passes (each corresponding to one latent sample) to compute their predictions. We use $S = 25$ latent samples, as described in App. 7.5.4. Furthermore, BA tends to require less complex encoder and decoder network architectures compared to MA, because it represents a more efficient mechanism to propagate information from the context set to the latent state. + +
PB/det.VIMC
BAMA (CNP)BAMA (LP-NP)BAMA
RBF GPRuntime11.418253227
#Parameters72k96k63k77k122k153k
Weakly Periodic GPRuntime11.411102215
#Parameters51k87k48k72k87k89k
Matern-5/2 GPRuntime11.16.5111519
#Parameters53k100k32k35k108k104k
+ +Table 10: Posterior predictive mean squared error (MSE) on all experiments presented in this paper. We average over the same context set sizes as used to compute the posterior predictive log-likelihood, cf. Sec. 5, and again use $S = 25$ latent samples to compute the mean prediction of sampling-based methods. Our BA consistently improves predictive performance compared to MA not only in terms of likelihood (as shown in Sec. 5), but also in terms of MSE. Furthermore, while ANP tends to perform poorly in terms of likelihood (cf. Sec. 5), it's MSE is improved greatly by the attention mechanism. + +
PB/det.VIMCANP
BAMA (CNP)BAMA (LP-NP)BAMAMA + Attention
RBF GP0.0623 ± 0.00090.0687 ± 0.00100.0736 ± 0.00050.0938 ± 0.00360.0637 ± 0.00070.0741 ± 0.00120.0550 ± 0.0009
Weakly Periodic GP0.0679 ± 0.00070.0761 ± 0.00140.0879 ± 0.00170.1326 ± 0.05180.0677 ± 0.00080.0832 ± 0.00090.0592 ± 0.0009
Matern-5/2 GP0.2452 ± 0.00880.3021 ± 0.00350.3702 ± 0.01000.6292 ± 0.10770.2321 ± 0.00190.5166 ± 0.14380.1890 ± 0.0012
Quadratics 1D, L = 640.1447 ± 0.00950.1513 ± 0.00910.1757 ± 0.01280.1833 ± 0.01540.1473 ± 0.01070.1636 ± 0.00820.1330 ± 0.0037
Quadratics 3D, L = 128190.5 ± 1.4195.4 ± 1.5253.1 ± 18.0278.1 ± 40.5196.8 ± 2.6206.7 ± 5.3192.5 ± 2.7
Furuta Dynamics0.1742 ± 0.00920.1989 ± 0.00950.2269 ± 0.00880.2606 ± 0.01650.1758 ± 0.01240.1977 ± 0.01540.1516 ± 0.0073
2D Image Completion0.0348 ± 0.00100.0417 ± 0.0026----0.0215 ± 0.0003
+ +# 7.6 ADDITIONAL EXPERIMENTAL RESULTS + +We provide additional experimental results accompanying the experiments presented in Sec. 5: + +- Results for relative evaluation runtimes and numbers of parameters of the optimized network architectures on the full GP suite of experiments, cf. Tab. 9. +- The posterior predictive mean squared error on all experiments, cf. Tab. 10. +- The context-size dependent results for the predictive posterior log-likelihood for the 1D and 3D Quadratic experiments, the Furuta dynamics experiment, as well as the 2D image completion experiment, cf. Fig. 5. +- More detailed plots of the predictions on one-dimensional experiments (1D Quadratics (Figs. 6, 7), RBF-GP, (Figs. 8, 9), Weakly Periodic GP (Figs. 10, 11), and Matern-5/2 GP (Figs. 12, 13)). + +![](images/7e8e0ad4a386801f70d4c69c404faccc18f62378b0eb3535593b0f69461a3cf7.jpg) +Figure 5: Posterior predictive log-likelihood in dependence of the context set size $N$ for the 1D and 3D Quadratic experiments, the Furuta dynamics experiment as well as the 2D image completion experiment. + +![](images/23f03d93ff3e073f69b5d30fd6d2074bc9c2360682ef1f6ff5b3014472b468a4.jpg) + +![](images/dbeec137ee75e634d1a45a734d64fae261750f0dbab457c70027baad8bf1692c.jpg) + +![](images/de8f7a2d367ea5f4f0443a25cd27ebc834e5e962f576409cf3efbe171f760574.jpg) + +![](images/58d697ed2f2fcea05038188f6f157da40e31fb6b4eaaef6eeb649d4f626c15ac.jpg) +(a) $\mathrm{BA} + \mathrm{PB}$ + +![](images/3ef137b56163a656320243bad7c7c63da885cb82674b147e425c14dbd7a69c51.jpg) +(b) MA + det. (CNP) + +![](images/a80c645537f01cb16e081326f82e28ea455273da4fd409cb41aa6720ecc2eba1.jpg) +(c) $\mathrm{BA} + \mathrm{VI}$ + +![](images/6425ada669f103355256b6ef26afe23ae28fb921fc6391b72f702fd8fd0d3e3a.jpg) +(d) MA + VI (LP-NP) + +![](images/4230ee0be4ece0b6032492191bb06e25a7c32a5a0e37874e066f486f2e284b30.jpg) +(e) ANP + +![](images/cffc21bf813d89beb620acdbd1e1690e93427873513be1eb0b7a1d2bd9c0ea7a.jpg) +(f) $\mathrm{BA} + \mathrm{MC}$ -LL +Figure 6: Predictions on two instances (dashed lines) of the 1D quadratic function class, given $N = 3$ context data points (circles). We plot mean and standard deviation (solid line, shaded area) predictions together with 10 function samples (for deterministic methods we employ AR sampling). + +![](images/140b47dbef0069318e9512b35ff3e2491a1d7b85ff07b54fca864cd2f6afe062.jpg) +(g) MA + MC-LL + +![](images/a52ebaf017b9ec17c2c1806f6d69989737d75e396af7cbf7de4b25de44b2974b.jpg) +(a) $\mathrm{BA} + \mathrm{PB}$ + +![](images/e25b43e2119687f291393596effcccbada2e019d3eab2748b27312b09ed9adac.jpg) +(b) MA + det. (CNP) + +![](images/a0ab7ddc75fe3b0c557729fa0fb6af9fca2511c26f6a919d72366c640dfd3e86.jpg) +(c) $\mathrm{BA} + \mathrm{VI}$ + +![](images/2ef30898cb1813b8134971b861afb10841d7d1d771dcc18abf083eb3d7472ce2.jpg) +(d) MA + VI (LP-NP) + +![](images/09e17329be88135fd897a20cbee11731199ea7a7d0ac48d769b9cb95c4a4b993.jpg) +(e) ANP + +![](images/586603ff3c9b76af98e49ba0f47897452e2ef88ff01549f981a9d4a785de7411.jpg) +(f) $\mathrm{BA} + \mathrm{MC}$ -LL +Figure 7: Predictions on two instances (dashed lines) of the 1D quadratic function class, given $N = 19$ context data points (circles). We plot mean and standard deviation (solid line, shaded area) predictions together with 10 function samples (for deterministic methods we employ AR sampling). + +![](images/275aacc37ce2df0252d064948042a7479e1f304d5e803b395b18ff07ca3d72bc.jpg) +(g) MA + MC-LL + +![](images/80a8878d82360c881f3e0af29479431180afc4a75da09da25ad617f2b865985f.jpg) +(a) $\mathrm{BA} + \mathrm{PB}$ + +![](images/002513c4e2e3761b46dc4380d054268184352fd73dc76726db95e81b447162dd.jpg) +(b) MA + det. (CNP) + +![](images/b573fd74d06a5b555011f7a1d320ea9abac970386846584f66df4d5e2e10c60a.jpg) +(c) $\mathrm{BA} + \mathrm{VI}$ + +![](images/a32ffdd202d7e7c2d536ba6a217368987d793340f9fc7df909f94fab7e6f88f3.jpg) +(d) MA + VI (LP-NP) + +![](images/b993963027502effea483e6827dbd7c2c6ab7038b0070c7024503869ef1869c7.jpg) +(e) ANP + +![](images/361e13bff5199047f1807c26bd705b2dddaf77ba893728d89b4b8fb66411aa3c.jpg) +(f) $\mathrm{BA} + \mathrm{MC}$ -LL + +![](images/b0b99c27b1e3d845859ce7adcff1e18d38fad2621f8dd3b7a23ecf97a896de11.jpg) +(g) MA + MC-LL +Figure 8: Predictions on two instances (dashed lines) of the RBF GP function class, given $N = 20$ context data points (circles). We plot mean and standard deviation (solid line, shaded area) predictions together with 10 function samples (for deterministic methods we employ AR sampling). + +![](images/8eea40b324e9234a73a8e13368b622f6148471f76e874cb3dbf2c03fcbe931e9.jpg) +(a) $\mathrm{BA} + \mathrm{PB}$ + +![](images/bdd17150cef5cb068ee6e516338859461ee99f991d729a33384fa602a7d7ef72.jpg) +(b) MA + det. (CNP) + +![](images/2cd8258ff618469dfa94fa169d2f0d336927914da9d15b5cf6e6d98f9286eed0.jpg) +(c) $\mathrm{BA} + \mathrm{VI}$ + +![](images/82c57ec0ce2b4d1602ef71295d588324664e77bbeb26617e5e0d3805c0737686.jpg) +(d) MA + VI (LP-NP) + +![](images/335d576cfeeff0cca73e00f154ea0e087047af6feaf74753ed5a57356dc51311.jpg) +(e) ANP + +![](images/165d6d8be4a4f446d24396876db6cfbfe1ff7147f8933fe8a45039e597d6cc32.jpg) +(f) $\mathrm{BA} + \mathrm{MC}$ -LL + +![](images/47034fc5831613fb8b1a9b53f6d80af32d0db0d4509ef15a2ba59a02191f2f88.jpg) +(g) MA + MC-LL +Figure 9: Predictions on two instances (dashed lines) of the RBF GP function class, given $N = 60$ context data points (circles). We plot mean and standard deviation (solid line, shaded area) predictions together with 10 function samples (for deterministic methods we employ AR sampling). + +![](images/054eee5b47c922e3e0cbcad48507e35c546ba3737d00a283ef259510bdc1d38c.jpg) +(a) $\mathrm{BA} + \mathrm{PB}$ + +![](images/ea6eed1cc0676b546383b553662c68e18e90c1d5b949f1953eecfcfe621360e1.jpg) +(b) MA + det. (CNP) + +![](images/93be3b3fa35c7a9e23b9a5b87ad8b419bad941fd933e0e3729e92d602589f37a.jpg) +(c) $\mathrm{BA} + \mathrm{VI}$ + +![](images/d38e6cc041dc47b35b41223d7676a0021a290ed5796e75147b62701a839119ff.jpg) +(d) MA + VI (LP-NP) + +![](images/06d74b35513a6cd2264f78859882674f551991e6738ebc29c0751bf0d8d8c071.jpg) +(e) ANP + +![](images/e8ef7fc7f46f617f3d48407c74e7adc45a8338f709bca93328af8ddb63924e42.jpg) +(f) $\mathrm{BA} + \mathrm{MC}$ -LL + +![](images/12271f3099c644916100f24224900efdfe85a6f591fc69a0ea0202ad16abf444.jpg) +(g) MA + MC-LL +Figure 10: Predictions on two instances (dashed lines) of the Weakly Periodic GP function class, given $N = 20$ context data points (circles). We plot mean and standard deviation (solid line, shaded area) predictions together with 10 function samples (for deterministic methods we employ AR sampling). + +![](images/405d31ca8bbc4c53095a29112ae632a1a0ff3c72c567fd797de11f719ff93920.jpg) +(a) $\mathrm{BA} + \mathrm{PB}$ + +![](images/8ca6b18620e84d9d3ee5c3280239b28991eef55bda610e12e0a1ab1e9e1d4cc6.jpg) +(b) MA + det. (CNP) + +![](images/0954514c4c85f03834cd8138bb8f637e379928226dc506ed14254eedbf1cb445.jpg) +(c) $\mathrm{BA} + \mathrm{VI}$ + +![](images/274bb733b795caa3acae31404da61c52c9823c4ec8df9e06b044f9d655b29a3c.jpg) +(d) MA + VI (LP-NP) + +![](images/1b12fb1dadb32c907ef7c8b6b0470bfc8a6f5cafd68e771888126fcdba1e3034.jpg) +(e) ANP + +![](images/76c11d1a8b92614827773b78b413081daf9f5164d343bbfe6248d14336acae9d.jpg) +(f) $\mathrm{BA} + \mathrm{MC}$ -LL + +![](images/b436a84f32ce4599125a14ff9ccd0a36dc16fc8ab493368f72a1efce8fc8b840.jpg) +(g) MA + MC-LL +Figure 11: Predictions on two instances (dashed lines) of the Weakly Periodic GP function class, given $N = 60$ context data points (circles). We plot mean and standard deviation (solid line, shaded area) predictions together with 10 function samples (for deterministic methods we employ AR sampling). + +![](images/a714cb96c4d7d1f0e37c29a2410b198d977c8d45025cf7040166556f3ae74eaa.jpg) +(a) $\mathrm{BA} + \mathrm{PB}$ + +![](images/e923aecd64fd2764324c64462dfb1245609f99af1e2676d6f4bd9beec5d58da0.jpg) +(b) MA + det. (CNP) + +![](images/fb1c0e1cc6a87df42bd0a50358aa62c47f34dcfef102691331d4c801daa9c06e.jpg) +(c) $\mathrm{BA} + \mathrm{VI}$ + +![](images/06bb5d1f743e3e6e5d10caf744c917d7d5da1d4beec8c47614404d33a1ec3e66.jpg) +(d) MA + VI (LP-NP) + +![](images/00064f7270273a752a8d37e8534b6ebb5d43d288cc760bb535bc1e7e114a5b66.jpg) +(e) ANP + +![](images/e5a149c310b4bac5532bdcb15cb1176e6bbb1891f2ec1fffe126830768dc341d.jpg) +(f) $\mathrm{BA} + \mathrm{MC}$ -LL + +![](images/d8a4c3dff303714eccd99ac383310b5f248655dfcaeacda101fdba622b288864.jpg) +(g) MA + MC-LL +Figure 12: Predictions on two instances (dashed lines) of the Matern-5/2 GP function class, given $N = 20$ context data points (circles). We plot mean and standard deviation (solid line, shaded area) predictions together with 10 function samples (for deterministic methods we employ AR sampling). + +![](images/cc13daa7cf9336cc28874e58fbe77a5db77c6f7765e10e5f1833ecd2a0da4496.jpg) +(a) $\mathrm{BA} + \mathrm{PB}$ + +![](images/14ae5f9e8a7a82e81b69ec6d9e4099f7b43a6bc7a161f7e73e5315152e8d35c5.jpg) +(b) MA + det. (CNP) + +![](images/db9b7fdfd8402710b3d14a9aab97277436ce93135c3ecc9b58424b784b6bc19d.jpg) +(c) $\mathrm{BA} + \mathrm{VI}$ + +![](images/cacf8918c3ab7e12177b553ca8c2b8b584fb3f12368e9a04bfb1fac1246ccc80.jpg) +(d) MA + VI (LP-NP) + +![](images/a3fdfbcaf26815091063a0d457852774ea8db6ba97bbcec6551efd6fb9a67928.jpg) +(e) ANP + +![](images/f55305d0248a26b86ed01e36b399d4597de142d768d87c95a12ecf56ac4c722c.jpg) +(f) $\mathrm{BA} + \mathrm{MC}$ -LL + +![](images/24916520eb63430966b90e16aca380fdd44baa5f2104191a9c42d1d0e915495a.jpg) +(g) MA + MC-LL +Figure 13: Predictions on two instances (dashed lines) of the Matern-5/2 GP function class, given $N = 60$ context data points (circles). We plot mean and standard deviation (solid line, shaded area) predictions together with 10 function samples (for deterministic methods we employ AR sampling). \ No newline at end of file diff --git a/bayesiancontextaggregationforneuralprocesses/images.zip b/bayesiancontextaggregationforneuralprocesses/images.zip new file mode 100644 index 0000000000000000000000000000000000000000..d60c0821b15f93c6c91e99dbff24d35602996357 --- /dev/null +++ b/bayesiancontextaggregationforneuralprocesses/images.zip @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:33259975dba522ff6c0fcc71c1571122f1060e2ff729902ca643a5afeb8c7492 +size 1344378 diff --git a/bayesiancontextaggregationforneuralprocesses/layout.json b/bayesiancontextaggregationforneuralprocesses/layout.json new file mode 100644 index 0000000000000000000000000000000000000000..44590c22efb86f178f172b3c88c27442257d5792 --- /dev/null +++ b/bayesiancontextaggregationforneuralprocesses/layout.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6d583e49897c211d46a6edef6da6c9ca8d3d18cf4fffa1d8738f87f2e337060a +size 1017862 diff --git a/bayesianfewshotclassificationwithonevseachplyagammaaugmentedgaussianprocesses/d67a40fe-301f-48a0-9127-71cd1e06517e_content_list.json b/bayesianfewshotclassificationwithonevseachplyagammaaugmentedgaussianprocesses/d67a40fe-301f-48a0-9127-71cd1e06517e_content_list.json new file mode 100644 index 0000000000000000000000000000000000000000..8cf99f852d673ea58e76fde25108331f4d17f7c9 --- /dev/null +++ b/bayesianfewshotclassificationwithonevseachplyagammaaugmentedgaussianprocesses/d67a40fe-301f-48a0-9127-71cd1e06517e_content_list.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:97cfd77c1e243498c275ace8508f888dc9e176c4e0d3a95c2bf4a67766f54fce +size 168149 diff --git a/bayesianfewshotclassificationwithonevseachplyagammaaugmentedgaussianprocesses/d67a40fe-301f-48a0-9127-71cd1e06517e_model.json b/bayesianfewshotclassificationwithonevseachplyagammaaugmentedgaussianprocesses/d67a40fe-301f-48a0-9127-71cd1e06517e_model.json new file mode 100644 index 0000000000000000000000000000000000000000..cf36d38060f3df7ad0a7d625eaa09b6c2f059d0f --- /dev/null +++ b/bayesianfewshotclassificationwithonevseachplyagammaaugmentedgaussianprocesses/d67a40fe-301f-48a0-9127-71cd1e06517e_model.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b5f7cda3d2ed8b1241c45f7fd044938e6b3e9f0e7d3566aa4100a9b3dbc09c52 +size 201514 diff --git a/bayesianfewshotclassificationwithonevseachplyagammaaugmentedgaussianprocesses/d67a40fe-301f-48a0-9127-71cd1e06517e_origin.pdf b/bayesianfewshotclassificationwithonevseachplyagammaaugmentedgaussianprocesses/d67a40fe-301f-48a0-9127-71cd1e06517e_origin.pdf new file mode 100644 index 0000000000000000000000000000000000000000..5c6d7b3c7db4de8fd67281a48d72bfff12666d34 --- /dev/null +++ b/bayesianfewshotclassificationwithonevseachplyagammaaugmentedgaussianprocesses/d67a40fe-301f-48a0-9127-71cd1e06517e_origin.pdf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7e681774d87418930858408576eeaae875d3bb210f2bef9bb06f75d45ecc7152 +size 6668584 diff --git a/bayesianfewshotclassificationwithonevseachplyagammaaugmentedgaussianprocesses/full.md b/bayesianfewshotclassificationwithonevseachplyagammaaugmentedgaussianprocesses/full.md new file mode 100644 index 0000000000000000000000000000000000000000..c778c369265fe12612a70f15b5ef9982b4b5f1f5 --- /dev/null +++ b/bayesianfewshotclassificationwithonevseachplyagammaaugmentedgaussianprocesses/full.md @@ -0,0 +1,783 @@ +# BAYESIAN FEW-SHOT CLASSIFICATION WITH ONE-VS-EACH POLYA-GAMMA AUGMENTED GAUSSIAN PROCESSES + +Jake C. Snell + +University of Toronto + +Vector Institute + +jsnell@cs.toronto.edu + +Richard Zemel + +University of Toronto + +Vector Institute + +Canadian Institute for Advanced Research + +zemel@cs.toronto.edu + +# ABSTRACT + +Few-shot classification (FSC), the task of adapting a classifier to unseen classes given a small labeled dataset, is an important step on the path toward human-like machine learning. Bayesian methods are well-suited to tackling the fundamental issue of overfitting in the few-shot scenario because they allow practitioners to specify prior beliefs and update those beliefs in light of observed data. Contemporary approaches to Bayesian few-shot classification maintain a posterior distribution over model parameters, which is slow and requires storage that scales with model size. Instead, we propose a Gaussian process classifier based on a novel combination of Pólya-Gamma augmentation and the one-vs-each softmax approximation (Titsias, 2016) that allows us to efficiently marginalize over functions rather than model parameters. We demonstrate improved accuracy and uncertainty quantification on both standard few-shot classification benchmarks and few-shot domain transfer tasks. + +# 1 INTRODUCTION + +Few-shot classification (FSC) is a rapidly growing area of machine learning that seeks to build classifiers able to adapt to novel classes given only a few labeled examples. It is an important step towards machine learning systems that can successfully handle challenging situations such as personalization, rare classes, and time-varying distribution shift. The shortage of labeled data in FSC leads to uncertainty over the parameters of the model, known as model uncertainty or epistemic uncertainty. If model uncertainty is not handled properly in the few-shot setting, there is a significant risk of overfitting. In addition, FSC is increasingly being used for risk-averse applications such as medical diagnosis (Prabhu, 2019) and human-computer interfaces (Wang et al., 2019) where it is important for a few-shot classifier to know when it is uncertain. + +Bayesian methods maintain a distribution over model parameters and thus provide a natural framework for capturing this inherent model uncertainty. In a Bayesian approach, a prior distribution is first placed over the parameters of a model. After data is observed, the posterior distribution over parameters is computed using Bayesian inference. This elegant treatment of model uncertainty has led to a surge of interest in Bayesian approaches to FSC that infer a posterior distribution over the weights of a neural network (Finn et al., 2018; Yoon et al., 2018; Ravi & Beatson, 2019). + +Although conceptually appealing, there are several practical obstacles to applying Bayesian inference directly to the weights of a neural network. Bayesian neural networks (BNNs) are expensive from both a computational and memory perspective. Moreover, specifying meaningful priors in parameter space is known to be difficult due to the complex relationship between weights and network outputs (Sun et al., 2019). + +Gaussian processes (GPs) instead maintain a distribution over functions rather than model parameters. The prior is directly specified by a mean and covariance function, which may be parameterized by deep neural networks. When used with Gaussian likelihoods, GPs admit closed form expressions for the posterior and predictive distributions. They exchange the computational drawbacks of BNNs + +for cubic scaling with the number of examples. In FSC, where the number of examples is small, this is often an acceptable trade-off. + +When applying GPs to classification with a softmax likelihood, the non-conjugacy of the GP prior renders posterior inference intractable. Many approximate inference methods have been proposed to circumvent this, including variational inference and expectation propagation. In this paper we investigate a particularly promising class of approaches that augment the GP model with a set of auxiliary random variables, such that when they are marginalized out the original model is recovered (Albert & Chib, 1993; Girolami & Rogers, 2006; Linderman et al., 2015). Such augmentation-based approaches typically admit efficient Gibbs sampling procedures for generating posterior samples which when combined with Fisher's identity (Douc et al., 2014) can be used to optimize the parameters of the mean and covariance functions. + +In particular, augmentation with Pólya-Gamma random variables (Polson et al., 2013) makes inference tractable in logistic models. Naively, this is useful for handling binary classification, but in this paper we show how to extend Pólya-Gamma augmentation to multiple classes by using the one-vs-each softmax approximation (Titsias, 2016), which can be expressed as a product of logistic sigmoidals. We further show that the one-vs-each approximation can be interpreted as a composite likelihood (Lindsay, 1988; Varin et al., 2011), a connection which to our knowledge has not been made in the literature. + +In this work, we make several contributions: + +- We show how the one-vs-each softmax approximation (Titsias, 2016) can be interpreted as a composite likelihood consisting of pairwise conditional terms. +- We propose a novel GP classification method that combines the one-vs-each softmax approximation with Pólya-Gamma augmentation for tractable inference. +- We demonstrate competitive classification accuracy of our method on standard FSC benchmarks and challenging domain transfer settings. +- We propose several new benchmarks for uncertainty quantification in FSC, including calibration, robustness to input noise, and out-of-episode detection. +- We demonstrate improved uncertainty quantification of our method on the proposed benchmarks relative to standard few-shot baselines. + +# 2 RELATED WORK + +Our work is related to both GP methods for handling non-conjugate classification likelihoods and Bayesian approaches to few-shot classification. We summarize relevant work here. + +# 2.1 GP CLASSIFICATION + +Non-augmentation approaches. There are several classes of approaches for applying Gaussian processes to classification. The most straightforward method, known as least squares classification (Rifkin & Klautau, 2004), treats class labels as real-valued observations and performs inference with a Gaussian likelihood. The Laplace approximation (Williams & Barber, 1998) constructs a Gaussian approximate posterior centered at the posterior mode. Variational approaches (Titsias, 2009; Matthews et al., 2016) maximize a lower bound on the log marginal likelihood. In expectation propagation (Minka, 2001; Kim & Ghahramani, 2006; Hernandez-Lobato & Hernandez-Lobato, 2016), local Gaussian approximations to the likelihood are fitted iteratively to minimize KL divergence from the true posterior. + +Augmentation approaches. Augmentation-based approaches introduce auxiliary random variables such that the original model is recovered when marginalized out. Girolami & Rogers (2006) propose a Gaussian augmentation for multinomial probit regression. Linderman et al. (2015) utilize Pólya-Gamma augmentation (Polson et al., 2013) and a stick-breaking construction to decompose a multinomial distribution into a product of binomials. Galy-Fajou et al. (2020) propose a logistic-softmax likelihood for classification and uses Gamma and Poisson augmentation in addition to Pólya-Gamma augmentation in order to perform inference. + +# 2.2 FEW-SHOT CLASSIFICATION + +Meta-learning. A common approach to FSC is meta-learning, which seeks to learn a strategy to update neural network parameters when faced with a novel learning task. The Meta-learner LSTM (Ravi & Larochelle, 2017) learns a meta-level LSTM to recurrently output a new set of parameters for a base learner. MAML (Finn et al., 2017) learns initializations of deep neural networks that perform well on task-specific losses after one or a few steps of gradient descent by backpropagating through the gradient descent procedure itself. LEO (Rusu et al., 2019) performs meta-learning in a learned low-dimensional latent space from which the parameters of a classifier are generated. + +Metric learning. Metric learning approaches learn distances such that input examples can be meaningfully compared. Siamese Networks (Koch, 2015) learn a shared embedding network along with a distance layer for computing the probability that two examples belong to the same class. Matching Networks (Vinyals et al., 2016) uses a nonparametric classification in the form of attention over nearby examples, which can be interpreted as a form of soft $k$ -nearest neighbors in the embedding space. Prototypical Networks (Snell et al., 2017) make predictions based on distances to nearest class centroids. Relation Networks (Sung et al., 2018) instead learn a more complex neural network distance function on top of the embedding layer. + +Bayesian Few-shot Classification. More recently, Bayesian FSC approaches that attempt to infer a posterior over task-specific parameters have appeared. Grant et al. (2018) reinterpret MAML as an approximate empirical Bayes algorithm and propose LLAMA, which optimizes the Laplace approximation to the marginal likelihood. Bayesian MAML (Yoon et al., 2018) instead uses Stein Variational Gradient Descent (SVGD) (Liu & Wang, 2016) to approximate the posterior distribution over model parameters. VERSA (Gordon et al., 2019) uses amortized inference networks to obtain an approximate posterior distribution over task-specific parameters. ABML (Ravi & Beatson, 2019) uses a few steps of Bayes by Backprop (Blundell et al., 2015) on the support set to produce an approximate posterior over network parameters. CNAPs (Requeima et al., 2019) modulate task-specific Feature-wise Linear Modulation (FiLM) (Perez et al., 2018) layer parameters as the output of an adaptation network that takes the support set as input. + +GPs for Few-shot Learning. There have been relatively few works applying GPs to few-shot learning. Tossou et al. (2020) consider Gaussian processes in the context of few-shot regression with Gaussian likelihoods. Deep Kernel Transfer (DKT) (Patacchiola et al., 2020) uses Gaussian processes with least squares classification to perform few-shot classification and learns covariance functions parameterized by deep neural networks. More recently, Titsias et al. (2020) applies GPs to meta-learning by maximizing the mutual information between the query set and a latent representation of the support set. + +# 3 BACKGROUND + +In this section we first review Pólya-Gamma augmentation for binary classification and the one-vseach approximation before we introduce our method in Section 4. + +# 3.1 PÓLYA-GAMMA AUGMENTATION + +The Pólya-Gamma augmentation scheme was originally introduced to address Bayesian inference in logistic models (Polson et al., 2013). Suppose we have a vector of logits $\psi \in \mathbb{R}^N$ with corresponding binary labels $\mathbf{y} \in \{0,1\}^N$ . The logistic likelihood is + +$$ +p (\mathbf {y} | \psi) = \prod_ {i = 1} ^ {N} \sigma \left(\psi_ {i}\right) ^ {y _ {i}} \left(1 - \sigma \left(\psi_ {i}\right)\right) ^ {1 - y _ {i}} = \prod_ {i = 1} ^ {N} \frac {\left(e ^ {\psi_ {i}}\right) ^ {y _ {i}}}{1 + e ^ {\psi_ {i}}}, \tag {1} +$$ + +where $\sigma (\cdot)$ is the logistic sigmoid function. Let the prior over $\psi$ be Gaussian: $p(\psi) = \mathcal{N}(\psi |\boldsymbol {\mu},\boldsymbol {\Sigma})$ . In Bayesian inference, we are interested in the posterior $p(\psi |\mathbf{y})\propto p(\mathbf{y}|\boldsymbol {\psi})p(\boldsymbol {\psi})$ but the form of (1) does not admit analytic computation of the posterior due to non-conjugacy. The main idea of Polya-Gamma augmentation is to introduce auxiliary random variables $\omega$ to the likelihood such that the original model is recovered when $\omega$ is marginalized out: $p(\mathbf{y}|\boldsymbol {\psi}) = \int p(\boldsymbol {\omega})p(\mathbf{y}|\boldsymbol {\psi},\boldsymbol {\omega})d\boldsymbol{\omega}$ . + +Conditioned on $\omega \sim \mathrm{PG}(1,0)$ , the batch likelihood is proportional to a diagonal Gaussian (see Section A for a full derivation): + +$$ +p (\mathbf {y} | \psi , \boldsymbol {\omega}) \propto \prod_ {i = 1} ^ {N} e ^ {- \omega_ {i} \psi_ {i} ^ {2} / 2} e ^ {\kappa_ {i} \psi_ {i}} \propto \mathcal {N} \left(\boldsymbol {\Omega} ^ {- 1} \boldsymbol {\kappa} | \psi , \boldsymbol {\Omega} ^ {- 1}\right), \tag {2} +$$ + +where $\kappa_{i} = y_{i} - 1 / 2$ and $\Omega = \mathrm{diag}(\omega)$ . The conditional distribution over $\psi$ given $\mathbf{y}$ and $\omega$ is now tractable: + +$$ +p (\boldsymbol {\psi} | \mathbf {y}, \boldsymbol {\omega}) \propto p (\mathbf {y} | \boldsymbol {\psi}, \boldsymbol {\omega}) p (\boldsymbol {\psi}) \propto \mathcal {N} (\boldsymbol {\psi} | \hat {\boldsymbol {\Sigma}} (\boldsymbol {\Sigma} ^ {- 1} \boldsymbol {\mu} + \boldsymbol {\kappa}), \hat {\boldsymbol {\Sigma}}), \tag {3} +$$ + +where $\tilde{\Sigma} = (\Sigma^{-1} + \Omega)^{-1}$ . The conditional distribution of $\omega$ given $\psi$ and $\mathbf{y}$ can also be easily computed: + +$$ +p \left(\omega_ {i} \mid y _ {i}, \psi_ {i}\right) \propto \operatorname {P G} \left(\omega_ {i} \mid 1, 0\right) e ^ {- \omega_ {i} \psi_ {i} ^ {2} / 2} \propto \operatorname {P G} \left(\omega_ {i} \mid 1, \psi_ {i}\right), \tag {4} +$$ + +where the last expression follows from the exponential tilting property of Pólya-Gamma random variables. This suggests a Gibbs sampling procedure in which iterates $\boldsymbol{\omega}^{(t)}\sim p(\boldsymbol {\omega}|\mathbf{y},\boldsymbol{\psi}^{(t - 1)})$ and $\psi^{(t)}\sim p(\psi |\mathbf{X},\mathbf{y},\boldsymbol{\omega}^{(t)})$ are drawn sequentially until the Markov chain reaches its stationary distribution, which is the joint posterior $p(\psi ,\omega |\mathbf{y})$ . Fortunately, efficient samplers for the Pólya-Gamma distribution have been developed (Windle et al., 2014) to facilitate this. + +# 3.2 ONE-VS-EACH APPROXIMATION TO SOFTMAX + +The one-vs-each (OVE) approximation (Titsias, 2016) was formulated as a lower bound to the softmax likelihood in order to handle classification over a large number of output classes, where computation of the normalizing constant is prohibitive. We employ the OVE approximation not to deal with extreme classification, but rather due to its compatibility with Pólya-Gamma augmentation, as we shall soon see. The one-vs-each approximation can be derived by first rewriting the softmax likelihood as follows: + +$$ +p (y = i \mid \mathbf {f}) \triangleq \frac {e ^ {f _ {i}}}{\sum_ {j} e ^ {f _ {j}}} = \frac {1}{1 + \sum_ {j \neq i} e ^ {- \left(f _ {i} - f _ {j}\right)}}, \tag {5} +$$ + +where $\mathbf{f} \triangleq (f_1, \ldots, f_C)^\top$ are the logits. Since in general $\prod_k (1 + \alpha_k) \geq (1 + \sum_k \alpha_k)$ for $\alpha_k \geq 0$ , the softmax likelihood (5) can be bounded as follows: + +$$ +p (y = i \mid \mathbf {f}) \geq \prod_ {j \neq i} \frac {1}{1 + e ^ {- \left(f _ {i} - f _ {j}\right)}} = \prod_ {j \neq i} \sigma \left(f _ {i} - f _ {j}\right), \tag {6} +$$ + +which is the OVE lower bound. This expression avoids the normalizing constant and factorizes into a product of pairwise sigmods, which is amenable to Pólya-Gamma augmentation for tractable inference. + +# 4 ONE-VS-EACH PÓLYA-GAMMA GPS + +In this section, we first show how the one-vs-each (OVE) approximation can be interpreted as a pairwise composite likelihood. We then we introduce our method for GP-based Bayesian few-shot classification, which brings together OVE and Pólya-Gamma augmentation in a novel combination. + +# 4.1 OVE AS A COMPOSITE LIKELIHOOD + +Titsias (2016) showed that the OVE approximation shares the same global optimum as the softmax maximum likelihood, suggesting a close relationship between the two. We show here that in fact OVE can be interpreted as a pairwise composite likelihood version of the softmax. Composite likelihoods (Lindsay, 1988; Varin et al., 2011) are a type of approximate likelihood often employed when the exact likelihood is intractable or otherwise difficult to compute. Given a collection of marginal or conditional events $\{E_1,\dots ,E_K\}$ and parameters $\mathbf{f}$ , a composite likelihood is defined as: + +$$ +\mathcal {L} _ {\mathrm {C L}} (\mathbf {f} \mid y) \triangleq \prod_ {k = 1} ^ {K} \mathcal {L} _ {k} (\mathbf {f} \mid y) ^ {w _ {k}}, \tag {7} +$$ + +where $\mathcal{L}_k(\mathbf{f} \mid y) \propto p(y \in E_k \mid \mathbf{f})$ and $w_k \geq 0$ are arbitrary weights. + +In order to make the connection to OVE, it will be useful to let the one-hot encoding of the label $y$ be denoted as $\mathbf{y} \in \{0,1\}^C$ . Define a set of $C(C - 1)/2$ pairwise conditional events $E_{ij}$ , one each for all pairs of classes $i \neq j$ , indicating the event that the model's output matches the target label for classes $i$ and $j$ conditioned on all the other classes: + +$$ +p (\mathbf {y} \in E _ {i j} \mid \mathbf {f}) \triangleq p \left(y _ {i}, y _ {j} \mid \mathbf {y} _ {\neg i j}, \mathbf {f}\right), \tag {8} +$$ + +where $\neg ij$ denotes the set of classes not equal to either $i$ or $j$ . This expression resembles the pseudolikelihood (Besag, 1975), but instead of a single conditional event per output site, the expression in (8) considers all pairs of sites. Stoehr & Friel (2015) explored similar composite likelihood generalizations of the pseudolikelihood in the context of random fields. + +Now suppose that $y_{c} = 1$ for some class $c \notin \{i,j\}$ . Then $p(y_{i},y_{j}|\mathbf{y}_{\neg ij},\mathbf{f}) = 1$ due to the one-hot constraint. Otherwise either $y_{i} = 1$ or $y_{j} = 1$ . In this case, assume without loss of generality that $y_{i} = 1$ and $y_{j} = 0$ and thus + +$$ +p \left(y _ {i}, y _ {j} \mid \mathbf {y} _ {\neg i j}, \mathbf {f}\right) = \frac {e ^ {f _ {i}}}{e ^ {f _ {i}} + e ^ {f _ {j}}} = \sigma \left(f _ {i} - f _ {j}\right). \tag {9} +$$ + +The composite likelihood defined in this way with unit component weights is therefore + +$$ +\mathcal {L} _ {\mathrm {O V E}} (\mathbf {f} \mid \mathbf {y}) = \prod_ {i} \prod_ {j \neq i} p \left(y _ {i}, y _ {j} \mid \mathbf {y} _ {\neg i j}, \mathbf {f}\right) = \prod_ {i} \prod_ {j \neq i} \sigma \left(f _ {i} - f _ {j}\right) ^ {y _ {i}}. \tag {10} +$$ + +Alternatively, we may simply write $\mathcal{L}_{\mathrm{OVE}}(\mathbf{f}|y = i) = \prod_{j\neq i}\sigma (f_i - f_j)$ , which is identical to the OVE bound (6). + +# 4.2 GP CLASSIFICATION WITH THE OVE LIKELIHOOD + +We now turn our attention to GP classification. Suppose we have access to examples $\mathbf{X} \in \mathbb{R}^{N \times D}$ with corresponding one-hot labels $\mathbf{Y} \in \{0,1\}^{N \times C}$ , where $C$ is the number of classes. We consider the logits jointly as a single vector + +$$ +\mathbf {f} \triangleq \left(f _ {1} ^ {1}, \dots , f _ {N} ^ {1}, f _ {1} ^ {2}, \dots , f _ {N} ^ {2}, \dots , f _ {1} ^ {C}, \dots , f _ {N} ^ {C}\right) ^ {\top} \tag {11} +$$ + +and place an independent GP prior on the logits for each class: $\mathbf{f}^c (\mathbf{x})\sim \mathcal{GP}(m(\mathbf{x}),k(\mathbf{x},\mathbf{x}'))$ Therefore we have $p(\mathbf{f}|\mathbf{X}) = \mathcal{N}(\mathbf{f}|\boldsymbol {\mu},\mathbf{K})$ , where $\mu_i^c = m(\mathbf{x}_i)$ and $\mathbf{K}$ is block diagonal with $K_{ij}^{c} = k(\mathbf{x}_{i},\mathbf{x}_{j})$ for each block $\mathbf{K}^c$ + +The Pólya-Gamma integral identity used to derive (2) does not have a multi-class analogue and thus a direct application of the augmentation scheme to the softmax likelihood is nontrivial. Instead, we propose to directly replace the softmax with the OVE-based composite likelihood function from (10) with unit weights. The posterior over $\mathbf{f}$ when using OVE as the likelihood function can be expressed as: + +$$ +p (\mathbf {f} | \mathbf {X}, \mathbf {y}) \propto p (\mathbf {f} | \mathbf {X}) \prod_ {i = 1} ^ {N} \prod_ {c ^ {\prime} \neq y _ {i}} \sigma \left(f _ {i} ^ {y _ {i}} - f _ {i} ^ {c ^ {\prime}}\right), \tag {12} +$$ + +to which Pólya-Gamma augmentation can be applied as we show in the next section. Our motivation for using a composite likelihood therefore differs from the traditional motivation, which is to avoid the use of a likelihood function which is intractable to evaluate. Instead, we employ a composite likelihood because it makes posterior inference tractable when coupled with Pólya-Gamma augmentation. + +Prior work on Bayesian inference with composite likelihoods has shown that the composite posterior is consistent under fairly general conditions for correctly specified models (Miller, 2019) but can produce overly concentrated posteriors (Pauli et al., 2011; Ribatet et al., 2012) since each component likelihood event is treated as independent when in reality there may be significant dependencies. Nevertheless, we show in Section 5 that in practice our method exhibits competitive accuracy and strong calibration relative to baseline few-shot learning algorithms. We leave further theoretical analysis of the OVE composite posterior and its properties for future work. + +Compared to choices of likelihoods used by previous approaches, there are several reasons to prefer OVE. Relative to the Gaussian augmentation approach of Girolami & Rogers (2006), Pólya-Gamma augmentation has the benefit of fast mixing and the ability of a single value of $\omega$ to capture much of the marginal distribution over function values1. The stick-breaking construction of Linderman et al. (2015) induces a dependence on the ordering of classes, which leads to undesirable asymmetry. Finally, the logistic-softmax likelihood of Galy-Fajou et al. (2020) requires three augmentations and careful learning of the mean function to avoid a priori underconfidence (see Section F.1 for more details). + +# 4.3 POSTERIOR INFERENCE VIA GIBBS SAMPLING + +We now describe how we perform tractable posterior inference in our model with Gibbs sampling. Define the matrix $\mathbf{A} \triangleq \mathrm{OVE-Matrix}(\mathbf{Y})$ to be a $CN \times CN$ sparse block matrix with $C$ row partitions and $C$ column partitions. Each block $\mathbf{A}_{cc'}$ is a diagonal $N \times N$ matrix defined as follows: + +$$ +\mathbf {A} _ {c c ^ {\prime}} \triangleq \operatorname {d i a g} \left(\mathbf {Y} _ {. c ^ {\prime}}\right) - \mathbb {1} [ c = c ^ {\prime} ] \mathbf {I} _ {n}, \tag {13} +$$ + +where $\mathbf{Y}_{c'}$ denotes the $c'$ th column of $\mathbf{Y}$ . Now the binary logit vector $\psi \triangleq \mathbf{A}\mathbf{f} \in \mathbb{R}^{CN}$ will have entries equal to $f_{i}^{y_{i}} - f_{i}^{c}$ for each unique combination of $c$ and $i$ , of which there are $CN$ in total. The OVE composite likelihood can now be written as $\mathcal{L}(\psi|\mathbf{Y}) = 2^{N}\prod_{j=1}^{NC}\sigma(\psi_{j})$ , where the $2^{N}$ term arises from the $N$ cases in which $\psi_{j} = 0$ due to comparing the ground truth logit with itself. + +Analogous to (2), the likelihood of $\psi$ conditioned on $\omega$ and $\mathbf{Y}$ is proportional to a diagonal Gaussian: + +$$ +\mathcal {L} (\psi | \mathbf {Y}, \omega) \propto \prod_ {j = 1} ^ {N C} e ^ {- \omega_ {j} \psi_ {j} ^ {2} / 2} e ^ {\kappa_ {j} \psi_ {j}} \propto \mathcal {N} \left(\Omega^ {- 1} \kappa | \psi , \Omega^ {- 1}\right), \tag {14} +$$ + +where $\kappa_{j} = 1 / 2$ and $\Omega = \mathrm{diag}(\omega)$ . By exploiting the fact that $\psi = \mathbf{A}\mathbf{f}$ , we can express the likelihood in terms of $\mathbf{f}$ and write down the conditional composite posterior as follows: + +$$ +p (\mathbf {f} | \mathbf {X}, \mathbf {Y}, \boldsymbol {\omega}) \propto \mathcal {N} \left(\Omega^ {- 1} \boldsymbol {\kappa} \mid \mathbf {A f}, \Omega^ {- 1}\right) \mathcal {N} (\mathbf {f} \mid \boldsymbol {\mu}, \mathbf {K}) \propto \mathcal {N} (\mathbf {f} | \tilde {\boldsymbol {\Sigma}} \left(\mathbf {K} ^ {- 1} \boldsymbol {\mu} + \mathbf {A} ^ {\top} \boldsymbol {\kappa}\right), \tilde {\boldsymbol {\Sigma}}), \tag {15} +$$ + +where $\tilde{\Sigma} = (\mathbf{K}^{-1} + \mathbf{A}^{\top}\Omega \mathbf{A})^{-1}$ , which is an expression remarkably similar to (3). Analogous to (4), the conditional distribution over $\omega$ given $\mathbf{f}$ and the data becomes $p(\omega |\mathbf{y},\mathbf{f}) = \mathrm{PG}(\omega |\mathbf{1},\mathbf{A}\mathbf{f})$ . + +The primary computational bottleneck of posterior inference lies in sampling $\mathbf{f}$ from (15). Since $\tilde{\Sigma}$ is a $CN\times CN$ matrix, a naive implementation has complexity $\mathcal{O}(C^3 N^3)$ . By utilizing the matrix inversion lemma and Gaussian sampling techniques summarized in (Doucet, 2010), this can be brought down to $\mathcal{O}(CN^3)$ . Details may be found in Section B. + +# 4.4 LEARNING COVARIANCE HYPERPARAMETERS FOR FEW-SHOT CLASSIFICATION + +We now describe how we apply OVE Pólya-Gamma augmented GPs to few-shot classification. We assume the standard episodic few-shot setup in which one observes a labeled support set $S = (\mathbf{X}, \mathbf{Y})$ . Predictions must then be made for a query example $(\mathbf{x}_*, \mathbf{y}_*)$ . We consider a zero-mean GP prior over the class logits $\mathbf{f}^c(\mathbf{x}) \sim \mathcal{GP}(\mathbf{0}, k_\theta(\mathbf{x}, \mathbf{x}'))$ , where $\theta$ are learnable parameters of our covariance function. These could include traditional hyperparameters such as lengthscales or the weights of a deep neural network as in deep kernel learning (Wilson et al., 2016). + +We consider two objectives for learning hyperparameters of the covariance function: the marginal likelihood (ML) and the predictive likelihood (PL). Marginal likelihood measures the likelihood of the hyperparameters given the observed data and is intuitively appealing from a Bayesian perspective. On the other hand, many standard FSC methods optimize for predictive likelihood on the query set (Vinyals et al., 2016; Finn et al., 2017; Snell et al., 2017). Both objectives marginalize over latent functions, thereby making full use of our Bayesian formulation. + +The details of these objectives and how we compute gradients can be found in Section C. Our learning algorithm for both marginal and predictive likelihood may be found in Section D. Details of computing the posterior predictive distribution $p(\mathbf{y}_*|\mathbf{x}_*,\mathbf{X},\mathbf{Y},\boldsymbol{\omega})$ may be found in Section E. Finally, details of our chosen "cosine" kernel may be found in Section H. + +# 5 EXPERIMENTS + +In this section, we present our results on few-shot classification both in terms of accuracy and uncertainty quantification. Additional results comparing the one-vs-each composite likelihood to the softmax, logistic softmax, and Gaussian likelihoods may be found in Section F. + +One of our aims is to compare methods based on uncertainty quantification. We therefore developed new benchmark evaluations and tasks: few-shot calibration, robustness, and out-of-episode detection. In order to empirically compare methods, we could not simply borrow the accuracy results from other papers, but instead needed to train each of these baselines ourselves. For all baselines except Bayesian MAML, ABML, and Logistic Softmax GP, we ran the code from (Patacchiola et al., 2020) and verified that the accuracies matched closely to their reported results. We have made PyTorch code for our experiments publicly available2. + +# 5.1 FEW-SHOT CLASSIFICATION + +For our few-shot classification experiments, we follow the training and evaluation protocol of Patačiola et al. (2020). We train both 1-shot and 5-shot versions of our model in four different settings: Caltech-UCSD Birds (CUB) (Wah et al., 2011), mini-Imagenet with the split proposed by Ravi & Larochelle (2017), as well as two cross-domain transfer tasks. The first transfer task entails training on mini-ImageNet and testing on CUB, and the second measures transfer from Omniglot (Lake et al., 2011) to EMNIST (Cohen et al., 2017). Experimental details and an overview of the baselines we used can be found in Section G. Classification results are shown in Table 1 and 2. We find that our proposed Pólya-Gamma OVE GPs yield strong classification results, outperforming the baselines in five of the eight scenarios. + +Table 1: Average accuracy and standard deviation (percentage) on 5-way FSC. Baseline results (through DKT) are from Patacchiola et al. (2020). Evaluation is performed on 3,000 randomly generated test episodes. Standard deviation for the remaining methods are computed by averaging over 5 batches of 600 episodes with different random seeds. The best results are highlighted in bold. + +
MethodCUBmini-ImageNet
1-shot5-shot1-shot5-shot
Feature Transfer46.19 ± 0.6468.40 ± 0.7939.51 ± 0.2360.51 ± 0.55
Baseline++61.75 ± 0.9578.51 ± 0.5947.15 ± 0.4966.18 ± 0.18
MatchingNet60.19 ± 1.0275.11 ± 0.3548.25 ± 0.6562.71 ± 0.44
ProtoNet52.52 ± 1.9075.93 ± 0.4644.19 ± 1.3064.07 ± 0.65
RelationNet62.52 ± 0.3478.22 ± 0.0748.76 ± 0.1764.20 ± 0.28
MAML56.11 ± 0.6974.84 ± 0.6245.39 ± 0.4961.58 ± 0.53
DKT + Cosine63.37 ± 0.1977.73 ± 0.2648.64 ± 0.4562.85 ± 0.37
Bayesian MAML55.93 ± 0.7172.87 ± 0.2644.46 ± 0.3062.60 ± 0.25
Bayesian MAML (Chaser)53.93 ± 0.7271.16 ± 0.3243.74 ± 0.4659.23 ± 0.34
ABML48.80 ± 0.4070.91 ± 0.3240.88 ± 0.2558.19 ± 0.17
Logistic Softmax GP + Cosine (ML)60.23 ± 0.5474.58 ± 0.2546.75 ± 0.2059.93 ± 0.31
Logistic Softmax GP + Cosine (PL)60.07 ± 0.2978.14 ± 0.0747.05 ± 0.2066.01 ± 0.25
OVE PG GP + Cosine (ML) [ours]63.98 ± 0.4377.44 ± 0.1850.02 ± 0.3564.58 ± 0.31
OVE PG GP + Cosine (PL) [ours]60.11 ± 0.2679.07 ± 0.0548.00 ± 0.2467.14 ± 0.23
+ +# 5.2 UNCERTAINTY QUANTIFICATION THROUGH CALIBRATION + +We next turn to uncertainty quantification, an important concern for few-shot classifiers. When used in safety-critical applications such as medical diagnosis, it is important for a machine learning system to defer when there is not enough evidence to make a decision. Even in non-critical applications, precise uncertainty quantification helps practitioners in the few-shot setting determine when a class has an adequate amount of labeled data or when more labels are required, and can facilitate active learning. + +Table 2: Average accuracy and standard deviation (percentage) on 5-way cross-domain FSC, with the same experimental setup as in Table 1. Baseline results (through DKT) are from (Patacchiola et al., 2020). + +
MethodOmniglot→EMNISTmini-ImageNet→CUB
1-shot5-shot1-shot5-shot
Feature Transfer64.22 ± 1.2486.10 ± 0.8432.77 ± 0.3550.34 ± 0.27
Baseline++56.84 ± 0.9180.01 ± 0.9239.19 ± 0.1257.31 ± 0.11
MatchingNet75.01 ± 2.0987.41 ± 1.7936.98 ± 0.0650.72 ± 0.36
ProtoNet72.04 ± 0.8287.22 ± 1.0133.27 ± 1.0952.16 ± 0.17
RelationNet75.62 ± 1.0087.84 ± 0.2737.13 ± 0.2051.76 ± 1.48
MAML72.68 ± 1.8583.54 ± 1.7934.01 ± 1.2548.83 ± 0.62
DKT + Cosine73.06 ± 2.3688.10 ± 0.7840.22 ± 0.5455.65 ± 0.05
Bayesian MAML63.94 ± 0.4765.26 ± 0.3033.52 ± 0.3651.35 ± 0.16
Bayesian MAML (Chaser)55.04 ± 0.3454.19 ± 0.3236.22 ± 0.5051.53 ± 0.43
ABML73.89 ± 0.2487.28 ± 0.4031.51 ± 0.3247.80 ± 0.51
Logistic Softmax GP + Cosine (ML)62.91 ± 0.4983.80 ± 0.1336.41 ± 0.1850.33 ± 0.13
Logistic Softmax GP + Cosine (PL)70.70 ± 0.3686.59 ± 0.1536.73 ± 0.2656.70 ± 0.31
OVE PG GP + Cosine (ML) [ours]68.43 ± 0.6786.22 ± 0.2039.66 ± 0.1855.71 ± 0.31
OVE PG GP + Cosine (PL) [ours]77.00 ± 0.5087.52 ± 0.1937.49 ± 0.1157.23 ± 0.31
+ +We chose several commonly used metrics for calibration. Expected calibration error (ECE) (Guo et al., 2017) measures the expected binned difference between confidence and accuracy. Maximum calibration error (MCE) is similar to ECE but measures maximum difference instead of expected difference. Brier score (BRI) (Brier, 1950) is a proper scoring rule computed as the squared error between the output probabilities and the one-hot label. For a recent perspective on metrics for uncertainty evaluation, please refer to Ovadia et al. (2019). The results for representative approaches on 5-shot, 5-way CUB can be found in Figure 1. Our OVE PG GPs are the best calibrated overall across the metrics. + +![](images/b697255a1359e9eb480a40b7f09ddd798c5b241d5e66b602c257ba6278e140f9.jpg) +Figure 1: Reliability diagrams, expected calibration error (ECE), maximum calibration error (MCE), and Brier Score (BRI) for 5-shot 5-way tasks on CUB (additional calibration results can be found in Appendix I). Metrics are computed on 3,000 random tasks from the test set. The last two plots are our proposed method. + +# 5.3 ROBUSTNESS TO INPUT NOISE + +Input examples for novel classes in FSC may have been collected under conditions that do not match those observed at training time. For example, labeled support images in a medical diagnosis application may come from a different hospital than the training set. To mimic a simplified version of this scenario, we investigate robustness to input noise. We used the Imagecorruptions package (Michaelis et al., 2019) to apply Gaussian noise, impulse noise, and defocus blur to both the support set and query sets of episodes at test time and evaluated both accuracy and calibration. We used corruption severity of 5 (severe) and evaluated across 1,000 randomly generated tasks on the three + +datasets involving natural images. The robustness results for Gaussian noise are shown in Figure 2. Full quantitative results tables for each noise type may be found in Section J. We find that in general Bayesian approaches tend to be robust due to their ability to marginalize over hypotheses consistent with the support labels. Our approach is one of the top performing methods across all settings. + +![](images/2c549ff4ed3b22a1a18ce97f471c0696073c20c9262a3792d871fdec74a69aee.jpg) + +![](images/0c3ebf063926eab3ec19c6c341d8cc8feb6159a0a388b27e1864ba2126bcab37.jpg) + +![](images/f88b0e3fddc2a686dceb36f7fd3b76d22be80c92a2118a420736d0aa967d8fe0.jpg) + +![](images/8d62519a9583bc0a5fec183903a7d9c301ec67c66f8f50d1f451cfcff155ba98.jpg) +Figure 2: Accuracy $(\uparrow)$ and Brier Score $(\downarrow)$ when corrupting both support and query with Gaussian noise on 5-way 5-shot tasks. Quantitative results may be found in Appendix J. + +![](images/9c371e2c01c0c1b177b6d53e5b3a8bf637e7eaad412fa60baf6b18d2f2273026.jpg) + +# 5.4 OUT-OF-EPISODE DETECTION + +Finally, we measure performance on out-of-episode detection, another application in which uncertainty quantification is important. In this experiment, we used 5-way, 5-shot support sets at test time but incorporated out-of-episode examples into the query set. Each episode had 150 query examples: 15 from each of 5 randomly chosen in-episode classes and 15 from each of 5 randomly chosen out-of-episode classes. We then computed the AUROC of binary outlier detection using the negative of the maximum logit as the score. Intuitively, if none of the support classes assign a high logit to the example, it can be classified as an outlier. The results are shown in Figure 3. Our approach generally performs the best across the datasets. + +![](images/06ea8c859dd75e126b66390f256434f7b1b696ac973376ed6cecccd02075895d.jpg) +Figure 3: Average AUROC $(\uparrow)$ for out-of-episode detection. The AUC is computed separately for each episode and averaged across 1,000 episodes. Bars indicate a $95\%$ bootstrapped confidence interval. + +# 6 CONCLUSION + +In this work, we have proposed a Bayesian few-shot classification approach based on Gaussian processes. Our method replaces the ordinary softmax likelihood with a one-vs-each pairwise composite likelihood and applies Pólya-Gamma augmentation to perform inference. This allows us to model class logits directly as function values and efficiently marginalize over uncertainty in each few-shot episode. Modeling functions directly enables our approach to avoid the dependence on model size that posterior inference in weight-space based models inherently have. Our approach compares favorably to baseline FSC methods under a variety of dataset and shot configurations, including dataset transfer. We also demonstrate strong uncertainty quantification, robustness to input noise, and out-of-episode detection. We believe that Bayesian modeling is a powerful tool for handling uncertainty and hope that our work will lead to broader adoption of efficient Bayesian inference in the few-shot scenario. + +# ACKNOWLEDGMENTS + +We would like to thank Ryan Adams, Ethan Fetaya, Mike Mozer, Eleni Triantafillou, Kuan-Chieh Wang, and Max Welling for helpful discussions. JS also thanks SK T-Brain for supporting him on an internship that led to precursors of some ideas in this paper. Resources used in preparing this research were provided, in part, by the Province of Ontario, the Government of Canada through CIFAR, and companies sponsoring the Vector Institute (https://www.vectorinstitute.ai/partners). This project is supported by NSERC and the Intelligence Advanced Research Projects Activity (IARPA) via Department of Interior/Interior Business Center (DoI/IBC) contract number D16PC00003. The U.S. Government is authorized to reproduce and distribute reprints for Governmental purposes notwithstanding any copyright annotation thereon. Disclaimer: The views and conclusions contained herein are those of the authors and should not be interpreted as necessarily representing the official policies or endorsements, either expressed or implied, of IARPA, DoI/IBC, or the U.S. Government. + +# REFERENCES + +James H. Albert and Siddhartha Chib. Bayesian analysis of binary and polychotomous response data. Journal of the American Statistical Association, 88(422):669-679, June 1993. +Julian Besag. Statistical analysis of non-lattice data. Journal of the Royal Statistical Society: Series D (The Statistician), 24(3):179-195, 1975. +Charles Blundell, Julien Cornebise, Koray Kavukcuoglu, and Daan Wierstra. Weight uncertainty in neural networks. In International Conference on Machine Learning, 2015. +Glenn W. Brier. Verification of forecasts expressed in terms of probability. Monthly Weather Review, 78(1):1-3, 1950. +Wei-Yu Chen, Yen-Cheng Liu, Zsolt Kira, Yu-Chiang Frank Wang, and Jia-Bin Huang. A closer look at few-shot classification. In International Conference on Learning Representations, 2019. +Gregory Cohen, Saeed Afshar, Jonathan Tapson, and André van Schaik. EMNIST: Extending MNIST to handwritten letters. In 2017 International Joint Conference on Neural Networks (IJCNN), pp. 2921-2926, 2017. +Randal Douc, Eric Moulines, and David Stoffer. Nonlinear Time Series: Theory, Methods and Applications with R Examples. CRC Press, 2014. +Arnaud Doucet. A Note on Efficient Conditional Simulation of Gaussian Distributions. 2010. URL https://www.cs.ubc.ca/~arnaud/doucet_simulationconditionalgaussian.pdf. +Chelsea Finn, Pieter Abbeel, and Sergey Levine. Model-agnostic meta-learning for fast adaptation of deep networks. In Doina Precup and Yee Whye Teh (eds.), Proceedings of the 34th International Conference on Machine Learning, volume 70 of Proceedings of Machine Learning Research, pp. 1126–1135, International Convention Centre, Sydney, Australia, August 2017. PMLR. +Chelsea Finn, Kelvin Xu, and Sergey Levine. Probabilistic model-agnostic meta-learning. In S. Bengio, H. Wallach, H. Larochelle, K. Grauman, N. Cesa-Bianchi, and R. Garnett (eds.), Advances in Neural Information Processing Systems, volume 31, pp. 9516–9527. Curran Associates, Inc., 2018. +R. A. Fisher. The use of multiple measurements in taxonomic problems. Annals of Eugenics, 7(2): 179-188, 1936. +Théo Galy-Fajou, Florian Wenzel, Christian Donner, and Manfred Opper. Multi-class Gaussian process classification made conjugate: Efficient inference via data augmentation. In Ryan P. Adams and Vibhav Gogate (eds.), Proceedings of the 35th Uncertainty in Artificial Intelligence Conference, volume 115 of Proceedings of Machine Learning Research, pp. 755-765, Tel Aviv, Israel, July 2020. PMLR. + +Mark Girolami and Simon Rogers. Variational Bayesian multinomial probit regression with Gaussian process priors. Neural Computation, 18(8):1790-1817, August 2006. +Jonathan Gordon, John Bronskill, Matthias Bauer, Sebastian Nowozin, and Richard Turner. Meta-learning probabilistic inference for prediction. In International Conference on Learning Representations, 2019. +Erin Grant, Chelsea Finn, Sergey Levine, Trevor Darrell, and Thomas Griffiths. Recasting gradient-based meta-learning as hierarchical Bayes. In International Conference on Learning Representations, 2018. +Chuan Guo, Geoff Pleiss, Yu Sun, and Kilian Q. Weinberger. On calibration of modern neural networks. In Doina Precup and Yee Whye Teh (eds.), Proceedings of the 34th International Conference on Machine Learning, volume 70 of Proceedings of Machine Learning Research, pp. 1321-1330, International Convention Centre, Sydney, Australia, August 2017. PMLR. +Daniel Hernandez-Lobato and Jose Miguel Hernandez-Lobato. Scalable Gaussian process classification via expectation propagation. In Arthur Gretton and Christian C. Robert (eds.), Proceedings of the 19th International Conference on Artificial Intelligence and Statistics, volume 51 of Proceedings of Machine Learning Research, pp. 168-176, Cadiz, Spain, May 2016. PMLR. +Nathan Hilliard, Lawrence Phillips, Scott Howland, Artem Yankov, Courtney D. Corley, and Nathan O. Hodas. Few-Shot Learning with Metric-Agnostic Conditional Embeddings. arXiv:1802.04376 [cs, stat], February 2018. +Yehuda Hoffman and Erez Ribak. Constrained realizations of Gaussian fields-A simple algorithm. The Astrophysical Journal, 380:L5-L8, 1991. +Hyun-Chul Kim and Zoubin Ghahramani. Bayesian Gaussian process classification with the EM-EP algorithm. IEEE Transactions on Pattern Analysis and Machine Intelligence, 28(12):1948-1959, 2006. +Diederik P. Kingma and Jimmy Ba. Adam: A Method for Stochastic Optimization. In International Conference on Learning Representations, 2015. +Diederik P. Kingma, Tim Salimans, and Max Welling. Variational dropout and the local reparameterization trick. In C. Cortes, N. Lawrence, D. Lee, M. Sugiyama, and R. Garnett (eds.), Advances in Neural Information Processing Systems, volume 28, pp. 2575-2583. Curran Associates, Inc., 2015. +Gregory Koch. Siamese Neural Networks for One-Shot Image Recognition. Master's Thesis, University of Toronto, 2015. +Brenden Lake, Ruslan Salakhutdinov, Jason Gross, and Joshua Tenenbaum. One shot learning of simple visual concepts. In Proceedings of the Annual Meeting of the Cognitive Science Society, volume 33, 2011. +Scott Linderman, Matthew J Johnson, and Ryan P Adams. Dependent multinomial models made easy: Stick-breaking with the Polya-Gamma augmentation. In C. Cortes, N. Lawrence, D. Lee, M. Sugiyama, and R. Garnett (eds.), Advances in Neural Information Processing Systems, volume 28, pp. 3456-3464. Curran Associates, Inc., 2015. +Bruce G. Lindsay. Composite Likelihood Methods. Contemporary Mathematics, 80:221-239, 1988. +Qiang Liu and Dilin Wang. Stein variational gradient descent: A general purpose bayesian inference algorithm. In D. Lee, M. Sugiyama, U. Luxburg, I. Guyon, and R. Garnett (eds.), Advances in Neural Information Processing Systems, volume 29, pp. 2378-2386. Curran Associates, Inc., 2016. +Alexander G. de G. Matthews, James Hensman, Richard Turner, and Zoubin Ghahramani. On sparse variational methods and the Kullback-Leibler divergence between stochastic processes. In Arthur Gretton and Christian C. Robert (eds.), Proceedings of the 19th International Conference on Artificial Intelligence and Statistics, volume 51 of Proceedings of Machine Learning Research, pp. 231-239, Cadiz, Spain, May 2016. PMLR. + +Claudio Michaelis, Benjamin Mitzkus, Robert Geirhos, Evgenia Rusak, Oliver Bringmann, Alexander S. Ecker, Matthias Bethge, and Wieland Brendel. Benchmarking Robustness in Object Detection: Autonomous Driving when Winter is Coming. In NeurIPS 2019 Machine Learning for Autonomous Driving Workshop, 2019. +Jeffrey W. Miller. Asymptotic normality, concentration, and coverage of generalized posteriors. arXiv:1907.09611 [math, stat], July 2019. +Thomas Peter Minka. A Family of Algorithms for Approximate Bayesian Inference. PhD thesis, Massachusetts Institute of Technology, 2001. +Yaniv Ovadia, Emily Fertig, Jie Ren, Zachary Nado, D. Sculley, Sebastian Nowozin, Joshua Dillon, Balaji Lakshminarayanan, and Jasper Snoek. Can you trust your models uncertainty? Evaluating predictive uncertainty under dataset shift. In H. Wallach, H. Larochelle, A. Beygelzimer, F. dAlché-Buc, E. Fox, and R. Garnett (eds.), Advances in Neural Information Processing Systems, volume 32, pp. 13991-14002. Curran Associates, Inc., 2019. +Massimiliano Patacchiola, Jack Turner, Elliot J. Crowley, Michael O'Boyle, and Amos Storkey. Bayesian Meta-Learning for the Few-Shot Setting via Deep Kernels. In Advances in Neural Information Processing Systems, 2020. +Francesco Pauli, Walter Racugno, and Laura Ven. Bayesian composite marginal likelihoods. Statistica Sinica, pp. 17, 2011. +Ethan Perez, Florian Strub, Harm de Vries, Vincent Dumoulin, and Aaron Courville. FiLM: Visual reasoning with a general conditioning layer. Proceedings of the AAAI Conference on Artificial Intelligence, 32(1), April 2018. +Nicholas G. Polson, James G. Scott, and Jesse Windle. Bayesian inference for logistic models using Pólya-Gamma latent variables. Journal of the American Statistical Association, 108(504): 1339-1349, December 2013. +Viraj Uday Prabhu. *Few-Shot Learning For Dermatological Disease Diagnosis*. Master's Thesis, Georgia Institute of Technology, 2019. +Sachin Ravi and Alex Beatson. Amortized Bayesian meta-learning. In International Conference on Learning Representations, 2019. +Sachin Ravi and Hugo Larochelle. Optimization as a model for few-shot learning. In International Conference on Learning Representations, 2017. +James Requeima, Jonathan Gordon, John Bronskill, Sebastian Nowozin, and Richard E Turner. Fast and flexible multi-task classification using conditional neural adaptive processes. In H. Wallach, H. Larochelle, A. Beygelzimer, F. dAlché-Buc, E. Fox, and R. Garnett (eds.), Advances in Neural Information Processing Systems, volume 32, pp. 7959-7970. Curran Associates, Inc., 2019. +Mathieu Ribatet, Daniel Cooley, and Anthony C. Davison. Bayesian inference from composite likelihoods, with an application to spatial extremes. Statistica Sinica, 2012. +Ryan Rifkin and Aldebaro Klautau. In defense of one-vs-all classification. Journal of Machine Learning Research, 5(Jan):101-141, 2004. +Andrei A. Rusu, Dushyant Rao, Jakub Sygnowski, Oriol Vinyals, Razvan Pascanu, Simon Osindero, and Raia Hadsell. Meta-learning with latent embedding optimization. In International Conference on Learning Representations, 2019. +Jake Snell, Kevin Swersky, and Richard Zemel. Prototypical networks for few-shot learning. In I. Guyon, U. V. Luxburg, S. Bengio, H. Wallach, R. Fergus, S. Vishwanathan, and R. Garnett (eds.), Advances in Neural Information Processing Systems, volume 30, pp. 4077-4087. Curran Associates, Inc., 2017. +Julien Stoehr and Nial Friel. Calibration of conditional composite likelihood for Bayesian inference on Gibbs random fields. In International Conference on Artificial Intelligence and Statistics, 2015. + +Shengyang Sun, Guodong Zhang, Jiaxin Shi, and Roger Grosse. Functional Variational Bayesian Neural Networks. In International Conference on Learning Representations, 2019. +Flood Sung, Yongxin Yang, Li Zhang, Tao Xiang, Philip H.S. Torr, and Timothy M. Hospedales. Learning to compare: Relation network for few-shot learning. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition (CVPR), June 2018. +Michalis Titsias. Variational learning of inducing variables in sparse Gaussian processes. In David van Dyk and Max Welling (eds.), Proceedings of the Twelfth International Conference on Artificial Intelligence and Statistics, volume 5 of Proceedings of Machine Learning Research, pp. 567-574, Hilton Clearwater Beach Resort, Clearwater Beach, Florida USA, April 2009. PMLR. +Michalis K. Titsias. One-vs-each approximation to softmax for scalable estimation of probabilities. In D. Lee, M. Sugiyama, U. Luxburg, I. Guyon, and R. Garnett (eds.), Advances in Neural Information Processing Systems, volume 29, pp. 4161-4169. Curran Associates, Inc., 2016. +Michalis K. Titsias, Sotirios Nikoloutsopoulos, and Alexandre Galashov. Information Theoretic Meta Learning with Gaussian Processes. arXiv:2009.03228 [cs, stat], October 2020. +Prudencio Tossou, Basile Dura, Francois Laviolette, Mario Marchand, and Alexandre Lacoste. Adaptive Deep Kernel Learning. arXiv:1905.12131 [cs, stat], December 2020. +Cristiano Varin, Nancy Reid, and David Firth. An overview of composite likelihood methods. *Institute of Statistical Science*, Academia Sinica, 2011. +Oriol Vinyals, Charles Blundell, Timothy Lillicrap, Koray Kavukcuoglu, and Daan Wierstra. Matching networks for one shot learning. In D. Lee, M. Sugiyama, U. Luxburg, I. Guyon, and R. Garnett (eds.), Advances in Neural Information Processing Systems, volume 29, pp. 3630-3638. Curran Associates, Inc., 2016. +Catherine Wah, Steve Branson, Peter Welinder, Pietro Perona, and Serge Belongie. The Caltech-UCSD Birds-200-2011 Dataset. Technical Report CNS-TR-2011-001, California Institute of Technology, 2011. +Kuan-Chieh Wang, Jixuan Wang, and Khai Truong. Customizable Facial Gesture Recognition For Improved Assistive Technology. In ICLR AI for Social Good Workshop, 2019. +Yeming Wen, Paul Vicol, Jimmy Ba, Dustin Tran, and Roger Grosse. Flipout: Efficient Pseudo-Independent Weight Perturbations on Mini-Batches. In International Conference on Learning Representations, 2018. +Christopher K. I. Williams and D. Barber. Bayesian classification with Gaussian processes. IEEE Transactions on Pattern Analysis and Machine Intelligence, 20(12):1342-1351, 1998. +Andrew Gordon Wilson, Zhiting Hu, Ruslan Salakhutdinov, and Eric P. Xing. Deep kernel learning. In Arthur Gretton and Christian C. Robert (eds.), Proceedings of the 19th International Conference on Artificial Intelligence and Statistics, volume 51 of Proceedings of Machine Learning Research, pp. 370-378, Cadiz, Spain, May 2016. PMLR. +Jesse Windle, Nicholas G. Polson, and James G. Scott. Sampling Polya-Gamma random variates: Alternate and approximate techniques. arXiv:1405.0506 [stat], May 2014. +Jaesik Yoon, Taesup Kim, Ousmane Dia, Sungwoong Kim, Yoshua Bengio, and Sungjin Ahn. Bayesian model-agnostic meta-learning. In S. Bengio, H. Wallach, H. Larochelle, K. Grauman, N. Cesa-Bianchi, and R. Garnett (eds.), Advances in Neural Information Processing Systems, volume 31, pp. 7332-7342. Curran Associates, Inc., 2018. + +# A DERIVATION OF POLYA-GAMMA AUGMENTED LOGISTIC LIKELIHOOD + +In this section, we show the derivation for the augmented logistic likelihood presented in Section 3.1. First, recall the logistic likelihood: + +$$ +p (\mathbf {y} \mid \psi) = \prod_ {i = 1} ^ {N} \sigma \left(\psi_ {i}\right) ^ {y _ {i}} \left(1 - \sigma \left(\psi_ {i}\right)\right) ^ {1 - y _ {i}} = \prod_ {i = 1} ^ {N} \frac {\left(e ^ {\psi_ {i}}\right) ^ {y _ {i}}}{1 + e ^ {\psi_ {i}}}, \tag {16} +$$ + +where $\sigma(\cdot)$ is the logistic sigmoid function. We have a Gaussian prior $p(\psi) = \mathcal{N}(\psi|\boldsymbol{\mu},\boldsymbol{\Sigma})$ and introduce Pólya-Gamma auxiliary random variables $\omega$ to the likelihood such that the original model is recovered when $\omega$ is marginalized out: $p(\mathbf{y}|\psi) = \int p(\boldsymbol{\omega})p(\mathbf{y}|\boldsymbol{\psi},\boldsymbol{\omega})d\boldsymbol{\omega}$ . + +The Pólya-Gamma distribution $\omega \sim \mathrm{PG}(b,c)$ can be written as an infinite convolution of Gamma distributions: + +$$ +\omega \stackrel {D} {=} \frac {1}{2 \pi^ {2}} \sum_ {k = 1} ^ {\infty} \frac {\operatorname {G a} (b , 1)}{(k - 1 / 2) ^ {2} + c ^ {2} / (4 \pi^ {2})}. \tag {17} +$$ + +The following integral identity holds for $b > 0$ : + +$$ +\frac {\left(e ^ {\psi}\right) ^ {a}}{\left(1 + e ^ {\psi}\right) ^ {b}} = 2 ^ {- b} e ^ {\kappa \psi} \int_ {0} ^ {\infty} e ^ {- \omega \psi^ {2} / 2} p (\omega) d \omega , \tag {18} +$$ + +where $\kappa = a - b / 2$ and $\omega \sim \mathrm{PG}(b,0)$ . Specifically, when $a = y$ and $b = 1$ , we recover an individual term of the logistic likelihood (16): + +$$ +p (y | \psi) = \frac {(e ^ {\psi}) ^ {y}}{1 + e ^ {\psi}} = \frac {1}{2} e ^ {\kappa \psi} \int_ {0} ^ {\infty} e ^ {- \omega \psi^ {2} / 2} p (\omega) d \omega , \tag {19} +$$ + +where $\kappa = y - 1/2$ and $\omega \sim PG(1,0)$ . Conditioned on $\omega$ , the batch likelihood is proportional to a diagonal Gaussian: + +$$ +p (\mathbf {y} | \psi , \boldsymbol {\omega}) \propto \prod_ {i = 1} ^ {N} e ^ {- \omega_ {i} \psi_ {i} ^ {2} / 2} e ^ {\kappa_ {i} \psi_ {i}} \propto \mathcal {N} \left(\boldsymbol {\Omega} ^ {- 1} \boldsymbol {\kappa} | \psi , \boldsymbol {\Omega} ^ {- 1}\right), \tag {20} +$$ + +where $\kappa_{i} = y_{i} - 1 / 2$ and $\Omega = \mathrm{diag}(\omega)$ . The conditional distribution over $\psi$ given $\mathbf{y}$ and $\omega$ is now tractable: + +$$ +p (\boldsymbol {\psi} | \mathbf {y}, \boldsymbol {\omega}) \propto p (\mathbf {y} | \boldsymbol {\psi}, \boldsymbol {\omega}) p (\boldsymbol {\psi}) \propto \mathcal {N} (\boldsymbol {\psi} | \hat {\boldsymbol {\Sigma}} (\boldsymbol {\Sigma} ^ {- 1} \boldsymbol {\mu} + \boldsymbol {\kappa}), \hat {\boldsymbol {\Sigma}}), \tag {21} +$$ + +where $\tilde{\Sigma} = (\Sigma^{-1} + \Omega)^{-1}$ + +# B EFFICIENT GIBBS SAMPLING + +The Gibbs conditional distribution over $\mathbf{f}$ is given by: + +$$ +p (\mathbf {f} | \mathbf {X}, \mathbf {y}, \boldsymbol {\omega}) = \mathcal {N} (\mathbf {f} | \tilde {\boldsymbol {\Sigma}} \left(\mathbf {K} ^ {- 1} \boldsymbol {\mu} + \mathbf {A} ^ {\top} \boldsymbol {\kappa}\right), \tilde {\boldsymbol {\Sigma}}), \tag {22} +$$ + +where $\tilde{\Sigma} = (\mathbf{K}^{-1} + \mathbf{A}^{\top}\boldsymbol {\Omega}\mathbf{A})^{-1}$ . Naively sampling from this distribution requires $\mathcal{O}(C^3 N^3)$ computation since $\tilde{\Sigma}$ is a $CN\times CN$ matrix. Here we describe a method for sampling from this distribution that requires $\mathcal{O}(CN^3)$ computation instead. + +First, we note that (22) can be interpreted as the conditional distribution $p(\mathbf{f}|\mathbf{z} = \Omega^{-1}\kappa)$ resulting from the following marginal distribution $p(\mathbf{f})$ and conditional $p(\mathbf{z}|\mathbf{f})$ : + +$$ +p (\mathbf {f}) = \mathcal {N} (\mathbf {f} | \boldsymbol {\mu}, \mathbf {K}) \tag {23} +$$ + +$$ +p (\mathbf {z} | \mathbf {f}) = \mathcal {N} (\mathbf {z} | \mathbf {A} \mathbf {f}, \boldsymbol {\Omega} ^ {- 1}), \tag {24} +$$ + +where we have made implicit the dependence on $\mathbf{X}$ , $\mathbf{Y}$ , and $\boldsymbol{\omega}$ for brevity of notation. Equivalently, the distribution over $\mathbf{f}$ and $\mathbf{z}$ can be represented by the partitioned Gaussian + +$$ +\left[ \begin{array}{l} \mathbf {f} \\ \mathbf {z} \end{array} \right] \sim \mathcal {N} \left(\left[ \begin{array}{c} \boldsymbol {\mu} \\ \mathbf {A} \boldsymbol {\mu} \end{array} \right], \left[ \begin{array}{c c} \mathbf {K} & \mathbf {K A} ^ {\top} \\ \mathbf {A K} & \mathbf {A K A} ^ {\top} + \boldsymbol {\Omega} ^ {- 1} \end{array} \right]\right). \tag {25} +$$ + +The conditional distribution $p(\mathbf{f}|\mathbf{z})$ is given as: + +$$ +p (\mathbf {f} | \mathbf {z}) = \mathcal {N} (\mathbf {f} | \tilde {\boldsymbol {\Sigma}} \left(\mathbf {K} ^ {- 1} \boldsymbol {\mu} + \mathbf {A} ^ {\top} \boldsymbol {\Omega} \mathbf {z}\right), \tilde {\boldsymbol {\Sigma}}), \tag {26} +$$ + +where $\tilde{\Sigma} = (\mathbf{K}^{-1} + \mathbf{A}^{\top}\boldsymbol {\Omega}\mathbf{A})^{-1}$ . Note that $p(\mathbf{f}|\mathbf{z} = \boldsymbol{\Omega}^{-1}\boldsymbol {\kappa})$ recovers our desired Gibbs conditional distribution from (22). + +An efficient approach to conditional Gaussian sampling is due to Hoffman & Ribak (1991) and described in greater clarity by Doucet (2010). The procedure is as follows: + +1. Sample $\mathbf{f}_0\sim p(\mathbf{f})$ and $\mathbf{z}_0\sim p(\mathbf{z}|\mathbf{f})$ +2. Return $\bar{\mathbf{f}} = \mathbf{f}_0 + \mathbf{K}\mathbf{A}^\top (\mathbf{A}\mathbf{K}\mathbf{A}^\top +\Omega^{-1})^{-1}(\Omega^{-1}\pmb {\kappa} - \mathbf{z}_0)$ as the sample from $p(\mathbf{f}|\mathbf{z})$ + +$\mathbf{K}$ is block diagonal and thus sampling from $p(\mathbf{f})$ requires $\mathcal{O}(CN^3)$ time. $\mathbf{A}\mathbf{f}$ can be computed in $\mathcal{O}(CN)$ time, since each entry is the difference between $f_{i}^{y_{i}}$ and $f_{i}^{c}$ for some $i$ and $c$ . Overall, step 1 requires $\mathcal{O}(CN^3)$ time. + +We now show how to compute $\overline{\mathbf{f}}$ from step 2 in $\mathcal{O}(CN^3)$ time. We first expand $(\mathbf{A}\mathbf{K}\mathbf{A}^\top +\Omega^{-1})^{-1}$ : + +$$ +\left(\mathbf {A} \mathbf {K} \mathbf {A} ^ {\top} + \boldsymbol {\Omega} ^ {- 1}\right) ^ {- 1} = \boldsymbol {\Omega} - \boldsymbol {\Omega} \mathbf {A} \left(\mathbf {K} ^ {- 1} + \mathbf {A} ^ {\top} \boldsymbol {\Omega} \mathbf {A}\right) ^ {- 1} \mathbf {A} ^ {\top} \boldsymbol {\Omega} \tag {27} +$$ + +We substitute into the expression for $\bar{\mathbf{f}}$ : + +$$ +\begin{array}{l} \bar {\mathbf {f}} = \mathbf {f} _ {0} + \mathbf {K} \mathbf {A} ^ {\top} (\boldsymbol {\Omega} - \boldsymbol {\Omega} \mathbf {A} (\mathbf {K} ^ {- 1} + \mathbf {A} ^ {\top} \boldsymbol {\Omega} \mathbf {A}) ^ {- 1} \mathbf {A} ^ {\top} \boldsymbol {\Omega}) (\boldsymbol {\Omega} ^ {- 1} \boldsymbol {\kappa} - \mathbf {z} _ {0}) (28) \\ = \mathbf {f} _ {0} + \mathbf {K A} ^ {\top} \boldsymbol {\Omega} \left(\boldsymbol {\Omega} ^ {- 1} \boldsymbol {\kappa} - \mathbf {z} _ {0}\right) - \mathbf {K A} ^ {\top} \boldsymbol {\Omega} \mathbf {A} \left(\mathbf {K} ^ {- 1} + \mathbf {A} ^ {\top} \boldsymbol {\Omega} \mathbf {A}\right) ^ {- 1} \mathbf {A} ^ {\top} \boldsymbol {\Omega} \left(\boldsymbol {\Omega} ^ {- 1} \boldsymbol {\kappa} - \mathbf {z} _ {0}\right) (29) \\ = \mathbf {f} _ {0} + \mathbf {K} \mathbf {v} - \mathbf {K} \mathbf {A} ^ {\top} \boldsymbol {\Omega} \mathbf {A} \left(\mathbf {K} ^ {- 1} + \mathbf {A} ^ {\top} \boldsymbol {\Omega} \mathbf {A}\right) ^ {- 1} \mathbf {v}, (30) \\ \end{array} +$$ + +where we have defined $\mathbf{v} \triangleq \mathbf{A}^{\top} \boldsymbol{\Omega} (\boldsymbol{\Omega}^{-1} \boldsymbol{\kappa} - \mathbf{z}_0)$ . + +Now let $\mathbf{d} \triangleq (d_1^1, \ldots, d_N^1, d_1^2, \ldots, d_N^2, \ldots, d_1^C, \ldots, d_N^C)^\top$ , where $d_i^c = Y_{ic} \sum_{c'} \omega_i^{c'}$ . Define $\mathbf{Y}^\dagger$ to be the $CN \times N$ matrix produced by vertically stacking $\mathrm{diag}(Y_{c})$ , and let $\mathbf{W}^\dagger$ be the $CN \times N$ matrix produced by vertically stacking $\mathrm{diag}((\omega_1^c, \ldots, \omega_N^c)^\top)$ . $\mathbf{A}^\top \Omega \mathbf{A}$ may then be written as follows: + +$$ +\mathbf {A} ^ {\top} \boldsymbol {\Omega} \mathbf {A} = \mathbf {D} - \mathbf {S P S} ^ {\top}, \text {w h e r e} \tag {31} +$$ + +$$ +\mathbf {D} = \boldsymbol {\Omega} + \operatorname {d i a g} (\mathbf {d}), \tag {32} +$$ + +$$ +\mathbf {S} = \left[ \begin{array}{l l} \mathbf {Y} ^ {\dagger} & \mathbf {W} ^ {\dagger} \end{array} \right], \tag {33} +$$ + +$$ +\mathbf {P} = \left[ \begin{array}{l l} \mathbf {0} _ {N} & \mathbf {I} _ {N} \\ \mathbf {I} _ {N} & \mathbf {0} _ {N} \end{array} \right]. \tag {34} +$$ + +Substituting (31) into (30): + +$$ +\bar {\mathbf {f}} = \mathbf {f} _ {0} + \mathbf {K v} - \mathbf {K A} ^ {\top} \boldsymbol {\Omega} \mathbf {A} \left(\mathbf {K} ^ {- 1} + \mathbf {D} - \mathbf {S P S} ^ {\top}\right) ^ {- 1} \mathbf {v}. \tag {35} +$$ + +Now we expand $(\mathbf{K}^{-1} + \mathbf{D} - \mathbf{S}\mathbf{P}\mathbf{S}^{\top})^{-1}$ + +$$ +\left(\mathbf {K} ^ {- 1} + \mathbf {D} - \mathbf {S P S} ^ {\top}\right) ^ {- 1} = \mathbf {E} - \mathbf {E S} \left(\mathbf {S} ^ {\top} \mathbf {E S} - \mathbf {P} ^ {- 1}\right) ^ {- 1} \mathbf {S} ^ {\top} \mathbf {E}, \tag {36} +$$ + +where $\mathbf{E} = (\mathbf{K}^{-1} + \mathbf{D})^{-1} = \mathbf{K}(\mathbf{K} + \mathbf{D}^{-1})^{-1}\mathbf{D}^{-1}$ is a block-diagonal matrix that can be computed in $\mathcal{O}(CN^3)$ time, since $\mathbf{D}$ is diagonal and $\mathbf{K}$ is block diagonal. Now, substituting (36) back into (35), + +$$ +\bar {\mathbf {f}} = \mathbf {f} _ {0} + \mathbf {K v} - \mathbf {K A} ^ {\top} \boldsymbol {\Omega} \mathbf {A E v} + \mathbf {K A} ^ {\top} \boldsymbol {\Omega} \mathbf {A E S} (\mathbf {S} ^ {\top} \mathbf {E S} - \mathbf {P} ^ {- 1}) ^ {- 1} \mathbf {S} ^ {\top} \mathbf {E v}. \tag {37} +$$ + +Note that $(\mathbf{S}^{\top}\mathbf{E}\mathbf{S} - \mathbf{P}^{-1})^{-1}$ is a $2N\times 2N$ matrix and thus can be inverted in $\mathcal{O}(N^3)$ time. The overall complexity is therefore $\mathcal{O}(CN^3)$ . + +# C MARGINAL LIKELIHOOD AND PREDICTIVE LIKELIHOOD OBJECTIVES + +Marginal Likelihood (ML). The log marginal likelihood can be written as follows: + +$$ +\begin{array}{l} L _ {\mathrm {M L}} (\boldsymbol {\theta}; \mathbf {X}, \mathbf {Y}) \triangleq \log p _ {\boldsymbol {\theta}} (\mathbf {Y} | \mathbf {X}) = \log \int p (\boldsymbol {\omega}) p _ {\boldsymbol {\theta}} (\mathbf {Y} | \boldsymbol {\omega}, \mathbf {X}) d \boldsymbol {\omega} \\ = \log \int p (\boldsymbol {\omega}) \int \mathcal {L} (\mathbf {f} | \mathbf {Y}, \boldsymbol {\omega}) p _ {\boldsymbol {\theta}} (\mathbf {f} | \mathbf {X}) d \mathbf {f} d \boldsymbol {\omega} \tag {38} \\ \end{array} +$$ + +The gradient of the log marginal likelihood can be estimated by posterior samples $\omega \sim p_{\theta}(\omega | \mathbf{X}, \mathbf{Y})$ . In practice, we use a stochastic training objective based on samples of $\omega$ from Gibbs chains. We use Fisher's identity (Douc et al., 2014) to derive the following gradient estimator: + +$$ +\nabla_ {\boldsymbol {\theta}} L _ {\mathrm {M L}} = \int p _ {\boldsymbol {\theta}} (\boldsymbol {\omega} | \mathbf {X}, \mathbf {Y}) \nabla_ {\boldsymbol {\theta}} \log p _ {\boldsymbol {\theta}} (\mathbf {Y} | \boldsymbol {\omega}, \mathbf {X}) d \boldsymbol {\omega} \approx \frac {1}{M} \sum_ {m = 1} ^ {M} \nabla_ {\boldsymbol {\theta}} \log p _ {\boldsymbol {\theta}} (\mathbf {Y} | \mathbf {X}, \boldsymbol {\omega} ^ {(m)}), \tag {39} +$$ + +where $\omega^{(1)},\ldots ,\omega^{(M)}$ are samples from the posterior Gibbs chain. As suggested by Patacchiola et al. (2020), who applied GPs to FSC via least-squares classification, we merge the support and query sets during learning to take full advantage of the available data within each episode. + +Predictive Likelihood (PL). The log predictive likelihood for a query example $\mathbf{x}_{*}$ is: + +$$ +L _ {\mathrm {P L}} \left(\boldsymbol {\theta}; \mathbf {X}, \mathbf {Y}, \mathbf {x} _ {*}, \mathbf {y} _ {*}\right) \triangleq \log p _ {\boldsymbol {\theta}} \left(\mathbf {y} _ {*} \mid \mathbf {x} _ {*}, \mathbf {X}, \mathbf {Y}\right) = \log \int p (\boldsymbol {\omega}) p _ {\boldsymbol {\theta}} \left(\mathbf {y} _ {*} \mid \mathbf {x} _ {*}, \mathbf {X}, \mathbf {Y}, \boldsymbol {\omega}\right) d \boldsymbol {\omega}. \tag {40} +$$ + +We use an approximate gradient estimator again based on posterior samples of $\omega$ : + +$$ +\nabla_ {\boldsymbol {\theta}} L _ {\mathrm {P L}} \approx \int p _ {\boldsymbol {\theta}} (\boldsymbol {\omega} | \mathbf {X}, \mathbf {Y}) \nabla_ {\boldsymbol {\theta}} \log p _ {\boldsymbol {\theta}} \left(\mathbf {y} _ {*} \mid \mathbf {x} _ {*}, \mathbf {X}, \mathbf {Y}\right) d \boldsymbol {\omega} \approx \frac {1}{M} \sum_ {m = 1} ^ {M} \nabla_ {\boldsymbol {\theta}} \log p _ {\boldsymbol {\theta}} \left(\mathbf {y} _ {*} \mid \mathbf {x} _ {*}, \mathbf {X}, \mathbf {Y}, \boldsymbol {\omega} ^ {(m)}\right). \tag {41} +$$ + +We note that this is not an unbiased estimator of the gradient, but find it works well in practice. + +# D LEARNING ALGORITHM + +Our learning algorithm for both marginal and predictive likelihood is summarized in Algorithm 1. + +Algorithm 1 One-vs-Each Pólya-Gamma GP Learning +Input: Objective $L\in \{L_{\mathrm{ML}},L_{\mathrm{PL}}\}$ , Task distribution $\mathcal{T}$ , number of parallel Gibbs chains $M$ +number of steps $T$ , learning rate $\eta$ +Initialize hyperparameters $\theta$ randomly. +repeat Sample $\mathcal{S} = (\mathbf{X},\mathbf{Y}),\mathcal{Q} = (\mathbf{X}_{*},\mathbf{Y}_{*})\sim \mathcal{T}$ if $L = L_{\mathrm{ML}}$ then $\mathbf{X}\gets \mathbf{X}\cup \mathbf{X}_{*},\mathbf{Y}\gets \mathbf{Y}\cup \mathbf{Y}_{*}$ +end if A $\leftarrow$ OVE-MATRiX(Y) +for $m = 1$ to $M$ do $\omega_0^{(m)}\sim PG(1,0),\mathbf{f}_0^{(m)}\sim p_\theta (\mathbf{f}|\mathbf{X})$ for $t = 1$ to $T$ do $\psi_t^{(m)}\gets \mathbf{A}\mathbf{f}_{t - 1}^{(m)}$ $\omega_{t}^{(m)}\sim \mathrm{PG}(1,\psi_{t}^{(m)})$ $\mathbf{f}_t^{(m)}\sim p_\theta (\mathbf{f}|\mathbf{X},\mathbf{Y},\omega_t^{(m)})$ end for +end for +if $L = L_{\mathrm{ML}}$ then $\theta \leftarrow \theta +\frac{\eta}{M}\sum_{m = 1}^{M}\nabla_{\theta}\log p_{\theta}(\mathbf{Y}|\mathbf{X},\omega_T^{(m)})$ else $\theta \leftarrow \theta +\frac{\eta}{M}\sum_{m = 1}^{M}\sum_{j}\nabla_{\theta}\log p_{\theta}(\mathbf{y}_{*j}|\mathbf{x}_{*j},\mathcal{S},\omega_T^{(m)})$ +end if +until convergence + +# E POSTERIOR PREDICTIVE DISTRIBUTION + +The posterior predictive distribution for a query example $\mathbf{x}_{*}$ conditioned on $\omega$ is: + +$$ +p \left(\mathbf {y} _ {*} \mid \mathbf {x} _ {*}, \mathbf {X}, \mathbf {Y}, \boldsymbol {\omega}\right) = \int p \left(\mathbf {y} _ {*} \mid \mathbf {f} _ {*}\right) p \left(\mathbf {f} _ {*} \mid \mathbf {x} _ {*}, \mathbf {X}, \mathbf {Y}, \boldsymbol {\omega}\right) d \mathbf {f} _ {*}, \tag {42} +$$ + +where $\mathbf{f}_{*}$ are the query example's logits. The predictive distribution over $\mathbf{f}_{*}$ can be obtained by noting that $\psi$ and the query logits are jointly Gaussian: + +$$ +\left[ \begin{array}{c} \boldsymbol {\psi} \\ \mathbf {f} _ {*} \end{array} \right] \sim \mathcal {N} \left(0, \left[ \begin{array}{c c} \mathbf {A K A} ^ {\top} + \boldsymbol {\Omega} ^ {- 1} & \mathbf {A K} _ {*} \\ (\mathbf {A K} _ {*}) ^ {\top} & \mathbf {K} _ {* *} \end{array} \right]\right), \tag {43} +$$ + +where $\mathbf{K}_{*}$ is the $NC\times C$ block diagonal matrix with blocks $K_{\theta}(\mathbf{X},\mathbf{x}_{*})$ and $\mathbf{K}_{**}$ is the $C\times C$ diagonal matrix with diagonal entries $k_{\theta}(\mathbf{x}_{*},\mathbf{x}_{*})$ . The predictive distribution becomes: + +$$ +p \left(\mathbf {f} _ {*} \mid \mathbf {x} _ {*}, \mathbf {X}, \mathbf {Y}, \omega\right) = \mathcal {N} \left(\mathbf {f} _ {*} \mid \boldsymbol {\mu} _ {*}, \boldsymbol {\Sigma} _ {*}\right), \text {w h e r e} +$$ + +$$ +\boldsymbol {\mu} _ {*} = \left(\mathbf {A} \mathbf {K} _ {*}\right) ^ {\top} \left(\mathbf {A} \mathbf {K} \mathbf {A} ^ {\top} + \boldsymbol {\Omega} ^ {- 1}\right) ^ {- 1} \boldsymbol {\Omega} ^ {- 1} \kappa \text {a n d} \tag {44} +$$ + +$$ +\boldsymbol {\Sigma} _ {*} = \mathbf {K} _ {* *} - (\mathbf {A} \mathbf {K} _ {*}) ^ {\top} (\mathbf {A} \mathbf {K} \mathbf {A} ^ {\top} + \boldsymbol {\Omega} ^ {- 1}) ^ {- 1} \mathbf {A} \mathbf {K} _ {*}. +$$ + +With $p(\mathbf{f}_*|\mathbf{x}_*,\mathbf{X},\mathbf{Y},\boldsymbol {\omega})$ in hand, the integral in (42) can easily be computed numerically for each class $c$ by forming the corresponding OVE linear transformation matrix $\mathbf{A}^c$ and then performing 1D Gaussian-Hermite quadrature on each dimension of $\mathcal{N}(\psi_{*}^{c}|\mathbf{A}^{c}\boldsymbol{\mu}^{*},\mathbf{A}^{c}\boldsymbol{\Sigma}_{*}\mathbf{A}^{c\top})$ + +# F DETAILED COMPARISON OF LIKELIHOODS + +In this section we seek to better understand the behaviors of the softmax, OVE, logistic softmax, and Gaussian likelihoods for classification. For convenience, we summarize the forms of these likelihoods in Table 3. + +Table 3: Likelihoods used in Section F. + +
LikelihoodL(f | y = c)
Softmaxexp(fc)/∑c' exp(fc')
GaussianΠc' N(2 · 11[c' = c] - 1 | μ = fc', σ² = 1)
Logistic Softmax (LSM)σ(fc)/∑c' σ(fc')
One-vs-Each (OVE)Πc' ≠ c σ(fc - fc')
+ +# F.1 HISTOGRAM OF CONFIDENCES + +We sampled logits from $f_{c} \sim \mathcal{N}(0,1)$ and plotted a histogram and kernel density estimate of the maximum output probability $\max_c p(y = c|\mathbf{f})$ for each of the likelihoods shown in Table 3, where $C = 5$ . The results are shown in Figure 4. Logistic softmax is a priori underconfident: it puts little probability mass on confidence above 0.4. This may be due to the use of the sigmoid function which squashes large values of $f$ . Gaussian likelihood and OVE are a priori overconfident in that they put a large amount of probability mass on confident outputs. Note that this is not a complete explanation, because GP hyperparameters such as the prior mean or Gaussian likelihood variance may be able to compensate for these imperfections to some degree. Indeed, we found it helpful to learn a constant mean for the logistic softmax likelihood, as mentioned in Section G.2. + +# F.2 LIKELIHOOD VISUALIZATION + +In order to visualize the various likelihoods under consideration, we consider a trivial classification task with a single observed example. We assume that there are three classes $(C = 3)$ and the single example belongs to the first class $(y = 1)$ . We place the following prior on $\mathbf{f} = (f_1, f_2, f_3)^\top$ : + +$$ +p (\mathbf {f}) = \mathcal {N} \left(\mathbf {f} \mid \boldsymbol {\mu} = \left[ \begin{array}{l} 0 \\ 0 \\ 0 \end{array} \right], \boldsymbol {\Sigma} = \left[ \begin{array}{l l l} 1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 0 \end{array} \right]\right). \tag {45} +$$ + +![](images/443b2d766dda37ee1d84c1ba97c6fa64bdf0af4021e3dd3c3b5cc24b74404677.jpg) +Figure 4: Histogram and kernel density estimate of confidence for randomly generated function samples $f_{c} \sim \mathcal{N}(0,1)$ . Normalized output probabilities were computed for $C = 5$ and a histogram of $\max_c p(y = c|\mathbf{f})$ was computed for 50,000 randomly generated simulations. + +In other words, the prior for $f_{1}$ and $f_{2}$ is a standard normal and $f_{3}$ is clamped at zero (for ease of visualization). The likelihoods are plotted in Figure 5 and the corresponding posteriors are plotted in Figure 6. + +![](images/f4693d3954c3abee5d9a4cd5510c222b061d4a01a82f1318d5fb0035b615f12d.jpg) +(a) Softmax + +![](images/2fcc30a189c27acea7264a28cca69f1a2cb6bb2b07654701b68bff3564c634f9.jpg) +(b) Gaussian +Figure 5: Plot of $\mathcal{L}(\mathbf{f} \mid y = 1)$ , where $f_{3}$ is clamped to 0. The Gaussian likelihood penalizes configurations far away from $(f_{1}, f_{2}) = (1, -1)$ . Logistic softmax is much flatter compared to softmax and has visibly different contours. One-vs-Each is visually similar to the softmax but penalizes $(f_{1}, f_{2})$ near the origin slightly more. + +![](images/f9b1a414e4b9abb423d3042df592847cb9b25b84edfe278ebeb9e61e0b09490e.jpg) +(c) Logistic Softmax + +![](images/de9db3426ac0e0332abbe8fab9867f5bb7476acfaac029c713d996d1456f4d4e.jpg) +(d) One-vs-Each + +![](images/0b7917b342c877790620a1c2353d5d994779d81784d6d30aa3ba4007d2ec7068.jpg) +(a) Softmax +Figure 6: Plot of posterior $p(\mathbf{f} \mid y = 1)$ , where $f_{3}$ is clamped to 0. The mode of each posterior distribution is similar, but each differs slightly in shape. Gaussian is more peaked about its mode, while logistic softmax is more spread out. One-vs-Each is similar to softmax, but is slightly more elliptical. + +![](images/8bd312e224aedf1b23cf64d51edb5dcd089ae075545cb6f66338ddeb56550878.jpg) +(b) Gaussian + +![](images/a092a5be03037dd59a5519c697ae37df4cc388adafcb58c8750fcb27093f239d.jpg) +(c) Logistic Softmax + +![](images/56e04df1ef58861e306da1be5c65b80fe66fe6935d6f132a03b22f7a79b69a22.jpg) +(d) One-vs-Each + +# F.3 2D IRIS EXPERIMENTS + +We also conducted experiments on a 2D version of the Iris dataset (Fisher, 1936), which contains 150 examples across 3 classes. The first two features of the dataset were retained (sepal length and width). We used a zero-mean GP prior and an RBF kernel $k(\mathbf{x},\mathbf{x}^{\prime}) = \exp \left(-\frac{1}{2} d(\mathbf{x},\mathbf{x}^{\prime})^{2}\right)$ , where $d(\cdot ,\cdot)$ is Euclidean distance. We considered training set sizes with 1, 2, 3, 4, 5, 10, 15, 20, 25, and 30 examples per class. For each training set size, we performed GP inference on 200 randomly generated train/test splits and compared the predictions across Gaussian, logistic softmax, and one-vs-each likelihoods. + +Predictions at a test point $\mathbf{x}_{*}$ were made by applying the (normalized) likelihood to the posterior predictive mean $\bar{\mathbf{f}}_{*}$ . The predictive probabilities for each likelihood is shown in Figure 7 for a randomly generated train/test split with 30 examples per class. Test predictive accuracy, Brier score, expected calibration error, and evidence lower bound (ELBO) results across various training set sizes are shown in Figure 8. + +The ELBO is computed by treating each likelihood's posterior $q(\mathbf{f}|\mathbf{X},\mathbf{Y})$ as an approximation to the softmax posterior $p(\mathbf{f}|\mathbf{X},\mathbf{Y})$ . + +$$ +\begin{array}{l} \operatorname {E L B O} (q) = \mathbb {E} _ {q} [ \log p (\mathbf {f} | \mathbf {X}) ] + \mathbb {E} _ {q} [ \log p (\mathbf {Y} | \mathbf {f}) ] - \mathbb {E} _ {q} [ \log q (\mathbf {f} | \mathbf {X}, \mathbf {Y}) ] \\ = \log p (\mathbf {x}) - \operatorname {K L} (q (\mathbf {f} | \mathbf {X}, \mathbf {Y}) | | p (\mathbf {f} | \mathbf {X}, \mathbf {Y})). \\ \end{array} +$$ + +Even though direct computation of the softmax posterior $p(\mathbf{f}|\mathbf{X},\mathbf{y})$ is intractable, computing the ELBO is tractable. A larger ELBO indicates a lower KL divergence to the softmax posterior. + +One-vs-Each performs well for accuracy, Brier score, and ELBO across the training set sizes. Gaussian performs best on expected calibration error through 15 examples per class, beyond which one-vs-each is better. + +![](images/ad1a03346308318a6c61baafc793bc267216142cb17609598a2ae3430362a9c8.jpg) +(a) Gaussian + +![](images/be00dee02b89814e01151c075b6be69537e78fd82ca3310aff754bc3f3da5e3a.jpg) +(b) Logistic Softmax + +![](images/dadc6a0ce5c8ffdb115b6d208a521cf0c2fbe5b4a4d11652b0fb6a9fdf42c48c.jpg) +(c) One-vs-Each + +![](images/e2e3d2b8bc6695b422c3762d803383c7f0d36c451d3d2f3d5cc1c18dd79605e9.jpg) +Figure 7: Training points (colored points) and maximum predictive probability for various likelihoods on the Iris dataset. The Gaussian likelihood produces more warped decision boundaries than the others. Logistic softmax tends to produce lower confidence predictions, while one-vs-each produces larger regions of greater confidence than the others. +(a) Accuracy +Figure 8: Comparison across likelihoods in terms of test predictive accuracy, Brier score, expected calibration error (computed with 10 bins), and ELBO. Results are averaged over 200 randomly generated splits for each training set size (1, 2, 3, 4, 5, 10, 15, 20, 25, and 30 examples per class). Error bars indicate $95\%$ confidence intervals. + +![](images/c39ce4ee7a4185480ecea99845e77772f38d7bafe90845e430c437be6b21a877.jpg) +(b) Brier + +![](images/1c06215ad5acc545822b2592558294dbd2707dff72ff65402feee00efa7294a2.jpg) +(c) ECE + +![](images/3e3e6bdfcf46bbc0a49c73a9379601ebd08d3ec12a8588e3f5aded654d04b859.jpg) +(d) ELBO + +# G FEW-SHOT EXPERIMENTAL DETAILS + +Here we provide more details about our experimental setup for our few-shot classification experiments, which are based on the protocol of (Patacchiola et al., 2020). + +# G.1 DATASETS + +We used the four dataset scenarios described below. The first three are the same used by Chen et al. (2019) and the final was proposed by Patacchiola et al. (2020). + +- CUB. Caltech-UCSD Birds (CUB) (Wah et al., 2011) consists of 200 classes and 11,788 images. A split of 100 training, 50 validation, and 50 test classes was used (Hilliard et al., 2018; Chen et al., 2019). +- mini-Imagenet. The mini-Imagenet dataset (Vinyals et al., 2016) consists of 100 classes with 600 images per class. We used the split proposed by Ravi & Larochelle (2017), which has 64 classes for training, 16 for validation, and 20 for test. +- mini-Imagenet $\rightarrow$ CUB. This cross-domain transfer scenario takes the training split of mini-Imagenet and the validation & test splits of CUB. +- Omniglot $\rightarrow$ EMNIST. We use the same setup as proposed by Patacchiola et al. (2020). Omniglot (Lake et al., 2011) consists of 1,623 classes, each with 20 examples, and is augmented by rotations of 90 degrees to create 6,492 classes, of which 4,114 are used for training. The EMNIST dataset (Cohen et al., 2017), consisting of 62 classes, is split into 31 training and 31 test classes. + +# G.2 FEW-SHOT CLASSIFICATION BASELINES + +Here we explain the few-shot baselines in greater detail. + +- Feature Transfer (Chen et al., 2019) involves first training an off-line classifier on the training classes and then training a new classification layer on the episode. +- Baseline++ (Chen et al., 2019) is similar to Feature Transfer except it uses a cosine distance module prior to the softmax during fine-tuning. +- Matching Networks (Vinyals et al., 2016) can be viewed as a soft form of $k$ -nearest neighbors that computes attention and sums over the support examples to form a predictive distribution over classes. +- Prototypical Networks (Snell et al., 2017) computes class means (prototypes) and forms a predictive distribution based on Euclidean distance to the prototypes. It can be viewed as a Gaussian classifier operating in an embedding space. +- MAML (Finn et al., 2017) performs one or a few steps of gradient descent on the support set and then makes predictions on the query set, backpropagating through the gradient descent procedure. For this baseline, we simply quote the classification accuracy reported by (Patacchiola et al., 2020). +- RelationNet (Sung et al., 2018) rather than using a predefined distance metric as in Matching Networks or Prototypical Networks instead learns a deep distance metric as the output of a neural network that accepts as input the latent representation of both examples. It is trained to minimize squared error of output predictions. +- Deep Kernel Transfer (DKT) (Patacchiola et al., 2020) relies on least squares classification (Rifkin & Klautau, 2004) to maintain tractability of Gaussian process posterior inference. In DKT, a separate binary classification task is formed for each class in one-vs-rest fashion by treating labels in $\{-1, +1\}$ as continuous targets. We include the results of DKT with the cosine kernel as implemented by Patacchiola et al. (2020), which is parameterized slightly differently from the version we used in (47): + +$$ +k _ {\mathrm {d k t}} ^ {\cos} \left(\mathbf {x}, \mathbf {x} ^ {\prime}; \boldsymbol {\theta}, \alpha , \nu\right) = \operatorname {s o f t p l u s} (\alpha) \cdot \operatorname {s o f t p l u s} (\nu) \cdot \frac {g _ {\boldsymbol {\theta}} \left(\mathbf {x}\right) ^ {\top} g _ {\boldsymbol {\theta}} \left(\mathbf {x} ^ {\prime}\right)}{\| g _ {\boldsymbol {\theta}} (\mathbf {x}) \| \| g _ {\boldsymbol {\theta}} \left(\mathbf {x} ^ {\prime}\right) \|}. \tag {46} +$$ + +- Bayesian MAML (Yoon et al., 2018) relies on Stein Variational Gradient Descent (SVGD) (Liu & Wang, 2016) to get an approximate posterior distribution in weight-space. We compare to both the non-chaser version, which optimizes cross-entropy of query predictions, and the chaser version, which optimizes mean squared error between the approximate posterior on the support set and the approximate posterior on the merged support & query set. The non-chaser version is therefore related to predictive likelihood methods and the chaser version is more analogous to the marginal likelihood methods. For the non-chaser version, we used 20 particles and 1 step of adaptation at both train and test time. For the chaser version, we also used 20 particles. At train time, the chaser took 1 step and the leader 1 additional step. At test time, we used 5 steps of adaptation. Due to the slow performance of this method, we followed the advice of Yoon et al. (2018) and only performed adaptation on the final layer of weights, which may help explain the drop in performance relative to MAML. The authors released Tensorflow code for regression only, so we reimplemented this baseline for classification in PyTorch. + +- Amortized Bayesian Meta-Learning (ABML) (Ravi & Beatson, 2019) performs a few steps of Bayes-by-backprop (Blundell et al., 2015) in order to infer a fully-factorized approximate posterior over the weights. The authors did not release code and so we implemented our own version of ABML in PyTorch. We found the weighting on the inner and outer KL divergences to be important for achieving good performance. We took the negative log likelihood to be mean cross entropy and used an inner KL weight of 0.01 and an outer KL weight of 0.001. These values were arrived upon by doing a small amount of hyperparameter tuning on the Omniglot $\rightarrow$ EMNIST dataset. We used $\alpha = 1.0$ and $\beta = 0.01$ for the Gamma prior over the weights. We only applied ABML to the weights of the network; the biases were learned as point estimates. We used 4 steps of adaptation and took 5 samples when computing expectations (using any more than this did not fit into GPU memory). We used the local reparameterization trick (Kingma et al., 2015) and flipout (Wen et al., 2018) when computing expectations in order to reduce variance. In order to match the architecture used by Ravi & Beatson (2019), we trained this baseline with 32 filters throughout the classification network. We trained each 1-shot ABML model for 800 epochs and each 5-shot ABML model for 600 epochs as the learning had not converged within the epoch limits specified in Section G.3. + +- Logistic Softmax GP (Galy-Fajou et al., 2020) is the multi-class Gaussian process classification method that relies on the logistic softmax likelihood. Galy-Fajou et al. (2020) did not consider few-shot, but we use the same objectives described in Section 4.4 to adapt this method to FSC. In addition, we used the cosine kernel (see Section H for a description) that we found to work best with our OVE PG GPs. For this method, we found it important to learn a constant mean function (rather than a zero mean) in order to improve calibration. + +# G.3 TRAINING DETAILS + +All methods employed the commonly-used Conv4 architecture (Vinyals et al., 2016) (see Table 4 for a detailed specification), except ABML which used 32 filters throughout. All of our experiments used the Adam (Kingma & Ba, 2015) optimizer with learning rate $10^{-3}$ . During training, all models used epochs consisting of 100 randomly sampled episodes. A single gradient descent step on the encoder network and relevant hyperparameters is made per episode. All 1-shot models are trained for 600 epochs and 5-shot models are trained for 400 epochs, except for ABML which was trained for an extra 200 epochs. Each episode contained 5 classes (5-way) and 16 query examples. At test time, 15 query examples are used for each episode. Early stopping was performed by monitoring accuracy on the validation set. The validation set was not used for retraining. + +We train both marginal likelihood and predictive likelihood versions of our models. For Polya-Gamma sampling we use the PyPólyaGamma package3. During training, we use a single step of Gibbs ( $T = 1$ ). For evaluation, we run until $T = 50$ . In both training and evaluation, we use $M = 20$ parallel Gibbs chains to reduce variance. + +Table 4: Specification of Conv4 architecture. Conv2d layers are $3 \times 3$ with stride 1 and same padding. MaxPool2d layers are $2 \times 2$ with stride 2 and valid padding. + +
Output SizeLayers
1 × 28 × 28Input image
64 × 14 × 14Conv2d +BatchNorm2d +ReLU +MaxPool2d
64 × 7 × 7Conv2d +BatchNorm2d +ReLU +MaxPool2d
64 × 3 × 3Conv2d +BatchNorm2d +ReLU +MaxPool2d
64 × 1 × 1Conv2d +BatchNorm2d +ReLU +MaxPool2d
64Flatten
+ +(a) Omniglot $\rightarrow$ EMNIST dataset. + +
Output SizeLayers
3 × 84 × 84Input image
64 × 42 × 42Conv2d +BatchNorm2d +ReLU +MaxPool2d
64 × 21 × 21Conv2d +BatchNorm2d +ReLU +MaxPool2d
64 × 10 × 10Conv2d +BatchNorm2d +ReLU +MaxPool2d
64 × 5 × 5Conv2d +BatchNorm2d +ReLU +MaxPool2d
1600Flatten
+ +(b) All other datasets. + +# H EFFECT OF KERNEL CHOICE ON CLASSIFICATION ACCURACY + +In this section, we examine the effect of kernel choice on classification accuracy for our proposed One-vs-Each Pólya-Gamma OVE GPs. + +Cosine Kernel. In the main paper, we showed results for the following kernel, which we refer to as the "cosine" kernel due to its resemblance to cosine similarity: + +$$ +k ^ {\cos} (\mathbf {x}, \mathbf {x} ^ {\prime}; \boldsymbol {\theta}, \alpha) = \exp (\alpha) \frac {g _ {\boldsymbol {\theta}} (\mathbf {x}) ^ {\top} g _ {\boldsymbol {\theta}} \left(\mathbf {x} ^ {\prime}\right)}{\| g _ {\boldsymbol {\theta}} (\mathbf {x}) \| \| g _ {\boldsymbol {\theta}} \left(\mathbf {x} ^ {\prime}\right) \|}, \tag {47} +$$ + +where $g_{\theta}(\cdot)$ is a deep neural network that outputs a fixed-dimensional encoded representation of the input and $\alpha$ is the scalar log output scale. Both $\theta$ and $\alpha$ are considered hyperparameters and learned simultaneously as shown in Algorithm 1. We found that this kernel works well for a range of datasets and shot settings. We note that the use of cosine similarity is reminiscent of the approach taken by Baseline++ method of (Chen et al., 2019), which computes the softmax over cosine similarity to class weights. + +Here we consider three additional kernels: linear, RBF, and normalized RBF. + +Linear Kernel. The linear kernel is defined as follows: + +$$ +k ^ {\mathrm {l i n}} \left(\mathbf {x}, \mathbf {x} ^ {\prime}; \boldsymbol {\theta}, \alpha\right) = \frac {1}{D} \exp (\alpha) g _ {\boldsymbol {\theta}} \left(\mathbf {x}\right) ^ {\top} g _ {\boldsymbol {\theta}} \left(\mathbf {x} ^ {\prime}\right), \tag {48} +$$ + +where $D$ is the output dimensionality of $g_{\theta}(\mathbf{x})$ . We apply this dimensionality scaling because the dot product between $g_{\theta}(\mathbf{x})$ and $g_{\theta}(\mathbf{x}^{\prime})$ may be large depending on $D$ . + +RBF Kernel. The RBF (also known as squared exponential) kernel can be defined as follows: + +$$ +k ^ {\mathrm {r b f}} \left(\mathbf {x}, \mathbf {x} ^ {\prime}; \boldsymbol {\theta}, \alpha , \ell\right) = \exp (\alpha) \exp \left(- \frac {1}{2 D \exp (\ell) ^ {2}} \| g _ {\boldsymbol {\theta}} (\mathbf {x}) - g _ {\boldsymbol {\theta}} \left(\mathbf {x} ^ {\prime}\right) \| ^ {2}\right), \tag {49} +$$ + +where $\ell$ is the log lengthscale parameter (as with $\alpha$ , we learn the $\ell$ alongside $\theta$ ). + +Normalized RBF Kernel. Finally, we consider a normalized RBF kernel similar in spirit to the cosine kernel: + +$$ +k ^ {\mathrm {r b f - n o r m}} (\mathbf {x}, \mathbf {x} ^ {\prime}; \boldsymbol {\theta}, \alpha , \ell) = \exp (\alpha) \exp \left(- \frac {1}{2 \exp (\ell) ^ {2}} \left\| \frac {g _ {\boldsymbol {\theta}} (\mathbf {x})}{\| g _ {\boldsymbol {\theta}} (\mathbf {x}) \|} - \frac {g _ {\boldsymbol {\theta}} \left(\mathbf {x} ^ {\prime}\right)}{\| g _ {\boldsymbol {\theta}} \left(\mathbf {x} ^ {\prime}\right) \|} \right\| ^ {2}\right). \tag {50} +$$ + +The results of our Pólya-Gamma OVE GPs with different kernels can be found in Tables 5 and 6. In general, we find that the cosine kernel works best overall, with the exception of Omniglot $\rightarrow$ EMNIST, where RBF does best. + +Table 5: Classification accuracy for Polya-Gamma OVE GPs (our method) using different kernels. Cosine is overall the best, followed closely by linear. RBF-based kernels perform worse, except for the Omniglot $\rightarrow$ EMNIST dataset. Evaluation is performed on 5 randomly generated sets of 600 test episodes. Standard deviation of the mean accuracy is also shown. ML = Marginal Likelihood, PL = Predictive Likelihood. + +
KernelCUBmini-ImageNet
Objective1-shot5-shot1-shot5-shot
CosineML63.98 ± 0.4377.44 ± 0.1850.02 ± 0.3564.58 ± 0.31
LinearML62.48 ± 0.2677.94 ± 0.2150.81 ± 0.3066.66 ± 0.45
RBFML58.49 ± 0.4075.50 ± 0.1850.33 ± 0.2664.62 ± 0.37
RBF (normalized)ML62.75 ± 0.3278.71 ± 0.0850.26 ± 0.3164.84 ± 0.39
CosinePL60.11 ± 0.2679.07 ± 0.0548.00 ± 0.2467.14 ± 0.23
LinearPL60.44 ± 0.3978.54 ± 0.1947.29 ± 0.3166.66 ± 0.36
RBFPL56.18 ± 0.6977.96 ± 0.1948.06 ± 0.2866.66 ± 0.39
RBF (normalized)PL59.78 ± 0.3478.42 ± 0.1347.51 ± 0.2066.42 ± 0.36
+ +Table 6: Cross-domain classification accuracy for Polya-Gamma OVE GPs (our method) using different kernels. The experimental setup is the same as Table 5. + +
KernelObjectiveOmniglot→EMNISTmini-ImageNet→CUB
1-shot5-shot1-shot5-shot
CosineML68.43 ± 0.6786.22 ± 0.2039.66 ± 0.1855.71 ± 0.31
LinearML72.42 ± 0.4988.27 ± 0.2039.61 ± 0.1955.07 ± 0.29
RBFML78.05 ± 0.3888.98 ± 0.1636.99 ± 0.0751.75 ± 0.27
RBF (normalized)ML75.51 ± 0.4788.86 ± 0.1638.42 ± 0.1654.20 ± 0.13
CosinePL77.00 ± 0.5087.52 ± 0.1937.49 ± 0.1157.23 ± 0.31
LinearPL75.87 ± 0.4388.77 ± 0.1036.83 ± 0.2756.46 ± 0.22
RBFPL74.62 ± 0.3589.87 ± 0.1335.06 ± 0.2555.12 ± 0.21
RBF (normalized)PL76.01 ± 0.3189.42 ± 0.1637.50 ± 0.2856.80 ± 0.39
+ +# I ADDITIONAL CALIBRATION RESULTS + +In Figure 9, we include calibration results for mini-Imagenet and Omniglot $\rightarrow$ EMNIST. They follow similar trends to the results presented in Section 5.2. + +![](images/6bc7c02e24bd6b202a676d78fd24c56a2a7ed37c64092e7a4ab0d5d22aaee179.jpg) + +![](images/f15565c469650cc2f9e7c049f276e4942661f713be2a2fcee5cb271e768c5c0e.jpg) + +![](images/791fd1bf662aaf39ba3eb32bd1ff65014efade563d10667aa4ec97d8bfefa995.jpg) +Figure 9: Reliability diagrams, expected calibration error, maximum calibration error, and Brier scores for 5-shot 5-way tasks on mini-Imagenet, Omniglot $\rightarrow$ EMNIST, and mini-Imagenet $\rightarrow$ CUB. Metrics are computed on 3,000 random tasks from the test set. + +# J QUANTITATIVE ROBUSTNESS TO INPUT NOISE RESULTS + +In this section we include quantitative results for the robustness to input noise results presented in Figure 2. Results for Gaussian noise are shown in Table 7, impulse noise in Table 8, and defocus blur in Table 9. + +Table 7: Accuracy (%) and Brier Score when applying Gaussian noise corruption of severity 5 to both the support and query set of test-time episodes. Results were evaluated across 1,000 randomly generated 5-shot 5-way tasks. + +
MethodCUBmini-ImageNetmini-ImageNet→CUB
Acc. (↑)Brier (↓)Acc. (↑)Brier (↓)Acc. (↑)Brier (↓)
Feature Transfer30.450.77522.580.79922.750.799
Baseline++22.600.79823.820.79724.130.797
MatchingNet26.720.80324.800.79723.590.804
ProtoNet32.280.77829.970.78132.300.779
RelationNet25.230.79923.690.80020.000.800
DKT + Cosine29.540.77927.780.79231.940.782
Bayesian MAML22.790.90520.520.96320.460.949
Bayesian MAML (Chaser)20.201.13320.411.11821.391.039
LSM GP + Cosine (ML)27.920.78722.430.79822.360.799
LSM GP + Cosine (PL)31.210.77231.770.76834.740.754
OVE PG GP + Cosine (ML) [ours]32.270.77429.990.77629.970.784
OVE PG GP + Cosine (PL) [ours]33.010.77133.290.76031.410.764
+ +Table 8: Accuracy (%) and Brier Score when applying impulse noise corruption of severity 5 to both the support and query set of test-time episodes. Results were evaluated across 1,000 randomly generated 5-shot 5-way tasks. + +
MethodCUBmini-ImageNetmini-ImageNet→CUB
Acc. (↑)Brier (↓)Acc. (↑)Brier (↓)Acc. (↑)Brier (↓)
Feature Transfer30.200.77623.540.79822.870.799
Baseline++28.050.79023.720.79825.580.795
MatchingNet28.250.79023.800.80323.210.811
ProtoNet32.120.77428.810.78332.700.775
RelationNet25.230.79923.130.80020.000.800
DKT + Cosine29.740.77829.110.78932.260.781
Bayesian MAML22.760.90320.500.97020.560.950
Bayesian MAML (Chaser)20.251.17220.511.11621.451.022
LSM GP + Cosine (ML)28.180.78721.820.79923.640.797
LSM GP + Cosine (PL)32.100.76930.220.77635.090.751
OVE PG GP + Cosine (ML) [ours]31.410.77829.660.77830.280.783
OVE PG GP + Cosine (PL) [ours]33.360.77233.230.76132.060.762
+ +Table 9: Accuracy (%) and Brier Score when applying defocus blur corruption of severity 5 to both the support and query set of test-time episodes. Results were evaluated across 1,000 randomly generated 5-shot 5-way tasks. + +
MethodCUBmini-ImageNetmini-ImageNet→CUB
Acc. (↑)Brier (↓)Acc. (↑)Brier (↓)Acc. (↑)Brier (↓)
Feature Transfer38.030.73433.060.79133.470.792
Baseline++42.550.71035.890.76139.880.740
MatchingNet44.430.68234.430.75435.950.741
ProtoNet46.780.67636.920.73741.450.714
RelationNet40.810.75930.110.79025.690.794
DKT + Cosine45.340.69538.290.73745.170.703
Bayesian MAML42.650.69730.630.80837.320.736
Bayesian MAML (Chaser)40.660.88129.931.12131.331.125
LSM GP + Cosine (ML)45.370.70634.100.76939.660.753
LSM GP + Cosine (PL)48.550.69039.460.73743.150.714
OVE PG GP + Cosine (ML) [ours]46.460.70137.650.77543.480.723
OVE PG GP + Cosine (PL) [ours]49.440.69538.950.78043.660.720
\ No newline at end of file diff --git a/bayesianfewshotclassificationwithonevseachplyagammaaugmentedgaussianprocesses/images.zip b/bayesianfewshotclassificationwithonevseachplyagammaaugmentedgaussianprocesses/images.zip new file mode 100644 index 0000000000000000000000000000000000000000..5b3358d6ace720765a5a77459573b971d0d689b2 --- /dev/null +++ b/bayesianfewshotclassificationwithonevseachplyagammaaugmentedgaussianprocesses/images.zip @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3bad3681a8c3e19ed71556c5318c31fbb5cc72db1394e5f2c7272cd0ee7a4fd1 +size 1786485 diff --git a/bayesianfewshotclassificationwithonevseachplyagammaaugmentedgaussianprocesses/layout.json b/bayesianfewshotclassificationwithonevseachplyagammaaugmentedgaussianprocesses/layout.json new file mode 100644 index 0000000000000000000000000000000000000000..808fe6a897f699ed7c2ae6461243e7e4accee4ed --- /dev/null +++ b/bayesianfewshotclassificationwithonevseachplyagammaaugmentedgaussianprocesses/layout.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6ffb9ef3238a240ab9a8f075709e42d59900ea0816ec91647f06b52c0465b54e +size 900857 diff --git a/benchmarksfordeepoffpolicyevaluation/d9f491a2-5714-40c0-be0a-de7214aaadf3_content_list.json b/benchmarksfordeepoffpolicyevaluation/d9f491a2-5714-40c0-be0a-de7214aaadf3_content_list.json new file mode 100644 index 0000000000000000000000000000000000000000..be7a2383ffce94500812c5a339097fe4bda687e7 --- /dev/null +++ b/benchmarksfordeepoffpolicyevaluation/d9f491a2-5714-40c0-be0a-de7214aaadf3_content_list.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8395c2336b55854060199d1bd61c1282bd3beb4b483c2b1c19af698f52684b80 +size 125190 diff --git a/benchmarksfordeepoffpolicyevaluation/d9f491a2-5714-40c0-be0a-de7214aaadf3_model.json b/benchmarksfordeepoffpolicyevaluation/d9f491a2-5714-40c0-be0a-de7214aaadf3_model.json new file mode 100644 index 0000000000000000000000000000000000000000..c19234e1fb6a0eda0dab5ac76bc2d85eae0cf171 --- /dev/null +++ b/benchmarksfordeepoffpolicyevaluation/d9f491a2-5714-40c0-be0a-de7214aaadf3_model.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d7216c36637deb8cc0f98e804b1e3296a6c60d543047de158641e5ae461344e5 +size 146677 diff --git a/benchmarksfordeepoffpolicyevaluation/d9f491a2-5714-40c0-be0a-de7214aaadf3_origin.pdf b/benchmarksfordeepoffpolicyevaluation/d9f491a2-5714-40c0-be0a-de7214aaadf3_origin.pdf new file mode 100644 index 0000000000000000000000000000000000000000..93aff0a00a02a234db0b1c7011b4544a58cf1c9b --- /dev/null +++ b/benchmarksfordeepoffpolicyevaluation/d9f491a2-5714-40c0-be0a-de7214aaadf3_origin.pdf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0512b054358af8ad87f64d67d0c453af3a053052e9625bc0626afd1f323d7982 +size 4798780 diff --git a/benchmarksfordeepoffpolicyevaluation/full.md b/benchmarksfordeepoffpolicyevaluation/full.md new file mode 100644 index 0000000000000000000000000000000000000000..9ab4535aaeedf52772ea934916bd8905efb128df --- /dev/null +++ b/benchmarksfordeepoffpolicyevaluation/full.md @@ -0,0 +1,381 @@ +# BENCHMARKS FOR DEEP OFF-POLICY EVALUATION + +Justin Fu $^{1}$ Mohammad Norouzi $^{2}$ Ofir Nachum $^{2}$ George Tucker $^{2}$ +Ziyu Wang $^{2}$ Alexander Novikov $^{3}$ Mengjiao Yang $^{2}$ Michael R. Zhang $^{2}$ +Yutian Chen $^{3}$ Aviral Kumar $^{1}$ Cosmin Paduraru $^{3}$ Sergey Levine $^{1}$ Tom Le Paine $^{3}$ + +$^{1}$ UC Berkeley ${}^{2}$ Google Brain ${}^{3}$ DeepMind justinfu@berkeley.edu, {mnorouzi, ofirnachum, gjt, tpaine}@google.com + +# ABSTRACT + +Off-policy evaluation (OPE) holds the promise of being able to leverage large, offline datasets for both evaluating and selecting complex policies for decision making. The ability to learn offline is particularly important in many real-world domains, such as in healthcare, recommender systems, or robotics, where online data collection is an expensive and potentially dangerous process. Being able to accurately evaluate and select high-performing policies without requiring online interaction could yield significant benefits in safety, time, and cost for these applications. While many OPE methods have been proposed in recent years, comparing results between papers is difficult because currently there is a lack of a comprehensive and unified benchmark, and measuring algorithmic progress has been challenging due to the lack of difficult evaluation tasks. In order to address this gap, we present a collection of policies that in conjunction with existing offline datasets can be used for benchmarking off-policy evaluation. Our tasks include a range of challenging high-dimensional continuous control problems, with wide selections of datasets and policies for performing policy selection. The goal of our benchmark is to provide a standardized measure of progress that is motivated from a set of principles designed to challenge and test the limits of existing OPE methods. We perform an evaluation of state-of-the-art algorithms and provide open-source access to our data and code to foster future research in this area $\dagger$ . + +# 1 INTRODUCTION + +Reinforcement learning algorithms can acquire effective policies for a wide range of problems through active online interaction, such as in robotics (Kober et al., 2013), board games and video games (Tesauro, 1995; Mnih et al., 2013; Vinyals et al., 2019), and recommender systems (Aggarwal et al., 2016). However, this sort of active online interaction is often impractical for real-world problems, where active data collection can be costly (Li et al., 2010), dangerous (Hauskrecht & Fraser, 2000; Kendall et al., 2019), or time consuming (Gu et al., 2017). Batch (or offline) reinforcement learning, has been studied extensively in domains such as healthcare (Thapa et al., 2005; Raghu et al., 2018), recommender systems (Dudik et al., 2014; Theocharous et al., 2015; Swaminathan et al., 2017), education (Mandel et al., 2014), and robotics (Kalashnikov et al., 2018). A major challenge with such methods is the off-policy evaluation (OPE) problem, where one must evaluate the expected performance of policies solely from offline data. This is critical for several reasons, including providing high-confidence guarantees prior to deployment (Thomas et al., 2015), and performing policy improvement and model selection (Bottou et al., 2013; Doroudi et al., 2017). + +The goal of this paper is to provide a standardized benchmark for evaluating OPE methods. Although considerable theoretical (Thomas & Brunskill, 2016; Swaminathan & Joachims, 2015; Jiang & Li, 2015; Wang et al., 2017; Yang et al., 2020) and practical progress (Gilotte et al., 2018; Nie et al., 2019; Kalashnikov et al., 2018) on OPE algorithms has been made in a range of different domains, there are few broadly accepted evaluation tasks that combine complex, high-dimensional problems + +commonly explored by modern deep reinforcement learning algorithms (Bellemare et al., 2013; Brockman et al., 2016) with standardized evaluation protocols and metrics. Our goal is to provide a set of tasks with a range of difficulty, exercise a variety of design properties, and provide policies with different behavioral patterns in order to establish a standardized framework for comparing OPE algorithms. We put particular emphasis on large datasets, long-horizon tasks, and task complexity to facilitate the development of scalable algorithms that can solve high-dimensional problems. + +Our primary contribution is the Deep Off-Policy Evaluation (DOPE) benchmark. DOPE is designed to measure the performance of OPE methods by 1) evaluating on challenging control tasks with properties known to be difficult for OPE methods, but which occur in real-world scenarios, 2) evaluating across a range of policies with different values, to directly measure performance on policy evaluation, ranking and selection, and 3) evaluating in ideal and adversarial settings in terms of dataset coverage and support. These factors are independent of task difficulty, but are known to have a large impact on OPE performance. To achieve 1, we selected tasks on a set of design principles outlined in Section 3.1. To achieve 2, for each task we include 10 to 96 policies for evaluation and devise an evaluation protocol that measures policy evaluation, ranking, and selection as outlined in Section 3.2. To achieve 3, we provide two domains with differing dataset coverage and support properties described in Section 4. Finally, to enable an easy-to-use research platform, we provide the datasets, target policies, evaluation API, as well as the recorded results of state-of-the-art algorithms (presented in Section 5) as open-source. + +# 2 BACKGROUND + +We briefly review the off-policy evaluation (OPE) problem setting. We consider Markov decision processes (MDPs), defined by a tuple $(\mathcal{S},\mathcal{A},\mathcal{T},R,\rho_0,\gamma)$ , with state space $\mathcal{S}$ , action space $\mathcal{A}$ , transition distribution $\mathcal{T}(s'|s,a)$ , initial state distribution $\rho_0(s)$ , reward function $R(s,a)$ and discount factor $\gamma \in (0,1]$ . In reinforcement learning, we are typically concerned with optimizing or estimating the performance of a policy $\pi(a|s)$ . + +The performance of a policy is commonly measured by the policy value $V^{\pi}$ , defined as the expected sum of discounted rewards: + +$$ +V ^ {\pi} := \mathbb {E} _ {s _ {0} \sim \rho_ {0}, s _ {1: \infty}, a _ {0: \infty} \sim \pi} \left[ \sum_ {t = 0} ^ {\infty} \gamma^ {t} R (s _ {t}, a _ {t}) \right]. \tag {1} +$$ + +If we have access to state and action samples collected from a policy $\pi$ , then we can use the sample mean of observed returns to estimate the value function above. However, in off-policy evaluation we are typically interested in estimating the value of a policy when the data is collected from a separate behavior policy $\pi_B(a|s)$ . This setting can arise, for example, when data is being generated online from another process, or in the purely offline case when we have a historical dataset. + +![](images/f3885bff56a5351e9a3e730090f3bfa660006a1112cab09a0ffa326f3e4e6b42.jpg) +Figure 1: In Off-Policy Evaluation (top) the goal is to estimate the value of a single policy given only data. Offline Policy Selection (bottom) is a closely related problem: given a set of N policies, attempt to pick the best given only data. + +In this work we consider the latter, purely offline setting. The typical setup for this problem formulation is that we are provided with a discount $\gamma$ , a dataset of trajectories collected from a behavior policy $\mathcal{D} = \{(s_0, a_0, r_0, s_1, \ldots)\}$ , and optionally the action probabilities for the behavior policy $\pi_B(a_t | s_t)$ . In many practical applications, logging action propensities is not possible, for example, when the behavior policy is a mix of ML and hard-coded business logic. For this reason, we focus on the setting without propensities to encourage future work on behavior-agnostic OPE methods. For the methods that require propensities, we estimate the propensities with behavior cloning. + +The objective can take multiple flavors, as shown in Fig. 1. A common task in OPE is to estimate the performance, or value, of a policy $\pi$ (which may not be the same as $\pi_B$ ) so that the estimated + +value is as close as possible to $V^{\pi}$ under a metric such as MSE or absolute error. A second task is to perform policy selection, where the goal is to select the best policy or set of policies out of a group of candidates. This setup corresponds to how OPE is commonly used in practice, which is to find the best performing strategy out of a pool when online evaluation is too expensive to be feasible. + +# 3 DOPE: DEEP OFF-POLICY EVALUATION + +The goal of the Deep Off-Policy Evaluation (DOPE) benchmark is to provide tasks that are challenging and effective measures of progress for OPE methods, yet is easy to use in order to better facilitate research. Therefore, we design our benchmark around a set of properties which are known to be difficult for existing OPE methods in order to gauge their shortcomings, and keep all tasks amenable to simulation in order for the benchmark to be accessible and easy to evaluate. + +# 3.1 TASK PROPERTIES + +We describe our motivating properties for selecting tasks for the benchmark as follows: + +High Dimensional Spaces (H) High-dimensionality is a key-feature in many real-world domains where it is difficult to perform feature engineering, such as in robotics, autonomous driving, and more. In these problems, it becomes challenging to accurately estimate quantities such as the value function without the use of high-capacity models such as neural networks and large datasets with wide state coverage. Our benchmark contains complex continuous-space tasks which exercise these challenges. + +Long Time-Horizon (L) Long time horizon tasks are known to present difficult challenges for OPE algorithms. Some algorithms have difficulty doing credit assignment for these tasks. This can be made worse as the state dimension or action dimension increases. + +Sparse Rewards (R) Sparse reward tasks increase the difficulty of credit assignment and add exploration challenges, which may interact with data coverage in the offline setting. We include a range robotics and navigation tasks which are difficult to solve due to reward sparsity. + +Temporally extended control (T) The ability to make decisions hierarchically is major challenge in many reinforcement learning applications. We include two navigation tasks which require high-level planning in addition to low-level control in order to simulate the difficulty in such problems. + +# 3.2 EVALUATION PROTOCOL + +The goal of DOPE to provide metrics for policy ranking, evaluation and selection. Many existing OPE methods have only been evaluated on point estimates of value such as MSE, but policy selection is an important, practical use-case of OPE. In order to explicitly measure the quality of using OPE for policy selection, we provide a set of policies with varying value, and devise two metrics that measure how well OPE methods can rank policies. + +For each task we include a dataset of logged experiences $\mathcal{D}$ and a set of policies $\{\pi_1,\pi_2,\dots,\pi_N\}$ with varying values. For each policy, OPE algorithms must use $\mathcal{D}$ to produce an estimate of the policy's value. For evaluation of these + +estimates, we provide "ground truth values" $\{V^{\pi_1}, V^{\pi_2}, \dots, V^{\pi_N}\}$ that are computed by running the policy for $M \geq 1000$ episodes, where the exact value of $M$ is given by the number of episodes needed to lower the error bar on the ground truth values to 0.666. The estimated values are then compared to these ground truth values using three different metrics encompassing both policy evaluation and selection (illustrated in Figure 2; see Appendix A.1 for mathematical definitions). + +![](images/6e73b5a607ed526399407a22d34300d45a54d673c69a2d91056caa701d772051.jpg) +Figure 2: Error is a natural measure for off-policy evaluation. However for policy selection, it is sufficient to (i) rank the policies as measured by rank correlation, or (ii) select a policy with the lowest regret. + +Absolute Error This metric measures estimate accuracy instead of its usefulness for ranking. Error is the most commonly used metric to assess performance of OPE algorithms. We opted to use absolute error instead of MSE to be robust to outliers. + +Regret@k This metric measures how much worse the best policies identified by the estimates are than the best policy in the entire set. It is computed by identifying the top-k policies according to the estimated returns. Regret@k is the difference between the actual expected return of the best policy in the entire set, and the actual value of the best policy in the top-k set. + +Rank correlation This metric directly measures how well estimated values rank policies, by computing the correlation between ordinal rankings according to the OPE estimates and ordinal rankings according to the ground truth values. + +# 4 DOMAINS + +DOPE contains two domains designed to provide a more comprehensive picture of how well OPE methods perform in different settings. These two domains are constructed using two benchmarks previously proposed for offline reinforcement learning: RL Unplugged (Gulcehre et al., 2020) and D4RL (Fu et al., 2020), and reflect the challenges found within them. + +The DOPE RL Unplugged domain is constrained in two important ways: 1) the data is always generated using online RL training, ensuring there is adequate coverage of the state-action space, and 2) the policies are generated by applying offline RL algorithms to the same dataset we use for evaluation, ensuring that the behavior policy and evaluation policies induce similar state-action distributions. Using it, we hope to understand how OPE methods work as task complexity increases from simple Cartpole tasks to controlling a Humanoid body while controlling for ideal data. + +On the other hand, the DOPE D4RL domain has: 1) data from various sources (including random exploration, human teleoperation, and RL-trained policies with limited exploration), which results in varying levels of coverage of the state-action space, and 2) policies that are generated using online RL algorithms, making it less likely that the behavior and evaluation policies share similar induced state-action distributions. Both of these result in distribution shift which is known to be challenging for OPE methods, even in simple tasks. So, using it we hope to measure how well OPE methods work in more practical data settings. + +# 4.1 DOPERL UNPLUGGED + +DeepMind Control Suite (Tassa et al., 2018) is a set of control tasks implemented in MuJoCo (Todorov et al., 2012). We consider the subset included in RL Unplugged. This subset includes tasks that cover a range of difficulties. From Cartpole swingup, a simple task with a single degree + +![](images/ef9d7ceeef46447f23d74766a28c3a39d5e83cb997b059ded3b307402a0955c9.jpg) + +of freedom, to Humanoid run which involves control of a complex bodies with 21 degrees of freedom. All tasks use the default feature representation of the system state, including proprioceptive information such as joint positions and velocity, and additional sensor information and target position where appropriate. The observation dimension ranges from 5 to 67. + +Datasets and policies We train four offline RL algorithms (D4PG (Barth-Maron et al., 2018), ABM (Siegel et al., 2020), CRR (Wang et al., 2020) and behavior cloning), varying their hyperparameters. For each algorithm-task-hyperparameter combination, we train an agent with 3 random seeds on the DM Control Suite dataset from RL Unplugged and record policy snapshots at exponentially increasing intervals (after 25k learner steps, 50k, 100K, 200K, etc). Following Gulcehre et al. (2020), we consider a deterministic policy for D4PG and stochastic policies for BC, ABM and CRR. The datasets are taken from the RL Unplugged benchmark, where they were created by training multiple (online) RL agents and collecting both successful and unsuccessful episodes throughout training. All offline RL algorithms are implemented using the Acme framework (Hoffman et al., 2020). + +# 4.2 DOPE D4RL + +Gym-MuJoCo tasks. Gym-MuJoCo consists of several continuous control tasks implemented within the MuJoCo simulator (Todorov et al., 2012) and provided in the OpenAI Gym (Brockman et al., 2016) benchmark for online RL. We include the HalfCheetah, Hopper, Walker2D, and Ant tasks. We include this domain primarily for comparison with past works, as a vast array of popular RL + +
Statisticscartpole swingupcheetah runfinger turn hardfish swimhumanoid runwalker standwalker walkmanipulator insert ballmanipulator insert peg
Dataset size40K300K500K200K3M200K200K1.5M1.5M
State dim.51712246724244444
Action dim.1625216655
Properties-H, LH, LH, LH, LH, LH, LH, L, TH, L, T
+ +
Statisticsmaze2dantmazehalfcheetahhopperwalkeranthammerdoorrelocatepen
Dataset size1/2/4M1M1M1M1M1M11K/1M7K/1M10K/1M5K/500K
# datasets1155553333
State dim.42917111711146393945
Action dim.28636826283024
PropertiesTT, RHHHHH, RH, RH, RH, R
+ +Table 1: Task statistics for RLUnplugged tasks (top) and D4RL tasks (bottom). Dataset size is the number of $(s,a,r,s^{\prime})$ tuples. For each dataset, we note the properties it possesses: high dimensional spaces $(\mathbf{H})$ , long time-horizon $(\mathbf{L})$ , sparse rewards $(\mathbf{R})$ , temporally extended control $(\mathbf{T})$ . + +![](images/9ccf4fe5da01e5e9dc3cf12fb44d07343c13759ab84191858959062163ce91a6.jpg) +Figure 3: Online evaluation of policy checkpoints for 4 Offline RL algorithms with 3 random seeds. We observe a large degree of variability between the behavior of algorithms on different tasks. Without online evaluation, tuning the hyperparameters (e.g., choice of Offline RL algorithm and policy checkpoint) is challenging. This highlights the practical importance of Offline policy selection when online evaluation is not feasible. See Figure A.7 for additional tasks. + +![](images/6c663608331db1687ce5165bd42e6ab299ecd8a4ae9b70193e524650d12905c2.jpg) + +![](images/42722839a380ab997d775b74000516ded4ea66a9bf67533a35f5bd59f91952a3.jpg) + +![](images/ff69565bf06d83d42709f259d2b72b1309ee3a2b277e02f33384badb36ff50cc.jpg) + +methods have been evaluated and developed on these tasks (Schulman et al., 2015; Lillicrap et al., 2015; Schulman et al., 2017; Fujimoto et al., 2018; Haarnoja et al., 2018). + +Gym-MuJoCo datasets and policies. For each task, in order to explore the effect of varying distributions, we include 5 datasets originally proposed by Fu et al. (2020). 3 correspond to different performance levels of the agent – “random”, “medium”, and “expert”. We additionally include labeled “medium-expert”, and data collected from a replay level of performance, labeled “medium-replay”. For police evenly-spaced snapshots of training a Soft Actor-Critic ag range of performance between random and expert. + +![](images/9e9dc7f9aa33535817963b3778a7275c69b77c47f9d4794ec80859ec1170d869.jpg) + +Maze2D and AntMaze tasks. Maze2D and AntMaze are two maze navigation tasks originally proposed in D4RL (Fu et al., 2020). The domain consists of 3 mazes ranging from easy to hard ("umaze", "medium", "large"), and two morphologies: a 2D ball in Maze2D and the "Ant" robot of the Gym benchmark in AntMaze. For Maze2D, + +![](images/a8bdbca38926f343a8ed8f9055dbab74cc4e4e57c4806e59d1f27d1f0bbee2ee.jpg) + +we provide a less challenging reward computed base on distance to a fixed goal. For the AntMaze environment reward is given only upon reaching the fixed goal. + +Maze2D and AntMaze datasets and policies. Datasets for both morphologies consists of undirect data navigating randomly to different goal locations. The datasets for Maze2D are collected by using a high-level planner to command waypoints to a low-level PID controller in order to reach randomly selected goals. The dataset in AntMaze is generated using the same high-level planner, but the low- + +level planner is replaced with a goal-conditioned policy trained to reach arbitrary waypoints. Both of these datasets are generated from non-Markovian policies, as the high-level controller maintains a history of waypoints reached in order to construct a plan to the goal. We provide policies for all environments except "antmaze-large" by taking training snapshots obtained while running the DAPG algorithm (Rajeswaran et al., 2017). Because obtaining high-performing policies for "antmaze-large" was challenging, we instead used imitation learning on a large amount of expert data to generate evaluation policies. This expert data is obtained by collecting additional trajectories that reach the goal using a high-level waypoint planner in conjunction with a low-level goal-conditioned policy (this is the same method as was used to generate the dataset, Sec. 5 (Fu et al., 2020)). + +Adroit tasks. The Adroit domain is a realistic simulation based on the Shadow Hand robot, first proposed by Rajeswaran et al. (2017). There are 4 tasks in this domain: opening a door ("door"), pen twirling ("pen"), moving a ball to a target location ("relocate"), and hitting a nail with a hammer ("hammer"). These tasks all contain sparse rewards and are difficult to learn without demonstrations. + +Adroit datasets and policies. We include 3 datasets for each task. The "human" dataset consists of a small amount of human demonstrations + +![](images/81ae8feac788298a7ab1355859ae3b81aa0a4a8538dde79d39b4f04f00cedecc.jpg) + +performing the task. The "expert" dataset consists of data collected from an expert trained via DAPG (Rajeswaran et al., 2017). Finally, the "cloned" dataset contains a mixture of human demonstrations and data collected from an imitation learning algorithm trained on the demonstrations. For policies, we include 11 policies collected from snapshots while running the DAPG algorithm, which range from random performance to expert performance. + +# 5 BASELINES AND RESULTS + +The goal of our evaluation is two-fold. First, we wish to measure the performance of a variety of existing algorithms to provide baselines and reference numbers for future research. Second, we wish to identify shortcomings in these approaches to reveal promising directions for future research. + +# 5.1 BASELINES + +We selected six methods to evaluate, which cover a variety of approaches that have been explored for the OPE problem. + +Fitted Q-Evaluation (FQE) As in Le et al. (2019), we train a neural network to estimate the value of the evaluation policy $\pi$ by bootstrapping from $Q(s', \pi(s'))$ . We tried two different implementations, one from Kostrikov & Nachum (2020) $^3$ and another from Paine et al. (2020) labeled FQE-L2 and FQE-D respectively to reflect different choices in loss function and parameterization. + +Model-Based (MB) Similar to Paduraru (2007), we train dynamics and reward models on transitions from the offline dataset $\mathcal{D}$ . Our models are deep neural networks trained to maximize the log likelihood of the next state and reward given the current state and action, similar to models from successful model-based RL algorithms (Chua et al., 2018; Janner et al., 2019). We follow the setup detailed in Zhang et al. (2021). We include both the feed-forward and auto-regressive models labeled MB-FF and MB-AR respectively. To evaluate a policy, we compute the return using simulated trajectories generated by the policy under the learned dynamics model. + +Importance Sampling (IS) We perform importance sampling with a learned behavior policy. We use the implementation from Kostrikov & Nachum $(2020)^{3}$ , which uses self-normalized (also known as weighted) step-wise importance sampling (Precup, 2000). Since the behavior policy is not known explicitly, we learn an estimate of it via a max-likelihood objective over the dataset $\mathcal{D}$ , as advocated by Xie et al. (2018); Hanna et al. (2019). In order to be able to compute log-probabilities when the target policy is deterministic, we add artificial Gaussian noise with standard deviation 0.01 for all deterministic target policies. + +![](images/e5a6a473ee91878e5de39607f2f14985b6601be6e894b450baec3ca6dc1daa05.jpg) +Figure 4: DOPE RL Unplugged Mean overall performance of baselines. + +![](images/face88597a036064f5dc101b9dd9d2424dd1b224758f8071417fc50f4563ee06.jpg) + +![](images/64ede4ef4ac49329d5bb5a89706b9febffab4f13f8f36c83e8e39c4e91b2a4f1.jpg) + +![](images/d913a5a7a769e87e9c39cadf780d9f4a537a848748f2bfff258ff77f9bc4997f.jpg) +Figure 5: DOPE D4RL Mean overall performance of baselines. + +![](images/f6024395e857140e67101df02740f3af0370bb5ca923a4b7460ea2b13cf37819.jpg) + +![](images/179fa71a277be3a86ed4de0f9c441bcfc61d793e5e14f2bdafaa99231159887c.jpg) + +Doubly-Robust (DR) We perform weighted doubly-robust policy evaluation Thomas & Brunskill (2016) using the implementation of Kostrikov & Nachum $(2020)^{3}$ . Specifically, this method combines the IS technique above with a value estimator for variance reduction. The value estimator is learned using deep FQE with an L2 loss function. More advanced approaches that trade variance for bias exist (e.g., MAGIC (Thomas & Brunskill, 2016)), but we leave implementing them to future work. + +DICE This method uses a saddle-point objective to estimate marginalized importance weights $d^{\pi}(s,a) / d^{\pi_B}(s,a)$ ; these weights are then used to compute a weighted average of reward over the offline dataset, and this serves as an estimate of the policy's value in the MDP. We use the implementation from Yang et al. (2020) corresponding to the algorithm BestDICE. + +Variational Power Method (VPM) This method runs a variational power iteration algorithm to estimate the importance weights $d^{\pi}(s,a) / d^{\pi_B}(s,a)$ without the knowledge of the behavior policy. It then estimates the target policy value using weighted average of rewards similar to the DICE method. Our implementation is based on the same network and hyperparameters for OPE setting as in Wen et al. (2020). We further tune the hyper-parameters including the regularization parameter $\lambda$ , learning rates $\alpha_{\theta}$ and $\alpha_{v}$ , and number of iterations on the Cartpole swingup task using ground-truth policy value, and then fix them for all other tasks. + +# 5.2 RESULTS + +To facilitate aggregate metrics and comparisons between tasks and between DOPE RL Unplugged and DOPE D4RL, we normalize the returns and estimated returns to range between 0 and 1. For each set of policies we compute the worst value $V_{worst} = \min \{V^{\pi_1}, V^{\pi_2}, \dots, V^{\pi_N}\}$ and best value $V_{best} = \max \{V^{\pi_1}, V^{\pi_2}, \dots, V^{\pi_N}\}$ and normalize the returns and estimated returns according to $x' = (x - V_{worst}) / (V_{best} - V_{worst})$ . + +We present results averaged across DOPE RL Unplugged in Fig. 4, and results for DOPE D4RL in Fig. 5. Overall, no evaluated algorithm attains near-oracle performance under any metric (absolute error, regret, or rank correlation). Because the dataset is finite, we do not expect that achieving oracle performance is possible. Nevertheless, based on recent progress on this benchmark (e.g., Zhang et al. (2021)), we hypothesize that the benchmark has room for improvement, making it suitable for driving further improvements on OPE methods and facilitating the development of OPE algorithms that can provide reliable estimates on the types of high-dimensional problems that we consider. + +While all algorithms achieve sub-optimal performance, some perform better than others. We find that on the DOPE RL Unplugged tasks model based (MB-AR, MB-FF) and direct value based methods (FQE-D, FQE-L2) significantly outperform importance sampling methods (VPM, DICE, IS) across all metrics. This is somewhat surprising as DICE and VPM have shown promising results in other settings. We hypothesize that this is due to the relationship between the behavior data and evaluation policies, which is different from standard OPE settings. Recall that in DOPE RL Unplugged the behavior data is collected from an online RL algorithm and the evaluation policies are learned via offline RL from the behavior data. In our experience all methods work better when the behavior policy is a noisy/perturbed version of the evaluation policy. Moreover, MB and FQE-based methods may + +![](images/5a0ceedd77c0d76f8f1f5d0625a3d680a002671e6f669a82d7058db5f076299d.jpg) +Figure 6: Rank correlation for each baseline algorithm for each RL Unplugged task considered. + +![](images/f42bf7a76d4bd739cd1faf46ed22c76c3a628491e65a5b52f297109379354e96.jpg) +Figure 7: Scatter plots of estimate vs ground truth return for MB-AR and FQE-D on selected tasks. + +implicitly benefit from the architectural and optimization advancements made in policy optimization settings, which focus on similar environments and where these methods are more popular than importance sampling approaches. Note that within the MB and FQE methods, design details can create a significant difference in performance. For example model architecture (MB-AR vs MB-FF) and implementation differences (FQE-D vs FQE-L2) show differing performance on certain tasks. + +On DOPE D4RL, direct value based methods still do well, with FQE-L2 performing best on the Absolute Error and Regret@1 metrics. However, there are cases where other methods outperform FQE. Notably, IS and DR outperform FQE-L2 under the rank correlation metric. As expected, there is a clear performance gap between DOPE RL Unplugged and DOPE D4RL. While both domains have challenging tasks, algorithms perform better under the more ideal conditions of DOPE RL Unplugged than under the challenging conditions of DOPE D4RL (0.69 vs 0.25 rank correlation respectively). + +In Fig. A.2 we show the rank correlation for each task in DOPE RL Unplugged. Most tasks follow the overall trends, but we will highlight a few exceptions. 1) Importance sampling is among the best methods for the humanoid run task, significantly outperforming direct value-based methods. 2) while MB-AR and FQE-D are similar overall, there are a few tasks where the difference is large, for example FQE-D outperforms MB-AR on finger turn hard, and manipulator insert ball, where as MB-AR outperforms FQE-D on cartpole swingup, fish swim, humanoid run, and manipulator insert peg. We show the scatter plots for MB-AR and FQE-D on these tasks in Fig 7 which highlights different failure modes: when MB-AR performs worse, it assigns similar values for all policies; when FQE-D performs worse, it severely over-estimates the values of poor policies. + +We present more detailed results, separated by task, in Appendix A.2. Note in particular how in Table A.2.2, which shows the regret@1 metric for different D4RL tasks, the particular choice of dataset for the Gym-MuJoCo, Adroit, and AntMaze domains causes a significant difference in the performance of OPE methods. This indicates the importance of evaluating multiple distinct datasets, with different data distribution properties (e.g., more narrow datasets, such as expert data, vs. broader datasets, such as random data), as no tested method is reliably robust to the effects of dataset variation. + +High-dimensional tasks requiring temporally extended control were also challenging, as highlighted by the performance on the AntMaze domain. No algorithm was able to achieve a good absolute error value on such tasks, and importance sampling was the only method able to achieve a correlation consistently above zero, suggesting that these more complex tasks are a particularly important area for future methods to focus on. + +# 6 RELATED WORK + +Off-policy evaluation (OPE) has been studied extensively across a range of different domains, from healthcare (Thapa et al., 2005; Raghu et al., 2018; Nie et al., 2019), to recommender systems (Li et al., 2010; Dudík et al., 2014; Theocharous et al., 2015), and robotics (Kalashnikov et al., 2018). While a full survey of OPE methods is outside the scope of this article, broadly speaking we can categories OPE methods into groups based the use of importance sampling (Precup, 2000), value functions (Sutton et al., 2009; Migliavacca et al., 2010; Sutton et al., 2016; Yang et al., 2020), and learned transition models (Paduraru, 2007), though a number of methods combine two or more of these components (Jiang & Li, 2015; Thomas & Brunskill, 2016; Munos et al., 2016). A significant body of work in OPE is also concerned with providing statistical guarantees (Thomas et al., 2015). Our focus instead is on empirical evaluation – while theoretical analysis is likely to be a critical part of future OPE research, combining such analysis with empirical demonstration on broadly accepted and standardized benchmarks is likely to facilitate progress toward practically useful algorithms. + +Current evaluation of OPE methods is based around several metrics, including error in predicting the true return of the evaluated policy (Voloshin et al., 2019), correlation between the evaluation output and actual returns (Irpan et al., 2019), and ranking and model selection metrics (Doroudi et al., 2017). As there is no single accepted metric used by the entire community, we provide a set of candidate metrics along with our benchmark, with a detailed justification in Section 5. Our work is closely related to (Paine et al., 2020) which studies OPE in a similar setting, however in our work we present a benchmark for the community and compare a range of OPE methods. Outside of OPE, standardized benchmark suites have led to considerable standardization and progress in RL (Stone & Sutton, 2001; Dutech et al., 2005; Riedmiller et al., 2007). The Arcade Learning Environment (ALE) (Bellemare et al., 2013) and OpenAI Gym (Brockman et al., 2016) have been widely used to compare online RL algorithms to good effect. More recently, Gulcehre et al. (2020); Fu et al. (2020) proposed benchmark tasks for offline RL. Our benchmark is based on the tasks and environments described in these two benchmarks, which we augment with a set of standardized policies for evaluation, results for a number of existing OPE methods, and standardized evaluation metrics and protocols. Voloshin et al. (2019) have recently proposed benchmarking for OPE methods on a variety of tasks ranging from tabular problems to image-based tasks in Atari. Our work differs in several key aspects. Voloshin et al. (2019) is composed entirely of discrete action tasks, whereas out benchmark focuses on continuous action tasks. Voloshin et al. (2019) assumes full support for the evaluation policy under the behavior policy data, whereas we designed our datasets and policies to ensure that different cases of dataset and policy distributions could be studied. Finally, all evaluations in Voloshin et al. (2019) are performed using the MSE metric, and they do not provide standardized datasets. In contrast, we provide a variety of policies for each problem which enables one to evaluate metrics such as ranking for policy selection, and a wide range of standardized datasets for reproducibility. + +# 7 CONCLUSION + +We have presented the Deep Off-Policy Evaluation (DOPE) benchmark, which aims to provide a platform for studying policy evaluation and selection across a wide range of challenging tasks and datasets. In contrast to prior benchmarks, DOPE provides multiple datasets and policies, allowing researchers to study how data distributions affect performance and to evaluate a wide variety of metrics, including those that are relevant for offline policy selection. In comparing existing OPE methods, we find that no existing algorithms consistently perform well across all of the tasks, which further reinforces the importance of standardized and challenging OPE benchmarks. Moreover, algorithms that perform poorly under one metric, such as absolute error, may perform better on other metrics, such as correlation, which provides insight into what algorithms to use depending on the use case (e.g., policy evaluation vs. policy selection). + +We believe that OPE is an exciting area for future research, as it allows RL agents to learn from large and abundant datasets in domains where online RL methods are otherwise infeasible. We hope that our benchmark will enable further progress in this field, though important evaluation challenges remain. As the key benefit of OPE is the ability to utilize real-world datasets, a promising direction for future evaluation efforts is to devise effective ways to use such data, where a key challenge is to develop evaluation protocols that are both reproducible and accessible. This could help pave the way towards developing intelligent decision making agents that can leverage vast banks of logged information to solve important real-world problems. + +# REFERENCES + +CharuC Aggarwal et al. Recommender systems, volume 1.Springer,2016. +Gabriel Barth-Maron, Matthew W. Hoffman, David Budden, Will Dabney, Dan Horgan, Dhruva TB, Alistair Muldal, Nicolas Heess, and Timothy Lillicrap. Distributional policy gradients. In International Conference on Learning Representations, 2018. +Marc G Bellemare, Yavar Naddaf, Joel Veness, and Michael Bowling. The arcade learning environment: An evaluation platform for general agents. Journal of Artificial Intelligence Research, 47: 253-279, 2013. +Léon Bottou, Jonas Peters, Joaquin Quinonero-Candela, Denis X Charles, D Max Chickering, Elon Portugaly, Dipankar Ray, Patrice Simard, and Ed Snelson. Counterfactual reasoning and learning systems: The example of computational advertising. The Journal of Machine Learning Research, 14(1):3207-3260, 2013. +Greg Brockman, Vicki Cheung, Ludwig Pettersson, Jonas Schneider, John Schulman, Jie Tang, and Wojciech Zaremba. Openai gym. arXiv preprint arXiv:1606.01540, 2016. +Kurtland Chua, Roberto Calandra, Rowan McAllister, and Sergey Levine. Deep reinforcement learning in a handful of trials using probabilistic dynamics models. In Advances in Neural Information Processing Systems, pp. 4754-4765, 2018. +Shayan Doroudi, Philip S Thomas, and Emma Brunskill. Importance sampling for fair policy selection. *Grantee Submission*, 2017. +Miroslav Dudík, Dumitru Erhan, John Langford, Lihong Li, et al. Doubly robust policy evaluation and optimization. Statistical Science, 29(4):485-511, 2014. +Alain Dutech, Timothy Edmunds, Jelle Kok, Michail Lagoudakis, Michael Littman, Martin Ried-miller, Bryan Russell, Bruno Scherrer, Richard Sutton, Stephan Timmer, et al. Reinforcement learning benchmarks and bake-offs ii. Advances in Neural Information Processing Systems (NIPS), 17:6, 2005. +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. +Scott Fujimoto, Herke Hoof, and David Meger. Addressing function approximation error in actor-critic methods. In International Conference on Machine Learning, pp. 1587-1596, 2018. +Alexandre Gilotte, Clément Calauzènes, Thomas Nedelec, Alexandre Abraham, and Simon Dollé. Offline a/b testing for recommender systems. In Proceedings of the Eleventh ACM International Conference on Web Search and Data Mining, pp. 198-206, 2018. +Shixiang Gu, Ethan Holly, Timothy Lillicrap, and Sergey Levine. Deep reinforcement learning for robotic manipulation with asynchronous off-policy updates. In 2017 IEEE international conference on robotics and automation (ICRA), pp. 3389-3396. IEEE, 2017. +Caglar Gulcehre, Ziyu Wang, Alexander Novikov, Tom Le Paine, Sergio Gomez Colmenarejo, Konrad Zolna, Rishabh Agarwal, Josh Merel, Daniel Mankowitz, Cosmin Paduraru, et al. R1 unplugged: Benchmarks for offline reinforcement learning. arXiv preprint arXiv:2006.13888, 2020. +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. +Josiah Hanna, Scott Niekum, and Peter Stone. Importance sampling policy evaluation with an estimated behavior policy. In International Conference on Machine Learning, pp. 2605-2613. PMLR, 2019. +Milos Hauskrecht and Hamish Fraser. Planning treatment of ischemic heart disease with partially observable markov decision processes. Artificial Intelligence in Medicine, 18(3):221-244, 2000. + +Matt Hoffman, Bobak Shahrioni, John Aslanides, Gabriel Barth-Maron, Feryal Behbahani, Tamara Norman, Abbas Abdolmaleki, Albin Cassirer, Fan Yang, Kate Baumli, et al. Acme: A research framework for distributed reinforcement learning. arXiv preprint arXiv:2006.00979, 2020. +Alexander Irpan, Kanishka Rao, Konstantinos Bousmalis, Chris Harris, Julian Ibarz, and Sergey Levine. Off-policy evaluation via off-policy classification. In Advances in Neural Information Processing Systems, pp. 5437-5448, 2019. +Michael Janner, Justin Fu, Marvin Zhang, and Sergey Levine. When to trust your model: Model-based policy optimization. In Advances in Neural Information Processing Systems, pp. 12519-12530, 2019. +Nan Jiang and Lihong Li. Doubly robust off-policy value evaluation for reinforcement learning. arXiv preprint arXiv:1511.03722, 2015. +Dmitry Kalashnikov, Alex Irpan, Peter Pastor, Julian Ibarz, Alexander Herzog, Eric Jang, Deirdre Quillen, Ethan Holly, Mrinal Kalakrishnan, Vincent Vanhoucke, et al. Qt-opt: Scalable deep reinforcement learning for vision-based robotic manipulation. arXiv preprint arXiv:1806.10293, 2018. +Alex Kendall, Jeffrey Hawke, David Janz, Przemyslaw Mazur, Daniele Reda, John-Mark Allen, Vinh-Dieu Lam, Alex Bewley, and Amar Shah. Learning to drive in a day. In 2019 International Conference on Robotics and Automation (ICRA), pp. 8248-8254. IEEE, 2019. +Jens Kober, J Andrew Bagnell, and Jan Peters. Reinforcement learning in robotics: A survey. The International Journal of Robotics Research, 32(11):1238-1274, 2013. +Ilya Kostrikov and Ofir Nachum. Statistical bootstrapping for uncertainty estimation in off-policy evaluation, 2020. +Hoang M Le, Cameron Voloshin, and Yisong Yue. Batch policy learning under constraints. arXiv preprint arXiv:1903.08738, 2019. +Lihong Li, Wei Chu, John Langford, and Robert E Schapire. A contextual-bandit approach to personalized news article recommendation. In Proceedings of the 19th international conference on World wide web, pp. 661-670, 2010. +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. +Travis Mandel, Yun-En Liu, Sergey Levine, Emma Brunskill, and Zoran Popovic. Offline policy evaluation across representations with applications to educational games. In AAMAS, pp. 1077-1084, 2014. +Martino Migliavacca, Alessio Pecorino, Matteo Pirotta, Marcello Restelli, and Andrea Bonarini. Fitted policy search: Direct policy search using a batch reinforcement learning approach. In 3rd International Workshop on Evolutionary and Reinforcement Learning for Autonomous Robot Systems (ERLARS 2010), pp. 35. CiteSeer, 2010. +Volodymyr Mnih, Koray Kavukcuoglu, David Silver, Alex Graves, Ioannis Antonoglou, Daan Wierstra, and Martin Riedmiller. Playing atari with deep reinforcement learning. In NIPS Deep Learning Workshop. 2013. +Rémi Munos, Tom Stepleton, Anna Harutyunyan, and Marc G. Bellemare. Safe and efficient off-policy reinforcement learning. arXiv preprint arXiv:1606.02647, 2016. +Xinkun Nie, Emma Brunskill, and Stefan Wager. Learning when-to-treat policies. arXiv preprint arXiv:1905.09751, 2019. +Cosmin Paduraru. Planning with approximate and learned models of markov decision processes. 2007. + +Tom Le Paine, Cosmin Paduraru, Andrea Michi, Caglar Gulcehre, Konrad Zolna, Alexander Novikov, Ziyu Wang, and Nando de Freitas. Hyperparameter selection for offline reinforcement learning. arXiv preprint arXiv:2007.09055, 2020. +Doina Precup. Eligibility traces for off-policy policy evaluation. Computer Science Department Faculty Publication Series, pp. 80, 2000. +Aniruddh Raghu, Omer Gottesman, Yao Liu, Matthieu Komorowski, Aldo Faisal, Finale Doshi-Velez, and Emma Brunskill. Behaviour policy estimation in off-policy policy evaluation: Calibration matters. arXiv preprint arXiv:1807.01066, 2018. +Aravind Rajeswaran, Vikash Kumar, Abhishek Gupta, Giulia Vezzani, John Schulman, Emanuel Todorov, and Sergey Levine. Learning complex dexterous manipulation with deep reinforcement learning and demonstrations. arXiv preprint arXiv:1709.10087, 2017. +Martin Riedmiller, Jan Peters, and Stefan Schaal. Evaluation of policy gradient methods and variants on the cart-pole benchmark. In 2007 IEEE International Symposium on Approximate Dynamic Programming and Reinforcement Learning, pp. 254-261. IEEE, 2007. +John Schulman, Sergey Levine, Pieter Abbeel, Michael Jordan, and Philipp Moritz. Trust region policy optimization. In International conference on machine learning, 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. +Noah Y Siegel, Jost Tobias Springenberg, Felix Berkenkamp, Abbas Abdelmaleki, Michael Neunert, Thomas Lampe, Roland Hafner, and Martin Riedmiller. Keep doing what worked: Behavioral modelling priors for offline reinforcement learning. In International Conference on Learning Representations, 2020. +Peter Stone and Richard S Sutton. Scaling reinforcement learning toward robocop soccer. In *Icml*, volume 1, pp. 537-544. CiteSeer, 2001. +Richard S Sutton, Hamid Reza Maei, Doina Precup, Shalabh Bhatnagar, David Silver, Csaba Szepesvári, and Eric Wiewiora. Fast gradient-descent methods for temporal-difference learning with linear function approximation. In Proceedings of the 26th Annual International Conference on Machine Learning, pp. 993-1000, 2009. +Richard S Sutton, A Rupam Mahmood, and Martha White. An emphatic approach to the problem of off-policy temporal-difference learning. The Journal of Machine Learning Research, 17(1): 2603-2631, 2016. +Adith Swaminathan and Thorsten Joachims. Counterfactual risk minimization: Learning from logged bandit feedback. In International Conference on Machine Learning, pp. 814-823, 2015. +Adith Swaminathan, Akshay Krishnamurthy, Alekh Agarwal, Miro Dudik, John Langford, Damien Jose, and Imed Zitouni. Off-policy evaluation for slate recommendation. In Advances in Neural Information Processing Systems, pp. 3632-3642, 2017. +Gerald Tesauro. Temporal difference learning and td-gammon. Communications of the ACM, 38(3): 58-68, 1995. +Devinder Thapa, In-Sung Jung, and Gi-Nam Wang. Agent based decision support system using reinforcement learning under emergency circumstances. In International Conference on Natural Computation, pp. 888-892. Springer, 2005. +Georgios Theocharous, Philip S Thomas, and Mohammad Ghavamzadeh. Personalized ad recommendation systems for life-time value optimization with guarantees. In Twenty-Fourth International Joint Conference on Artificial Intelligence, 2015. +Philip Thomas and Emma Brunskill. Data-efficient off-policy policy evaluation for reinforcement learning. In International Conference on Machine Learning, pp. 2139-2148, 2016. + +Philip S Thomas, Georgios Theochondrous, and Mohammad Ghavamzadeh. High-confidence off-policy evaluation. In Twenty-Ninth AAAI Conference on Artificial Intelligence, 2015. +Emanuel Todorov, Tom Erez, and Yuval Tassa. Mujoco: A physics engine for model-based control. In 2012 IEEE/RSJ International Conference on Intelligent Robots and Systems, pp. 5026-5033. IEEE, 2012. +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. +Cameron Voloshin, Hoang M Le, Nan Jiang, and Yisong Yue. Empirical study of off-policy policy evaluation for reinforcement learning. arXiv preprint arXiv:1911.06854, 2019. +Yu-Xiang Wang, Alekh Agarwal, and Miroslav Dudik. Optimal and adaptive off-policy evaluation in contextual bandits. In International Conference on Machine Learning, pp. 3589-3597. PMLR, 2017. +Ziyu Wang, Alexander Novikov, Konrad Zolna, Jost Tobias Springenberg, Scott Reed, Bobak Shahriari, Noah Siegel, Josh Merel, Caglar Gulcehre, Nicolas Heess, and Nando de Freitas. Critic regularized regression. arXiv preprint arXiv:2006.15134, 2020. +Junfeng Wen, Bo Dai, Lihong Li, and Dale Schuurmans. Batch stationary distribution estimation. arXiv preprint arXiv:2003.00722, 2020. +Yuan Xie, Boyi Liu, Qiang Liu, Zhaoran Wang, Yuan Zhou, and Jian Peng. Off-policy evaluation and learning from logged bandit feedback: Error reduction via surrogate policy. arXiv preprint arXiv:1808.00232, 2018. +Mengjiao Yang, Ofir Nachum, Bo Dai, Lihong Li, and Dale Schuurmans. Off-policy evaluation via the regularized lagrangian. arXiv preprint arXiv:2007.03438, 2020. +Michael R Zhang, Thomas Paine, Ofir Nachum, Cosmin Paduraru, George Tucker, ziyu wang, and Mohammad Norouzi. Autoregressive dynamics models for offline policy evaluation and optimization. In International Conference on Learning Representations, 2021. URL https://openreview.net/forum?id=kmqjgSNXby. + +# A APPENDIX + +# A.1 METRICS + +The metrics we use in our paper are defined as follows: + +Absolute Error We evaluate policies using absolute error in order to be robust to outliers. The absolute error is defined as the difference between the value and estimated value of a policy: + +$$ +\operatorname {A b s E r r} = \left| V ^ {\pi} - \hat {V} ^ {\pi} \right| \tag {2} +$$ + +Where $V^{\pi}$ is the true value of the policy, and $\hat{V}^{\pi}$ is the estimated value of the policy. + +Regret@k Regret@k is the difference between the value of the best policy in the entire set, and the value of the best policy in the top-k set (where the top-k set is chosen by estimated values). It can be defined as: + +$$ +\operatorname {R e g r e t} @ k = \max _ {i \in 1: N} V _ {i} ^ {\pi} - \max _ {j \in \operatorname {t o p k} (1: N)} V _ {j} ^ {\pi} \tag {3} +$$ + +Where $\mathrm{topk}(1:N)$ denotes the indices of the top K policies as measured by estimated values $\hat{V}^{\pi}$ . + +Rank correlation Rank correlation (also Spearman's $\rho$ ) measures the correlation between the ordinal rankings of the value estimates and the true values. It can be written as: + +$$ +\operatorname {R a n k C o r r} = \frac {\operatorname {C o v} \left(V _ {1 : N} ^ {\pi} , \hat {V} _ {1 : N} ^ {\pi}\right)}{\sigma \left(V _ {1 : N} ^ {\pi}\right) \sigma \left(\hat {V} _ {1 : N} ^ {\pi}\right)} \tag {4} +$$ + +# A.2 DETAILED RESULTS + +Detailed results figures and tables are presented here. We show results by task in both tabular and chart form, as well as scatter plots which compare the estimated returns against the ground truth returns for every policy. + +# A.2.1 CHART RESULTS + +First we show the normalized results for each algorithm and task. + +![](images/b0eac99898168dbd3a539ffb63a5f16b69ae2be493ef34311bfd4e31eb937297.jpg) +Figure A.1: Absolute error for each baseline algorithm for each RL Unplugged task considered. + +![](images/cf00d90ac807a7501e6595c390f6907a8388562f932e65f5af209fe4e6c5b0bf.jpg) +Figure A.2: Rank correlation for each baseline algorithm for each RL Unplugged task considered. + +![](images/f2ae889f8663e0b6a5d6d7b066ff80c4b699cbde0d69bc5819464157dc990320.jpg) +Figure A.3: Regret@1 for each baseline algorithm for each RL Unplugged task considered. + +![](images/38630fe55b5ea656378dc32a75f8085c781a02e6719dff366fd022ee470adf15.jpg) +Figure A.4: Absolute error for each baseline algorithm for each D4RL task domain considered. + +![](images/5b3dfb94091270d64bcca0c0cf8b29939835f225e2d87035565d487664e4cad7.jpg) +Figure A.5: Rank correlation for each baseline algorithm for each D4RL task domain considered. + +![](images/038611844c687a4593ffbbe7920420665a87be89fcb5f263c532031ab813b385.jpg) +Figure A.6: Regret@1 for each baseline algorithm for each D4RL task domain considered. + +![](images/141263d6e8f7bad6acd585fbf6cc9b842d46f96d6ceeeff17192d5df19b482b8.jpg) +Figure A.7: Online evaluation of policy checkpoints for 4 Offline RL algorithms with 3 random seeds. We observe a large degree of variability between the behavior of algorithms on different tasks. + +![](images/8d7b4a8b4a1506de5281f917a4aab0749003f04776e917989cba6aac74a37ddd.jpg) + +![](images/77831a84c7112ce11567c6b4f6d582812cedcfd529ae0b843de48d7d046a4e1b.jpg) + +![](images/6cc812bc178394be8f7345c4b61da3c96be11ee8730a8f1df7f072aa19f5799d.jpg) + +![](images/e85f7c415c3824166e97c4cd6b25ebef87eddee905cdc385b3844b591273058f.jpg) + +# A.2.2 TABULAR RESULTS + +Next, we present the results for each task and algorithm in tabular form, with means and standard deviations reported across 3 seeds. + +
Cartpole swingupCheetah runFinger turn hardFish swimHumanoid run
Absolute Error btw. OPE and ground truthVariational power method37.53 ±3.5061.89 ±4.2546.22 ±3.9331.27 ±0.9935.29 ±3.03
Importance Sampling68.75 ±2.3944.29 ±1.9190.10 ±4.6834.82 ±1.9327.89 ±1.98
Best DICE22.73 ±1.6523.35 ±1.3233.52 ±3.4859.48 ±2.4731.42 ±2.04
Model based - FF6.80 ±0.8513.64 ±0.5935.99 ±3.004.75 ±0.2330.12 ±2.40
FQE (L2)19.02 ±1.3448.26 ±1.7827.91 ±1.1819.82 ±1.5756.28 ±3.52
Doubly Robust (IS, FQE)24.38 ±2.5140.27 ±2.0525.26 ±2.4820.28 ±1.9053.64 ±3.68
FQE (distributional)12.63 ±1.2136.50 ±1.6210.23 ±0.937.76 ±0.9532.36 ±2.27
Model based - AR5.32 ±0.544.64 ±0.4622.93 ±1.724.31 ±0.2220.95 ±1.61
Walker standWalker walkManipulator insert ballManipulator insert pegMedian ↓
Absolute Error btw. OPE and ground truthVariational power method96.76 ±3.5987.24 ±4.2579.25 ±6.1921.95 ±1.1746.22
Importance Sampling66.50 ±1.9067.24 ±2.7029.93 ±1.1012.78 ±0.6644.29
Best DICE27.58 ±3.0147.28 ±3.13103.45 ±5.2122.75 ±3.0031.42
Model based - FF23.34 ±2.4152.23 ±2.3434.30 ±2.55121.12 ±1.5830.12
FQE (L2)6.51 ±0.7118.34 ±0.9536.32 ±1.0731.12 ±2.3727.91
Doubly Robust (IS, FQE)26.82 ±2.6624.63 ±1.6913.33 ±1.1622.28 ±2.3424.63
FQE (distributional)21.49 ±1.4127.57 ±1.549.75 ±1.1012.66 ±1.3912.66
Model based - AR19.12 ±1.235.14 ±0.4917.13 ±1.349.71 ±0.709.71
+ +Table A.1: Average absolute error between OPE metrics and ground truth values at a discount factor of 0.995 In each column, absolute error values that are not significantly different from the best $(p > 0.05)$ are bold faced. Methods are ordered by median. + +
Cartpole swingupCheetah runFinger turn hardFish swimHumanoid run
Rank Correlation btw. OPE and ground truthImportance Sampling-0.23 ±0.11-0.01 ±0.12-0.45 ±0.08-0.17 ±0.110.91 ±0.02
Best DICE-0.16 ±0.110.07 ±0.11-0.22 ±0.110.44 ±0.09-0.10 ±0.10
Variational power method0.01 ±0.110.01 ±0.12-0.25 ±0.110.56 ±0.080.36 ±0.09
Doubly Robust (IS, FQE)0.55 ±0.090.56 ±0.080.67 ±0.050.11 ±0.12-0.03 ±0.12
Model based - FF0.83 ±0.050.64 ±0.080.08 ±0.110.95 ±0.020.35 ±0.10
FQE (distributional)0.69 ±0.070.67 ±0.060.94 ±0.010.59 ±0.100.74 ±0.06
FQE (L2)0.70 ±0.070.56 ±0.080.83 ±0.040.10 ±0.12-0.02 ±0.12
Model based - AR0.91 ±0.020.74 ±0.070.57 ±0.090.96 ±0.010.90 ±0.02
Walker standWalker walkManipulator insert ballManipulator insert pegMedian ↑
Rank Correlation btw. OPE and ground truthImportance Sampling0.59 ±0.080.38 ±0.10-0.72 ±0.05-0.25 ±0.08-0.17
Best DICE-0.11 ±0.12-0.58 ±0.080.19 ±0.11-0.35 ±0.10-0.11
Variational power method-0.35 ±0.10-0.10 ±0.110.61 ±0.080.41 ±0.090.01
Doubly Robust (IS, FQE)0.88 ±0.030.85 ±0.040.42 ±0.10-0.47 ±0.090.55
Model based - FF0.82 ±0.040.80 ±0.050.06 ±0.10-0.56 ±0.080.64
FQE (distributional)0.87 ±0.020.89 ±0.030.63 ±0.08-0.23 ±0.100.69
FQE (L2)0.96 ±0.010.94 ±0.020.70 ±0.07-0.48 ±0.080.70
Model Based - AR0.96 ±0.010.98 ±0.00-0.33 ±0.090.47 ±0.090.90
+ +Table A.2: Spearman's rank correlation $(\rho)$ coefficient (bootstrap mean $\pm$ standard deviation) between different OPE metrics and ground truth values at a discount factor of 0.995. In each column, rank correlation coefficients that are not significantly different from the best $(p > 0.05)$ are bold faced. Methods are ordered by median. Also see Table A.3 and Table A.1 for Normalized Regret@5 and Average Absolute Error results. + +
Cartpole swingupCheetah runFinger turn hardFish swimHumanoid run
Regret@5 for OPE vs. ground truthImportance Sampling0.73 ±0.160.40 ±0.210.64 ±0.050.12 ±0.050.31 ±0.09
Best DICE0.68 ±0.410.27 ±0.050.44 ±0.040.35 ±0.240.84 ±0.22
Variational power method0.50 ±0.130.37 ±0.040.45 ±0.130.02 ±0.020.56 ±0.08
Doubly Robust (IS, FQE)0.28 ±0.050.09 ±0.050.56 ±0.120.61 ±0.120.99 ±0.00
FQE (L2)0.06 ±0.040.17 ±0.050.30 ±0.110.50 ±0.030.99 ±0.00
Model based - FF0.02 ±0.020.24 ±0.120.43 ±0.040.00 ±0.000.44 ±0.02
FQE (distributional)0.03 ±0.090.11 ±0.090.10 ±0.120.49 ±0.060.24 ±0.15
Model based - AR0.00 ±0.020.01 ±0.020.63 ±0.110.03 ±0.020.32 ±0.06
Walker standWalker walkManipulator insert ballManipulator insert pegMedian ↓
Regret@5 for OPE vs. ground truthImportance Sampling0.54 ±0.110.54 ±0.230.83 ±0.050.22 ±0.030.54
Best DICE0.24 ±0.070.55 ±0.060.44 ±0.070.75 ±0.040.44
Variational power method0.41 ±0.020.39 ±0.020.52 ±0.200.32 ±0.020.41
Doubly Robust (IS, FQE)0.02 ±0.010.05 ±0.070.30 ±0.100.73 ±0.010.30
FQE (L2)0.04 ±0.020.00 ±0.020.37 ±0.070.74 ±0.010.30
Model based - FF0.18 ±0.100.03 ±0.050.83 ±0.060.74 ±0.010.24
FQE (distributional)0.03 ±0.030.01 ±0.020.50 ±0.300.73 ±0.010.11
Model based - AR0.04 ±0.020.04 ±0.020.85 ±0.020.30 ±0.040.04
+ +Table A.3: Normalized Regret@5 (bootstrap mean ± standard deviation) for OPE methods vs. ground truth values at a discount factor of 0.995. In each column, normalized regret values that are not significantly different from the best $(p > 0.05)$ are bold faced. Methods are ordered by median. + +
Halfcheetah expertHalfcheetah mediumHalfcheetah medium-expertHalfcheetah medium-replayHalfcheetah random
Abs. ErrorIS1404±1521217±1231400±1461409±1541405±155
VPM945±1641374±1531427±1111384±1481411±154
Best DICE944±1611382±1301078±1321440±1581446±156
Doubly Robust1025±951222±1341015±1031001±129949±126
FQE (L2)1031±951211±1301014±1011003±132938±125
Antmaze large-diverseAntmaze large-playAntmaze medium-diverseAntmaze medium-playAntmaze umaze
Abs. ErrorIS0.62±0.010.85±0.000.55±0.010.81±0.000.62±0.04
VPM0.02±0.020.26±0.240.07±0.050.11±0.060.12±0.03
Best DICE5.55±0.3619.62±1.282.42±1.5619.47±2.1514.97±1.93
Doubly Robust0.99±0.011.59±0.010.61±0.031.47±0.010.87±0.04
FQE (L2)0.53±0.010.78±0.000.29±0.010.71±0.010.39±0.03
Antmaze umaze-diverseDoor clonedDoor expertDoor humanHammer cloned
Abs. ErrorIS0.14±0.02891±188648±122870±1737403±1126
VPM0.12±0.031040±188879±182862±1637459±1114
Best DICE0.17±0.04697±79856±1341108±1994169±839
Doubly Robust0.11±0.02424±731353±218379±656101±679
FQE (L2)0.11±0.03438±811343±84389±605415±558
Hammer expertHammer humanMaze2d largeMaze2d mediumMaze2d umaze
Abs. ErrorIS3052±6087352±111845.61±10.4361.29±7.7850.20±9.16
VPM7312±11177105±110744.10±10.6960.30±8.3762.81±8.40
Best DICE3963±7585677±93642.46±9.6658.97±9.5721.95±4.69
Doubly Robust3485±5905768±75122.94±6.8223.64±4.9676.93±4.42
FQE (L2)2950±7286000±61224.31±6.5635.11±6.3379.67±4.93
Pen clonedPen expertPen humanRelocate clonedRelocate expert
Abs. ErrorIS1707±1284547±2223926±128632±2152731±147
VPM2324±1292325±1361569±215586±135620±214
Best DICE1454±2192963±2794193±2441347±4851095±221
Doubly Robust1323±982013±5642846±200412±1241193±350
FQE (L2)1232±1051057±2812872±170439±1251351±393
Relocate humanAnt expertAnt mediumAnt medium-expertAnt medium-replay
Abs. ErrorIS638±217605±104594±104604±102603±101
VPM806±166607±108570±109604±106612±105
Best DICE4526±474558±108495±90471±100583±110
Doubly Robust606±116584±114345±66326±66421±72
FQE (L2)593±113583±122345±64319±67410±79
Ant randomHopper expertHopper mediumHopper randomWalker2d expert
Abs. ErrorIS606±103106±29405±48412±45405±62
VPM570±99442±43433±44438±44367±68
Best DICE530±92259±54215±41122±16437±60
Doubly Robust404±106426±99307±85289±50519±179
FQE (L2)398±111282±76283±73261±42453±142
Walker2d mediumWalker2d medium-expertWalker2d medium-replayWalker2d randomMedian
Abs. ErrorIS428±60436±62427±60430±61603.82
VPM426±60425±61424±64440±58585.53
Best DICE273±31322±60374±51419±57530.43
Doubly Robust368±74217±46296±54347±74411.99
FQE (L2)350±79233±42313±73354±73398.37
Halfcheetah expertHalfcheetah medium-expertHalfcheetah medium-replayHalfcheetah randomDoor cloned
Rank Corr.Best DICE-0.44 ±0.30-0.08 ±0.35-0.15 ±0.41-0.70 ±0.220.18 ±0.31
VPM0.18 ±0.35-0.47 ±0.29-0.07 ±0.360.27 ±0.36-0.29 ±0.36
FQE (L2)0.78 ±0.150.62 ±0.270.26 ±0.37-0.11 ±0.410.55 ±0.27
IS0.01 ±0.35-0.06 ±0.370.59 ±0.26-0.24 ±0.360.66 ±0.22
Doubly Robust0.77 ±0.170.62 ±0.270.32 ±0.37-0.02 ±0.380.60 ±0.28
Door expertHammer clonedHammer expertMaze2d largeMaze2d medium
Rank Corr.Best DICE-0.06 ±0.320.35 ±0.38-0.42 ±0.310.56 ±0.21-0.64 ±0.23
VPM0.65 ±0.23-0.77 ±0.220.39 ±0.31-0.26 ±0.33-0.05 ±0.39
FQE (L2)0.89 ±0.09-0.15 ±0.330.29 ±0.340.30 ±0.360.16 ±0.38
IS0.76 ±0.170.58 ±0.270.64 ±0.240.63 ±0.190.44 ±0.25
Doubly Robust0.76 ±0.13-0.70 ±0.200.49 ±0.310.31 ±0.360.41 ±0.35
Pen expertRelocate expertAnt expertAnt mediumAnt medium-expert
Rank Corr.Best DICE-0.53 ±0.30-0.27 ±0.34-0.13 ±0.37-0.36 ±0.28-0.33 ±0.40
VPM0.08 ±0.330.39 ±0.31-0.42 ±0.38-0.20 ±0.31-0.28 ±0.28
FQE (L2)-0.01 ±0.33-0.57 ±0.28-0.13 ±0.320.65 ±0.250.37 ±0.35
IS-0.45 ±0.310.52 ±0.230.14 ±0.41-0.17 ±0.32-0.21 ±0.35
Doubly Robust0.52 ±0.28-0.40 ±0.24-0.28 ±0.320.66 ±0.260.35 ±0.35
Ant medium-replayAnt randomHopper expertHopper mediumHopper random
Rank Corr.Best DICE-0.24 ±0.39-0.21 ±0.35-0.08 ±0.320.19 ±0.33-0.13 ±0.39
VPM-0.26 ±0.290.24 ±0.310.21 ±0.320.13 ±0.37-0.46 ±0.20
FQE (L2)0.57 ±0.280.04 ±0.33-0.33 ±0.30-0.29 ±0.33-0.11 ±0.36
IS0.07 ±0.390.26 ±0.340.37 ±0.27-0.55 ±0.260.23 ±0.34
Doubly Robust0.45 ±0.320.01 ±0.33-0.41 ±0.27-0.31 ±0.34-0.19 ±0.36
Walker2d expertWalker2d mediumWalker2d medium-expertWalker2d medium-replayWalker2d random
Rank Corr.Best DICE-0.37 ±0.270.12 ±0.38-0.34 ±0.340.55 ±0.23-0.19 ±0.36
VPM0.17 ±0.320.44 ±0.210.49 ±0.37-0.52 ±0.25-0.42 ±0.34
FQE (L2)0.35 ±0.33-0.09 ±0.360.25 ±0.32-0.19 ±0.360.21 ±0.31
IS0.22 ±0.37-0.25 ±0.350.24 ±0.330.65 ±0.24-0.05 ±0.38
Doubly Robust0.26 ±0.340.02 ±0.370.19 ±0.33-0.37 ±0.390.16 ±0.29
Median
Rank Corr.Best DICE-0.19
VPM-0.05
FQE (L2)0.21
IS0.23
Doubly Robust0.26
Halfcheetah expertHalfcheetah mediumHalfcheetah medium-expertHalfcheetah medium-replayHalfcheetah random
Regret@1Best DICE0.32±0.400.82±0.290.38±0.370.30±0.070.81±0.30
VPM0.14±0.090.33±0.190.80±0.340.25±0.090.12±0.07
Doubly Robust0.11±0.080.37±0.150.14±0.070.33±0.180.31±0.10
FQE (L2)0.12±0.070.38±0.130.14±0.070.36±0.160.37±0.08
IS0.15±0.080.05±0.050.73±0.420.13±0.100.31±0.11
Antmaze large-diverseAntmaze large-playAntmaze medium-diverseAntmaze medium-playAntmaze umaze
Regret@1Best DICE0.54±0.340.96±0.130.04±0.110.09±0.100.69±0.39
VPM0.88±0.270.45±0.300.14±0.100.03±0.080.62±0.32
Doubly Robust0.83±0.300.93±0.210.05±0.070.17±0.310.42±0.36
FQE (L2)0.93±0.251.00±0.030.16±0.100.05±0.190.41±0.35
IS0.39±0.260.71±0.200.14±0.090.18±0.060.86±0.06
Antmaze umaze-diverseDoor clonedDoor expertDoor humanHammer cloned
Regret@1Best DICE0.42±0.280.65±0.450.37±0.270.10±0.270.67±0.48
VPM0.63±0.320.81±0.330.03±0.030.69±0.240.72±0.39
Doubly Robust0.79±0.140.11±0.080.05±0.070.05±0.090.78±0.38
FQE (L2)0.64±0.370.11±0.060.03±0.030.05±0.080.36±0.39
IS0.22±0.360.02±0.070.01±0.040.45±0.400.03±0.15
Hammer expertHammer humanMaze2d largeMaze2d mediumMaze2d umaze
Regret@1Best DICE0.24±0.340.04±0.080.15±0.080.44±0.050.03±0.07
VPM0.04±0.070.18±0.290.66±0.100.24±0.240.06±0.12
Doubly Robust0.09±0.090.46±0.230.21±0.160.27±0.140.03±0.07
FQE (L2)0.05±0.040.46±0.230.20±0.140.31±0.140.03±0.07
IS0.01±0.040.19±0.300.16±0.230.15±0.150.02±0.12
Pen clonedPen expertPen humanRelocate clonedRelocate expert
Regret@1Best DICE0.12±0.080.33±0.200.04±0.090.96±0.180.97±0.07
VPM0.36±0.180.25±0.130.28±0.120.11±0.290.76±0.23
Doubly Robust0.13±0.060.05±0.070.09±0.080.18±0.270.98±0.08
FQE (L2)0.12±0.070.11±0.140.07±0.050.29±0.421.00±0.06
IS0.14±0.090.31±0.100.17±0.150.63±0.410.18±0.14
Relocate humanAnt expertAnt mediumAnt medium-expertAnt medium-replay
Regret@1Best DICE0.97±0.110.62±0.150.43±0.100.60±0.160.64±0.13
VPM0.77±0.180.88±0.220.40±0.210.32±0.240.72±0.43
Doubly Robust0.17±0.150.43±0.220.12±0.180.37±0.130.05±0.09
FQE (L2)0.17±0.140.43±0.220.12±0.180.36±0.140.05±0.09
IS0.63±0.410.47±0.320.61±0.180.46±0.180.16±0.23
Ant randomHopper expertHopper mediumHopper randomWalker2d expert
Regret@1Best DICE0.50±0.290.20±0.080.18±0.190.30±0.150.35±0.36
VPM0.15±0.240.13±0.100.10±0.140.26±0.100.09±0.19
Doubly Robust0.28±0.150.34±0.350.32±0.320.41±0.170.06±0.07
FQE (L2)0.28±0.150.41±0.200.32±0.320.36±0.220.06±0.07
IS0.56±0.220.06±0.030.38±0.280.05±0.050.43±0.26
Walker2d mediumWalker2d medium-expertWalker2d medium-replayWalker2d randomMedian
Regret@1Best DICE0.27±0.430.78±0.270.18±0.120.39±0.330.38
VPM0.08±0.060.24±0.420.46±0.310.88±0.200.28
Doubly Robust0.25±0.090.30±0.120.68±0.230.15±0.200.25
FQE (L2)0.31±0.100.22±0.140.24±0.200.15±0.210.24
IS0.70±0.390.13±0.070.02±0.050.74±0.330.18
+ +# A.2.3 SCATTER PLOTS + +Finally, we present scatter plots plotting the true returns of each policy against the estimated returns. Each point on the plot represents one evaluated policy. + +![](images/2c3f3ffc86c1f0b82e18e2882e0ad942507be113915650b7e6357723775cbdb0.jpg) +Figure A.8: Scatter plots of estimate vs ground truth return for each baseline on each task in DOPE RL Unplugged. + +![](images/8083c58a7392d342ccbcd0366f5f19d5f5c9643e2ca81eb7622360a049eeeed8.jpg) +Figure A.9: Scatter plots of estimate vs ground truth return for each baseline on each task in DOPE D4RL (part 1). + +![](images/8638bae4ec1926d40f63d1b50dc41d03ccfb050b8c5891b9a1c428bc2bf92f77.jpg) +Figure A.10: Scatter plots of estimate vs ground truth return for each baseline on each task in DOPE D4RL (part 2). + +![](images/0b16d04a4002bec2f0ca9c3a5d173aa25b6b0ee0730836a816f6a0f0e9b83841.jpg) +Figure A.11: Scatter plots of estimate vs ground truth return for each baseline on each task in DOPE D4RL (part 3). + +![](images/25d0ad9556aabee0e2ddd6a270311579fa17364d3746a71274b0544009d3f6dd.jpg) +Figure A.12: Scatter plots of estimate vs ground truth return for each baseline on each task in DOPE D4RL (part 4). + +![](images/ddc225513e00b18044430d2d010d2b8ffba38e44a30144c6212481bd564d97f6.jpg) +Figure A.13: Scatter plots of estimate vs ground truth return for each baseline on each task in DOPE D4RL (part 5). + +![](images/5c4d7309160834b5b77af372cf18c68bd078c8e1bd0458e89d341c9974d46e0f.jpg) +Figure A.14: Scatter plots of estimate vs ground truth return for each baseline on each task in DOPE D4RL (part 6). \ No newline at end of file diff --git a/benchmarksfordeepoffpolicyevaluation/images.zip b/benchmarksfordeepoffpolicyevaluation/images.zip new file mode 100644 index 0000000000000000000000000000000000000000..d47f009628c7e5195463e4f31f5c96c469964a0e --- /dev/null +++ b/benchmarksfordeepoffpolicyevaluation/images.zip @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:394539ffc64528c652c1a847304256d40088a78b2ca1ebc2dd0ddd49003daa5d +size 2565211 diff --git a/benchmarksfordeepoffpolicyevaluation/layout.json b/benchmarksfordeepoffpolicyevaluation/layout.json new file mode 100644 index 0000000000000000000000000000000000000000..cf632d0ac22ef3364aaf2995df79583bfc90b7ae --- /dev/null +++ b/benchmarksfordeepoffpolicyevaluation/layout.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a97ef6d00c082b10ccaf97697cdef576a2f0e546ce53193dc0fe41fc130accac +size 522922 diff --git a/bertologymeetsbiologyinterpretingattentioninproteinlanguagemodels/6445afe9-2ae7-4a66-a021-d1a93c727204_content_list.json b/bertologymeetsbiologyinterpretingattentioninproteinlanguagemodels/6445afe9-2ae7-4a66-a021-d1a93c727204_content_list.json new file mode 100644 index 0000000000000000000000000000000000000000..45ca3ced317f17fd1c1462c7500b7f21f985d5f6 --- /dev/null +++ b/bertologymeetsbiologyinterpretingattentioninproteinlanguagemodels/6445afe9-2ae7-4a66-a021-d1a93c727204_content_list.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e0b05f3eb86e7b1880e7f2ffaade6b15a4f3d330572b6305839812fc9963ac3d +size 129653 diff --git a/bertologymeetsbiologyinterpretingattentioninproteinlanguagemodels/6445afe9-2ae7-4a66-a021-d1a93c727204_model.json b/bertologymeetsbiologyinterpretingattentioninproteinlanguagemodels/6445afe9-2ae7-4a66-a021-d1a93c727204_model.json new file mode 100644 index 0000000000000000000000000000000000000000..dd3e0ec5545e53d8030f95c5d5fd33860cbab5c1 --- /dev/null +++ b/bertologymeetsbiologyinterpretingattentioninproteinlanguagemodels/6445afe9-2ae7-4a66-a021-d1a93c727204_model.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f61361ce87e865cbaf23266b8f01f33fe713e40d0b59169dca79f9d0dd501f06 +size 166917 diff --git a/bertologymeetsbiologyinterpretingattentioninproteinlanguagemodels/6445afe9-2ae7-4a66-a021-d1a93c727204_origin.pdf b/bertologymeetsbiologyinterpretingattentioninproteinlanguagemodels/6445afe9-2ae7-4a66-a021-d1a93c727204_origin.pdf new file mode 100644 index 0000000000000000000000000000000000000000..aa17b0070a78e04b6883acb65bb16303bf821fa2 --- /dev/null +++ b/bertologymeetsbiologyinterpretingattentioninproteinlanguagemodels/6445afe9-2ae7-4a66-a021-d1a93c727204_origin.pdf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:03cbe8cd5b04fac15eb15df98444c3740bec3e0c075784593dad9417b7d7808f +size 2722947 diff --git a/bertologymeetsbiologyinterpretingattentioninproteinlanguagemodels/full.md b/bertologymeetsbiologyinterpretingattentioninproteinlanguagemodels/full.md new file mode 100644 index 0000000000000000000000000000000000000000..e984d924f4e9517ae6b2ea5c89aaa5e6bf639d88 --- /dev/null +++ b/bertologymeetsbiologyinterpretingattentioninproteinlanguagemodels/full.md @@ -0,0 +1,577 @@ +# BERTOLOGY MEETS BIOLOGY: INTERPRETING ATTENTION IN PROTEIN LANGUAGE MODELS + +Jesse Vig $^{1}$ Ali Madani $^{1}$ Lav R. Varshney $^{1,2}$ Caiming Xiong $^{1}$ + +Richard Socher1 Nazneen Fatema Rajani1 + +$^{1}$ Salesforce Research, $^{2}$ University of Illinois at Urbana-Champaign + +{jvig,amadani,cxiong,rsocher,nazneen.rajani}@salesforce.com varshney@illinois.edu + +# ABSTRACT + +Transformer architectures have proven to learn useful representations for protein classification and generation tasks. However, these representations present challenges in interpretability. In this work, we demonstrate a set of methods for analyzing protein Transformer models through the lens of attention. We show that attention: (1) captures the folding structure of proteins, connecting amino acids that are far apart in the underlying sequence, but spatially close in the three-dimensional structure, (2) targets binding sites, a key functional component of proteins, and (3) focuses on progressively more complex biophysical properties with increasing layer depth. We find this behavior to be consistent across three Transformer architectures (BERT, ALBERT, XLNet) and two distinct protein datasets. We also present a three-dimensional visualization of the interaction between attention and protein structure. Code for visualization and analysis is available at https://github.com/salesforce/provis. + +# 1 INTRODUCTION + +The study of proteins, the fundamental macromolecules governing biology and life itself, has led to remarkable advances in understanding human health and the development of disease therapies. The decreasing cost of sequencing technology has enabled vast databases of naturally occurring proteins (El-Gebali et al., 2019a), which are rich in information for developing powerful machine learning models of protein sequences. For example, sequence models leveraging principles of co-evolution, whether modeling pairwise or higher-order interactions, have enabled prediction of structure or function (Rollins et al., 2019). + +Proteins, as a sequence of amino acids, can be viewed precisely as a language and therefore modeled using neural architectures developed for natural language. In particular, the Transformer (Vaswani et al., 2017), which has revolutionized unsupervised learning for text, shows promise for similar impact on protein sequence modeling. However, the strong performance of the Transformer comes at the cost of interpretability, and this lack of transparency can hide underlying problems such as model bias and spurious correlations (Niven & Kao, 2019; Tan & Celis, 2019; Kurita et al., 2019). In response, much NLP research now focuses on interpreting the Transformer, e.g., the subspecialty of "BERTology" (Rogers et al., 2020), which specifically studies the BERT model (Devlin et al., 2019). + +In this work, we adapt and extend this line of interpretability research to protein sequences. We analyze Transformer protein models through the lens of attention, and present a set of interpretability methods that capture the unique functional and structural characteristics of proteins. We also compare the knowledge encoded in attention weights to that captured by hidden-state representations. Finally, we present a visualization of attention contextualized within three-dimensional protein structure. + +Our analysis reveals that attention captures high-level structural properties of proteins, connecting amino acids that are spatially close in three-dimensional structure, but apart in the underlying sequence (Figure 1a). We also find that attention targets binding sites, a key functional component of proteins (Figure 1b). Further, we show how attention is consistent with a classic measure of similarity between amino acids—the substitution matrix. Finally, we demonstrate that attention captures progressively higher-level representations of structure and function with increasing layer depth. + +![](images/e2d1337a75f4b8fad70782cab32783b9fe10ba2c8529ac0d8d9804c175a9748f.jpg) +(a) Attention in head 12-4, which targets amino acid pairs that are close in physical space (see inset subsequence 117D-157I) but lie apart in the sequence. Example is a de novo designed TIMbarrel (5BVL) with characteristic symmetry. + +![](images/4aa57183d35e8a874c8d1633b3249190dce4bf8d6e2072df7ba322985a957e4c.jpg) +(b) Attention in head 7-1, which targets binding sites, a key functional component of proteins. Example is HIV-1 protease (7HVP). The primary location receiving attention is 27G, a binding site for protease inhibitor small-molecule drugs. +Figure 1: Examples of how specialized attention heads in a Transformer recover protein structure and function, based solely on language model pre-training. Orange lines depict attention between amino acids (line width proportional to attention weight; values below 0.1 hidden). Heads were selected based on correlation with ground-truth annotations of contact maps and binding sites. Visualizations based on the NGL Viewer (Rose et al., 2018; Rose & Hildebrand, 2015; Nguyen et al., 2017). + +In contrast to NLP, which aims to automate a capability that humans already have—understanding natural language—protein modeling also seeks to shed light on biological processes that are not fully understood. Thus we also discuss how interpretability can aid scientific discovery. + +# 2 BACKGROUND: PROTEINS + +In this section we provide background on the biological concepts discussed in later sections. + +Amino acids. Just as language is composed of words from a shared lexicon, every protein sequence is formed from a vocabulary of amino acids, of which 20 are commonly observed. Amino acids may be denoted by their full name (e.g., Proline), a 3-letter abbreviation (Pro), or a single-letter code $(P)$ . + +Substitution matrix. While word synonyms are encoded in a thesaurus, proteins that are similar in structure or function are captured in a substitution matrix, which scores pairs of amino acids on how readily they may be substituted for one another while maintaining protein viability. One common substitution matrix is BLOSUM (Henikoff & Henikoff, 1992), which is derived from co-occurrence statistics of amino acids in aligned protein sequences. + +Protein structure. Though a protein may be abstracted as a sequence of amino acids, it represents a physical entity with a well-defined three-dimensional structure (Figure 1). Secondary structure describes the local segments of proteins; two commonly observed types are the alpha helix and beta sheet. Tertiary structure encompasses the large-scale formations that determine the overall shape and function of the protein. One way to characterize tertiary structure is by a contact map, which describes the pairs of amino acids that are in contact (within 8 angstroms of one another) in the folded protein structure but lie apart (by at least 6 positions) in the underlying sequence (Rao et al., 2019). + +Binding sites. Proteins may also be characterized by their functional properties. Binding sites are protein regions that bind with other molecules (proteins, natural ligands, and small-molecule drugs) to carry out a specific function. For example, the HIV-1 protease is an enzyme responsible for a critical process in replication of HIV (Brik & Wong, 2003). It has a binding site, shown in Figure 1b, that is a target for drug development to ensure inhibition. + +Post-translational modifications. After a protein is translated from RNA, it may undergo additional modifications, e.g. phosphorylation, which play a key role in protein structure and function. + +# 3 METHODOLOGY + +Model. We demonstrate our interpretability methods on five Transformer models that were pretrained through language modeling of amino acid sequences. We primarily focus on the BERT-Base model from TAPE (Rao et al., 2019), which was pretrained on Pfam, a dataset of 31M protein sequences (ElGebali et al., 2019b). We refer to this model as TapeBert. We also analyze 4 pre-trained Transformer models from ProtTrans (Elnaggar et al., 2020): ProtBert and ProtBert-BFD, which are 30-layer, 16-head BERT models; ProtAlbert, a 12-layer, 64-head ALBERT (Lan et al., 2020) model; and ProtXLNet, a 30-layer, 16-head XLNet (Yang et al., 2019) model. ProtBert-BFD was pretrained on BFD (Steinegger & Söding, 2018), a dataset of 2.1B protein sequences, while the other ProtTrans models were pretrained on UniRef100 (Suzek et al., 2014), which includes 216M protein sequences. A summary of these 5 models is presented in Appendix A.1. + +Here we present an overview of BERT, with additional details on all models in Appendix A.2. BERT inputs a sequence of amino acids $\boldsymbol{x} = (x_{1},\ldots ,x_{n})$ and applies a series of encoders. Each encoder layer $\ell$ outputs a sequence of continuous embeddings $(\mathbf{h}_1^{(\ell)},\dots,\mathbf{h}_n^{(\ell)})$ using a multi-headed attention mechanism. Each attention head in a layer produces a set of attention weights $\alpha$ for an input, where $\alpha_{i,j} > 0$ is the attention from token $i$ to token $j$ , such that $\sum_{j}\alpha_{i,j} = 1$ . Intuitively, attention weights define the influence of every token on the next layer's representation for the current token. We denote a particular head by $\langle \text{layer} \rangle$ - $\langle \text{head\_index} \rangle$ , e.g. head 3-7 for the 3rd layer's 7th head. + +Attention analysis. We analyze how attention aligns with various protein properties. For properties of token pairs, e.g. contact maps, we define an indicator function $f(i,j)$ that returns 1 if the property is present in token pair $(i,j)$ (e.g., if amino acids $i$ and $j$ are in contact), and 0 otherwise. We then compute the proportion of high-attention token pairs $(\alpha_{i,j} > \theta)$ where the property is present, aggregated over a dataset $X$ : + +$$ +p _ {\alpha} (f) = \sum_ {\mathbf {x} \in \mathbf {X}} \sum_ {i = 1} ^ {| \mathbf {x} |} \sum_ {j = 1} ^ {| \mathbf {x} |} f (i, j) \cdot \mathbb {1} _ {\alpha_ {i, j} > \theta} / \sum_ {\mathbf {x} \in \mathbf {X}} \sum_ {i = 1} ^ {| \mathbf {x} |} \sum_ {j = 1} ^ {| \mathbf {x} |} \mathbb {1} _ {\alpha_ {i, j} > \theta} \tag {1} +$$ + +where $\theta$ is a threshold to select for high-confidence attention weights. We also present an alternative, continuous version of this metric in Appendix B.1. + +For properties of individual tokens, e.g. binding sites, we define $f(i,j)$ to return 1 if the property is present in token $j$ (e.g. if $j$ is a binding site). In this case, $p_{\alpha}(f)$ equals the proportion of attention that is directed to the property (e.g. the proportion of attention focused on binding sites). + +When applying these metrics, we include two types of checks to ensure that the results are not due to chance. First, we test that the proportion of attention that aligns with particular properties is significantly higher than the background frequency of these properties, taking into account the Bonferroni correction for multiple hypotheses corresponding to multiple attention heads. Second, we compare the results to a null model, which is an instance of the model with randomly shuffled attention weights. We describe these methods in detail in Appendix B.2. + +Probing tasks. We also perform probing tasks on the model, which test the knowledge contained in model representations by using them as inputs to a classifier that predicts a property of interest (Veldhoen et al., 2016; Conneau et al., 2018; Adi et al., 2016). The performance of the probing classifier serves as a measure of the knowledge of the property that is encoded in the representation. We run both embedding probes, which assess the knowledge encoded in the output embeddings of each layer, and attention probes (Reif et al., 2019; Clark et al., 2019), which measure the knowledge contained in the attention weights for pairwise features. Details are provided in Appendix B.3. + +Datasets. For our analyses of amino acids and contact maps, we use a curated dataset from TAPE based on ProteinNet (AlQuraishi, 2019; Fox et al., 2013; Berman et al., 2000; Moult et al., 2018), which contains amino acid sequences annotated with spatial coordinates (used for the contact map analysis). For the analysis of secondary structure and binding sites we use the Secondary Structure dataset (Rao et al., 2019; Berman et al., 2000; Moult et al., 2018; Klausen et al., 2019) from TAPE. We employed a taxonomy of secondary structure with three categories: Helix, Strand, and Turn/Bend, with the last two belonging to the higher-level beta sheet category (Sec. 2). We used this taxonomy to study how the model understood structurally distinct regions of beta sheets. We obtained token-level binding site and protein modification labels from the Protein Data Bank (Berman et al., 2000). For analyzing attention, we used a random subset of 5000 sequences from the training split of the + +![](images/b2ace175a5abd83580ed3956c33d7cc33f0c37417d38e0a38f9e781faa636d8a.jpg) +(a) TapeBert + +![](images/7bb8bb8ef029d8823118f6194d3e24228cd43bf837d0e4aaf8f288b431ea87bc.jpg) +(b) ProtAlbert + +![](images/93c7fcbfe7c73cd3ba327f4766df57414a616c99f2d65dad1b85a70fc592ad47.jpg) +(c) ProtBert + +![](images/e81134a3d28c3eb0b6667e0d21689c2ce8d9c421612324ede69b788b32850104.jpg) +(d) ProtBert-BFD +Figure 2: Agreement between attention and contact maps across five pretrained Transformer models from TAPE (a) and ProtTrans (b-e). The heatmaps show the proportion of high-confidence attention weights $(\alpha_{i,j} > \theta)$ from each head that connects pairs of amino acids that are in contact with one another. In TapeBert (a), for example, we can see that $45\%$ of attention in head 12-4 (the 12th layer's 4th head) maps to contacts. The bar plots show the maximum value from each layer. Note that the vertical striping in ProtAlbert (b) is likely due to cross-layer parameter sharing (see Appendix A.3). + +![](images/99684706ec03041ff9ad79ac53b2b292856e6001a9486c69e8bcd0456f5e03a7.jpg) +(e) ProtXLNet + +respective datasets (note that none of the aforementioned annotations were used in model training). For the diagnostic classifier, we used the respective training splits for training and the validation splits for evaluation. See Appendix B.4 for additional details. + +Experimental details We exclude attention to the [SEP] delimiter token, as it has been shown to be a "no-op" attention token (Clark et al., 2019), as well as attention to the [CLS] token, which is not explicitly used in language modeling. We only include results for attention heads where at least 100 high-confidence attention arcs are available for analysis. We set the attention threshold $\theta$ to 0.3 to select for high-confidence attention while retaining sufficient data for analysis. We truncate all protein sequences to a length of 512 to reduce memory requirements. $^{1}$ + +We note that all of the above analyses are purely associative and do not attempt to establish a causal link between attention and model behavior (Vig et al., 2020; Grimsley et al., 2020), nor to explain model predictions (Jain & Wallace, 2019; Wiegrefe & Pinter, 2019). + +# 4 WHAT DOES ATTENTION UNDERSTAND ABOUT PROTEINS? + +# 4.1 PROTEIN STRUCTURE + +Here we explore the relationship between attention and tertiary structure, as characterized by contact maps (see Section 2). Secondary structure results are included in Appendix C.1. + +Attention aligns strongly with contact maps in the deepest layers. Figure 2 shows how attention aligns with contact maps across the heads of the five models evaluated², based on the metric defined in Equation 1. The most aligned heads are found in the deepest layers and focus up to $44.7\%$ (TapeBert), $55.7\%$ (ProtAlbert), $58.5\%$ (ProtBert), $63.2\%$ (ProtBert-BFD), and $44.5\%$ (ProtXLNet) of attention on contacts, whereas the background frequency of contacts among all amino acid pairs in the dataset is $1.3\%$ . Figure 1a shows an example of the induced attention from the top head in TapeBert. We note that the model with the single most aligned head—ProtBert-BFD—is the largest model (same size as ProteinBert) at 420M parameters (Appendix A.1) and it was also the only model pre-trained on the + +![](images/d5c9efcf9295fab1a62a2b75d2b6a834893d783b09bf38be0092ea489b0bc483.jpg) +(a) TapeBert + +![](images/2912e3aabebdc3d04b9b0f24effd19228353bb2cccff7891d64dffe203590716.jpg) + +![](images/20176fcf5505d8af309162af36850c71143b1c46d060f0899d8531597fb34a87.jpg) +(c) ProtBert + +![](images/cf8175d9ce28f3aaa214f72610521575665b8cf386135883c1000ffb941c7878.jpg) +(d) ProtBert-BFD + +![](images/6f9bcfc35dcc625759d250200a421d61acb5425d8f95c416a8b579926d800534.jpg) +(e) ProtXLNet +Figure 3: Proportion of attention focused on binding sites across five pretrained models. The heatmaps show the proportion of high-confidence attention $(\alpha_{i,j} > \theta)$ from each head that is directed to binding sites. In TapeBert (a), for example, we can see that $49\%$ of attention in head 11-6 (the 11th layer's 6th head) is directed to binding sites. The bar plots show the maximum value from each layer. + +largest dataset, BFD. It's possible that both factors helped the model learn more structurally-aligned attention patterns. Statistical significance tests and null models are reported in Appendix C.2. + +Considering the models were trained on language modeling tasks without any spatial information, the presence of these structurally-aware attention heads is intriguing. One possible reason for this emergent behavior is that contacts are more likely to biochemically interact with one another, creating statistical dependencies between the amino acids in contact. By focusing attention on the contacts of a masked position, the language models may acquire valuable context for token prediction. + +While there seems to be a strong correlation between the attention head output and classically-defined contacts, there are also differences. The models may have learned differing contextualized or nuanced formulations that describe amino acid interactions. These learned interactions could then be used for further discovery and investigation or repurposed for prediction tasks similar to how principles of coevolution enabled a powerful representation for structure prediction. + +# 4.2 BINDING SITES AND POST-TRANSLATIONAL MODIFICATIONS + +We also analyze how attention interacts with binding sites and post-translational modifications (PTMs), which both play a key role in protein function. + +Attention targets binding sites throughout most layers of the models. Figure 3 shows the proportion of attention focused on binding sites (Eq. 1) across the heads of the 5 models studied. Attention to binding sites is most pronounced in the ProtAlbert model (Figure 3b), which has 22 heads that focus over $50\%$ of attention on bindings sites, whereas the background frequency of binding sites in the dataset is $4.8\%$ . The three BERT models (Figures 3a, 3c, and 3d) also attend strongly to binding sites, with attention heads focusing up to $48.2\%$ , $50.7\%$ , and $45.6\%$ of attention on binding sites, respectively. Figure 1b visualizes the attention in one strongly-aligned head from the TapeBert model. Statistical significance tests and a comparison to a null model are provided in Appendix C.3. + +ProtXLNet (Figure 3e) also targets binding sites, but not as strongly as the other models: the most aligned head focuses $15.1\%$ of attention on binding sites, and the average head directs just $6.2\%$ of attention to binding sites, compared to $13.2\%$ , $19.8\%$ , $16.0\%$ , and $15.1\%$ for the first four models in Figure 3. It's unclear whether this disparity is due to differences in architectures or pre-training objectives; for example, ProtXLNet uses a bidirectional auto-regressive pretraining method (see Appendix A.2), whereas the other 4 models all use masked language modeling objectives. + +![](images/bc65588a4ee9c1551fd426056aa5df926c90421dbb620f8a6816681ed83730a8.jpg) +Figure 4: Each plot shows the percentage of attention focused on the given property, averaged over all heads within each layer. The plots, sorted by center of gravity (red dashed line), show that heads in deeper layers focus relatively more attention on binding sites and contacts, whereas attention toward specific secondary structures is more even across layers. + +![](images/5b94c4dd0f77a120b31a8778bad9482a6d7992331572b867844554a4c32f60b0.jpg) +Figure 5: Performance of probing classifiers by layer, sorted by task order in Figure 4. The embedding probes (orange) quantify the knowledge of the given property that is encoded in each layer's output embeddings. The attention probe (blue), show the amount of information encoded in attention weights for the (pairwise) contact feature. Additional details are provided in Appendix B.3. + +Why does attention target binding sites? In contrast to contact maps, which reveal relationships within proteins, binding sites describe how a protein interacts with other molecules. These external interactions ultimately define the high-level function of the protein, and thus binding sites remain conserved even when the sequence as a whole evolves (Kinjo & Nakamura, 2009). Further, structural motifs in binding sites are mainly restricted to specific families or superfamilies of proteins (Kinjo & Nakamura, 2009), and binding sites can reveal evolutionary relationships among proteins (Lee et al., 2017). Thus binding sites may provide the model with a high-level characterization of the protein that is robust to individual sequence variation. By attending to these regions, the model can leverage this higher-level context when predicting masked tokens throughout the sequence. + +Attention targets PTMs in a small number of heads. A small number of heads in each model concentrate their attention very strongly on amino acids associated with post-translational modifications (PTMs). For example, Head 11-6 in TapeBert focused $64\%$ of attention on PTM positions, though these occur at only $0.8\%$ of sequence positions in the dataset.3 Similar to our discussion on binding sites, PTMs are critical to protein function (Rubin & Rosen, 1975) and thereby are likely to exhibit behavior that is conserved across the sequence space. See Appendix C.4 for full results. + +# 4.3 CROSS-LAYER ANALYSIS + +We analyze how attention captures properties of varying complexity across different layers of TapeBert, and compare this to a probing analysis of embeddings and attention weights (see Section 3). + +Attention targets higher-level properties in deeper layers. As shown in Figure 4, deeper layers focus relatively more attention on binding sites and contacts (high-level concept), whereas secondary structure (low- to mid-level concept) is targeted more evenly across layers. The probing analysis of attention (Figure 5, blue) similarly shows that knowledge of contact maps (a pairwise feature) + +![](images/f92ddcfc4c377ce4cd44c73c32beb245dde8bcbe9ac411dc6ca70e310b6a9cce.jpg) +Figure 6: Percentage of each head's attention focused on amino acids Pro (left) and Phe (right). + +![](images/4555b7f28ca1a65d6c66feaab12e1fb25a085630400b43550178e80af6f7e572.jpg) + +![](images/7530eb887e9432266451cc40eea57d72c223f9d4b02562723e38d08d99d7cdd1.jpg) +Figure 7: Pairwise attention similarity (left) vs. substitution matrix (right) (codes in App. C.5) + +![](images/2342a3d10ebd3f9ece2dcb587be11c971412bae9c880f526a46b08e7203ca2e9.jpg) + +is encoded in attention weights primarily in the last 1-2 layers. These results are consistent with prior work in NLP that suggests deeper layers in text-based Transformers attend to more complex properties (Vig & Belinkov, 2019) and encode higher-level representations (Raganato & Tiedemann, 2018; Peters et al., 2018; Tenney et al., 2019; Jawahar et al., 2019). + +The embedding probes (Figure 5, orange) also show that the model first builds representations of local secondary structure in lower layers before fully encoding binding sites and contact maps in deeper layers. However, this analysis also reveals stark differences in how knowledge of contact maps is accrued in embeddings, which accumulate this knowledge gradually over many layers, compared to attention weights, which acquire this knowledge only in the final layers in this case. This example points out limitations of common layerwise probing approaches that only consider embeddings, which, intuitively, represent what the model knows but not necessarily how it operationalizes that knowledge. + +# 4.4 AMINO ACIDS AND THE SUBSTITUTION MATRIX + +In addition to high-level structural and functional properties, we also performed a fine-grained analysis of the interaction between attention and particular amino acids. + +Attention heads specialize in particular amino acids. We computed the proportion of TapeBert's attention to each of the 20 standard amino acids, as shown in Figure 6 for two example amino acids. For 16 of the amino acids, there exists an attention head that focuses over $25\%$ of attention on that amino acid, significantly greater than the background frequencies of the corresponding amino acids, which range from $1.3\%$ to $9.4\%$ . Similar behavior was observed for ProtBert, ProtBert-BFD, ProtAlbert, and ProtXLNet models, with 17, 15, 16, and 18 amino acids, respectively, receiving greater than $25\%$ of the attention from at least one attention head. Detailed results for TapeBert including statistical significance tests and comparison to a null model are presented in Appendix C.5. + +Attention is consistent with substitution relationships. A natural follow-up question from the above analysis is whether each head has "memorized" specific amino acids to target, or whether it has actually learned meaningful properties that correlate with particular amino acids. To test the latter hypothesis, we analyze whether amino acids with similar structural and functional properties are attended to similarly across heads. Specifically, we compute the Pearson correlation between the distribution of attention across heads between all pairs of distinct amino acids, as shown in Figure 7 (left) for TapeBert. For example, the entry for Pro (P) and Phe (F) is the correlation between the two heatmaps in Figure 6. We compare these scores to the BLOSUM62 substitution scores (Sec. 2) in Figure 7 (right), and find a Pearson correlation of 0.73, suggesting that attention is moderately + +consistent with substitution relationships. Similar correlations are observed for the ProtTrans models: 0.68 (ProtBert), 0.75 (ProtBert-BFD), 0.60 (ProtAlbert), and 0.71 (ProtXLNet). As a baseline, the randomized versions of these models (Appendix B.2) yielded correlations of -0.02 (TapeBert), 0.02 (ProtBert), -0.03 (ProtBert-BFD), -0.05 (ProtAlbert), and 0.21 (ProtXLNet). + +# 5 RELATED WORK + +# 5.1 PROTEIN LANGUAGE MODELS + +Deep neural networks for protein language modeling have received broad interest. Early work applied the Skip-gram model (Mikolov et al., 2013) to construct continuous embeddings from protein sequences (Asgari & Mofrad, 2015). Sequence-only language models have since been trained through autoregressive or autoencoding self-supervision objectives for discriminative and generative tasks, for example, using LSTMs or Transformer-based architectures (Alley et al., 2019; Bepler & Berger, 2019; Rao et al., 2019; Rives et al., 2019). TAPE created a benchmark of five tasks to assess protein sequence models, and ProtTrans also released several large-scale pretrained protein Transformer models (Elnaggar et al., 2020). Riesselman et al. (2019); Madani et al. (2020) trained autoregressive generative models to predict the functional effect of mutations and generate natural-like proteins. + +From an interpretability perspective, Rives et al. (2019) showed that the output embeddings from a pretrained Transformer can recapitulate structural and functional properties of proteins through learned linear transformations. Various works have analyzed output embeddings of protein models through dimensionality reduction techniques such as PCA or t-SNE (Elnaggar et al., 2020; Biswas et al., 2020). In our work, we take an interpretability-first perspective to focus on the internal model representations, specifically attention and intermediate hidden states, across multiple protein language models. We also explore novel biological properties including binding sites and post-translational modifications. + +# 5.2 INTERPRETING MODELS IN NLP + +The rise of deep neural networks in ML has also led to much work on interpreting these so-called black-box models. This section reviews the NLP interpretability literature on the Transformer model, which is directly comparable to our work on interpreting Transformer models of protein sequences. + +Interpreting Transformers. The Transformer is a neural architecture that uses attention to accelerate learning (Vaswani et al., 2017). In NLP, transformers are the backbone of state-of-the-art pre-trained language models such as BERT (Devlin et al., 2019). BERTology focuses on interpreting what the BERT model learns about language using a suite of probes and interventions (Rogers et al., 2020). So-called diagnostic classifiers are used to interpret the outputs from BERT's layers (Veldhoen et al., 2016). At a high level, mechanisms for interpreting BERT can be placed into three main categories: interpreting the learned embeddings (Ethayarajh, 2019; Wiedemann et al., 2019; Mickus et al., 2020; Adi et al., 2016; Conneau et al., 2018), BERT's learned knowledge of syntax (Lin et al., 2019; Liu et al., 2019; Tenney et al., 2019; Htut et al., 2019; Hewitt & Manning, 2019; Goldberg, 2019), and BERT's learned knowledge of semantics (Tenney et al., 2019; Ettinger, 2020). + +Interpreting attention specifically. Interpreting attention on textual sequences is a well-established area of research (Wiegreff & Pinter, 2019; Zhong et al., 2019; Brunner et al., 2020; Hewitt & Manning, 2019). Past work has been shown that attention correlates with syntactic and semantic relationships in natural language in some cases (Clark et al., 2019; Vig & Belinkov, 2019; Htut et al., 2019). Depending on the task and model architecture, attention may have less or more explanatory power for model predictions (Jain & Wallace, 2019; Serrano & Smith, 2019; Pruthi et al., 2020; Moradi et al., 2019; Vashisth et al., 2019). Visualization techniques have been used to convey the structure and properties of attention in Transformers (Vaswani et al., 2017; Kovaleva et al., 2019; Hoover et al., 2020; Vig, 2019). Recent work has begun to analyze attention in Transformer models outside of the domain of natural language (Schwaller et al., 2020; Payne et al., 2020). + +Our work extends these methods to protein sequence models by considering particular biophysical properties and relationships. We also present a joint cross-layer probing analysis of attention weights and layer embeddings. While past work in NLP has analyzed attention and embeddings across layers, we believe we are the first to do so in any domain using a single, unified metric, which enables us to + +directly compare the relative information content of the two representations. Finally, we present a novel tool for visualizing attention embedded in three-dimensional structure. + +# 6 CONCLUSIONS AND FUTURE WORK + +This paper builds on the synergy between NLP and computational biology by adapting and extending NLP interpretability methods to protein sequence modeling. We show how a Transformer language model recovers structural and functional properties of proteins and integrates this knowledge directly into its attention mechanism. While this paper focuses on reconciling attention with known properties of proteins, one might also leverage attention to uncover novel relationships or more nuanced forms of existing measures such as contact maps, as discussed in Section 4.1. In this way, language models have the potential to serve as tools for scientific discovery. But in order for learned representations to be accessible to domain experts, they must be presented in an appropriate context to facilitate discovery. Visualizing attention in the context of protein structure (Figure 1) is one attempt to do so. We believe there is the potential to develop such contextual visualizations of learned representations in a range of scientific domains. + +# ACKNOWLEDGMENTS + +We would like to thank Xi Victoria Lin, Stephan Zheng, Melvin Gruesbeck, and the anonymous reviewers for their valuable feedback. + +# REFERENCES + +Yossi Adi, Einat Kermany, Yonatan Belinkov, Ofer Lavi, and Yoav Goldberg. Fine-grained analysis of sentence embeddings using auxiliary prediction tasks. arXiv:1608.04207 [cs.CL], 2016. +Ethan C Alley, Grigory Khimulya, Surojit Biswas, Mohammed AlQuraishi, and George M Church. Unified rational protein engineering with sequence-based deep representation learning. Nature Methods, 16(12):1315-1322, 2019. +Mohammed AlQuraishi. ProteinNet: a standardized data set for machine learning of protein structure. BMC Bioinformatics, 20, 2019. +Ehsaneddin Asgari and Mohammad RK Mofrad. Continuous distributed representation of biological sequences for deep proteomics and genomics. PLOS One, 10(11), 2015. +Tristan Bepler and Bonnie Berger. Learning protein sequence embeddings using information from structure. In International Conference on Learning Representations, 2019. +Helen M Berman, John Westbrook, Zukang Feng, Gary Gilliland, Talapady N Bhat, Helge Weissig, Ilya N Shindyalov, and Philip E Bourne. The protein data bank. *Nucleic Acids Research*, 28(1): 235-242, 2000. +Surojit Biswas, Grigory Khimulya, Ethan C. Alley, Kevin M. Esvelt, and George M. Church. Low-n protein engineering with data-efficient deep learning. bioRxiv, 2020. doi: 10.1101/2020.01.23.917682. URL https://www.biorxiv.org/content/early/2020/08/31/2020.01.23.917682. +Ashraf Brik and Chi-Huey Wong. HIV-1 protease: Mechanism and drug discovery. Organic & Biomolecular Chemistry, 1(1):5-14, 2003. +Gino Brunner, Yang Liu, Damian Pascual, Oliver Richter, Massimiliano Ciaramita, and Roger Wattenhofer. On identifiability in Transformers. In International Conference on Learning Representations, 2020. URL https://openreview.net/forum?id=BJg1f6EFDB. +Kevin Clark, Urvashi Khandelwal, Omer Levy, and Christopher D. Manning. What does BERT look at? An analysis of BERT's attention. In BlackBoxNLP@ACL, 2019. + +Alexis Conneau, German Kruszewski, Guillaume Lample, Loic Barrault, and Marco Baroni. What you can cram into a single $\$ 8!\#$ * vector: Probing sentence embeddings for linguistic properties. In Proceedings of the 56th Annual Meeting of the Association for Computational Linguistics, pp. 2126-2136, 2018. +Jacob Devlin, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova. BERT: Pre-training of deep bidirectional transformers for language understanding. In Proceedings of the 2019 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, Volume 1 (Long and Short Papers), pp. 4171–4186, Minneapolis, Minnesota, 2019. Association for Computational Linguistics. +Sara El-Gebali, Jaina Mistry, Alex Bateman, Sean R. Eddy, Aurélien Luciani, Simon C. Potter, Matloob Qureshi, Lorna J. Richardson, Gustavo A. Salazar, Alfredo Smart, Erik L. L. Sonnhammer, Layla Hirsh, Lisanna Paladin, Damiano Piovesan, Silvio C. E. Tosatto, and Robert D. Finn. The Pfam protein families database in 2019. *Nucleic Acids Research*, 47(D1):D427–D432, January 2019a. doi: 10.1093/nar/gky995. +Sara El-Gebali, Jaina Mistry, Alex Bateman, Sean R Eddy, Aurélien Luciani, Simon C Potter, Matloob Qureshi, Lorna J Richardson, Gustavo A Salazar, Alfredo Smart, Erik L L Sonnhammer, Layla Hirsh, Lisanna Paladin, Damiano Piovesan, Silvio C E Tosatto, and Robert D Finn. The Pfam protein families database in 2019. *Nucleic Acids Research*, 47(D1):D427–D432, 2019b. ISSN 0305-1048. doi: 10.1093/nar/gky995. +Ahmed Elnaggar, Michael Heinzinger, Christian Dallago, Ghalia Rihawi, Yu Wang, Llion Jones, Tom Gibbs, Tamas Feher, Christoph Angerer, Martin Steinegger, Debsindhu Bhowmik, and Burkhard Rost. ProtTrans: Towards cracking the language of life's code through self-supervised deep learning and high performance computing. arXiv preprint arXiv:2007.06225, 2020. +Kawin Ethayarajh. How contextual are contextualized word representations? Comparing the geometry of BERT, ELMo, and GPT-2 embeddings. In Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing and the 9th International Joint Conference on Natural Language Processing (EMNLP-IJCNLP), pp. 55–65, Hong Kong, China, 2019. Association for Computational Linguistics. +Allyson Ettinger. What BERT is not: Lessons from a new suite of psycholinguistic diagnostics for language models. Transactions of the Association for Computational Linguistics, 8:34-48, 2020. +Naomi K Fox, Steven E Brenner, and John-Marc Chandonia. SCOPe: Structural classification of proteins—extended, integrating scop and astral data and classification of new structures. *Nucleic Acids Research*, 42(D1):D304–D309, 2013. +Yoav Goldberg. Assessing BERT's syntactic abilities. arXiv preprint arXiv:1901.05287, 2019. +Christopher Grimsley, Elijah Mayfield, and Julia R.S. Bursten. Why attention is not explanation: Surgical intervention and causal reasoning about neural models. In Proceedings of The 12th Language Resources and Evaluation Conference, pp. 1780-1790, Marseille, France, May 2020. European Language Resources Association. ISBN 979-10-95546-34-4. URL https://www.aclweb.org/anthology/2020.lrec-1.220. +S Henikoff and J G Henikoff. Amino acid substitution matrices from protein blocks. Proceedings of the National Academy of Sciences, 89(22):10915-10919, 1992. ISSN 0027-8424. doi: 10.1073/pnas.89.22.10915. URL https://www.pnas.org/content/89/22/10915. +John Hewitt and Christopher D Manning. A structural probe for finding syntax in word representations. In Proceedings of the 2019 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, Volume 1 (Long and Short Papers), pp. 4129-4138, 2019. +Benjamin Hoover, Hendrik Strobelt, and Sebastian Gehrmann. exBERT: A Visual Analysis Tool to Explore Learned Representations in Transformer Models. In Proceedings of the 58th Annual Meeting of the Association for Computational Linguistics: System Demonstrations, pp. 187-196. Association for Computational Linguistics, 2020. + +Phu Mon Htut, Jason Phang, Shikha Bordia, and Samuel R Bowman. Do attention heads in BERT track syntactic dependencies? arXiv preprint arXiv:1911.12246, 2019. +Sarthak Jain and Byron C. Wallace. Attention is not Explanation. In Proceedings of the 2019 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, Volume 1 (Long and Short Papers), pp. 3543-3556, June 2019. +Ganesh Jawahar, Benoit Sagot, and Djamé Seddah. What does BERT learn about the structure of language? In ACL 2019 - 57th Annual Meeting of the Association for Computational Linguistics, Florence, Italy, July 2019. URL https://hal.inria.fr/hal-02131630. +Akira Kinjo and Haruki Nakamura. Comprehensive structural classification of ligand-binding motifs in proteins. Structure, 17(2), 2009. +Michael Schantz Klausen, Martin Closter Jespersen, Henrik Nielsen, Kamilla Kjaergaard Jensen, Vanessa Isabell Jurtz, Casper Kaae Soenderby, Morten Otto Alexander Sommer, Ole Winther, Morten Nielsen, Bent Petersen, et al. NetSurfP-2.0: Improved prediction of protein structural features by integrated deep learning. Proteins: Structure, Function, and Bioinformatics, 2019. +Olga Kovaleva, Alexey Romanov, Anna Rogers, and Anna Rumshisky. Revealing the dark secrets of BERT. In Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing and the 9th International Joint Conference on Natural Language Processing (EMNLP-IJCNLP), pp. 4365-4374, Hong Kong, China, 2019. Association for Computational Linguistics. +Keita Kurita, Nidhi Vyas, Ayush Pareek, Alan W Black, and Yulia Tsvetkov. Measuring bias in contextualized word representations. In Proceedings of the First Workshop on Gender Bias in Natural Language Processing, pp. 166-172, Florence, Italy, 2019. Association for Computational Linguistics. +Zhenzhong Lan, Mingda Chen, Sebastian Goodman, Kevin Gimpel, Piyush Sharma, and Radu Soricut. Albert: A lite bert for self-supervised learning of language representations. In International Conference on Learning Representations, 2020. +Juyong Lee, Janez Konc, Dusanka Janezic, and Bernard Brooks. Global organization of a binding site network gives insight into evolution and structure-function relationships of proteins. Sci Rep, 7 (11652), 2017. +Yongjie Lin, Yi Chern Tan, and Robert Frank. Open sesame: Getting inside BERT's linguistic knowledge. In Proceedings of the 2019 ACL Workshop BlackboxNLP: Analyzing and Interpreting Neural Networks for NLP, pp. 241-253, Florence, Italy, 2019. Association for Computational Linguistics. +Nelson F. Liu, Matt Gardner, Yonatan Belinkov, Matthew E. Peters, and Noah A. Smith. Linguistic knowledge and transferability of contextual representations. In Proceedings of the 2019 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, Volume 1 (Long and Short Papers), pp. 1073-1094. Association for Computational Linguistics, 2019. +Ali Madani, Bryan McCann, Nikhil Naik, Nitish Shirish Keskar, Namrata Anand, Raphael R. Eguchi, Po-Ssu Huang, and Richard Socher. Progen: Language modeling for protein generation. arXiv preprint arXiv:2004.03497, 2020. +Timothee Mickus, Mathieu Constant, Denis Paperno, and Kees Van Deemter. What do you mean, BERT? Assessing BERT as a Distributional Semantics Model. Proceedings of the Society for Computation in Linguistics, 3, 2020. +Tomas Mikolov, Ilya Sutskever, Kai Chen, Greg S Corrado, and Jeff Dean. Distributed representations of words and phrases and their compositionality. In C. J. C. Burges, L. Bottou, M. Welling, Z. Ghahramani, and K. Q. Weinberger (eds.), Advances in Neural Information Processing Systems 26, pp. 3111-3119. Curran Associates, Inc., 2013. + +Pooya Moradi, Nishant Kambhatla, and Anoop Sarkar. Interrogating the explanatory power of attention in neural machine translation. In Proceedings of the 3rd Workshop on Neural Generation and Translation, pp. 221-230, Hong Kong, November 2019. Association for Computational Linguistics. doi: 10.18653/v1/D19-5624. URL https://www.aclweb.org/anthology/D19-5624. +John Moult, Krzysztof Fidelis, Andriy Kryshtafovych, Torsten Schwede, and Anna Tramontano. Critical assessment of methods of protein structure prediction (CASP)-Round XII. Proteins: Structure, Function, and Bioinformatics, 86:7-15, 2018. ISSN 08873585. doi: 10.1002/prot.25415. URL http://doi.wiley.com/10.1002/prot.25415. +Hai Nguyen, David A Case, and Alexander S Rose. NGLview–interactive molecular graphics for Jupyter notebooks. Bioinformatics, 34(7):1241–1242, 12 2017. ISSN 1367-4803. doi: 10.1093/bioinformatics/btx789. URL https://doi.org/10.1093/bioinformatics/btx789. +Timothy Niven and Hung-Yu Kao. Probing neural network comprehension of natural language arguments. In Proceedings of the 57th Annual Meeting of the Association for Computational Linguistics, pp. 4658-4664, Florence, Italy, 2019. Association for Computational Linguistics. +Josh Payne, Mario Srouji, Dian Ang Yap, and Vineet Kosaraju. Bert learns (and teaches) chemistry. arXiv preprint arXiv:2007.16012, 2020. +Matthew Peters, Mark Neumann, Luke Zettlemoyer, and Wen-tau Yih. Dissecting contextual word embeddings: Architecture and representation. In Proceedings of the 2018 Conference on Empirical Methods in Natural Language Processing, pp. 1499-1509, Brussels, Belgium, October-November 2018. Association for Computational Linguistics. doi: 10.18653/v1/D18-1179. URL https://www.aclweb.org/anthology/D18-1179. +Danish Pruthi, Mansi Gupta, Bhuwan Dhingra, Graham Neubig, and Zachary C. Lipton. Learning to deceive with attention-based explanations. In Annual Conference of the Association for Computational Linguistics (ACL), July 2020. URL https://arxiv.org/abs/1909.07913. +Alessandro Raganato and Jörg Tiedemann. An analysis of encoder representations in Transformer-based machine translation. In Proceedings of the 2018 EMNLP Workshop BlackboxNLP: Analyzing and Interpreting Neural Networks for NLP, pp. 287-297, Brussels, Belgium, November 2018. Association for Computational Linguistics. doi: 10.18653/v1/W18-5431. URL https://www.aclweb.org/anthology/W18-5431. +Roshan Rao, Nicholas Bhattacharya, Neil Thomas, Yan Duan, Xi Chen, John Canny, Pieter Abbeel, and Yun S Song. Evaluating protein transfer learning with TAPE. In Advances in Neural Information Processing Systems, 2019. +Emily Reif, Ann Yuan, Martin Wattenberg, Fernanda B Viegas, Andy Coenen, Adam Pearce, and Been Kim. Visualizing and measuring the geometry of BERT. In H. Wallach, H. Larochelle, A. Beygelzimer, F. dAlché-Buc, E. Fox, and R. Garnett (eds.), Advances in Neural Information Processing Systems, volume 32, pp. 8594-8603. Curran Associates, Inc., 2019. +Adam J Riesselman, Jung-Eun Shin, Aaron W Kollasch, Conor McMahon, Elana Simon, Chris Sander, Aashish Manglik, Andrew C Kruse, and Debora S Marks. Accelerating protein design using autoregressive generative models. bioRxiv, pp. 757252, 2019. +Alexander Rives, Siddharth Goyal, Joshua Meier, Demi Guo, Myle Ott, C Lawrence Zitnick, Jerry Ma, and Rob Fergus. Biological structure and function emerge from scaling unsupervised learning to 250 million protein sequences. bioRxiv, pp. 622803, 2019. +Anna Rogers, Olga Kovaleva, and Anna Rumshisky. A primer in BERTology: What we know about how BERT works. Transactions of the Association for Computational Linguistics, 8:842-866, 2020. +Nathan J Rollins, Kelly P Brock, Frank J Poelwijk, Michael A Stiffler, Nicholas P Gauthier, Chris Sander, and Debora S Marks. Inferring protein 3D structure from deep mutation scans. Nature Genetics, 51(7):1170, 2019. + +Alexander S. Rose and Peter W. Hildebrand. NGL Viewer: a web application for molecular visualization. *Nucleic Acids Research*, 43(W1):W576-W579, 04 2015. ISSN 0305-1048. doi: 10.1093/nar/gkv402. URL https://doi.org/10.1093/nar/gkv402. +Alexander S Rose, Anthony R Bradley, Yana Valasatava, Jose M Duarte, Andreas Prlic, and Peter W Rose. NGL viewer: web-based molecular graphics for large complexes. Bioinformatics, 34(21): 3755-3758, 05 2018. ISSN 1367-4803. doi: 10.1093/bioinformatics/bty419. URL https://doi.org/10.1093/bioinformatics/bty419. +Charles Rubin and Ora Rosen. Protein phosphorylation. Annual Review of Biochemistry, 44:831-887, 1975. URL https://doi.org/10.1146/annurev.bi.44.070175.004151. +Philippe Schwaller, Benjamin Hoover, Jean-Louis Reymond, Hendrik Strobelt, and Teodoro Laino. Unsupervised attention-guided atom-mapping. ChemRxiv, 5 2020. doi: 10.26434/chemrxiv.12298559.v1. URL https://chemrxiv.org/articles/Unsupervised Attention-Guided_Atom-Mapping/12298559. +Sofia Serrano and Noah A. Smith. Is attention interpretable? In Proceedings of the 57th Annual Meeting of the Association for Computational Linguistics, pp. 2931-2951, Florence, Italy, July 2019. Association for Computational Linguistics. doi: 10.18653/v1/P19-1282. URL https://www.aclweb.org/anthology/P19-1282. +Martin Steinegger and Johannes Söding. Clustering huge protein sequence sets in linear time. Nature Communications, 9(2542), 2018. doi: 10.1038/s41467-018-04964-5. +Baris E. Suzek, Yuqi Wang, Hongzhan Huang, Peter B. McGarvey, Cathy H. Wu, and the UniProt Consortium. UniRef clusters: a comprehensive and scalable alternative for improving sequence similarity searches. Bioinformatics, 31(6):926-932, 11 2014. ISSN 1367-4803. doi: 10.1093/bioinformatics/btu739. URL https://doi.org/10.1093/bioinformatics/btu739. +Yi Chern Tan and L. Elisa Celis. Assessing social and intersectional biases in contextualized word representations. In Advances in Neural Information Processing Systems 32, pp. 13230-13241. Curran Associates, Inc., 2019. +Ian Tenney, Dipanjan Das, and Ellie Pavlick. BERT rediscovers the classical NLP pipeline. In Proceedings of the 57th Annual Meeting of the Association for Computational Linguistics, pp. 4593-4601, Florence, Italy, 2019. Association for Computational Linguistics. +Shikhar Vashishth, Shyam Upadhyay, Gaurav Singh Tomar, and Manaal Faruqui. Attention interpretability across NLP tasks. arXiv preprint arXiv:1909.11218, 2019. +Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N Gomez, Lukasz Kaiser, and Illia Polosukhin. Attention is all you need. In Advances in Neural Information Processing Systems, pp. 5998-6008, 2017. +Sara Veldhoen, Dieuwke Hupkes, and Willem H. Zuidema. Diagnostic classifiers revealing how neural networks process hierarchical structure. In CoCo@NIPS, 2016. +Jesse Vig. A multiscale visualization of attention in the Transformer model. In Proceedings of the 57th Annual Meeting of the Association for Computational Linguistics: System Demonstrations, pp. 37-42, Florence, Italy, 2019. Association for Computational Linguistics. +Jesse Vig and Yonatan Belinkov. Analyzing the structure of attention in a Transformer language model. In Proceedings of the 2019 ACL Workshop BlackboxNLP: Analyzing and Interpreting Neural Networks for NLP, pp. 63-76, Florence, Italy, 2019. Association for Computational Linguistics. +Jesse Vig, Sebastian Gehrmann, Yonatan Belinkov, Sharon Qian, Daniel Nevo, Yaron Singer, and Stuart Shieber. Investigating gender bias in language models using causal mediation analysis. In Advances in Neural Information Processing Systems, volume 33, pp. 12388-12401, 2020. +Gregor Wiedemann, Steffen Remus, Avi Chawla, and Chris Biemann. Does BERT make any sense? Interpretable word sense disambiguation with contextualized embeddings. arXiv preprint arXiv:1909.10430, 2019. + +Sarah Wiegrefe and Yuval Pinter. Attention is not not explanation. In Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing and the 9th International Joint Conference on Natural Language Processing (EMNLP-IJCNLP), pp. 11-20, November 2019. +Zhilin Yang, Zihang Dai, Yiming Yang, Jaime Carbonell, Russ R Salakhutdinov, and Quoc V Le. XLNet: Generalized autoregressive pretraining for language understanding. In H. Wallach, H. Larochelle, A. Beygelzimer, F. dAlché-Buc, E. Fox, and R. Garnett (eds.), Advances in Neural Information Processing Systems, volume 32, pp. 5753-5763. Curran Associates, Inc., 2019. +Ruiqi Zhong, Steven Shao, and Kathleen McKeown. Fine-grained sentiment analysis with faithful attention. arXiv preprint arXiv:1908.06870, 2019. + +# A MODEL OVERVIEW + +# A.1 PRE-TRAINED MODELS + +Table 1 provides an overview of the five pre-trained Transformer models studied in this work. The models originate from the TAPE and ProtTrans repositories, spanning three model architectures: BERT, ALBERT, and XLNet. + +Table 1: Summary of pre-trained models analyzed, including the source of the model, the type of Transformer used, the number of layers and heads, the total number of model parameters, the source of the pre-training dataset, and the number of protein sequences in the pre-training dataset. + +
SourceNameTypeLayersHeadsParamsTrain Dataset# Seq
TAPETapeBertBERT121294MPfam31M
ProtTransProtBertBERT3016420MUniref100216M
ProtTransProtBert-BFDBERT3016420MBFD2.1B
ProtTransProtAlbertALBERT1264224MUniref100216M
ProtTransProtXLNetXLNet3016409MUniref100216M
+ +# A.2 BERT TRANSFORMER ARCHITECTURE + +Stacked Encoder: BERT uses a stacked-encoder architecture, which inputs a sequence of tokens $\mathbf{x} = (x_{1},\dots,x_{n})$ and applies position and token embeddings followed by a series of encoder layers. Each layer applies multi-head self-attention (see below) in combination with a feedforward network, layer normalization, and residual connections. The output of each layer $\ell$ is a sequence of contextualized embeddings $(\mathbf{h}_1^{(\ell)},\ldots ,\mathbf{h}_n^{(\ell)})$ . + +Self-Attention: Given an input $\boldsymbol{x} = (x_{1},\ldots ,x_{n})$ , the self-attention mechanism assigns to each token pair $i,j$ an attention weight $\alpha_{i,j} > 0$ where $\sum_{j}\alpha_{i,j} = 1$ . Attention in BERT is bidirectional. In the multi-layer, multi-head setting, $\alpha$ is specific to a layer and head. The BERT-Base model has 12 layers and 12 heads. Each attention head learns a distinct set of weights, resulting in $12\times 12 = 144$ distinct attention mechanisms in this case. + +The attention weights $\alpha_{i,j}$ are computed from the scaled dot-product of the query vector of $i$ and the key vector of $j$ , followed by a softmax operation. The attention weights are then used to produce a weighted sum of value vectors: + +$$ +\operatorname {A t t e n t i o n} (Q, K, V) = \operatorname {s o f t m a x} \left(\frac {Q K ^ {T}}{\sqrt {d _ {k}}}\right) V \tag {2} +$$ + +using query matrix $Q$ , key matrix $K$ , and value matrix $V$ , where $d_k$ is the dimension of $K$ . In a multi-head setting, the queries, keys, and values are linearly projected $h$ times, and the attention operation is performed in parallel for each representation, with the results concatenated. + +# A.3 OTHER TRANSFORMER VARIANTS + +ALBERT: The architecture of ALBERT differs from BERT in two ways: (1) It shares parameters across layers, unlike BERT which learns distinct parameters for every layer and (2) It uses factorized embeddings, which allows the input token embeddings to be of a different (smaller) size than the hidden states. The original version of ALBERT designed for text also employed a sentence-order prediction pretraining task, but this was not used on the models studied in this paper. + +XLNet: Instead of the masked-language modeling pretraining objective use for BERT, XLNet uses a bidirectional auto-regressive pretraining method that considers all possible orderings of the input factorization. The architecture also adds a segment recurrence mechanism to process long sequences, as well as a relative rather than absolute encoding scheme. + +# B ADDITIONAL EXPERIMENTAL DETAILS + +# B.1 ALTERNATIVE ATTENTION AGREEMENT METRIC + +Here we present an alternative formulation to Eq. 1 based on an attention-weighted average. We define an indicator function $f(i,j)$ for property $f$ that returns 1 if the property is present in token pair $(i,j)$ (i.e., if amino acids $i$ and $j$ are in contact), and zero otherwise. We then compute the proportion of attention that matches with $f$ over a dataset $X$ as follows: + +$$ +p _ {\alpha} (f) = \sum_ {x \in X} \sum_ {i = 1} ^ {| x |} \sum_ {j = 1} ^ {| x |} f (i, j) \alpha_ {i, j} (x) / \sum_ {x \in X} \sum_ {i = 1} ^ {| x |} \sum_ {j = 1} ^ {| x |} \alpha_ {i, j} (x) \tag {3} +$$ + +where $\alpha_{i,j}(x)$ denotes the attention from $i$ to $j$ for input sequence $x$ . + +# B.2 STATISTICAL SIGNIFICANCE TESTING AND NULL MODELS + +We perform statistical significance tests to determine whether any results based on the metric defined in Equation 1 are due to chance. Given a property $f$ , as defined in Section 3, we perform a two-proportion z-test comparing (1) the proportion of high-confidence attention arcs $(\alpha_{i,j} > \theta)$ for which $f(i,j) = 1$ , and (2) the proportion of all possible pairs $i,j$ for which $f(i,j) = 1$ . Note that the first proportion is exactly the metric $p_{\alpha}(f)$ defined in Equation 1 (e.g. the proportion of attention aligned with contact maps). The second proportion is simply the background frequency of the property (e.g. the background frequency of contacts). Since we extract the maximum scores over all of the heads in the model, we treat this as a case of multiple hypothesis testing and apply the Bonferroni correction, with the number of hypotheses $m$ equal to the number of attention heads. + +As an additional check that the results did not occur by chance, we also report results on baseline (null) models. We initially considered using two forms of null models: (1) a model with randomly initialized weights, and (2) a model trained on randomly shuffled sequences. However, in both cases, none of the sequences in the dataset yielded attention weights greater than the attention threshold $\theta$ . This suggests that the mere existence of the high-confidence attention weights used in the analysis could not have occurred by chance, but it does not shed light on the particular analyses performed. Therefore, we implemented an alternative randomization scheme in which we randomly shuffle attention weights from the original models as a post-processing step. Specifically, we permute the sequence of attention weights from each token for every attention head. To illustrate, let's say that the original model produced attention weights of (0.3, 0.2, 0.1, 0.4, 0.0) from position $i$ in protein sequence $x$ from head $h$ , where $|x| = 5$ . In the null model, the attention weights from position $i$ in sequence $x$ in head $h$ would be a random permutation of those weights, e.g., (0.2, 0.0, 0.4, 0.3, 0.1). Note that these are still valid attention weights as they would sum to 1 (since the original weights would sum to 1 by definition). We report results using this form of baseline model. + +# B.3 PROBING METHODOLOGY + +**Embedding probe.** We probe the embedding vectors output from each layer using a linear probing classifier. For token-level probing tasks (binding sites, secondary structure) we feed each token's output vector directly to the classifier. For token-pair probing tasks (contact map) we construct a pairwise feature vector by concatenating the elementwise differences and products of the two tokens' output vectors, following the $\mathrm{TAPE}^4$ implementation. + +We use task-specific evaluation metrics for the probing classifier: for secondary structure prediction, we measure F1 score; for contact prediction, we measure precision@ $L / 5$ , where $L$ is the length of the protein sequence, following standard practice (Moult et al., 2018); for binding site prediction, we measure precision@ $L / 20$ , since approximately one in twenty amino acids in each sequence is a binding site (4.8% in the dataset). + +Attention probe. Just as the attention weight $\alpha_{i,j}$ is defined for a pair of amino acids $(i,j)$ , so is the contact property $f(i,j)$ , which returns true if amino acids $i$ and $j$ are in contact. Treating the attention weight as a feature of a token-pair $(i,j)$ , we can train a probing classifier that predicts the + +contact property based on this feature, thereby quantifying the attention mechanism's knowledge of that property. In our multi-head setting, we treat the attention weights across all heads in a given layer as a feature vector, and use a probing classifier to assess the knowledge of a given property in the attention weights across the entire layer. As with the embedding probe, we measure performance of the probing classifier using precision@ $L / 5$ , where $L$ is the length of the protein sequence, following standard practice for contact prediction. + +# B.4 DATASETS + +We used two protein sequence datasets from the TAPE repository for the analysis: the ProteinNet dataset (AlQuraishi, 2019; Fox et al., 2013; Berman et al., 2000; Moult et al., 2018) and the Secondary Structure dataset (Rao et al., 2019; Berman et al., 2000; Moult et al., 2018; Klausen et al., 2019). The former was used for analysis of amino acids and contact maps, and the latter was used for analysis of secondary structure. We additionally created a third dataset for binding site and post-translational modification (PTM) analysis from the Secondary Structure dataset, which was augmented with binding site and PTM annotations obtained from the Protein Data Bank's Web API. We excluded any sequences for which annotations were not available. The resulting dataset sizes are shown in Table 2. For the analysis of attention, a random subset of 5000 sequences from the training split of each dataset was used, as the analysis was purely evaluative. For training and evaluating the diagnostic classifier, the full training and validation splits were used. + +Table 2: Datasets used in analysis + +
DatasetTrain sizeValidation size
ProteinNet25299224
Secondary Structure86782170
Binding Sites / PTM57341418
+ +# C ADDITIONAL RESULTS OF ATTENTION ANALYSIS + +# C.1 SECONDARY STRUCTURE + +![](images/8456da6a83d53fb526189e0f42e2e08f0d40e88a903915110466760d1b1d5933.jpg) +(a) TapeBert + +![](images/5c07998298315e74d3ebef9badc4d7e62766f30bb2e60305393282601b556976.jpg) +(b) ProtAlbert + +![](images/b9ac3d278c8de0e4e10cbfea2ec02cc5ce1885277fc6904236f1b0b7f321f400.jpg) +(c) ProtBert + +![](images/e08950bb18341d4ef0874c01f4fe0de31d9100234c1ec9832ff082a8bb91b160.jpg) +(d) ProtBert-BFD + +![](images/6d84eb90334fea1eb9b3f6b431b863ab815c0d3aa1fef3f024ea5bcd79a461ff.jpg) +(e) ProtXLNet +Figure 8: Percentage of each head's attention that is focused on Helix secondary structure. + +![](images/06854af82c8153d78a746af78d8586cdd7f35375fc7344d04fefa49fed891dcf.jpg) +(a) TapeBert + +![](images/d68483a147ad40b3cdcf0d9bf8fb6ef28a051028272dc43b07b9c3db518757fa.jpg) +(b) ProtAlbert + +![](images/831d57a6540893a054afbc8d13cd1219fe8a17d01b22b8c507eca9f9798d9fd6.jpg) +(c) ProtBert + +![](images/dd8d87d0cbcc4385b336b57717f3c5d1b0dbf7d74cbcdb0e32fabb33e0d55924.jpg) +(d) ProtBert-BFD +Figure 9: Percentage of each head's attention that is focused on Strand secondary structure. + +![](images/5c1f8ef79b018a5e4a7b7658b8a4af9241ed49536d042d4bf72394a3e696bf94.jpg) +(e) ProtXLNet + +![](images/156473e9c594f802578666efd185799609240b896033f8dc73f44d440ca847ed.jpg) +(a) TapeBert + +![](images/fc1a0b7b0337410a4218296f93865599b3bfd2369f88e095847e61ba6a55850c.jpg) +(b) ProtAlbert + +![](images/64cd353964c2ef66aa01b9e7ee858776c496079e8f2b586b57b28362673a8238.jpg) +(c) ProtBert +Figure 10: Percentage of each head's attention that is focused on Turn/Bend secondary structure. + +![](images/dfd86ad7d58bf747898e422307d0b831cf882a45dcc0708bddc839a6daef163d.jpg) +(d) ProtBert-BFD + +![](images/dba5e66a2c75a437fbae8f71da73c89cafa54ff509b4e4066805b1befa352198.jpg) +(e) ProtXLNet + +# C.2 CONTACT MAPS: STATISTICAL SIGNIFICANCE TESTS AND NULL MODELS + +![](images/6e27e10a508ab2494e16fbbaa7e4f779f92e22a132c897c1ba4d2949dabd586f.jpg) +(a) TapeBert + +![](images/f1f12ccc58b1a173e9caeae37e425b66207f3250583e9be557de262cb9285449.jpg) +(b) ProtAlbert + +![](images/e5af7492f52ae89b4c517ca8909d67479ebeca8e7374f2bc6ba9b023e36d2c49.jpg) +(c) ProtBert + +![](images/e98488a102653c1590d00183a56de06b7d27df069a65851349fc592689f3b186.jpg) +(d) ProtBert-BFD + +![](images/3b030350163fe7b96dd00fdf262cfa0363e412cb577254f1f0e590bee14e1639.jpg) +(e) ProtXLNet + +![](images/3f6403bd11c0e0db6ab26ce4c144d0ae55f76eec4012f2b352d170b8fae8f595.jpg) +Figure 11: Top 10 heads (denoted by $<\text{layer}>$ - $<\text{head}>$ ) for each model based on the proportion of attention aligned with contact maps [95% conf. intervals]. The differences between the attention proportions and the background frequency of contacts (orange dashed line) are statistically significant $(p < 0.00001)$ . Bonferroni correction applied for both confidence intervals and tests (see App. B.2). + +![](images/f1395339feb1bd4dd984ed8eeea8a9dfd4e13333c431463309a97410ad9e36fd.jpg) +(b) ProtAlbert-Random + +![](images/9804e9b597537ed084068883ddad97e875916f149dce83e2d5e080734963c64d.jpg) +(a) TapeBert-Random + +![](images/5cb05b31e52a93551383937389b58058d039d5b8e1d4782ba088390756682c74.jpg) +(d) ProtBert-BFD-Random + +![](images/d262d311207273b268da7cf6ecb0346056194643c6bafbf1d74e6c38250a5f44.jpg) +(c) ProtBert-Random +(e) ProtXLNet-Random +Figure 12: Top-10 contact-aligned heads for null models. See Appendix B.2 for details. + +# C.3 BINDING SITES: STATISTICAL SIGNIFICANCE TESTS AND NULL MODEL + +![](images/cb9fe4449f341b8d9df4162cabc72e3a5727e5c9d88b0bde927ac74e951ed658.jpg) +(a) TapeBert + +![](images/d5f95b612811dda221949e322f1e3a01107df1ca166010f3fd7ffaa904395f81.jpg) +(b) ProtAlbert + +![](images/7ce75edc80891d1b17c244356ce78ec0488cfb02a8702d09733e810f2ada229a.jpg) +(c) ProtBert + +![](images/730f1555047e81482aa7cc336815028570b41a1ca55284dcbb1b8763779a6bd6.jpg) +(d) ProtBert-BFD + +![](images/6cf85d7072236d5c1477821a3dfb8f7d39766b62822973769aaf2533dc862f59.jpg) +(e) ProtXLNet + +![](images/dc1364a5e1041b10f92726f68583468db376f619061efac745c317e37c4a111a.jpg) +Figure 13: Top 10 heads (denoted by $<\text{layer}>$ - $<\text{head}>$ ) for each model based on the proportion of attention focused on binding sites [95% conf. intervals]. Differences between attention proportions and the background frequency of binding sites (orange dashed line) are all statistically significant $(p < 0.00001)$ . Bonferroni correction applied for both confidence intervals and tests (see App. B.2). +(a) TapeBert-Random + +![](images/c8c11dbc3bee5d3b7cf71113d98a7e4db0d8cbe9456a64bf0f6db3a1b4d15536.jpg) +(b) ProtAlbert-Random + +![](images/c0b50a7334231846e80113b87f7996d21f93f39e85cb20915335472de537cc79.jpg) +(c) ProtBert-Random + +![](images/ebfc1fb71db1be5e4ca61af2af2203b23cf35c701f28492dea3d5d94e6cb75d8.jpg) +(d) ProtBert-BFD-Random + +![](images/ef076fcac68ca8090ed5df9e17cdea79d6a15ea4dcfc1aa16486e40284d26340.jpg) +(e) ProtXLNet-Random +Figure 14: Top-10 heads most focused on binding sites for null models. See Appendix B.2 for details. + +# C.4 POST-TRANSLATIONAL MODIFICATIONS (PTMS) + +![](images/a0cadc17a6bf95cceafb98e324cb972233d9d0efca057094bf4030f37593cb98.jpg) +(a) TapeBert + +![](images/2431e28f1b0ae882b951a7917f7475c14a9c1728393ea2d96ef569b4ce8f6970.jpg) +(b) ProtAlbert + +![](images/7e52096e025563f3d9bdd19d09a766b4bef93067283c1b6f2a6bb0c5a6ae0658.jpg) +(c) ProtBert + +![](images/bdf644e94f6f8dc7486fa19219d0256a2f2a3ba30b9bfbd06fe25810a720d8d0.jpg) +(d) ProtBert-BFD +Figure 15: Percentage of each head's attention that is focused on post-translational modifications. + +![](images/0b8e12c5753836f9fec7ba6da2359eefea18281c2d995d98f83ae275f2c278c6.jpg) +(e) ProtXLNet + +![](images/200e077adf1a169782e01cd194d0eed8d59824cdce33298e49ba0e32e9f333bb.jpg) +(a) TapeBert + +![](images/118c338f870858f144a57844e197a1e404133e48ac4f3045f24eee6f33c0e507.jpg) +(b) ProtAlbert + +![](images/cb647e18323d8a5b4b481a39976a03d41d09723419b7fdf498ebfd25d6a5485a.jpg) +(c) ProtBert + +![](images/fa47d495e1e2ac8f45ff127e7b786acc68404f5bc00f414e4b17535153e4a2de.jpg) +(d) ProtBert-BFD + +![](images/b0568f80683a448b5eaf48371f4b616a65ec9df12838b21c6b5ee5bae484723e.jpg) +(e) ProtXLNet + +![](images/66b2f715ad0e8938e424bd49c57709cf84590f676eb7d5b3262022f36bb4f615.jpg) +Figure 16: Top 10 heads (denoted by $<\text{layer}>$ - $<\text{head}>$ ) for each model based on the proportion of attention focused on PTM positions [95% conf. intervals]. The differences between the attention proportions and the background frequency of PTMs (orange dashed line) are statistically significant $(p < 0.00001)$ . Bonferroni correction applied for both confidence intervals and tests (see App. B.2). + +![](images/1710bc8f9f7d925b5fad622640b035a465efcaeb5d17c07a71fc22cd267b675f.jpg) +(b) ProtAlbert-Random + +![](images/84c585f20e5a747774338a7c3ddac90005e0ad9fee4be11adbec86a5dd97ee61.jpg) +(a) TapeBert-Random + +![](images/c62ea7490906da48839a0beec2c9883b54e0b4b678b4e37989fb77b1d89db115.jpg) +(d) ProtBert-BFD-Random + +![](images/c8a80205e1dafd2040a5c7af5140b17066e1e20c80e63d812de99daf3c5015de.jpg) +(c) ProtBert-Random +(e) ProtXLNet-Random +Figure 17: Top-10 heads most focused on PTMs for null models. See Appendix B.2 for details. + +# C.5 AMINO ACIDS + +![](images/2bd9be6da7810e5c258da7ee0814287472e8155c1458ed9bd552f5cc05ccab16.jpg) +(a) ALA + +![](images/dc7ce0e423f5f373c32b6b27068c646b418e931c8901d608b604ba0fcc8c0169.jpg) +(b) ARG + +![](images/830c57498e6834815a52ba8e892527d7618fd4eb2e782221f847bc061a77194f.jpg) +(c) ASN + +![](images/2200295da09fe8e39d0b67984c19c4e7e5071661dcf3fa78e5696e6b199cea32.jpg) +(d) ASP + +![](images/094b6f1816f85b9a6d8720f32d07fc6f4090b2b9e1ddf68cab0b5c541ec7d46d.jpg) +(e) CYS + +![](images/e09afe58f05a21a87cc36b8938354ba84af521bdb2f779c510ea96a8b6e6bb69.jpg) +(f) GLN + +![](images/37aabba9333b9d493f9a5a9c382ade6c03d9d8b8a0e884385cba64add7b3a92e.jpg) +(g) GLU + +![](images/af494af486b0e24a8f33a18e60ec10eadab225e5324478d72202105eb1d0641c.jpg) +(h) GLY + +![](images/ecb4a282f78a8a4e5196d91e2e6e084ea8300ece73303edbd59731d77181b85c.jpg) +(i) HIS + +![](images/e9e4572e3030093ed78adce8881920f8181a4353bcd462df7f240a1dc02a013e.jpg) +(j) ILE + +![](images/d6809df6d99adbb0fa5514c96073ccfdbab198f701f952999c16e44180152d9a.jpg) +(k)LEU + +![](images/1ff5c0331df48af0edd05d1a32c5279b53ddcee5a14accda92ad2ca94bd52585.jpg) +(1) LYS + +![](images/55c5a9d112dc27779888132c2ee2d1f419544e8e279ae2af61578f2bfa9347ae.jpg) +(m) MET + +![](images/bc0196926c0609a7adb2a52d2e2d037943169add03dbe2c886980f5cf2821dc6.jpg) +(n) PHE + +![](images/d82b7e7748b508d1c998fab0ce12b6e7a8f2e03dafc921a1175f0944a1989ade.jpg) +(o) PRO +Figure 18: Percentage of each head's attention that is focused on the given amino acid, averaged over a dataset (TapeBert). + +![](images/f7761ebfd08f239bb28b8eaae70d27b9daeefe04cd98d3a3ef55c2757164df59.jpg) +(a) SER + +![](images/6984f8f7e165c57339e694f456d5223535debeeac30dade0f46e7465bfe99f5a.jpg) +(b) THR + +![](images/8e1979452fe409892af12b5d7866a82d49be078540cc141a6e74ead78e36783b.jpg) +(c) TRP + +![](images/826bb56bcc8d8dbc3eb736bde63cde8abcb8ec0981abffa5d8003de73bb410a7.jpg) +(d) TYR + +![](images/def6722d218cc9b50d144313f015c4a88c0a6d396dd11bdfe08647b0ac52820a.jpg) +(e) VAL +Figure 19: Percentage of each head's attention that is focused on the given amino acid, averaged over a dataset (cont.) + +Table 3: Amino acids and the corresponding maximally attentive heads in the standard and randomized versions of TapeBert. The differences between the attention percentages for TapeBert and the background frequencies of each amino acid are all statistically significant $(p < 0.00001)$ taking into account the Bonferroni correction. See Appendix B.2 for details. The bolded numbers represent the higher of the two values between the standard and random models. In all cases except for Glutamine, which was the amino acid with the lowest top attention proportion in the standard model (7.1), the standard TapeBert model has higher values than the randomized version. + +
AbbrevCodeNameBackground %TapeBertTapeBert-Random
Top HeadAttn %Top HeadAttn %
AlaAAlanine7.912-1125.511-1212.1
ArgRArginine5.212-863.212-78.4
AsnNAsparagine4.38-244.88-26.7
AspDAspartic acid5.812-679.95-410.7
CysCCysteine1.311-683.211-69.3
GlnQGlutamine3.811-77.112-19.2
GluEGlutamic acid6.911-716.211-411.8
GlyGGlycine7.12-1198.111-814.6
HisHHistidine2.79-1056.711-65.4
IleIIsoleucine5.611-1027.09-510.6
LeuLLeucine9.42-1244.112-1113.9
LysKLysine6.012-829.46-1112.9
MetMMethionine2.33-1073.59-36.2
PheFPhenylalanine3.912-322.712-16.7
ProPProline4.61-1198.310-67.6
SerSSerine6.412-736.111-1211.0
ThrTThreonine5.412-719.010-49.0
TrpWTryptophan1.311-468.19-23.0
TyrYTyrosine3.412-351.612-116.6
ValVValine6.812-1134.08-215.0
\ No newline at end of file diff --git a/bertologymeetsbiologyinterpretingattentioninproteinlanguagemodels/images.zip b/bertologymeetsbiologyinterpretingattentioninproteinlanguagemodels/images.zip new file mode 100644 index 0000000000000000000000000000000000000000..4695851ed72040b05b972622f45c1dea7a342331 --- /dev/null +++ b/bertologymeetsbiologyinterpretingattentioninproteinlanguagemodels/images.zip @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:91ce58fb983b272af0f72968597efb665148bb8230ad92c48cd2b3aa72f2d0e5 +size 1420471 diff --git a/bertologymeetsbiologyinterpretingattentioninproteinlanguagemodels/layout.json b/bertologymeetsbiologyinterpretingattentioninproteinlanguagemodels/layout.json new file mode 100644 index 0000000000000000000000000000000000000000..1174ee45579c2d0c6996a2ebc6cae504b31859b3 --- /dev/null +++ b/bertologymeetsbiologyinterpretingattentioninproteinlanguagemodels/layout.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:13037fe6ae15f0074c515caff07f8f92efe4803ceedde1c68936f85b0c2acddf +size 770367 diff --git a/betterfinetuningbyreducingrepresentationalcollapse/a5ab975b-3420-4821-a0d2-5bffad9cfb75_content_list.json b/betterfinetuningbyreducingrepresentationalcollapse/a5ab975b-3420-4821-a0d2-5bffad9cfb75_content_list.json new file mode 100644 index 0000000000000000000000000000000000000000..26f66ed225b69e9ccc5f28507d41d21a4e90c102 --- /dev/null +++ b/betterfinetuningbyreducingrepresentationalcollapse/a5ab975b-3420-4821-a0d2-5bffad9cfb75_content_list.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1cc716ec40645afdd2608d427c87eae8750334262980d4c0f4ca0825bbd5f8ba +size 77602 diff --git a/betterfinetuningbyreducingrepresentationalcollapse/a5ab975b-3420-4821-a0d2-5bffad9cfb75_model.json b/betterfinetuningbyreducingrepresentationalcollapse/a5ab975b-3420-4821-a0d2-5bffad9cfb75_model.json new file mode 100644 index 0000000000000000000000000000000000000000..11fe3896d4943061b98f09af6741df38e450c777 --- /dev/null +++ b/betterfinetuningbyreducingrepresentationalcollapse/a5ab975b-3420-4821-a0d2-5bffad9cfb75_model.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a7f5130349ad5797e5db81ca1ade032249635b1d2d246a519d9f89ce3f6249d8 +size 90914 diff --git a/betterfinetuningbyreducingrepresentationalcollapse/a5ab975b-3420-4821-a0d2-5bffad9cfb75_origin.pdf b/betterfinetuningbyreducingrepresentationalcollapse/a5ab975b-3420-4821-a0d2-5bffad9cfb75_origin.pdf new file mode 100644 index 0000000000000000000000000000000000000000..e754c29742c00a3fae36ad88bedfebe97e6e2387 --- /dev/null +++ b/betterfinetuningbyreducingrepresentationalcollapse/a5ab975b-3420-4821-a0d2-5bffad9cfb75_origin.pdf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2cfe916b4a0384286b0ad18fd766df869e49546d450fa054e2e70247b7512a90 +size 458254 diff --git a/betterfinetuningbyreducingrepresentationalcollapse/full.md b/betterfinetuningbyreducingrepresentationalcollapse/full.md new file mode 100644 index 0000000000000000000000000000000000000000..fadcee07981d1c372c48789e15b4f2895d400448 --- /dev/null +++ b/betterfinetuningbyreducingrepresentationalcollapse/full.md @@ -0,0 +1,335 @@ +# BETTER FINE-TUNING BY REDUCING REPRESENTATIONAL COLLAPSE + +Armen Aghajanyan, Akshit Shrivastava, Anchit Gupta & Naman Goyal + +Facebook + +{armenag, akshats, anchit, naman}@fb.com + +Luke Zettlemoyer & Sonal Gupta + +Facebook + +{lsz, sonalgupta}@fb.com + +# ABSTRACT + +Although widely adopted, existing approaches for fine-tuning pre-trained language models have been shown to be unstable across hyper-parameter settings, motivating recent work on trust region methods. This paper presents a simplified and efficient method rooted in trust region theory that replaces previously used adversarial objectives with parametric noise (sampling from either a normal or uniform distribution), thereby discouraging representation change during fine-tuning when possible without hurting performance. We also introduce a new analysis to motivate the use of trust region methods more generally, by studying representational collapse; the degradation of generalizable representations from pre-trained models as they are fine-tuned for a specific end task. Extensive experiments show that our fine-tuning method matches or exceeds the performance of previous trust region methods on a range of understanding and generation tasks (including DailyMail/CNN, Gigaword, Reddit TIFU, and the GLUE benchmark), while also being much faster. We also show that it is less prone to representation collapse; the pre-trained models maintain more generalizable representations every time they are fine-tuned. + +# 1 INTRODUCTION + +Pre-trained language models (Radford et al., 2019; Devlin et al., 2018; Liu et al., 2019; Lewis et al., 2019; 2020) have been shown to capture a wide array of semantic, syntactic, and world knowledge (Clark et al., 2019), and provide the defacto initialization for modeling most existing NLP tasks. However, fine-tuning them for each task is a highly unstable process, with many hyperparameter settings producing failed fine-tuning runs, unstable results (considerable variation between random seeds), over-fitting, and other unwanted consequences (Zhang et al., 2020; Dodge et al., 2020). + +Recently, trust region or adversarial based approaches, including SMART (Jiang et al., 2019) and FreeLB (Zhu et al., 2019), have been shown to increase the stability and accuracy of fine-tuning by adding additional constraints limiting how much the fine-tuning changes the initial parameters. However, these methods are significantly more computationally and memory intensive than the more commonly adopted simple-gradient-based approaches. + +This paper presents a lightweight fine-tuning strategy that matches or improves performance relative to SMART and FreeLB while needing just a fraction of the computational and memory overhead and no additional backward passes. Our approach is motivated by trust region theory while also reducing to simply regularizing the model relative to parametric noise applied to the original pre-trained representations. We show uniformly better performance, setting a new state of the art for RoBERTa fine-tuning on GLUE and reaching state of the art on XNLI using no novel pre-training approaches (Liu et al., 2019; Wang et al., 2018; Conneau et al., 2018). Furthermore, the low overhead of our family of fine-tuning methods allows our method to be applied to generation tasks where we consistently outperform standard fine-tuning, setting state of the art on summarization tasks. + +We also introduce a new analysis to motivate the use of trust-region-style methods more generally, by defining a new notion of representational collapse and introducing a new methodology for measuring it during fine-tuning. Representational collapse is the degradation of generalizable representations of pre-trained models during the fine-tuning stage. We empirically show that standard fine-tuning degrades generalizable representations through a series of probing experiments on GLUE tasks. Furthermore, we attribute this phenomenon to using standard gradient descent algorithms for the fine-tuning stage. We also find that (1) recently proposed fine-tuning methods rooted in trust region, i.e., SMART, can alleviate representation collapse, and (2) our methods alleviate representational collapse to an even greater degree, manifesting in better performance across almost all datasets and models. + +Our contributions in this paper are the following. + +- We propose a novel approach to fine-tuning rooted in trust-region theory, which we show directly alleviates representational collapse at a fraction of the cost of other recently proposed fine-tuning methods. +- Through extensive experimentation, we show that our method outperforms standard fine-tuning methodology following recently proposed best practices from Zhang et al. (2020). We improve various SOTA models from sentence prediction to summarization, from monolingual to cross-lingual. +- We further define and explore the phenomena of representational collapse in fine-tuning and directly correlate it with generalization in tasks of interest. + +# 2 LEARNING ROBUST REPRESENTATIONS THROUGH REGULARIZED FINE-TUNING + +We are interested in deriving methods for fine-tuning representations that provide guarantees on the movement of representations, in the sense that they do not forget the original pre-trained representations when they are fine-tuned for new tasks (see Section 4 for more details). We introduce a new fine-tuning method rooted in an approximation to trust region, which provides guarantees for stochastic gradient descent algorithms by bounding some divergence between model at update $t$ and $t + 1$ (Pascanu & Bengio, 2013; Schulman et al., 2015b; Jiang et al., 2019). + +Let $f: \mathbb{R}^{m \times n} \to \mathbb{R}^p$ be a function which returns some pre-trained representation parameterized by $\theta_f$ from $m$ tokens embedded into a fixed vector of size $n$ . Let the learned classification head $g: \mathbb{R}^p \to \mathbb{R}^q$ be a function which takes an input from $f$ and outputs a valid probability distribution parameterized by $\theta_g$ in $q$ dimensions and let $X$ be our dataset. In the case of generation, we can assume the classification head is simply an identity function or softmax depending on the loss function. Let $\mathcal{L}(\theta)$ denote a loss function given by $\theta = [\theta_f, \theta_g]$ . + +We are interested in minimizing $\mathcal{L}$ with respect to $\theta$ such that each update step is constrained by movement in the representational density space $p(f)$ . More formally given an arbitrary $\epsilon$ + +$$ +\underset {\Delta \theta} {\arg \min } \mathcal {L} (\theta + \Delta \theta) \tag {1} +$$ + +$$ +s. t. K L (p (f (\cdot ; \theta_ {f})) | | p (f (\cdot ; \theta_ {f} + \Delta \theta_ {f}))) = \epsilon +$$ + +This constrained optimization problem is equivalent to doing natural gradient descent directly over the representations (Pascanu & Bengio, 2013). Unfortunately, we do not have direct access to the density of representations; therefore, it is not trivial to directly bound this quantity. Instead, we propose to do natural gradient over $g \cdot f$ with an additional constraint that $g$ is at most 1-Lipschitz (which naturally constrains change of representations, see Section A.1 in the Appendix). Traditional computation of natural gradient is computationally prohibitive due to the need for inverting the Hessian. An alternative formulation of natural gradient can be stated through mirror descent, using Bregmann divergences (Raskutti & Mukherjee, 2015; Jiang et al., 2019). + +This method primarily serves as a robust regularizer by preventing large updates in the model's probability space. This family of methods is classically known as trust-region methods (Pascanu & Bengio, 2013; Schulman et al., 2015a). + +$$ +\mathcal {L} _ {S M A R T} (\theta , f, g) = \mathcal {L} (\theta) + \lambda \mathbb {E} _ {x \sim X} \left[ \sup _ {x ^ {\sim}: | x ^ {\sim} - x | \leq \epsilon} K L _ {S} (g \cdot f (x) \| g \cdot f \left(x ^ {\sim}\right)) \right] \tag {2} +$$ + +However, the supremum is computationally intractable. An approximation is possible by doing gradient ascent steps, similar to finding adversarial examples. This was first proposed by SMART with a symmetrical $KL_{S}(X,Y) = KL(X||Y) + KL(Y||X)$ term (Jiang et al., 2019). + +We propose an even simpler approximation which does not require extra backward computations and empirically works as well as or better than SMART. We altogether remove the adversarial nature from SMART and instead optimize for a smoothness parameterized by $KL_{S}$ . Furthermore, we optionally also add a constraint on the smoothness of $g$ by making it at most 1-Lipschitz, the intuition being if we can bound the volume of change in $g$ we can more effectively bound $f$ . + +$$ +\mathcal {L} _ {R 3} (f, g, \theta) = \mathcal {L} (\theta) + \lambda \mathbb {E} _ {x \sim X} \left[ K L _ {S} (g \cdot f (x) \| g \cdot f (x + z)) \right] \quad \text {R 3 F M e t h o d} \tag {3} +$$ + +$$ +s. t. \quad z \sim \mathcal {N} (0, \sigma^ {2} I) \text {o r} z \sim \mathcal {U} (- \sigma , \sigma) \tag {4} +$$ + +$$ +s. t. \quad L i p \{g \} \leq 1 \quad \text {O p t i o n a l R 4 F M e t h o d} \tag {5} +$$ + +where $KL_{S}$ is the symmetric KL divergence and $z$ is a sample from a parametric distribution. In our work we test against two distributions, normal and uniform centered around 0. We denote this as the Robust Representations through Regularized Finetuning (R3F) method. + +Additionally we propose an extension to R3F (R4F; Robust Representations through Regularized and Reparameterized Finetuning, which reparameterizes $g$ to be at most 1-Lipschitz via Spectral Normalization (Miyato et al., 2018). By constraining $g$ to be at most 1-Lipschitz, we can more directly bound the change in representation (Appendix Section A.1). Specifically we scale all the weight matrices of $g$ by the inverse of their largest singular values $W_{SN} \coloneqq W / \sigma(W)$ . Given that spectral radius $\sigma(W_{SN}) = 1$ we can bound $Lip\{g\} \leq 1$ . In the case of generation, $g$ does not have any weights therefore we can only apply the R3F method. + +# 2.1 RELATIONSHIP TO SMART AND FREELB + +Our method is most closely related to the SMART algorithm, which utilizes an auxiliary smoothness inducing regularization term, which directly optimizes the Bregmann divergence mentioned above in Equation 2 (Jiang et al., 2019). + +SMART solves the supremum by using an adversarial methodology to ascent to the largest KL divergence with an $\epsilon$ -ball. We instead propose to remove the ascent step completely, optionally fixing the smoothness of the classification head $g$ . This completely removes SMART's adversarial nature and is more akin to optimizing the smoothness of $g \cdot f$ directly. Another recently proposed adversarial method for fine-tuning, FreeLB optimizes a direct adversarial loss $\mathcal{L}_{FreeLB}(\theta) = \sup_{\Delta \theta: |\Delta \theta| \leq \epsilon} \mathcal{L}(\theta + \Delta \theta)$ through iterative gradient ascent steps. This is similar to SMART in the sense that both are adversarial and require gradient ascent steps. Unfortunately, the need for extra forward-backward passes can be prohibitively expensive when fine-tuning large pre-trained models (Zhu et al., 2019). + +
FPBPxFP
FreeLB1 + S1 + S3 + 3S
SMART1 + S1 + S3 + 3S
R3F/R4F214
Standard113
+ +Table 1: Computational cost of recently proposed fine-tuning algorithms. We show Forward Passes (FP), Backward Passes (BP) as well as computation cost as a factor of forward passes (xFP). $S$ is the number of gradient ascent steps, with a minimum of $S \geq 1$ + +Our method is significantly more computationally effi + +cient than adversarial based fine-tuning methods, as seen in Table 1. We show that this efficiency does not hurt performance; we can match or exceed FreeLB and SMART on a large number of tasks. In addition, the relatively low costs of our methods allow us to improve over fine-tuning on an array of generation tasks. + +# 3 EXPERIMENTS + +We will first measure performance by fine-tuning on a range of tasks and languages. The next sections report why methods rooted in trust region, including ours, outperform standard fine-tuning. We aimed for fair comparisons throughout all of our experiments by using fixed budget hyperparameters searches across all methods. Furthermore, for computationally tractable tasks, we report median/max numbers as well as show distributions across a large number of runs. + +# 3.1 SENTENCE PREDICTION + +# GLUE + +We will first test R3F and R4F on sentence classification tasks from the GLUE benchmark (Wang et al., 2018). We select the same subset of GLUE tasks that have been reported by prior work in this space (Jiang et al., 2019): MNLI (Williams et al., 2018), QQP (Iyer et al., 2017), RTE (Bentivogli et al., 2009), QNLI (Rajpurkar et al., 2016), MRPC (Dolan & Brockett, 2005), CoLA (Warstadt et al., 2018), SST-2 (Socher et al., 2013).1 + +Consistent with prior work (Jiang et al., 2019; Zhu et al., 2019), we focus on improving the performance of RoBERTa-Large based models in the single-task setting (Liu et al., 2019). We report the performance of all models on the GLUE development set. + +![](images/64086000aa3e4ca1ad29bb37e7789401d88d72214a29e9057e552d34f054b913.jpg) +Figure 1: Empirical evidence towards the computational benefits of our method we present training wall time analysis on the SST-2 dataset. Each method includes a violin plot for 10 random runs. We define wall-time as the training time in seconds to best checkpoint. + +We fine-tune each of the GLUE tasks with four methods: Standard (STD), the traditional fine-tuning scheme as done by RoBERTa (Liu et al., 2019); Standard++ (STD++), a variant of standard fine-tuning that incorporates recently proposed best practices for fine-tuning, specifically longer fine-tuning and using bias correction in Adam (Zhang et al., 2020); and our proposed methods R3F and R4F. We compare against the numbers reported by SMART, FreeLB, and RoBERTa on the validation set. For each method, we applied a hyper-parameter search with equivalent fixed budgets per method. Fine-tuning each task has task-specific hyperparameters described in the Appendix (Section A.2). After finding the best hyperparameters, we replicated experiments with optimal parameters across ten different random seeds. Our numbers reported are the maximum of 10 seeds to be comparable with other benchmarks in Table 2. + +In addition to showing the best performance, we also show the distribution of various meth + +ods across ten seeds to demonstrate the stability properties of individual methods in Figure 2. + +R3F and R4F unanimously improve over Standard and Standard++ fine-tuning. Furthermore, our methods match or exceed adversarial methods such as SMART/FreeLB at a fraction of the computational cost when comparing median runs. We show computational cost in Figure 1 for a single task, but the relative behavior of wall times is consistent across all other GLUE tasks. We note that we could not find a discernable difference in the experimental setting, which would make the selection between R3F vs. R4F trivial. + +![](images/a629ef0f83fca07fba2287c1fb19926336aa4bdece6976b7e64cb133477f4ae7.jpg) +Figure 2: We show the results of our method against Standard++ fine-tuning and SMART across 3 tasks. Across 10 random seeds both max and median of our runs were higher using our method than both SMART and Standard++. + +![](images/df6d69ffe2a3ac511184c68451b7a87f75c277518118eae3738fc0346f287590.jpg) + +![](images/2c0c5661ffefc0151e86dd4f04336310a279296d93a83f8a74ee2492ea723acb.jpg) + +
MNLI Acc-m/mmQQP Acc/F1RTE AccQNLI AccMRPC AccCoLA MccSST-2 Acc
STD90.2/-92.2/-86.694.789.168.096.4
STD++91.0/-92.2/-87.494.891.169.496.9
FreeLB90.6/-92.6/-88.195.0-71.196.7
SMART91.1/91.392.4/89.892.095.689.270.696.9
R3F91.1/91.392.4/89.988.595.391.671.297.0
R4F90.1/90.892.5/89.988.895.190.970.697.1
+ +
MNLI Acc-m/mmQQP Acc/F1RTE AccQNLI AccMRPC AccCoLA MccSST-2 Acc
90.2/-91.9/-86.692.184.466.296.4
90.8/-92.1/-87.492.589.168.496.9
-/--/------
90.85/91.1091.7/88.289.594.883.969.496.6
91.10/91.1092.1/88.488.495.191.270.696.2
90.0/90.691.8/88.288.394.890.170.196.8
+ +# XNLI + +We hypothesize that staying closer to the original representations is especially crucial for cross-lingual tasks, especially in the zero-shot fashion where drifting away from pre-trained representations for a single language might manifest in loss of cross-lingual capabilities. In particular, we take a look at the popular XNLI benchmark, containing 15 languages (Conneau et al., 2018). We compare our method against the standard trained XLM-R model in the zero-shot setting (Conneau et al., 2019). + +Table 2: We present our best results on the GLUE development set for various fine-tuning methods applied to the RoBERTa Large model. On the left side table, we present our best numbers and numbers published in other papers. On the right side, we present median numbers from 10 runs for the mentioned methods. + +
ModelenfresdeelbgrutrarvithzhhiswurAvg
XLM-R Base85.879.780.778.777.579.678.174.273.876.574.676.772.466.568.376.2
XLM-R Large89.184.185.183.982.984.081.279.679.880.878.180.276.973.973.880.9
+R3F89.484.285.183.783.684.682.380.780.681.179.480.177.372.674.281.2
+R4F89.684.785.284.283.684.682.580.380.580.979.280.678.272.773.981.4
InfoXLM89.784.585.584.183.484.281.380.980.480.878.980.977.974.873.781.4
+ +Table 3: To remain consistent with prior experiments, we report an average of 5 runs of zero-shots results on the XNLI test set for our method applied to XLM-R Large. Various versions of our method win over the majority of languages. The bottom row shows the current SOTA on XNLI, which requires the pre-training of a novel model. + +We present our result in Table 3. R3F and R4F dominate standard pre-training on 14 out of the 15 languages in the XNLI task. R4F improves over the best known XLM-R XNLI results reaching SOTA with an average language score of 81.4 across five runs. The current state of the art, INFO-XLM required a novel pre-training method to reach the same numbers (Chi et al., 2020). + +
CNN/DailyMailGigawordReddit TIFU (Long)
Random Transformer38.27/15.03/35.4835.70/16.75/32.8315.89/1.94/12.22
BART44.16/21.28/40.9039.29/20.09/35.6524.19/8.12/21.31
PEGASUS44.17/21.47/41.1139.12/19.86/36.2426.63/9.01/21.60
ERNIE-GEN44.02/21.17/41.2639.25/ 20.25/36.53-
ProphetNet (Old SOTA)44.20/21.17/41.3039.51/20.42/36.69-
BART+R3F (New SOTA)44.38/21.53/41.1740.45/20.69/36.5630.31/10.98/24.74
+ +Table 4: Our results on various summarization data-sets. We report Rouge-1, Rouge-2 and Rouge-L per element in table. Following PEGASUS, we bold the best number and numbers within 0.15 of the best. + +# 3.2 SUMMARIZATION + +While prior work in non-standard finetuning methods tends to focus on sentence prediction and GLUE tasks (Jiang et al., 2019; Zhu et al., 2019; Zhang et al., 2020), we look to improve abstractive summarization, due to its additional complexity and computational cost, specifically we look at three datasets: CNN/Dailymail (Hermann et al., 2015), Gigaword (Napoles et al., 2012) and Reddit TIFU (Kim et al., 2018). + +Like most other NLP tasks, summarization recently has been dominated by the fine-tuning of large pre-trained models. For example, PEGASUS explicitly defines a pre-training objective to facilitate the learning of representations tailored to summarization tasks manifesting in state-of-the-art performance on various summarization benchmarks (Zhang et al., 2019). ProphetNet (Yan et al., 2020) improved over these numbers by introducing their own novel self-supervised task as did ERNIEGEN (Xiao et al., 2020). + +Independent of the pre-training task, standard fine-tuning on downstream tasks follows a simple formula of using a label smoothing loss while directly fine-tuning the whole model without adding any new parameters. We propose the addition of the R3F term directly to the label smoothing loss. We note that R4F cannot be applied directly to generation tasks due to its reparameterization nature. + +We present our results in Table 4. Our method (R3F) outperforms standard fine-tuning across the board for three tasks across all of the ROUGE metric variants. Notably, we improve Gigaword and Reddit TIFU ROUGE-1 scores by a point and four points, respectively. + +# 4 REPRESENTATIONAL COLLAPSE + +Catastrophic forgetting, proposed initially as catastrophic interference, is a phenomenon that occurs during sequential training where new updates interfere catastrophically with previous updates manifesting in forgetting of particular examples for a fixed task (McCloskey & Cohen, 1989). Catastrophic forgetting has been historically associated with continuous learning, and recent work (Mosbach et al., 2020) showed that catastrophic forgetting concerning the original MLM objective is not detrimental for end task training. Instead, the issue lies in optimization. Inspired by this work, we explore the related problem of representational collapse, the degradation of generalizable representations of pre-trained models during the fine-tuning stage. This definition is independent of a specific fine-tuning task but is rather over the internal representations generalizability over a large union of tasks. Another view of this phenomenon is that fine-tuning collapses the wide range of information available in the representations into a smaller set needed only for the immediate task and particular training set. + +Measuring such degradations is non-trivial. Simple metrics such as the distance between pre-trained representations and fine-tuned representations are not sufficient (e.g., adding a constant to the pretrained representations will not change representation power, but will change distances). One approach would be to estimate mutual information of representations across tasks before and after fine-tuning, but the estimation of mutual information is notoriously hard, especially in high-dimensions (Tschannen et al., 2019). We instead propose a series of probing experiments meant to provide us + +![](images/5c7f5db865fb7277b0fe563749206121a800cabcc6604a1879a1c42dba973ba6.jpg) + +![](images/cb022b0f25812b8d5107015509c5d615d1e9b78a7a9bd77c5cafba1bca47e00d.jpg) + +![](images/eac7a45ffd654442f03371b7aa3b854275c4658870426531ecefeb81693cf08e.jpg) + +![](images/f410293f92f6eb4da8f5056f3ddbbfa9e8b5a62dea9456506562ab6568d65930.jpg) +Figure 3: Results from our probing experiments comparing our proposed algorithms R3F, R4F to standard fine-tuning. Variants of our method consistently outperform past work. + +![](images/13da0266d76c85135c48c1fbf77c65531e1d480b4acd31cd602d7fa349650e01.jpg) + +![](images/29468c883e2b8868eeb32666facbaee63c06e3dde78bcf39f08b25454dd2f8a1.jpg) + +with empirical evidence of the existence of representation collapse on the GLUE benchmark (Wang et al., 2018). + +# 4.1 PROBING EXPERIMENTS + +# PROBING GENERALIZATION OF FINE-TUNED REPRESENTATIONS + +To measure the generalization properties of various fine-tuning methodologies, we follow probing methodology by first freezing the representations from the model trained on one task and then fine-tuning a linear layer on top of the model for another task. Doing this form of probing can directly measure the quality of representations learned by various fine-tuning methods and how much they collapse when fine-tuned on a sequence of tasks. + +In particular, we fine-tune a RoBERTa model on SST-2 and train a linear layer for six other GLUE tasks, respectively. Our results are shown in Figure 3. Appendix A.2 presents the hyperparameters. Across all tasks, one of the two variants of our method performed best across various fine-tuning methods. + +Conversely, standard fine-tuning produced representations that were worse than other fine-tuning methods across the board, hinting at the sub-optimality of standard fine-tuning. Furthermore, R3F/R4F consistently outperforms the adversarial fine-tuning method SMART. + +# PROBING REPRESENTATION DEGRADATION + +To show the effect of representation collapse, we propose an experiment to measure how the fine-tuning process degrades representations by sequentially training on a series of GLUE tasks. We arbitrarily select 3 GLUE tasks (QNLI, QQP, and RTE) and a source task (SST-2). We begin by training a model on our source task and then train on QNLI, QQP, and RTE in a sequential order using the best checkpoint from + +![](images/df56d25c16d92685908ee3c6d55cabdb4cad31eec3ba0bfce657cee837b3a91c.jpg) +Figure 4: We show the results of the chained probing experiments. We do not show the distributional properties of the runs because there was minimal variance in the results. + +the prior iteration. At each point in the chain, we probe the source task and measure performance. We compare standard SGD with the best trust-region fine-tuning approach (R4F). Our results are depicted in Figure 4. + +As we can see with the standard fine-tuning process, our model diverges from the source task resulting in lower performance probes; however, with our method, the probes change much less with sequential probing resulting in better probing and end performance. + +# PROBING REPRESENTATION RETENTION + +To further understand representational collapse's impact, we extend our probing experiments to train a cyclic chain of tasks. We showed that traditional fine-tuning degrades representations during the fine-tuning process in our prior experiments, meaning standard fine-tuning learns poorer representation compared to alternative fine-tuning methods. The dual to looking at degradation is to look at the retainment of learned representations. To do this, we take a look at cyclic sequential probing. Sequential probing involves training a model on task A, probing B, then training model fine-tuned on B and probing task C, and so forth. We then create a cyclic chain $\underbrace{A\rightarrow B\rightarrow C}_{\text{Cycle 1}}\rightarrow \underbrace{A\rightarrow B\rightarrow C}_{\text{Cycle 2}}$ + +from where we compare tasks via their probe performance at each cycle. + +We expect probing performance to increase at every cycle; since every cycle, the task we are probing on will undergo a full fine-tuning. What we are interested in is the level of retention in representations after the fine-tuning. Specifically, we hypothesize that our method, specifically R4F, will retain representations significantly better than the Standard++ fine-tuning method. + +In our experiments we consider the following sequence of GLUE tasks: SST-2 $\rightarrow$ QNLI $\rightarrow$ QQP $\rightarrow$ RTE. We defer hyperparameter values to Appendix (Section A.2). + +![](images/d46062c7319438b6547dfd42afa78b9d32a8cc84e1885400dc4d32f0f9a4cc89.jpg) +Figure 5: We present the results of cyclical sequential probing for 3 cycles. + +Looking at Figure 5, we see that R4F retains the quality of representations significantly better than standard fine-tuning methods. + +# 5 CONCLUSION + +We propose a family of new fine-tuning approaches for pre-trained representations based on trust-region theory: R3F and R4F. Our methods are more computationally efficient and outperform prior work in fine-tuning via adversarial learning (Jiang et al., 2019; Zhu et al., 2019). We show that this is due to a new phenomenon during fine-tuning: representational collapse, where representations learned during fine-tuning degrade, leading to worse generalization. Our analysis shows that standard fine-tuning is sub-optimal when it comes to learning generalizable representations, and instead, our methods retain representation generalizability and improve end task performance. + +With our method, we improve upon monolingual and multilingual sentence prediction tasks as well as generation tasks compared to standard and adversarial fine-tuning methods. Notably, we set state of the art on DailyMail/CNN, Gigaword, Reddit TIFU, improve the best-known results on fine-tuning RoBERTa on GLUE, and reach state of the art on zero-shot XNLI without the need for any new pre-training method. + +We note there are many flavors of RXF that can occur with various noise distributions or perturbation strategies. We believe a larger, more general framework exists which connects trust region methods and fine-tuning in general. We leave this area of exploration for future work. + +# REFERENCES + +Luisa Bentivogli, Peter Clark, Ido Dagan, and Danilo Giampiccolo. The fifth pascal recognizing textual entailment challenge. In TAC, 2009. +Daniel Cer, Mona Diab, Eneko Agirre, Inigo Lopez-Gazpio, and Lucia Specia. Semeval-2017 task 1: Semantic textual similarity-multilingual and cross-lingual focused evaluation. arXiv preprint arXiv:1708.00055, 2017. +Zewen Chi, Li Dong, Furu Wei, Nan Yang, Saksham Singhal, Wenhui Wang, Xia Song, Xian-Ling Mao, Heyan Huang, and Ming Zhou. Infoxm: An information-theoretic framework for crosslingual language model pre-training, 2020. +Kevin Clark, Urvashi Khandelwal, Omer Levy, and Christopher D Manning. What does bert look at? an analysis of bert's attention. arXiv preprint arXiv:1906.04341, 2019. +Alexis Conneau, Guillaume Lample, Rudy Rinott, Adina Williams, Samuel R Bowman, Holger Schwenk, and Veselin Stoyanov. Xnli: Evaluating cross-lingual sentence representations. arXiv preprint arXiv:1809.05053, 2018. +Alexis Conneau, Kartikay Khandelwal, Naman Goyal, Vishrav Chaudhary, Guillaume Wenzek, Francisco Guzmán, Edouard Grave, Myle Ott, Luke Zettlemoyer, and Veselin Stoyanov. Unsupervised cross-lingual representation learning at scale. arXiv preprint arXiv:1911.02116, 2019. +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. +Jesse Dodge, Gabriel Ilharco, Roy Schwartz, Ali Farhadi, Hannaneh Hajishirzi, and Noah Smith. Fine-tuning pretrained language models: Weight initializations, data orders, and early stopping. arXiv preprint arXiv:2002.06305, 2020. +William B Dolan and Chris Brockett. Automatically constructing a corpus of sentential paraphrases. In Proceedings of the Third International Workshop on Paraphrasing (IWP2005), 2005. +Karl Moritz Hermann, Tomas Kocisky, Edward Grefenstette, Lasse Espeholt, Will Kay, Mustafa Suleyman, and Phil Blunsom. Teaching machines to read and comprehend. In Advances in neural information processing systems, pp. 1693-1701, 2015. +Shankar Iyer, Nikhil Dandekar, and Kornel Csernai. First quora dataset release: Question pairs, 2017. URL https://data.quora.com/First-Quora-Dataset-Release-Question-Pairs. +Haoming Jiang, Pengcheng He, Weizhu Chen, Xiaodong Liu, Jianfeng Gao, and Tuo Zhao. Smart: Robust and efficient fine-tuning for pre-trained natural language models through principled regularized optimization. arXiv preprint arXiv:1911.03437, 2019. +Byeongchang Kim, Hyunwoo Kim, and Gunhee Kim. Abstractive summarization of reddit posts with multi-level memory networks. arXiv preprint arXiv:1811.00783, 2018. +Mike Lewis, Yinhan Liu, Naman Goyal, Marjan Ghazvininejad, Abdelrahman Mohamed, Omer Levy, Ves Stoyanov, and Luke Zettlemoyer. Bart: Denoising sequence-to-sequence pretraining for natural language generation, translation, and comprehension. arXiv preprint arXiv:1910.13461, 2019. +Mike Lewis, Marjan Ghazvininejad, Gargi Ghosh, Armen Aghajanyan, Sida Wang, and Luke Zettle-moyer. Pre-training via paraphrasing, 2020. +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, 2019. + +Michael McCloskey and Neal J Cohen. Catastrophic interference in connectionist networks: The sequential learning problem. In *Psychology of learning and motivation*, volume 24, pp. 109-165. Elsevier, 1989. +Takeru Miyato, Toshiki Kataoka, Masanori Koyama, and Yuichi Yoshida. Spectral normalization for generative adversarial networks. arXiv preprint arXiv:1802.05957, 2018. +Marius Mosbach, Maksym Andriushchenko, and Dietrich Klakow. On the stability of fine-tuning bert: Misconceptions, explanations, and strong baselines. arXiv preprint arXiv:2006.04884, 2020. +Courtney Naples, Matthew R Gormley, and Benjamin Van Durme. Annotated gigaword. In Proceedings of the Joint Workshop on Automatic Knowledge Base Construction and Web-scale Knowledge Extraction (AKBC-WEKEX), pp. 95-100, 2012. +Razvan Pascanu and Yoshua Bengio. Revisiting natural gradient for deep networks. arXiv preprint arXiv:1301.3584, 2013. +Alec Radford, Jeffrey Wu, Rewon Child, David Luan, Dario Amodei, and Ilya Sutskever. Language models are unsupervised multitask learners. OpenAI Blog, 1(8):9, 2019. +Pranav Rajpurkar, Jian Zhang, Konstantin Lopyrev, and Percy Liang. Squad: 100,000+ questions for machine comprehension of text. arXiv preprint arXiv:1606.05250, 2016. +Garvesh Raskutti and Sayan Mukherjee. The information geometry of mirror descent. IEEE Transactions on Information Theory, 61(3):1451-1457, 2015. +John Schulman, Sergey Levine, Pieter Abbeel, Michael Jordan, and Philipp Moritz. Trust region policy optimization. In International conference on machine learning, pp. 1889-1897, 2015a. +John Schulman, Sergey Levine, Pieter Abbeel, Michael Jordan, and Philipp Moritz. Trust region policy optimization. In International conference on machine learning, pp. 1889-1897, 2015b. +Richard Socher, Alex Perelygin, Jean Wu, Jason Chuang, Christopher D Manning, Andrew Ng, and Christopher Potts. Recursive deep models for semantic compositionality over a sentiment treebank. In Proceedings of the 2013 conference on empirical methods in natural language processing, pp. 1631-1642, 2013. +Michael Tschannen, Josip Djolonga, Paul K Rubenstein, Sylvain Gelly, and Mario Lucic. On mutual information maximization for representation learning. arXiv preprint arXiv:1907.13625, 2019. +Alex Wang, Amanpreet Singh, Julian Michael, Felix Hill, Omer Levy, and Samuel Bowman. GLUE: A multi-task benchmark and analysis platform for natural language understanding. In Proceedings of the 2018 EMNLP Workshop BlackboxNLP: Analyzing and Interpreting Neural Networks for NLP, pp. 353-355, Brussels, Belgium, November 2018. Association for Computational Linguistics. doi: 10.18653/v1/W18-5446. URL https://www.aclweb.org/anthology/W18-5446. +Alex Warstadt, Amanpreet Singh, and Samuel R Bowman. Neural network acceptability judgments. arXiv preprint arXiv:1805.12471, 2018. +Adina Williams, Nikita Nangia, and Samuel Bowman. A broad-coverage challenge corpus for sentence understanding through inference. In Proceedings of the 2018 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, Volume 1 (Long Papers), pp. 1112–1122. Association for Computational Linguistics, 2018. URL http://aclweb.org/anthology/N18-1101. +Dongling Xiao, Han Zhang, Yukun Li, Yu Sun, Hao Tian, Hua Wu, and Haifeng Wang. Ernie-gen: An enhanced multi-flow pre-training and fine-tuning framework for natural language generation. arXiv preprint arXiv:2001.11314, 2020. +Yu Yan, Weizhen Qi, Yeyun Gong, Dayiheng Liu, Nan Duan, Jiusheng Chen, Ruofei Zhang, and Ming Zhou. Prophetnet: Predicting future n-gram for sequence-to-sequence pre-training. arXiv preprint arXiv:2001.04063, 2020. + +Jingqing Zhang, Yao Zhao, Mohammad Saleh, and Peter J Liu. Pegasus: Pre-training with extracted gap-sentences for abstractive summarization. arXiv preprint arXiv:1912.08777, 2019. + +Tianyi Zhang, Felix Wu, Arzoo Katiyar, Kilian Q Weinberger, and Yoav Artzi. Revisiting few-sample bert fine-tuning. arXiv preprint arXiv:2006.05987, 2020. + +Chen Zhu, Yu Cheng, Zhe Gan, Siqi Sun, Tom Goldstein, and Jingjing Liu. Freelb: Enhanced adversarial training for natural language understanding. In International Conference on Learning Representations, 2019. + +# A APPENDIX + +# A.1 CONTROLLING CHANGE OF REPRESENTATION VIA CHANGE OF VARIABLE + +Let us say we have random variables in some type of markovian chain $x, y, z; y = f(x; \theta_f), z = g(y; \theta_g)$ + +The change of variable formulation for probability densities is + +$$ +p \left(f \left(x; \theta_ {f}\right)\right) = p \left(g \left(f \left(x; \theta_ {f}\right)\right)\right) \left| \det \frac {d g \left(f \left(x ; \theta_ {f}\right)\right)}{d f \left(x ; \theta_ {f}\right)} \right| \tag {6} +$$ + +Direct application of change of variable gives us + +$$ +K L \left(p \left(f \left(x; \theta_ {f}\right)\right) \mid \mid p \left(f \left(x; \theta_ {f} + \Delta \theta_ {f}\right)\right)\right) = \tag {7} +$$ + +$$ +\sum p \left(f \left(x; \theta_ {f}\right)\right) \log \frac {p \left(f \left(x ; \theta_ {f}\right)\right)}{p \left(f \left(x ; \theta_ {f} + \Delta \theta_ {f}\right)\right)} = \tag {8} +$$ + +$$ +\sum p \left(g \left(f \left(x; \theta_ {f}\right)\right)\right) \left| \det \frac {d g \left(f \left(x ; \theta_ {f}\right)\right)}{d f \left(x ; \theta_ {f}\right)} \right| [ \tag {9} +$$ + +$$ +\log p \left(g \left(f \left(x; \theta_ {f}\right)\right)\right) + \log \left| \det \frac {d g \left(f \left(x ; \theta_ {f}\right)\right)}{d f \left(x ; \theta_ {f}\right)} \right| \tag {10} +$$ + +$$ +- \log p \left(g \left(f \left(x; \Delta \theta_ {f}\right)\right)\right) - \log \left| \det \frac {d g \left(f \left(x ; \Delta \theta_ {f}\right)\right)}{d f \left(x ; \Delta \theta_ {f}\right)} \right| \tag {11} +$$ + +$$ +] \tag {12} +$$ + +Let us make some more assumptions. Let $g(y) = Wy$ where the spectral norm of $W, \rho(W) = 1$ . We can then trivially bound $\det W \leq 1$ . Then we have + +$$ +\begin{array}{l} = \sum p \left(g \left(f \left(x; \theta_ {f}\right)\right) \mid \det \frac {d g \left(f \left(x ; \theta_ {f}\right)\right)}{d f \left(x ; \theta_ {f}\right)} \mid \left[ \log p \left(g \left(f \left(x; \theta_ {f}\right)\right)\right) - \log p \left(g \left(f \left(x; \Delta \theta_ {f}\right)\right)\right) \right] \right. (13) \\ = \sum p \left(g \left(f \left(x; \theta_ {f}\right)\right)\right) \left| \det \frac {d g \left(f \left(x ; \theta_ {f}\right)\right)}{d f \left(x ; \theta_ {f}\right)} \right| \log \frac {p \left(g \left(f \left(x ; \theta_ {f}\right)\right)\right)}{p \left(g \left(f \left(x ; \Delta \theta_ {f}\right)\right)\right)} (14) \\ \leq \sum p \left(g \left(f \left(x; \theta_ {f}\right)\right)\right) \log \frac {p \left(g \left(f \left(x ; \theta_ {f}\right)\right)\right)}{p \left(g \left(f \left(x ; \Delta \theta_ {f}\right)\right)\right)} (15) \\ = K L \left(p \left(g \left(f \left(x; \theta_ {f}\right)\right)\right) \mid \mid p \left(g \left(f \left(x; \Delta \theta_ {f}\right)\right)\right)\right) (16) \\ \end{array} +$$ + +We also see that tightness is controlled by $|\det W|$ , which is bounded by the singular value giving us intuition to the importance of using spectral normalization. + +# A.2 EXPERIMENT HYPER-PARAMETERS + +For our GLUE related experiments, both full fine-tuning and probing, the following parameters are used. For probing experiments, the difference is our RoBERTa encoder is frozen, and the encoder dropout is removed. + +
Hyper ParameterMNLIQNLIQQPSST-2RTEMRPCCoLA
Learning Rate5e-65e-65e-65e-61e-51e-51e-5
Max Updates1238733311211327220935312022965336
Max Sentences88323281616
+ +Table 5: Task specific hyper parameters for GLUE experiments + +
Hyper parameterValue
OptimizerAdam
Adam-betas(0.9, 0.98)
Adam-eps1e-6
LR Schedulerpolynomial decay
Dropout0.1
Weight Decay0.01
Warmup Updates0.06 * max updates
+ +
Hyper parameterValue
λ[0.1, 0.5, 1.0, 5.0]
Noise Types[U, N]
σ1e-5
+ +Table 6: Hyper parameters for R3F and R4F experiments on GLUE + +
Hyper ParameterCNN/DailymailGigawordReddit TIFU
Max Tokens102420482048
Total updates80000200000200000
Warmup Updates100050005000
+ +Table 7: Task specific hyper parameters for Summarization experiments. + +
Hyper parameterValue
OptimizerAdam
Adam-betas(0.9, 0.98)
Adam-eps1e-8
LR Schedulerpolynomial decay
Learning Rate3e-05
+ +
Hyper parameterValue
λ[0.001, 0.01, 0.1]
Noise Types[U, N]
σ1e-5
Dropout0.1
Weight Decay0.01
Clip Norm0.1
+ +Table 8: Hyper parameters for R3F and R4F experiments on Summarization experiments. + +
Hyper parameterValue
OptimizerAdam
Adam-betas(0.9, 0.98)
Adam-eps1e-8
LR Schedulerpolynomial decay
Learning Rate3e-05
Dropout0.1
Weight Decay0.01
+ +
Hyper parameterValue
λ[0.5, 1, 3, 5]
Noise Types[U, N]
σ1e-5
Total Updates450000
Max Positions512
Max Tokens4400
Max Sentences8
+ +Table 9: Hyper parameters for R3F and R4F experiments on XNLI. \ No newline at end of file diff --git a/betterfinetuningbyreducingrepresentationalcollapse/images.zip b/betterfinetuningbyreducingrepresentationalcollapse/images.zip new file mode 100644 index 0000000000000000000000000000000000000000..da163f39ca03b9a8a075f6eecd8b0d195ed8870e --- /dev/null +++ b/betterfinetuningbyreducingrepresentationalcollapse/images.zip @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:bd8f54e0fafe476bd633960aff6243705071ad90041cfb9a036f5c6947bc815d +size 601168 diff --git a/betterfinetuningbyreducingrepresentationalcollapse/layout.json b/betterfinetuningbyreducingrepresentationalcollapse/layout.json new file mode 100644 index 0000000000000000000000000000000000000000..d4434fd839a96540846405610e8faed7aa61152c --- /dev/null +++ b/betterfinetuningbyreducingrepresentationalcollapse/layout.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5265314e7b80f71332eeb2b3fe6dd2efe033a31ea1dec1f621dbcf2dbcca7a64 +size 344268 diff --git a/beyondcategoricallabelrepresentationsforimageclassification/f629610f-d96b-46ed-832a-f1a1bba5cad1_content_list.json b/beyondcategoricallabelrepresentationsforimageclassification/f629610f-d96b-46ed-832a-f1a1bba5cad1_content_list.json new file mode 100644 index 0000000000000000000000000000000000000000..56b9588cb02f6a7161dc11618f749d0d651661da --- /dev/null +++ b/beyondcategoricallabelrepresentationsforimageclassification/f629610f-d96b-46ed-832a-f1a1bba5cad1_content_list.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ee6a134f84062ea697781b9f9421fd4e098f1a4fd01bf0bacda7ee45ed3b813d +size 86798 diff --git a/beyondcategoricallabelrepresentationsforimageclassification/f629610f-d96b-46ed-832a-f1a1bba5cad1_model.json b/beyondcategoricallabelrepresentationsforimageclassification/f629610f-d96b-46ed-832a-f1a1bba5cad1_model.json new file mode 100644 index 0000000000000000000000000000000000000000..b2876b0f804211df4ed88c80894d0e5704e7fb06 --- /dev/null +++ b/beyondcategoricallabelrepresentationsforimageclassification/f629610f-d96b-46ed-832a-f1a1bba5cad1_model.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a62e087e994d2e2d95a4ba3ae96e424adab58003860129139e164c8304ccf3b2 +size 106485 diff --git a/beyondcategoricallabelrepresentationsforimageclassification/f629610f-d96b-46ed-832a-f1a1bba5cad1_origin.pdf b/beyondcategoricallabelrepresentationsforimageclassification/f629610f-d96b-46ed-832a-f1a1bba5cad1_origin.pdf new file mode 100644 index 0000000000000000000000000000000000000000..000aa3561f753d9a1bdd99b5511970ad055fb382 --- /dev/null +++ b/beyondcategoricallabelrepresentationsforimageclassification/f629610f-d96b-46ed-832a-f1a1bba5cad1_origin.pdf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:14d1bac75d2b5fe6613b28f469e527c192599e5bb3c5a85b9f80f1c7b01b5138 +size 3042698 diff --git a/beyondcategoricallabelrepresentationsforimageclassification/full.md b/beyondcategoricallabelrepresentationsforimageclassification/full.md new file mode 100644 index 0000000000000000000000000000000000000000..395d4f12a943c78f06fee4687a74f0988d453bd1 --- /dev/null +++ b/beyondcategoricallabelrepresentationsforimageclassification/full.md @@ -0,0 +1,343 @@ +# BEYOND CATEGORICAL LABEL REPRESENTATIONS FOR IMAGE CLASSIFICATION + +Boyuan Chen, Yu Li, Sunand Raghupathi, Hod Lipson + +Columbia University + +https://www.creativemachineslab.com/about-representation.html + +# ABSTRACT + +We find that the way we choose to represent data labels can have a profound effect on the quality of trained models. For example, training an image classifier to regress audio labels rather than traditional categorical probabilities produces a more reliable classification. This result is surprising, considering that audio labels are more complex than simpler numerical probabilities or text. We hypothesize that high dimensional, high entropy label representations are generally more useful because they provide a stronger error signal. We support this hypothesis with evidence from various label representations including constant matrices, spectrograms, shuffled spectrograms, Gaussian mixtures, and uniform random matrices of various dimensionalities. Our experiments reveal that high dimensional, high entropy labels achieve comparable accuracy to text (categorical) labels on the standard image classification task, but features learned through our label representations exhibit more robustness under various adversarial attacks and better effectiveness with a limited amount of training data. These results suggest that label representation may play a more important role than previously thought. + +# 1 INTRODUCTION + +Image classification is a well-established task in machine learning. The standard approach takes an input image and predicts a categorical distribution over the given classes. The most popular method to train these neural network is through a cross-entropy loss with backpropagation. Deep convolutional neural networks (Lecun et al., 1998; Krizhevsky et al., 2012; Simonyan & Zisserman, 2014; He et al., 2015; Huang et al., 2016) have achieved extraordinary performance on this task, while some even surpass human level performance. However, is this a solved problem? The state-of-the-art performance commonly relies on large amounts of training data (Krizhevsky, 2009; Russakovsky et al., 2015; Kuznetsova et al., 2018), and there exist many examples of networks with good performance that fail on images with imperceptible adversarial perturbations (Biggio et al., 2013; Szegedy et al., 2013; Nguyen et al., 2014). + +Much progress has been made in domains such as few-shot learning and meta-learning to improve the data efficiency of neural networks. There is also a large body of research addressing the challenge of adversarial defense. Most efforts have focused on improving optimization methods, weight initialization, architecture design, and data preprocessing. In this work, we find that simply replacing standard categorical labels with high dimensional, high entropy variants (e.g. an audio spectrogram pronouncing the name of the class) can lead to interesting properties such as improved robustness and efficiency, without a loss of accuracy. + +Our research is inspired by key observations from human learning. Humans appear to learn to recognize new objects from few examples, and are not easily fooled by the types of adversarial perturbations applied to current neural networks. There could be many reasons for the discrepancy between how humans and machines learn. One significant aspect is that humans do not output categorical probabilities on all known categories. A child shown a picture of a dog and asked "what is this a picture of?" will directly speak out the answer — "dog." Similarly, a child being trained by a parent is shown a picture and then provided the associated label in the form of speech. These observations raise the question: Are we supervising neural networks on the best modality? + +![](images/4785f9c01719b554da5abfd6e4aef32d7b25a25ae5b07d83889897773d12e246.jpg) +Figure 1: Label Representations beyond Categorical Probabilities: We study the role of label representation in training neural networks for image classification. We find that high-dimensional labels with high entropy lead to more robust and data-efficient feature learning. + +In this paper, we take one step closer to understanding the role of label representations inside the training pipeline of deep neural networks. However, while useful properties emerge by utilizing various label representations, we do not attempt to achieve state-of-the-art performance over these metrics. Rather, we hope to provide a novel research perspective on the standard setup. Therefore, our study is not mutually exclusive with previous research on improving adversarial robustness and data efficiency. + +An overview of our approach is shown in Figure 1. We first follow the above natural observation and modify the existing image classifiers to "speak out" the predictions instead of outputting a categorical distribution. Our initial experiments show surprising results: that neural networks trained with speech labels learn more robust features against adversarial attacks, and are more data-efficient when only less than $20\%$ of training data is available. + +Furthermore, we hypothesize that the improvements from the speech label representation come from its property as a specific type of high-dimensional object. To test our hypothesis, we performed a large-scale systematic study with various other high-dimensional label representations including constant matrices, speech spectrograms, shuffled speech spectrograms, composition of Gaussians, and high dimensional and low dimensional uniform random vectors. Our experimental results show that high-dimensional label representations with high entropy generally lead to robust and data efficient network training. We believe that our findings suggest a significant role of label representations which has been largely unexplored when considering the training of deep neural networks. + +Our contributions are three fold. First, we introduce a new paradigm for the image classification task by using speech as the supervised signal. We demonstrate that speech models can achieve comparable performance to traditional models that rely on categorical outputs. Second, we quantitatively show that high-dimensional label representations with high entropy (e.g. audio spectrograms and composition of Gaussians) produce more robust and data-efficient neural networks, while high-dimensional labels with low entropy (e.g. constant matrices) and low-dimensional labels with high entropy do not have these benefits and may even lead to worse performance. Finally, we present a set of quantitative and qualitative analyses to systematically study and understand the learned feature representations of our networks. Our visualizations suggest that speech labels encourage learning more discriminative features. + +# 2 RELATED WORKS + +Data Efficiency and Robustness Data efficiency has been a widely studied problem within the context of few-shot learning and meta-learning (Thrun & Pratt, 2012; Vilalta & Drissi, 2002; Vanschoren, 2018; Wang et al., 2019). Researchers have made exciting progress on improving methods of optimization (Ravi & Larochelle, 2016; Li et al., 2017), weight initialization (Finn et al., 2017; Ravi & Larochelle, 2017), and architecture design (Santoro et al., 2016a;b). + +There is also a large body of research addressing the challenge of adversarial defense. Adversarial training is perhaps the most common measure against adversarial attacks (Goodfellow et al., 2014; Kurakin et al., 2016; Szegedy et al., 2013; Shaham et al., 2018; Madry et al., 2017). Recent works try to tackle the problem by leveraging GANs (Samangouei et al., 2018), detecting adversarial examples (Meng & Chen, 2017; Lu et al., 2017; Metzen et al., 2017), and denoising or reconstruction (Song et al., 2017; Liao et al., 2017). + +Most of these techniques for improving data efficiency and adversarial robustness study the problem from the perspective of model, optimizer and data. Relatively little research has been conducted on the labels themselves or more specifically, their representation. Hosseini et al. (2017) augmented categorical labels with a new NULL class to allow the model to classify and reject perturbed examples. Papernot et al. (2015) utilizes model distillation (Hinton et al., 2015) for adversarial defense. Papernot & McDaniel (2017) further augment the label used to train the distilled model with the predictive uncertainty from the original model. Nevertheless, the method of Hosseini et al. (2017) requires adversarial examples to train on while that of defensive distillation has been shown to be vulnerable to substitute model black-box attacks (Papernot et al., 2017). + +Label Smoothing The closest approach to our work is Label Smoothing (LS) (Szegedy et al., 2016). Here we highlight key differences between our approach and LS. First, LS applies to discriminative outputs where both correct and incorrect class information are presented during training, while our output is generative and only correct class information is presented. That is, our outputs are not a distribution over classes. Although LS has been shown to improve adversarial robustness (Goibert & Dohmatob, 2020), it has not been shown to be effective for low-data learning. As we will show in our experiments, LS does not help when the amount of training data is limited, while our label representations lead to significant improvements. Therefore, our high-dimensional, high-entropy labels provide benefits beyond those provided by label smoothing. + +# 3 BEYOND ACCURACY: EMERGENCE OF ROBUSTNESS AND EFFICIENCY + +It is well-known that deep neural networks with similar accuracy on the same task may perform very differently under different evaluation scenarios. Additionally, real-world applications rely on more considerations than just accuracy. Robustness and data efficiency are two practical challenges for deep neural networks. We test the emergence of those properties under various label representations. + +# 3.1 ROBUSTNESS UNDER ADVERSARIAL ATTACKS + +We evaluate the robustness of all the trained models using the fast gradient sign method (FGSM) (Goodfellow et al., 2014) and the iterative method (Kurakin et al., 2016) across multiple widely used convolutional networks. We choose these attacks because their adversarial images $I_{\mathrm{adv}}$ are usually indistinguishable from the original images $I$ or do not significantly affect human evaluation, but they can be very challenging for neural networks to correctly classify. When a loss function $J$ is involved in generating the adversarial images, we use the cross-entropy loss for the text model and the smooth L1 loss for the speech model. + +FGSM is a fast one-step attack that generates an adversarial image by adding a small adversarial perturbation to the original image. The perturbation is based on the gradient of the loss with respect to the original image. The maximum magnitude of the perturbation is maintained by $\epsilon$ : + +$$ +\left\| I - I _ {\mathrm {a d v}} \right\| _ {\infty} \leq \epsilon . \tag {1} +$$ + +We test both untargeted and targeted versions of FGSM. The untargeted attacks increase the loss between the predicted class and the true class $Y_{\mathrm{true}}$ : + +$$ +I _ {\mathrm {a d v}} = I + \epsilon \cdot \operatorname {S i g n} \left(\nabla_ {I} J (I, Y _ {\text {t r u e}})\right), \tag {2} +$$ + +whereas the targeted attacks decrease the loss between the predicted class and a target class $Y_{\text{target}}$ : + +$$ +I _ {\mathrm {a d v}} = I - \epsilon \cdot \operatorname {S i g n} \left(\nabla_ {I} J (I, Y _ {\text {t a r g e t}})\right). \tag {3} +$$ + +We choose a random incorrect class as the target class for each input image, and the same target classes are used to test different models. All $I_{\mathrm{adv}}$ are normalized after the perturbation. + +Iterative Method As an extension to FGSM, the iterative method applies multiple steps of gradient-based updates. In our experiments, we initialize the adversarial image $I_{\mathrm{adv}}$ to be the original image $I$ so that $I_{\mathrm{adv}}^0 = I$ . Then we apply FGSM for 5 times with a small step size $\alpha = \epsilon / 5$ . The untargeted update for each iteration becomes + +$$ +I _ {\mathrm {a d v}} ^ {N + 1} = \operatorname {C l i p} _ {I, e} \left\{I _ {\mathrm {a d v}} ^ {N} + \alpha \cdot \operatorname {S i g n} \left(\nabla_ {I} J \left(I _ {\mathrm {a d v}} ^ {N}, Y _ {\text {t r u e}}\right)\right) \right\}, \tag {4} +$$ + +and the targeted update becomes + +$$ +I _ {\mathrm {a d v}} ^ {N + 1} = \operatorname {C l i p} _ {I, \epsilon} \left\{I _ {\mathrm {a d v}} ^ {N} - \alpha \cdot \operatorname {S i g n} \left(\nabla_ {I} J \left(I _ {\mathrm {a d v}} ^ {N}, Y _ {\text {t a r g e t}}\right)\right) \right\}, \tag {5} +$$ + +where $\mathrm{Clip}_{I,\epsilon}$ denotes clipping the total perturbation $I_{\mathrm{adv}}^N - I$ in the range of $[- \epsilon, \epsilon]$ . We use the same targeted classes from FGSM for the evaluation on the iterative method. + +# 3.2 LEARNING EFFICIENCY WITH LIMITED DATA + +We take the most straightforward approach to evaluate data efficiency. We start with only $1\%$ of the original training data. We always use the full amount of testing data. We then gradually increase the amount of training data to $2\%$ , $4\%$ , $8\%$ , $10\%$ , and $20\%$ of the original to perform extensive multi-scale evaluation. + +# 4 EXPERIMENTAL SETUP + +Dataset We evaluate our models on the CIFAR-10 and CIFAR-100 datasets (Krizhevsky, 2009). We use the same training, validation and testing data split $(45,000 / 5,000 / 10,000)$ for all of our experiments. We also keep the same random seed for data preprocessing and augmentation. Therefore, we present apple to apple comparisons for all label representations. + +Speech Label Generation We generate the speech labels shown in Figure 1 by following the standard practice as in recent works (Naranjo-Alcazar et al., 2019; Zhang et al., 2019): + +- We first generate the English speech audio automatically with a text-to-speech (TTS) system from the text labels in the corresponding dataset. Therefore, all the speech labels are pronounced consistently by the same API with the same parameters for controlled experiments. We leave the exploration of different languages and intonations as future work. +- We save each audio file in the WAVE format with the 16-bit pulse-code modulation encoding, and trim the silent edges from all audio files. +- Since different speech signals may last for various lengths, we preprocess each speech label to generate a Log Mel spectrogram to maintain the same dimension. We use a sampling rate of $22,050\mathrm{Hz}$ , 64 Mel frequency bands, and a hop length of 256. Another advantage of this preprocessing into spectrograms is that we can then utilize convolutional neural networks as the speech decoder to reconstruct our speech labels. Meanwhile, we convert the amplitudes to the decibel scale. +- Finally, the spectrograms are shaped into a $N \times N$ matrix with values ranging from $-80$ to 0, where $N$ is double the dimension of the image input. Our resulting speech spectrogram can be viewed as a 2D image. + +Given the first step in this procedure, note that for a given class (e.g. "bird") there is only one corresponding spectrogram. Therefore, the improved robustness we observe is not a result of any label-augmentation. + +Other Labels For a deeper understanding of which properties of speech labels introduce different feature learning characteristics, we replicate all the experiments using the following high-dimensional label variants. We also show visualizations for all the label variants in Figure 1. + +- shuffled-speech We cut the speech spectrogram image into 64 slices along the time dimension, shuffle the order of them, and then combine them back together as an image. Although the new image cannot be converted back to a meaningful audio, it preserves the frequency information from the original audio. More importantly, this variant does not change the entropy or dimensionality of the original speech label. +- constant-matrix In contrast, the constant matrix represents another extreme of high-dimensional label representation, with all elements having the same value and zero entropy. The constant-matrix label has the same dimension as the speech label, and values are evenly spaced with a range of 80 (which is also the range of the speech labels). +- Gaussian-composition We obtain this representation by plotting a composition of 2D Gaussians directly as images. Each composition is obtained by adding 10 Gaussians with uniformly sampled positions and orientations. +- random/uniform-matrix We also adopt a matrix with same dimensions as the above high-dimensional labels by randomly sampling from a uniform distribution. We additionally + +construct a uniform random vector with low dimensionality to inspect whether dimensionality matters. Throughout the paper, we will use random matrix and uniform matrix interchangeably to refer to the same representation. + +- BERT embedding We obtain the BERT embedding from the last hidden state of a pretrained BERT model (Devlin et al., 2018; Wolf et al., 2020). We remove outlines larger than twice the standard deviation and normalize the matrix to the same range of our other high-dimensional labels. The BERT embedding results in a $64 \times 64$ matrix. +- GloVe embedding. Similarly, we directly use the pretrained GloVe (Pennington et al., 2014) word vectors.3 This results in a 50-dimensional label vector. + +Models We take three widely used convolutional networks as our base model: VGG19 (Simonyan & Zisserman, 2014), ResNet-32 and ResNet-110 (He et al., 2015). Here we define that a categorical classification model has two parts: an image encoder $I_{e}$ and a category (text) decoder $I_{td}$ . Traditionally, $I_{td}$ represents fully connected layers following various forms of convolutional backbones $I_{e}$ . Finally, a softmax function is applied to the output from the last layer of $I_{td}$ to convert the predictions to a categorical probability distribution. The prediction is retrieved from the class with the highest probability. + +Similarly, we define that the models for our high-dimensional labels consists of two parts: an image encoder and a label decoder $I_{ld}$ . Throughout the paper, we use the same image encoder but replace the category decoder $I_{td}$ with one dense layer and several transpose convolutional layers as $I_{ld}$ . All the layers inside $I_{ld}$ are equipped with batch normalization (Ioffe & Szegedy, 2015) and leaky ReLU with a 0.01 negative slope. + +Overall, the majority of parameters of the network comes from the image encoder which is shared across both categorical labels and other label representations. The decoder for high-dimensional labels increases the number of parameters by a very limited amount (see Appendix for all the numbers). Thus, our experiments are well-controlled with respect to the number of parameters. + +Learning We train the categorical model to minimize the traditional cross-entropy objective function. We minimize Equation 6 for other models with high-dimensional labels. We use the smooth L1 loss (Huber loss) $\bar{L}_s$ shown in Equation 7. Here, $y_{i}$ is the predicted label matrix while $s_i$ stands for the ground-truth matrix. + +$$ +\min _ {\theta_ {s}} \sum_ {i} \mathcal {L} _ {s} \left(y _ {i}, s _ {i}\right) \tag {6} +$$ + +$$ +\mathcal {L} _ {s} \left(y _ {i}, s _ {i}\right) = \left\{ \begin{array}{l l} \frac {1}{2} \left(y _ {i} - s _ {i}\right) ^ {2}, & \text {i f} \left| y _ {i} - s _ {i} \right| \leq 1 \\ \left| y _ {i} - s _ {i} \right|, & \text {o t h e r w i s e} \end{array} \right. \tag {7} +$$ + +We optimize all the networks using stochastic gradient descent (SGD) with back-propagation, and we select the best model based on the accuracy on the validation set. + +Evaluation For categorical models, a prediction is considered correct if the class with the highest probability indicates the same category as the target class. For high-dimensional labels, we provide two types of measurements. Given the model output, we select the ground-truth label that minimizes the distance to the output. We refer to this as the "nearest neighbor" (NN) choice. The other criteria is to check whether the smooth L1 loss is below a certain threshold. We use Amazon Mechanical Turk (Sorokin & Forsyth, 2008) to validate that generated speech below our threshold is correctly identifiable by humans. In our experiments, we find 3.5 is a reasonable threshold. The human evaluations on the speech label demonstrate that our metric captures both the numerical performance and the level of interpretability of the generated speech output. Note that we mainly rely on the NN method for evaluation and only refer to the threshold method to demonstrate the qualitative results from the speech label. + +# 5 RESULTS AND DISCUSSION + +# 5.1 DO ALL THE MODELS LEARN TO CLASSIFY IMAGES? + +We report the classification accuracy for all the labels in Table 1. Speech labels, shuffled-speech and Gaussian-composition labels achieve comparable accuracy with the traditional categorical labels, + +while the constant-matrix performs slightly worse than these representations. This suggests that the constant-matrix label is harder to train with. We verify this observation by visualizing the training curves for all label representations on CIFAR-100 with the ResNet-110 image encoder in Figure 2. The training curves show that the constant-matrix model takes longer to converge than the others, and converges to a higher loss. + +
LabelsCIFAR-10 Accuracy (%)CIFAR-100 Accuracy (%)
VGG19ResNet32ResNet110VGG19ResNet32ResNet110
Category92.82 ± 0.0892.34 ± 0.2593.23 ± 0.2970.98 ± 0.1068.05 ± 0.7270.03 ± 0.49
Speech Threshold91.97 ± 0.1791.90 ± 0.0492.44 ± 0.1169.13 ± 0.7561.08 ± 0.2767.88 ± 0.16
Speech NN92.12 ± 0.1892.34 ± 0.0192.73 ± 0.0870.27 ± 0.6164.74 ± 0.3669.51 ± 0.25
Shuffle Threshold92.27 ± 0.1691.49 ± 0.2292.44 ± 0.0567.04 ± 0.4151.95 ± 0.8563.00 ± 1.45
Shuffle NN92.64 ± 0.1992.72 ± 0.2092.92 ± 0.2470.88 ± 0.3164.23 ± 0.8069.41 ± 0.66
Composition Threshold91.53 ± 0.2491.49 ± 0.2292.36 ± 0.0268.06 ± 0.2860.54 ± 0.5467.17 ± 0.40
Composition NN91.94 ± 0.2292.39 ± 0.1793.07 ± 0.0370.20 ± 0.2366.72 ± 0.4470.62 ± 0.20
Constant Threshold88.27 ± 0.6388.50 ± 0.2589.27 ± 0.1562.99 ± 0.1155.70 ± 0.3658.78 ± 0.18
Constant NN88.33 ± 0.6588.61 ± 0.2789.37 ± 0.1334.29 ± 2.4019.00 ± 1.1924.46 ± 3.70
+ +Table 1: Classification accuracy on CIFAR-10 and CIFAR-100 for all label representations. Speech labels, shuffled speech labels, and composition of Gaussian labels all achieve comparable accuracies with categorical labels. Constant matrix labels perform slightly worse than the others. + +![](images/dc67582a1eaa5fceccb03400209ed41de633e5bab1350ff3656d3023590844a6.jpg) + +![](images/7acd2a5a27a44bd1bb09e68dcbf6573d6c25a5e86720a0c85c1526ef1de5c6cc.jpg) +Figure 2: Training and validation losses on CIFAR-10 dataset with ResNet-110 image encoder for models with the speech / shuffled speech / composition of Gaussians / constant matrix labels (left) and categorical labels (right). All of the models are trained to converge. The model trained with constant matrix labels converges slower than models trained with other high dimensional labels. + +# 5.2 FEATURE ROBUSTNESS + +In order to evaluate the robustness of the models, we take all the trained models (Table 1) as the starting points for adversarial attacks with the FGSM and the iterative method. We apply an $\epsilon$ from 0 to 0.3 with a 0.05 increment to the normalized images by following the original FGSM setup (Goodfellow et al., 2014) and test the model accuracy for each $\epsilon$ value. We only run attacks on the original correctly classified images and mark the original misclassified images as incorrect when we compute the accuracy for all $\epsilon$ values. We provide the accuracy computed on the subset of test images that are initially correctly classified in the Appendix, though the ranking among different models remains the same. + +Figure 3 shows the test accuracy under various attacks. Although the accuracy of all models decreases as the attack becomes stronger (larger $\epsilon$ ), the models with speech labels, shuffled speech labels, and composition of Gaussian labels perform consistently much better than the models with traditional categorical labels across all three image encoders, for all types of attacks, and on both CIFAR datasets. Uniform random matrix labels perform similarly well in this setting (see the Appendix for details). Interestingly, models with constant matrix labels perform worse than all other models with high-dimensional labels, suggesting that there are some inherent properties that enhance model robustness beyond simply high dimensionality. + +![](images/0bd5755de6f39ea15a574ec6c11326685fa5d398afc79c69e12204090be6625e.jpg) +Figure 3: Test accuracy under adversarial attacks on CIFAR-10 (left four columns) and CIFAR-100 (right four columns). The accuracy evaluated by the threshold and the nearest neighbor is plotted in solid and dotted lines respectively. We show the results of targeted and untargeted FGSM and iterative method on three image encoders with three random seeds. The horizontal axis indicates the strength of different attacks. + +![](images/ff18559dc9b88ae23ffe37aa373e5393913c0d264e5c3b033e60cca83d5042c1.jpg) + +# 5.3 FEATURE EFFECTIVENESS + +With the CIFAR-10 dataset, we train models with various label representations using $1\%$ , $2\%$ , $4\%$ , $8\%$ , $10\%$ , and $20\%$ of the training data. For each amount of data, we train with the VGG19, ResNet-32, and ResNet-110 image encoders with five different random seeds. To conduct controlled experiments, we use the exact same training procedures and hyperparameters as the full-data experiments, so that the only difference is the amount of training data. All models are evaluated on the same validation set and test set. Figure 4 reports the test accuracy. Similar to the results from the robustness evaluation, speech labels, shuffled speech labels, composition of Gaussian labels, and uniform random labels achieve higher accuracies than the models with categorical labels for both VGG19 and ResNet-110, and comparable results for ResNet-32. The results demonstrate that the speech models are able to learn more generalizable and effective features with less data. This property is extremely valuable when the amount of training data is limited. + +Additionally, our results suggest that label-smoothing does not provide further benefits when the amount of training data is limited, as discussed above. Lastly, the performance of the models trained on constant matrix labels is consistent with that in the robustness experiment: it performs worse than all other high-dimensional labels. We provide further analysis in the next section. + +![](images/626caf33746dfdea9b6a5028d557584d09cf7d9d3804ff51767f9743c8aabfbc.jpg) +Figure 4: Test accuracy when limited training data is available. Accuracy is computed using the nearest-neighbor method + +# 5.4 WHAT IS SPECIAL ABOUT AUDIO LABELS? + +Our experiments for robustness and data efficiency suggest that high-dimensional labels hold some interesting inherent property beyond just high-dimensionality that encourage learning of more robust + +and effective features. We hypothesize that high-dimensional label representations with high entropy provide stronger learning signals which give rise to better feature representations. + +To verify our hypothesis, we measure several standard statistics over various label representations, shown in Table 2. Specifically, we measure the normalized L1 and L2 distance between pairs of labels for each representation. We further measure the entropy for each individual label. + +
Label TypesCIFAR-10CIFAR-100
EntropyL1 DistanceL2 DistanceEntropyL1 DistanceL2 Distance
Category0.47 ± 0.002.00 ± 0.001.41 ± 0.000.08 ± 0.002.00 ± 0.001.41 ± 0.00
Constant0.00 ± 0.0026.07 ± 15.7226.07 ± 15.720.00 ± 0.0021.76 ± 15.1621.76 ± 15.16
Speech11.35 ± 0.3523.80 ± 5.1612.95 ± 2.7011.37 ± 0.3221.45 ± 5.5313.15 ± 2.19
Shuffle11.35 ± 0.3535.29 ± 2.1818.87 ± 1.5311.37 ± 0.3234.40 ± 2.5917.81 ± 1.24
Composite12.00 ± 0.0024.13 ± 3.3619.41 ± 1.4712.00 ± 0.0025.75 ± 4.7220.60 ± 2.96
BERT11.17 ± 0.005.71 ± 0.942.06 ± 0.2411.17 ± 0.007.89 ± 2.842.63 ± 0.70
GloVe5.64 ± 0.007.35 ± 1.691.30 ± 0.315.64 ± 0.005.62 ± 0.900.99 ± 0.16
+ +Table 2: Different basic statistics of all types of label representations. Labels that encourage more robust and effective feature learning also have higher entropy than other label forms. + +Interestingly, although the Manhattan and Euclidean distance between pairs of labels do not show any particularly useful patterns, the average entropy of the speech labels, the shuffled speech labels, and composition of Gaussian labels are all higher than that of the constant matrix and original categorical labels. The ranking of the entropy between these two groups exactly matches the performance in our robustness and data efficiency experiments shown in Figure 3 and Figure 4. This correlation suggests that high dimensional labels with high entropy may have positive impacts on robustness and data-efficient training. + +We further validate that the benefits come from both high dimensionality and high entropy by training a model with low-dimensional and high-entropy labels. We generated these labels by sampling from a uniform distribution, following the same procedure as the uniform-random matrix label described previously. We found that while models trained with this label perform comparably to ones trained with high-dimensional high-entropy labels in terms of adversarial robustness (see Appendix), high-dimensional and high-entropy label models outperform the low-dimensional high-entropy model in terms of data efficiency, as shown by the curve "Low-dim" in Figure 4. We find a similar result for categorical models trained with label smoothing, which has been previously shown to improve adversarial robustness (Goibert & Dohmatob, 2020). In fact, high dimensionality is a prerequisite for high entropy because the maximum entropy is limited by the dimensionality of the label. + +Note that the model trained with label smoothing uses the standard cross-entropy loss, meanwhile the low-dimensional high-entropy model is trained with the Huber loss. As a result, we argue that the loss is not responsible for the improved performance of models trained with high-dimensional, high-entropy labels. + +# 5.5 VISUALIZATIONS + +Throughout the training process, we visualized the learned features immediately after the image encoder layer of ResNet-110 with t-SNE (van der Maaten & Hinton, 2008), both for audio and categorical models on CIFAR-10 test set. The results are shown in Figure 5. We observe that the embedding of the learned features evolve as the training progresses. Compared with the feature embedding of the categorical model, the embedding of the speech models shows the formation of clusters at earlier stages of training. More separated clusters are also obtained towards convergence. We provide further visualizations and Grad-CAM interpretations in the Appendix. + +![](images/b9045d2cb04c42a0079de4e92ab12d0c63930359d29982abccfad13777b3989e.jpg) +Figure 5: T-SNE progression for speech (top row) and categorical (bottom row) models with ResNet-110 image encoder. From left to right, the plot shows $10\%$ , $30\%$ , $50\%$ , $70\%$ , and $100\%$ progress in training. The speech model develops distinctive clusters at an earlier stage and has better separated clusters overall. + +# 6 CONCLUSION + +We introduce a novel paradigm for the traditional image classification task by replacing categorical labels with high-dimensional, high-entropy matrices such as speech spectrograms. We demonstrate comparable accuracy on the original task with our speech labels, however, models trained with our speech labels achieve superior performance under various adversarial attacks and are able to learn in a more data efficient manner with only a small percentage of training data. We further study the inherent properties of high dimensional label representations that potentially introduce the advantages. Through a large scale systematic study on various label representations, we suggest that high-entropy, high-dimensional labels generally lead to more robust and data efficient training. Our work provides novel insights for the role of label representation in training deep neural networks. + +# ACKNOWLEDGMENTS + +This research is supported by NSF NRI 1925157 and DARPA MTO grant L2M Program HR0011-18-2-0020. + +# REFERENCES + +Battista Biggio, Igino Corona, Davide Maiorca, Blaine Nelson, Nedim Šrndić, Pavel Laskov, Giorgio Giacinto, and Fabio Roli. Evasion attacks against machine learning at test time. Lecture Notes in Computer Science, pp. 387-402, 2013. ISSN 1611-3349. doi: 10.1007/978-3-642-40994-3_25. URL http://dx.doi.org/10.1007/978-3-642-40994-3_25. +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. +Chelsea Finn, Pieter Abbeel, and Sergey Levine. Model-agnostic meta-learning for fast adaptation of deep networks, 2017. +Morgane Goibert and Elvis Dohmatob. Adversarial robustness via label-smoothing. 2020. +Ian J. Goodfellow, Jonathon Shlens, and Christian Szegedy. Explaining and Harnessing Adversarial Examples. arXiv e-prints, art. arXiv:1412.6572, Dec 2014. +Ian J. Goodfellow, Jonathon Shlens, and Christian Szegedy. Explaining and harnessing adversarial examples, 2014. +Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Deep residual learning for image recognition, 2015. +Geoffrey Hinton, Oriol Vinyals, and Jeff Dean. Distilling the knowledge in a neural network, 2015. +Hossein Hosseini, Yize Chen, Sreeram Kannan, Baosen Zhang, and Radha Poovendran. Blocking transferability of adversarial examples in black-box learning systems, 2017. +Gao Huang, Zhuang Liu, Laurens van der Maaten, and Kilian Q. Weinberger. Densely connected convolutional networks, 2016. +Sergey Ioffe and Christian Szegedy. Batch normalization: Accelerating deep network training by reducing internal covariate shift. arXiv preprint arXiv:1502.03167, 2015. + +Alex Krizhevsky. Learning multiple layers of features from tiny images. Technical report, 2009. +Alex Krizhevsky, Ilya Sutskever, and Geoffrey E Hinton. Imagenet classification with deep convolutional neural networks. In F. Pereira, C. J. C. Burges, L. Bottou, and K. Q. Weinberger (eds.), Advances in Neural Information Processing Systems 25, pp. 1097-1105. Curran Associates, Inc., 2012. URL http://papers.nips.cc/paper/4824-imagenet-classification-with-deep-convolutional-neural-networks.pdf. +Alexey Kurakin, Ian Goodfellow, and Samy Bengio. Adversarial examples in the physical world, 2016. +Alina Kuznetsova, Hassan Rom, Neil Alldrin, Jasper Uijlings, Ivan Krasin, Jordi Pont-Tuset, Shahab Kamali, Stefan Popov, Matteo Malloci, Tom Duerig, and Vittorio Ferrari. The open images dataset v4: Unified image classification, object detection, and visual relationship detection at scale. arXiv:1811.00982, 2018. +Yann Lecun, Leon Bottou, Joshua Bengio, and Patrick Haffner. Gradient-based learning applied to document recognition. In Proceedings of the IEEE, pp. 2278-2324, 1998. +Zhenguo Li, Fengwei Zhou, Fei Chen, and Hang Li. Meta-sgd: Learning to learn quickly for few-shot learning. arXiv preprint arXiv:1707.09835, 2017. +Fangzhou Liao, Ming Liang, Yinpeng Dong, Tianyu Pang, Xiaolin Hu, and Jun Zhu. Defense against adversarial attacks using high-level representation guided denoiser, 2017. +Jiajun Lu, Theerasit Issaranon, and David Forsyth. Safetynet: Detecting and rejecting adversarial examples robustly, 2017. +Aleksander Madry, Aleksandar Makelov, Ludwig Schmidt, Dimitris Tsipras, and Adrian Vladu. Towards deep learning models resistant to adversarial attacks, 2017. +Dongyu Meng and Hao Chen. Magnet: a two-pronged defense against adversarial examples, 2017. +Jan Hendrik Metzen, Tim Genewein, Volker Fischer, and Bastian Bischoff. On detecting adversarial perturbations, 2017. +Javier Naranjo-Alcazar, Sergi Perez-Castanos, Pedro Zuccarello, and Maximo Cobos. Dcase 2019: Cnn depth analysis with different channel inputs for acoustic scene classification, 2019. +Anh Nguyen, Jason Yosinski, and Jeff Clune. Deep Neural Networks are Easily Fooled: High Confidence Predictions for Unrecognizable Images. arXiv e-prints, art. arXiv:1412.1897, Dec 2014. +Nicolas Papernot and Patrick McDaniel. Extending defensive distillation, 2017. +Nicolas Papernot, Patrick McDaniel, Xi Wu, Somesh Jha, and Ananthram Swami. Distillation as a defense to adversarial perturbations against deep neural networks, 2015. +Nicolas Papernot, Patrick McDaniel, Ian Goodfellow, Somesh Jha, Z. Berkay Celik, and Ananthram Swami. Practical black-box attacks against machine learning. Proceedings of the 2017 ACM on Asia Conference on Computer and Communications Security, Apr 2017. doi: 10.1145/3052973.3053009. URL http://dx.doi.org/10.1145/3052973.3053009. +Adam Paszke, Sam Gross, Francisco Massa, Adam Lerer, James Bradbury, Gregory Chanan, Trevor Killeen, Zeming Lin, Natalia Gimelshein, Luca Antiga, et al. Pytorch: An imperative style, high-performance deep learning library. In Advances in Neural Information Processing Systems, pp. 8024-8035, 2019. +Jeffrey Pennington, Richard Socher, and Christopher D. Manning. Glove: Global vectors for word representation. In Empirical Methods in Natural Language Processing (EMNLP), pp. 1532-1543, 2014. URL http://www.aclweb.org/anthology/D14-1162. +Sachin Ravi and Hugo Larochelle. Optimization as a model for few-shot learning. 2016. + +Sachin Ravi and Hugo Larochelle. Optimization as a model for few-shot learning. In ICLR, 2017. +Olga Russakovsky, Jia Deng, Hao Su, Jonathan Krause, Sanjeev Satheesh, Sean Ma, Zhiheng Huang, Andrej Karpathy, Aditya Khosla, Michael Bernstein, Alexander C. Berg, and Li Fei-Fei. ImageNet Large Scale Visual Recognition Challenge. International Journal of Computer Vision (IJCV), 115(3):211-252, 2015. doi: 10.1007/s11263-015-0816-y. +Pouya Samangouei, Maya Kabbab, and Rama Chellappa. Defense-gan: Protecting classifiers against adversarial attacks using generative models, 2018. +Adam Santoro, Sergey Bartunov, Matthew Botvinick, Daan Wierstra, and Timothy Lillicrap. Meta-learning with memory-augmented neural networks. In Proceedings of the 33rd International Conference on International Conference on Machine Learning - Volume 48, ICML'16, pp. 1842-1850. JMLR.org, 2016a. +Adam Santoro, Sergey Bartunov, Matthew Botvinick, Daan Wierstra, and Timothy Lillicrap. One-shot learning with memory-augmented neural networks, 2016b. +Uri Shaham, Yutaro Yamada, and Sahand Negahban. Understanding adversarial training: Increasing local stability of supervised models through robust optimization. Neurocomputing, 307:195 - 204, 2018. ISSN 0925-2312. doi: https://doi.org/10.1016/j.neucom.2018.04.027. URL http://www.sciencedirect.com/science/article/pii/S0925231218304557. +Karen Simonyan and Andrew Zisserman. Very deep convolutional networks for large-scale image recognition, 2014. +Yang Song, Taesup Kim, Sebastian Nowozin, Stefano Ermon, and Nate Kushman. Pixeldefend: Leveraging generative models to understand and defend against adversarial examples, 2017. +Alexander Sorokin and David Forsyth. Utility data annotation with amazon mechanical turk. In 2008 IEEE Computer Society Conference on Computer Vision and Pattern Recognition Workshops, pp. 1-8. IEEE, 2008. +Christian Szegedy, Wojciech Zaremba, Ilya Sutskever, Joan Bruna, Dumitru Erhan, Ian Goodfellow, and Rob Fergus. Intriguing properties of neural networks. arXiv e-prints, art. arXiv:1312.6199, Dec 2013. +Christian Szegedy, Wojciech Zaremba, Ilya Sutskever, Joan Bruna, Dumitru Erhan, Ian Goodfellow, and Rob Fergus. Intriguing properties of neural networks, 2013. +Christian Szegedy, Vincent Vanhoucke, Sergey Ioffe, Jon Shlens, and Zbigniew Wojna. Rethinking the inception architecture for computer vision. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 2818-2826, 2016. +Sebastian Thrun and Lorien Pratt. Learning to learn. Springer Science & Business Media, 2012. +Laurens van der Maaten and Geoffrey Hinton. Visualizing data using t-SNE. Journal of Machine Learning Research, 9:2579-2605, 2008. URL http://www.jmlr.org/papers/v9/vandermaaten08a.html. +Joaquin Vanschoren. Meta-learning: A survey. arXiv preprint arXiv:1810.03548, 2018. +Ricardo Vilalta and Youssef Drissi. A perspective view and survey of meta-learning. Artificial intelligence review, 18(2):77-95, 2002. +Yaqing Wang, Quanming Yao, J Kwok, and LM Ni. Few-shot learning: A survey. arXiv preprint arXiv:1904.05046, 2019. +Thomas Wolf, Lysandre Debut, Victor Sanh, Julien Chaumont, Clement Delangue, Anthony Moi, Pierrick Cistac, Tim Rault, Rémi Louf, Morgan Funtowicz, Joe Davison, Sam Shleifer, Patrick von Platen, Clara Ma, Yacine Jernite, Julien Plu, Canwen Xu, Teven Le Scao, Sylvain Gugger, Mariama Drame, Quentin Lhoest, and Alexander M. Rush. Transformers: State-of-the-art natural language processing. In Proceedings of the 2020 Conference on Empirical Methods in Natural Language Processing: System Demonstrations, pp. 38-45, Online, October 2020. Association for Computational Linguistics. URL https://www.aclweb.org/anthology/2020.emnlp-demos.6. + +Jing-Xuan Zhang, Zhen-Hua Ling, Li-Juan Liu, Yuan Jiang, and Li-Rong Dai. Sequence-to-sequence acoustic modeling for voice conversion. IEEE/ACM Transactions on Audio, Speech, and Language Processing, 27(3):631-644, Mar 2019. ISSN 2329-9304. doi: 10.1109/taslp.2019.2892235. URL http://dx.doi.org/10.1109/TASLP.2019.2892235. + +# A APPENDIX + +# A.1 THRESHOLD VALIDATION + +We deployed a large-scale study on Amazon Mechanical Turk $^4$ to validate our choice of 3.5 as a classification threshold for the speech model. + +In particular, we asked workers to listen to the outputs of the speech model and choose from the set of classes (with a "None" class for unintelligible output) the one which best fits the output. We assigned 3 workers to evaluate each output from the VGG19 speech model on CIFAR-10 test set. We chose a restrictive selection criteria to ensure maximum quality of responses. Only workers with a $\geq 99\%$ approval rating and at least 10,000 approvals were selected. + +To measure agreement between humans and our speech model, for each sample in the test set we determine the decision made by the model using our pre-selected threshold (loss $< 3.5$ is correct, while loss $\geq 3.5$ is incorrect). Then we compare these decisions to those of the human workers. When we count each of the three workers independently, we find that humans agree with the model $99.4\%$ of the time. When we take a majority vote (2/3 humans agreeing) we find that humans agree with the model $99.8\%$ of the time. We conclude that 3.5 is a reasonable threshold for evaluating the model. + +# A.2 SUBSET ROBUSTNESS + +Additional robustness evaluation is computed using the subset of the test images that are initially correctly classified by the models without any adversarial attacks (Figure 6). All test accuracy starts at $100\%$ and decreases with stronger attacks. The strength of the attacks is described by the value of epsilon. + +![](images/768ab5f69df219dada5cafd901960865302386edc0bdc4809ac105da765bb52b.jpg) +Figure 6: Test accuracy under adversarial attacks on CIFAR-10 (left four columns) and CIFAR-100 (right four columns) for the initially correct subset of the test images. The accuracy evaluated by the threshold and the nearest neighbor is plotted in solid and dotted lines respectively. The general trend from the subset is similar to that from the full test set. + +![](images/908507f45edf6e7d8c3edcde1fc50f0077ceaf44a1b596841f0b1c21f92a0810.jpg) + +# A.3 ADDITIONAL RESULTS ON ROBUSTNESS EVALUATION + +We here include the full results on robustness evaluation on CIFAR-10 dataset in Figure 7. + +![](images/0cb8343c98486dfed555dba1a983dcd65e9a4d3fd0a39598e2784de09c5d5115.jpg) +Figure 7: Full results of the robustness evaluation on CIFAR-10 + +# A.4 HYPERPARAMETERS + +# A.4.1 IMPLEMENTATION DETAILS + +We train the categorical models for 200 epochs with a starting learning rate of 0.1, and decay the learning rate by 0.1 at epoch 100 and 150. The high-dimensional models are trained for 600 epochs with the same initial learning rate, and we drop the learning rate by 0.1 at epoch 300 and 450. All models are trained with a batch size of 128 using the SGD optimizer with 0.9 momentum and 0.0001 weight decay. One exception is when train categorical models with the VGG19 image encoder, we use a larger weight decay, 0.0005. We implement our models using PyTorch Paszke et al. (2019). All experiments are performed on a single GeForce RTX 2080 Ti GPU. The limited-data experiments are conducted using the same settings as the full data experiments. + +# A.4.2 ARCHITECTURE PARAMETERS + +We provide the parameter counts for the all models in Table 3 and Table 4. The majority of the parameters come from the image encoders. High-dimensional models have slightly more parameters than categorical models due to the high-dimensional label decoder (Table 5). + +
ModelCIFAR-10
VGG19ResNet32ResNet110
Category2 × 1074.67 × 1051.73 × 106
High-dimensional2.01 × 1075.80 × 1051,84 × 106
+ +Table 3: Total number of parameters of the category and high-dimensional models for CIFAR-10 dataset + +# A.5 DATASET + +To demonstrate the effectiveness of our proposed method, we evaluate our models on the CIFAR-10 and CIFAR-100 datasets Krizhevsky (2009). For each dataset, we train different models on the same training set and evaluate the models on the same validation set using the same random seeds for fair comparisons. To preprocess the training images, we randomly crop them with a padding size 4 and perform random horizontal flips. All CIFAR images are normalized with mean (0.4914, 0.4822, 0.4465) and standard deviation (0.2023, 0.1994, 0.2010) of the training set. + +
ModelCIFAR-100
VGG19ResNet32ResNet110
Category2.01 × 1074.73 × 1051.74 × 105
High-dimensional2.02 × 1075.80 × 1051.84 × 105
+ +Table 4: Total number of parameters of the category and high-dimensional models for CIFAR-100 dataset + +
LayerInputOutputKernelStridePadding
DenseIe out64---
ConvTranspose 2D64 × 1 × 164 × 4 × 44 × 41 × 10
ConvTranspose 2D64 × 4 × 432 × 8 × 84 × 42 × 21 × 1
ConvTranspose 2D32 × 8 × 816 × 16 × 164 × 42 × 21 × 1
ConvTranspose 2D16 × 16 × 168 × 32 × 324 × 42 × 21 × 1
ConvTranspose 2D8 × 32 × 321 × 64 × 644 × 42 × 21 × 1
+ +Table 5: The architecture of the high-dimensional label decoder $I_{ld}$ . The input dimension of the first dense layer is the dimension of the output of the image encoder $I_e$ . The output of the last ConvTranspose2d layer is the target label. + +CIFAR-10 consists of 60,000 images of size $32 \times 32$ uniformly distributed across 10 classes. The dataset comes with 50,000 training images and 10,000 test images. We use a 45,000/5,000 training/validation split. + +CIFAR-100 also comprises 60,000 images of size $32 \times 32$ , but it has 100 classes each containing 600 images. The dataset is split into 50,000 training images and 10,000 test images. We randomly select 5,000 images from the training images to form the validation set. + +# A.6 VISUALIZATIONS + +In addition to the progressive t-SNE plots we presented in the main context, we plot the embedding of all three types of image encoders of models trained on speech labels, categorical labels, and constant matrix labels in Figure 8. We only show the results from the models with highest accuracy. Similarly, we observe that speech models have better separation of clusters. The feature embedding of the constant model is worse than that of the speech model, further confirming that the speech representation is unique in addition to its dimensionality. + +Grad-CAM We visualize activations from beginning, intermediate, and final layers in the image encoders for both speech and categorical models in Figure 9. We see that the input activations for the speech model conform more tightly than those of the categorical model to the central object of each image at all three stages. This may suggest that the speech model learns more discriminative features than the categorical model. These features are also visually more easily understandable to humans. + +![](images/b78eb3be12595bb0c0dde1c8e425593d4729c6b40640474f92618d28797a300f.jpg) +Figure 8: T-SNE of the best uniform (left), speech (middle), and categorical (right) models trained with the same random seed. Speech models show best separated clusters across all three models. + +![](images/fc091dfea0dbcd3442969ab0116196c3806befb0abc31b18397bea828cfd42b7.jpg) +(a) VGG19 + +![](images/c5a2863516222faa278eb69669aa31c1f4db2ab0dfeeb4b256e8e0d5ec403f2a.jpg) +Figure 9: Grad-CAM visualization of learned features. Each triplet contains (from left to right) an unaltered image, a categorical model visualization, and a speech model visualization. From top to bottom, the activations are taken from some beginning, intermediate, and final layer in the respective image encoders. Speech models learn more discriminative features than categorical models. + +![](images/0473d060aa1ba711ef5e8f11be67f44b42288a88a504a37c3401baaa3a14df49.jpg) + +![](images/b7991e9bc9b56e471b8646c5813260ebdd113c355f07c2e58bc4200fbc6b5a00.jpg) +(b) ResNet32 + +![](images/f0b66ed15a68b0813252241eca991c7854ee26b9ad03402b8c3f8789db543f1d.jpg) + +![](images/e9e7794fee26fb7e277a13b694d4c392bd08235ce21668899026d48b8053dea9.jpg) + +![](images/b1e38403ecc7cc4d722e0f413144eb3a68d4a40785a346d90ebb35843345cce5.jpg) +(c) ResNet110 + +![](images/75794df1877f6b2adbf0ecbcb8a2d593c5049b39a61b2743ece1c247026269cf.jpg) + +![](images/a067e003f05b99c885eb83f88394104164e17f96bf6377b9d6fdf297e69d5469.jpg) \ No newline at end of file diff --git a/beyondcategoricallabelrepresentationsforimageclassification/images.zip b/beyondcategoricallabelrepresentationsforimageclassification/images.zip new file mode 100644 index 0000000000000000000000000000000000000000..3f282ae4a205576b306cef5ab589c494dbf8243e --- /dev/null +++ b/beyondcategoricallabelrepresentationsforimageclassification/images.zip @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ab248dbddb4a66e70a41648a99c2f1fa7b4ecb025159977518994d9cc4ec011c +size 744696 diff --git a/beyondcategoricallabelrepresentationsforimageclassification/layout.json b/beyondcategoricallabelrepresentationsforimageclassification/layout.json new file mode 100644 index 0000000000000000000000000000000000000000..ee4cd12ca86a6c42703e57e5fc6a16cad1a453ef --- /dev/null +++ b/beyondcategoricallabelrepresentationsforimageclassification/layout.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:adc08456bae0b75142bc3ac3b6e2e04d9c66605fc8bda7e6b55f4df07ef60540 +size 414331 diff --git a/bidirectionalvariationalinferencefornonautoregressivetexttospeech/bc4486a0-6014-4a3b-b8f2-b91ad6bc4ef4_content_list.json b/bidirectionalvariationalinferencefornonautoregressivetexttospeech/bc4486a0-6014-4a3b-b8f2-b91ad6bc4ef4_content_list.json new file mode 100644 index 0000000000000000000000000000000000000000..45b9f5f537aa1420ece85dcf97787000eed075af --- /dev/null +++ b/bidirectionalvariationalinferencefornonautoregressivetexttospeech/bc4486a0-6014-4a3b-b8f2-b91ad6bc4ef4_content_list.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:64e1d11802797becec995376c0c48a4140bc3882b91a363f5cb43156bbacd45b +size 105617 diff --git a/bidirectionalvariationalinferencefornonautoregressivetexttospeech/bc4486a0-6014-4a3b-b8f2-b91ad6bc4ef4_model.json b/bidirectionalvariationalinferencefornonautoregressivetexttospeech/bc4486a0-6014-4a3b-b8f2-b91ad6bc4ef4_model.json new file mode 100644 index 0000000000000000000000000000000000000000..0f95801415262c0805b16f7d92ad89a9f19c4c6c --- /dev/null +++ b/bidirectionalvariationalinferencefornonautoregressivetexttospeech/bc4486a0-6014-4a3b-b8f2-b91ad6bc4ef4_model.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9c7763640f4b9709e02c7bf6219fb905c8e35ae8d47e225128ea83212f91896e +size 122719 diff --git a/bidirectionalvariationalinferencefornonautoregressivetexttospeech/bc4486a0-6014-4a3b-b8f2-b91ad6bc4ef4_origin.pdf b/bidirectionalvariationalinferencefornonautoregressivetexttospeech/bc4486a0-6014-4a3b-b8f2-b91ad6bc4ef4_origin.pdf new file mode 100644 index 0000000000000000000000000000000000000000..60525155a8692034bc31f819eba3fb6a8c914adb --- /dev/null +++ b/bidirectionalvariationalinferencefornonautoregressivetexttospeech/bc4486a0-6014-4a3b-b8f2-b91ad6bc4ef4_origin.pdf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8d12d814f2f33add970eb26a3b3b98a2764581eac74e4be2d1ec422c33b2a001 +size 2312542 diff --git a/bidirectionalvariationalinferencefornonautoregressivetexttospeech/full.md b/bidirectionalvariationalinferencefornonautoregressivetexttospeech/full.md new file mode 100644 index 0000000000000000000000000000000000000000..962380400e6704abc76edab9a26e73ff19015762 --- /dev/null +++ b/bidirectionalvariationalinferencefornonautoregressivetexttospeech/full.md @@ -0,0 +1,494 @@ +# BIDIRECTIONAL VARIATIONAL INFERENCE FOR NON-AUTOREGRESSIVE TEXT-TO-SPEECH + +Yoonhyung Lee, Joongbo Shin, Kyomin Jung + +Department of Electrical and Computer Engineering + +Seoul National University + +Seoul, South Korea + +{cpi1234,jbshin,kjung}@snu.ac.kr + +# ABSTRACT + +Although early text-to-speech (TTS) models such as Tacotron 2 have succeeded in generating human-like speech, their autoregressive architectures have several limitations: (1) They require a lot of time to generate a mel-spectrogram consisting of hundreds of steps. (2) The autoregressive speech generation lacks robustness due to its error propagation property. In this paper, we propose a novel non-autoregressive TTS model called BVAE-TTS, which eliminates the architectural limitations and generates a mel-spectrogram in parallel. BVAE-TTS adopts a bidirectional-inference variational autoencoder (BVAE) that learns hierarchical latent representations using both bottom-up and top-down paths to increase its expressiveness. To apply BVAE to TTS, we design our model to utilize text information via an attention mechanism. By using attention maps that BVAE-TTS generates, we train a duration predictor so that the model uses the predicted duration of each phoneme at inference. In experiments conducted on LJSpeech dataset, we show that our model generates a mel-spectrogram 27 times faster than Tacotron 2 with similar speech quality. Furthermore, our BVAE-TTS outperforms Glow-TTS, which is one of the state-of-the-art non-autoregressive TTS models, in terms of both speech quality and inference speed while having $58\%$ fewer parameters. + +# 1 INTRODUCTION + +End-to-end text-to-speech (TTS) systems have recently attracted much attention, as neural TTS models began to generate high-quality speech that is very similar to the human voice (Sotelo et al., 2017; Wang et al., 2017; Shen et al., 2018; Ping et al., 2018; Li et al., 2019). Typically, those TTS systems first generate a mel-spectrogram from a text using a sequence-to-sequence (seq2seq) model (Sutskever et al., 2014) and then synthesize speech from the mel-spectrogram using a neural vocoder like WaveGlow (Prenger et al., 2019). + +Early neural TTS systems have used an autoregressive (AR) architecture to generate a mel-spectrogram mainly because of its two benefits. First, the AR generation eases the difficulty of modeling mel-spectrogram distribution by factorizing the distribution into the product of homogeneous conditional factors in sequential order. Second, the seq2seq based AR architecture helps the model predict the length of the target mel-spectrogram from an input text, which is a non-trivial task because there are no pre-defined rules between the lengths of text and mel-spectrogram. + +Although they facilitate high-quality speech synthesis, AR TTS models have several shortcomings. First, they cannot generate a mel-spectrogram in parallel, so the inference time increases linearly with mel-spectrogram time steps. Second, the AR-based generation suffers from accumulated prediction error, resulting in being vulnerable to the out-of-domain data, e.g. very long input text, or text patterns not existing in the training dataset. + +In this work, we present a novel non-AR TTS model called BVAE-TTS that achieves fast and robust high-quality speech synthesis. BVAE-TTS generates a mel-spectrogram in parallel by adopting a bidirectional-inference variational autoencoder (BVAE) (Sønderby et al., 2016; Kingma et al., 2016; Maaløe et al., 2019; Vahdat & Kautz, 2020) consisting of 1-D convolutional networks. For + +the high-quality speech synthesis, BVAE-TTS learns mel-spectrogram distribution jointly with hierarchical latent variables in a bidirectional manner, where BVAE uses both bottom-up and top-down paths. Furthermore, to match the length of the target mel-spectrogram at inference, BVAE-TTS has an additional module called duration predictor, which predicts how many steps of a mel-spectrogram will be generated from each phoneme. To train the duration predictor, we employ an attention mechanism in BVAE-TTS to make BVAE-TTS utilize the text while learning attention maps between the text and the mel-spectrogram, where the mapping information is used for duration labels. + +Our BVAE-TTS has advantages over the previous non-AR TTS models as follows: + +- It has a simpler training process compared to the previous non-AR TTS models such as ParaNet (Peng et al., 2020) and FastSpeech (Ren et al., 2019). In the previous TTS models, well-trained AR teacher models are needed for duration labels or knowledge-distillation. Although FastSpeech 2 (Ren et al., 2020) removes the dependency on the teacher model, it still requires additional duration labels and acoustic features prepared in advance using other speech analysis methods. In contrast, BVAE-TTS requires only the text-speech paired dataset without any helps from the teacher model. +- It is more flexible in designing its architecture compared to the previous flow-based non-AR TTS models such as Flow-TTS (Miao et al., 2020) and Glow-TTS (Kim et al., 2020). The flow-based models have architectural constraints caused by their bijective transformation property, which leads to deeper models with a lot of parameters. On the contrary, the VAE-based model is free from the architectural constraints. + +In experiments, we compare our BVAE-TTS with Tacotron 2 and Glow-TTS in terms of speech quality, inference speed, and model size. The results show that our model achieves 27 times speed improvement over Tacotron 2 in generating a mel-spectrogram with similar speech quality. Furthermore, BVAE-TTS outperforms the state-of-the-art non-AR TTS model, Glow-TTS, in both speech quality and inference time, while having $58\%$ fewer model parameters. Additionally, we analyze how the latent representations are learned by BVAE-TTS. In this analysis, we confirm that the bottom part of BVAE-TTS captures the variation of mel-spectrograms that can occur from a text. + +Related work: In the meantime, several TTS systems have utilized VAE to relax the one-to-many mapping nature in TTS, so improve the naturalness and the controllability of the systems. For example, (Hsu et al., 2018) and (Zhang et al., 2019) incorporate VAE to Tacotron 2 to learn the style or prosody of the input speech. However, previous uses of VAE have been limited to an auxiliary network in TTS based on the main AR TTS model. To the best of our knowledge, our BVAE-TTS is the first parallel TTS model that directly uses the VAE architecture to the task of TTS. + +More discussions about other related works on the previous non-AR TTS models are in Section 5. + +# 2 BACKGROUND + +# 2.1 BIDIRECTIONAL-INFERENCE VARIATIONAL AUTOENCODER + +Variational autoencoder (VAE) is a neural network generative model $p_{\theta}(\mathbf{x}, \mathbf{z})$ parameterized by $\theta$ , where $\mathbf{x}$ is an observed data and $\mathbf{z}$ is a latent vector. In practice, since we only have a dataset $X = \{\mathbf{x}_1, \dots, \mathbf{x}_N\}$ without the knowledge about $\mathbf{z}$ , $\theta$ is typically optimized by maximizing the likelihood: + +$$ +\max _ {\theta} \log p _ {\theta} (X) = \max _ {\theta} \sum_ {i = 1} ^ {N} \log \int_ {\mathbf {z}} p _ {\theta} (\mathbf {x} _ {i}, \mathbf {z}) d \mathbf {z}. \tag {1} +$$ + +However, the integral over $\mathbf{z}$ is intractable to compute. Therefore, the VAE introduces an approximate posterior $q_{\phi}(\mathbf{z}|\mathbf{x})$ and does variational inference while maximizing the evidence lower bound (ELBO): + +$$ +\log p _ {\theta} (\mathbf {x}) \geq \mathbb {E} _ {q _ {\phi} (\mathbf {z} | \mathbf {x})} \left[ \log p _ {\theta} (\mathbf {x} | \mathbf {z}) \right] - D _ {K L} \left[ q _ {\phi} (\mathbf {z} | \mathbf {x}) \right| | p (\mathbf {z}) ]. \tag {2} +$$ + +![](images/e82dd5c67685be4ecd2bbb1148203a4eeac4c6ce0ada8c8079b1af2d1fd4334e.jpg) +Figure 1: A Schematic diagram of the bidirectional-inference variational autoencoder. Samplings of latent variables occur in the layers expressed as circles. + +In practice, for easy sampling and easy computation of the KL-divergence, each of the prior $p(\mathbf{z})$ and the approximate posterior $q_{\phi}(\mathbf{z}|\mathbf{x})$ is usually modeled as a multivariate normal distribution with a diagonal covariance matrix. + +For a more expressive model, the latent vector $\mathbf{z}$ can be factorized into $\{\mathbf{z}_1,\dots,\mathbf{z}_K\}$ with hierarchical dependency, where $K$ is the number of hierarchies. Then, each of the prior and the approximate posterior is represented as $p_{\theta}(\mathbf{z}) = \Pi_k p_{\theta}(\mathbf{z}_k|\mathbf{z}_{< k})$ and $q_{\phi}(\mathbf{z}|\mathbf{x}) = \Pi_k q_{\phi}(\mathbf{z}_k|\mathbf{z}_{< k},\mathbf{x})$ , respectively. In (Sønderby et al., 2016; Kingma et al., 2016; Vahdat & Kautz, 2020), the variational inference is designed in a bidirectional way based on bottom-up path and top-down path, while letting the inference network (left) and generative network (right) share their parameters as shown in Figure 1. First, along the bottom-up path, BVAE extracts hierarchical features from $\mathbf{x}$ and stores them inside of it. Then, along the top-down path, BVAE does the variational inference and reconstructs the input data considering the stored hierarchical features together. This architecture helps the model effectively learn the hierarchies between the latent variables, and equation (2) is changed as follows: + +$$ +\log p _ {\theta} (\mathbf {x}) \geq \mathbb {E} _ {q _ {\phi} (\mathbf {z} | \mathbf {x})} [ \log p _ {\theta} (\mathbf {x} | \mathbf {z}) ] - \sum_ {k = 1} ^ {K} \mathbb {E} _ {q _ {\phi} (\mathbf {z} < k | \mathbf {x})} [ D _ {K L} [ q _ {\phi} (\mathbf {z} _ {k} | \mathbf {x}, \mathbf {z} < k) ] ] ]. \tag {3} +$$ + +# 2.2 DURATION PREDICTOR IN NON-AUTOREGRESSIVE TEXT-TO-SPEECH + +To achieve the non-autoregressive (non-AR) text-to-speech (TTS) model, the model needs to predict the length of the target mel-spectrogram from a text. This is because there is no way to access to the length of the target mel-spectrogram at inference. However, this is a challenging task considering that there are no pre-defined rules between the lengths of text and mel-spectrogram. Recently, several non-AR TTS models (Ren et al., 2019; Zeng et al., 2020; Kim et al., 2020) resolved the issue by introducing a module called duration predictor. The duration predictor is a module that predicts how many mel-spectrogram steps will be generated from each phoneme. + +First, using the duration predictor, the non-AR TTS models compute durations $\hat{D} = \{\hat{d}_1,\dots,\hat{d}_S\}$ corresponding to each phoneme based on phoneme representations $H = \{\mathbf{h}_1,\dots,\mathbf{h}_S\}$ , where each $\hat{d}_i$ is a positive integer that is rounded off from a positive real number, and $S$ is the number of phonemes. Then, $H$ is expanded to the length of the target mel-spectrogram $T$ , by repeating each $\mathbf{h}_i$ as many steps as $\hat{d}_i$ . Finally, the non-AR TTS models generate a mel-spectrogram in parallel by decoding the expanded phoneme representations. + +In practice, since there are no ground-truth duration labels for the training of the duration predictor, the non-AR models obtain the duration labels using various methods, and we adopt a method used in FastSpeech (Ren et al., 2019). From well-aligned attention maps, the duration labels are obtained according to $d_{i} = \sum_{t=1}^{t=T} [\arg\max_{s} a_{s,t} == i]$ , where $a_{s,t}$ represents an attention weight given from the $t$ -th mel-spectrogram step to the $s$ -th phoneme. + +# 3 METHODOLOGY + +In this section, we explain a novel non-autoregressive (non-AR) TTS model, BVAE-TTS, which is based on the bidirectional-inference variational autoencoder (BVAE). As shown in Figure 2-(a), during training, BVAE-TTS is given a mel-spectrogram with a phoneme sequence, and it is trained to reconstruct the mel-spectrogram while maximizing the ELBO. Here, the duration predictor is jointly trained using the attention maps that BVAE-TTS generates during training. As shown in Figure 2-(c), at inference BVAE-TTS generates a mel-spectrogram from a phoneme sequence using the duration predictor as described in Section 2.2, while using its top-down path for decoding the expanded phoneme representations. In Appendix A.1, pseudo-codes for the training and inference of BVAE-TTS are contained for detailed descriptions. The other aspects of BVAE-TTS are described in the following sub-sections in more detail. + +# 3.1 USING BVAE FOR TEXT-TO-SPEECH + +Unlike the previous BVAE models (Sonderby et al., 2016; Kingma et al., 2016; Vahdat & Kautz, 2020) are trained to generate natural images, our model should learn to generate a mel-spectrogram + +![](images/54ae010785471c187520c17b82a04426d24600150835f38b0e8a4d77b1bdadf8.jpg) +Figure 2: (a) The training procedure of BVAE-TTS. The scissors represent to detach the signal from the computational graph to block the gradient signal in backpropagation. The Downsample and Upsample layers are included in even-numbered BVAE blocks. $\mathbf{V}_{\mathrm{exp}}$ represents the expanded V to fit the length of the top-down path input. The $f(\cdot)$ represents the Straight-Through argmax with jitter, and $\nabla \mathcal{L}$ represents the gradient signal. (b) BVAE Layer. The dotted arrow represents sampling. The red lines indicate the parameters of prior and approximate posterior normal distributions. (c) The inference procedure of BVAE-TTS that uses the top-down path only. + +![](images/b5a195bf23966ff6f4514f679ca90c69d60bdbc117945326153ec8bb735acae1.jpg) + +![](images/99cf8d822affa7a03bd81a452a170c78fd5647c6b2b4196cfc1a503b75cc49bf.jpg) + +that is not only natural but also corresponding to the input text. To this end, we add a dot-product attention network (Bahdanau et al., 2015) on top of the BVAE, which is a channel for BVAE-TTS to learn how to utilize the text properly. First, using a text encoder, key $(\mathbf{K})$ and value $(\mathbf{V})$ are obtained from a phoneme sequence, and from the bottom-up path, query $(\mathbf{Q})$ is obtained. Here, obtaining $\mathbf{Q}$ is different from the bottom-up paths of the previous BVAE studies used in the image domain, where only the parameters for posterior approximation are obtained. Second, based on the dot-product attention with $\mathbf{Q}, \mathbf{K},$ and $\mathbf{V}$ , the $\mathbf{V}$ are expanded to $\mathbf{V}_{\mathrm{exp}}$ to fit the length of the top-down path, and then the $\mathbf{V}_{\mathrm{exp}}$ is inputted into the top-down path of BVAE-TTS. Lastly, the BVAE-TTS does both the variational inference and mel-spectrogram reconstruction along the top-down path using the expanded text representations with the following objectives: + +$$ +\mathcal {L} _ {\text {r e c o n}} = - \mathbb {E} _ {q _ {\phi} (\mathbf {z} | \mathbf {x}, \mathbf {y})} \left[ \log p _ {\theta} (\mathbf {x} | \mathbf {z}, \mathbf {y}) \right], \tag {4} +$$ + +$$ +\mathcal {L} _ {K L} = \sum_ {k = 1} ^ {K} \mathbb {E} _ {q _ {\phi} (\mathbf {z} _ {< k} | \mathbf {x}, \mathbf {y})} [ D _ {K L} [ q _ {\phi} (\mathbf {z} _ {k} | \mathbf {x}, \mathbf {z} _ {< k}, \mathbf {y}) | | p (\mathbf {z} _ {k} | \mathbf {z} _ {< k}, \mathbf {y}) ] ], \tag {5} +$$ + +where $\mathbf{x}$ represents mel-spectrogram, $\mathbf{y}$ represents text, $\mathbf{z}$ represents latent representation, and mean absolute error (MAE) loss is used for the $\mathcal{L}_{\text{recon}}$ . + +In addition to that, a duration predictor is jointly trained to predict durations corresponding to each phoneme in the logarithmic domain using mean square error (MSE) loss, $\mathcal{L}_{dur} = \mathbb{E}[(\log d_i - \log \hat{d}_i)^2]$ , where $d_{i}$ and $\hat{d}_i$ are obtained as described in Section 2.2. The duration predictor takes as input the $\mathbf{V}$ obtained from the text encoder, and here the $\mathbf{V}$ is detached from the computational graph to prevent it from affecting the BVAE training. + +# 3.2 ARCHITECTURE OF BVAE-TTS + +In this section, we describe the architecture of BVAE-TTS that hierarchically learns the latent representations based on BVAE blocks consisting of BVAE layers. + +BVAE block: As shown in Figure 2-(a), the main part of BVAE-TTS is the stacked BVAE blocks, each consisting of BVAE layers. To guide the multi-scale fine-to-coarse latent features to be contained in the latent hierarchies, the time dimension of input mel-spectrogram is downsampled using bilinear downsampling operations (Zhang, 2019) in even-numbered BVAE blocks along the bottom-up path. Here, the numbering of BVAE blocks starts with one and increases from bottom to top. On the contrary, its time dimension is upsampled again along the top-down path, by repeating the signals in the BVAE blocks where the downsamplings have occurred. In odd-numbered BVAE-blocks, the channel dimension is decreased along the bottom-up path and is increased along the top-down path. It is done at the pre- or post-convolutional network of the first BVAE layer in the BVAE blocks shown in Figure 2-(b). + +BVAE layer: The main element of the BVAE block is the BVAE layer. As shown in Figure 2-(b), at each bottom-up and top-down path, the parameters of the prior and the approximate posterior distributions $\{\pmb{\mu}_k,\pmb{\Sigma}_k\}$ , $\{\Delta \pmb{\mu}_{k_1},\Delta \pmb{\Sigma}_{k_1}\}$ , $\{\Delta \pmb{\mu}_{k_2},\Delta \pmb{\Sigma}_{k_2}\}$ are obtained from 1-D convolutional networks. Then, the prior distribution $p_{\theta}(\mathbf{z}_k|\mathbf{z}_{< k},\mathbf{y})$ , and the approximate posterior distribution $q_{\phi}(\mathbf{z}_k|\mathbf{z}_{< k},\mathbf{x},\mathbf{y})$ are defined as follow: + +$$ +p _ {\theta} \left(\mathbf {z} _ {k} \mid \mathbf {z} _ {< k}, \mathbf {y}\right) := \mathcal {N} \left(\boldsymbol {\mu} _ {k}, \boldsymbol {\Sigma} _ {k}\right), \tag {6} +$$ + +$$ +q _ {\phi} \left(\mathbf {z} _ {k} \mid \mathbf {z} _ {< k}, \mathbf {x}, \mathbf {y}\right) := \mathcal {N} \left(\boldsymbol {\mu} _ {k} + \Delta \boldsymbol {\mu} _ {k _ {1}} + \Delta \boldsymbol {\mu} _ {k _ {2}}, \boldsymbol {\Sigma} _ {k} \cdot \Delta \boldsymbol {\Sigma} _ {k _ {1}} \cdot \Delta \boldsymbol {\Sigma} _ {k _ {2}}\right), \tag {7} +$$ + +where diagonal covariance matrices $\pmb{\Sigma}$ are used after applying a softplus function to guarantee that they are positive. This parameterization follows (Vahdat & Kautz, 2020), where the approximate posterior $q_{\phi}(\mathbf{z}_k|\mathbf{z}_{< k},\mathbf{x},\mathbf{y})$ is relative to the prior $p_{\theta}(\mathbf{z}_k|\mathbf{z}_{< k},\mathbf{y})$ . With this parameterization, when the prior moves, the approximate posterior moves accordingly while making the BVAE training easier and more stable. During training, the latent representation $\mathbf{z}_k$ is sampled from $q_{\phi}(\mathbf{z}_k|\mathbf{z}_{< k},\mathbf{x},\mathbf{y})$ and sampled from $p_{\theta}(\mathbf{z}_k|\mathbf{z}_{< k},\mathbf{y})$ at inference. Other details on the BVAE-TTS architecture such as text encoder or duration predictor are in Appendix A.2. + +# 3.3 BRIDGE THE GAP BETWEEN TRAINING AND INFERENCE + +When BVAE-TTS reconstructs a mel-spectrogram during training, text representations are expanded via the attention network. In contrast, text representations are expanded via the duration predictor at inference. Therefore, to bridge the gap between the attention-based mel-spectrogram generation and the duration-based mel-spectrogram generation, we use the following techniques in this work. + +Straight-Through argmax: In the duration-based generation, the predicted duration of each phoneme is used after it is rounded to the nearest integer. It means that there is a corresponding phoneme for every time step of a mel-spectrogram. Therefore, during training, we use a trick called Straight-Through (ST) argmax, where the phoneme representation given the largest attention weight from each query time step, which is computed using arg max operation, is passed to the top-down path instead of the weighted sum in the attention mechanism. However, during backpropagation, the parameter update is conducted as if the signal was a result of the weighted sum. + +Jitter: To make the model more robust to the errors of the duration predictor, we apply jitter to the text representations, where each of the text representations obtained from the ST-argmax is replaced with a text representation attended by one of the neighboring queries with each probability of $25\%$ during training. We also experimentally observe that applying jitter makes the learning of the attention maps more stable, so the attention maps are not defused throughout the training and stay diagonal. + +Positional encoding biasing & Guided attention: In order to reduce the gap between the attention-based generation and the duration-based generation, it is important for the learned attention maps to have diagonal shapes. Therefore, we use two additional techniques to directly help BVAE-TTS learn the diagonal attention maps. First, we add positional encoding vectors with different angular speeds to query and key as an inductive bias following (Ping et al., 2018). Second, we use an additional guided attention loss $\mathcal{L}_{\text {guide }}$ that gives penalties for attention weights deviating from the diagonal following (Tachibana et al., 2018). For more details on the techniques in this section, see Appendix A.3. + +With the above techniques, BVAE-TTS is trained with the following objective: + +$$ +\mathcal {L} _ {\text {t o t a l}} = \mathcal {L} _ {\text {r e c o n}} + \alpha * \mathcal {L} _ {K L} + \mathcal {L} _ {\text {d u r}} + \mathcal {L} _ {\text {g u i d e}}, \tag {8} +$$ + +where the $\alpha$ is a warm-up constant that linearly increases from 0 to 1 over the first $20\%$ of training. This technique is proposed in (Sønderby et al., 2016) to weaken the variational regularization in the early stages of training. + +# 4 EXPERIMENTS + +In this section, we describe the experimental setup and the results obtained from the quantitative and qualitative experiments that are conducted to evaluate our BVAE-TTS $^1$ . For comparison, we use two state-of-the-art TTS models: Tacotron $2^2$ for an AR TTS model and Glow-TTS $^3$ for a non-AR TTS model. Here, we use the pre-trained weights of the models that are publicly available. + +# 4.1 EXPERIMENTAL SETUP + +In the experiments, we mainly use the LJSpeech dataset (Ito & Johnson, 2017) consisting of 12500/100/500 samples for training / validation / test splits, respectively. For speech data, we convert raw waveforms into log-mel-spectrograms with 1024 window length and 256 hop length and use them as target sequences of our BVAE-TTS model. For text data, we convert raw texts into phoneme sequences using grapheme-to-phoneme library (Park, 2019) and use them as input sequences of BVAE-TTS. + +We train the BVAE-TTS consisting of 4 BVAE blocks for 300K iterations with a batch size of 128. For an optimizer, we use the Adamax Optimizer (Kingma & Ba, 2015) with $\beta_{1} = 0.9$ , $\beta_{2} = 0.999$ using the learning rate scheduling used in (Vaswani et al., 2017), where initial learning rate of 1e-3 and warm-up step of 4000 are used. Training of BVAE-TTS takes about 48 hours on Intel(R) Xeon(R) Gold 5120 CPU (2.2GHz) and NVIDIA V100 GPU on the Pytorch 1.16.0 library with Python 3.6.10 over the Ubuntu 16.04 LTS. For more details on the hyperparameters, see Appendix A.4. + +# 4.2 EXPERIMENTAL RESULTS + +In this section, we compare BVAE-TTS with Tacotron 2 and Glow-TTS in terms of speech quality, inference time, and model size. For the quality evaluation, we use pre-trained WaveGlow as a vocoder that converts mel-spectrograms to waveforms. When we sample latent representations in Glow-TTS and BVAE-TTS, we use the temperature of 0.333 for the models for better speech quality. (Kingma & Dhariwal, 2018) + +Table 1: Experimental results. The MOS-ID and MOS-OOD are written with $95\%$ confidence intervals. The number in parentheses represents the number of parameters of BVAE-TTS that are used at inference. + +
MethodMOS-IDMOS-OODInference Time (ms)# of Parameters
GT Audio4.68 ± 0.06---
GT Mel-spectrogram4.41 ± 0.07---
Tacotron 24.35 ± 0.074.16 ± 0.07658.528.2M
Glow-TTS3.96 ± 0.083.89 ± 0.1043.0728.6M
BVAE-TTS4.14 ± 0.074.21 ± 0.0724.2016.0M (12.0M)
+ +Speech quality: In this experiment, we measure the Mean-Opinion-Score (MOS) for audio samples generated by each TTS model using fifty sentences randomly sampled from the in-domain LJSpeech test set (MOS-ID). In addition, we measure another MOS on fifty sentences randomly sampled from the test-clean set of LibriTTS (Zen et al., 2019) to see the generalization ability on the out-of-domain + +text data (MOS-OOD). Via Amazon Mechanical Turk (AMT), we assign five testers living in the United States to each audio sample, and ask them to listen to the audio sample and give a score between 1 to 5 in 9-scale based on its naturalness. + +The MOS results shown in Table 1 demonstrate the superiority of our BVAE-TTS, where it outperforms the state-of-the-art non-AR TTS model, Glow-TTS, on both MOS-ID and MOS-OOD. Although BVAE-TTS does not surpass Tacotron 2 in MOS-ID, our model achieves better results on MOS-OOD. It shows its robustness to the out-of-domain text over the autoregressive TTS model which suffers from the accumulated prediction error. For a better understanding of the speech quality generated by the models, we strongly encourage the readers to listen to the audio samples in the supplementary material or on the demo page. + +Inference time: We measure inference times taken to generate a mel-spectrogram from a text on the 500 sentences of LJSpeech test set in GPU environment. The average inference time of each TTS model is shown in Table 1. As can be seen in the table, our BVAE-TTS shows 27.2 times faster inference speed on average compared with Tacotron 2, and it is also 1.78 times faster than Glow-TTS. Besides, due to the sequential generation property of the AR TTS model, the gap between the inference speed of BVAE-TTS and Tacotron 2 increases with a longer length of an input text. See Appendix B for more details. + +Model size: As can be seen in the last column of Table 1, BVAE-TTS has the smallest number of parameters of 16.0M while maintaining high-quality speech synthesis. Furthermore, BVAE-TTS gets smaller (to 12.0M) at inference because the layers belonging to the bottom-up path are not used to generate a mel-spectrogram, where the number of parameters is $58\%$ fewer parameters compared to Glow-TTS. This shows that the training principle of BVAE-TTS that hierarchically learns the latent features while adjusting hidden dimensions enables our model to have small parameters. It is contrary to the flow-based TTS models such as Flow-TTS (Miao et al., 2020) and Glow-TTS (Kim et al., 2020), where many parameters are used due to its architectural constraint. + +# 4.3 MODEL ANALYSIS + +As our BVAE-TTS is the first VAE-based parallel TTS model, we conduct several analyses on it. First, we analyze BVAE-TTS to see how the hierarchies are contained in the latent representations and how the variance in mel-spectrograms is learned. Then, we verify the effectiveness of the techniques used in BVAE-TTS such as Straight-Through (ST) argmax and jitter through ablation studies. + +# 4.3.1 ANALYSIS ON HIERARCHY + +In this experiment, we conduct an analysis on the hierarchical latent representation learning of BVAE-TTS. To see how the latent features of the mel-spectrograms are learned in the hierarchies, we observe the variations of the mel-spectrograms sampled from the same text, while using different temperatures for different BVAE blocks. Specifically, we set a target BVAE block among the four BVAE blocks and increase the variance of the target BVAE block, by using a temperature of 1.0 or 2.0 or 5.0 for the samplings occurred in the BVAE layers belonging to the target BVAE block. On the contrary, we lower the variance of the nontarget BVAE blocks using a temperature of 0.333. Then, we sample 100 different mel-spectrograms each from the same text, while varying the target BVAE block and its temperature. + +![](images/f266b662db0fff3a3512c4bfe0b7c1d70ae3396d89afc6cca9d4e23b56d0a043.jpg) +Figure 3: Averages of pixel-by-pixel standard deviations measured on randomly sampled 100 mel-spectrograms. + +Figure 3 shows the averages of pixel-by-pixel standard deviations measured on the randomly sampled 100 mel-spectrograms from the same text. The block numbers in the figure are given from one to four starting from the BVAE block at the bottom. In this experiment, we observe that the variance of the speech is mostly contained in the latent representations of BVAE blocks 1, 2, which are close to the mel-spectrogram. However, there is not much variance in the generated mel-spectrograms when we increase the temperature of BVAE blocks 3, 4, which are close to the text representations. Therefore, we can conclude that the global content is mostly contained in the expanded text representations obtained using the text encoder and the duration predictor, and the BVAE blocks 3, 4 focus on building the content rather than its style. Note that while Figure 3 shows standard deviations measured using one exemplar sentence, "One, Two, Three," the tendency is consistent regardless of the input sentence. Mel-spectrogram samples obtained in this experiment are in Appendix C. + +# 4.3.2 ABLATION STUDY + +![](images/7471d8beaf68225ca8ad0397c9544c6c2bf638a97f275116219e5aa1ef1145ae.jpg) + +![](images/41168a019142a9e330aafa7668238aec55bfb9b4eea837d60883b572c4ba4c7f.jpg) + +![](images/68a3c23f0447522d2beda37e01b0441b360220935540e031e8fe4c254dab8b6e.jpg) + +![](images/a1094479bb18d59e973525aa2b573f369e4cd721bbdd073a009db3e77f2228c6.jpg) +(a) BVAE-TTS +Figure 4: Examples of ablations. Each row represents (1) learned attention map, (2) reconstructed mel-spectrogram, (3) diagonally stacked predicted durations, (4) generated mel-spectrogram from a text. (1), (2) are obtained during training, and (3),(4) are obtained at inference. The red lines represent the section of the durations corresponding to a 'comma' and a 'whitespace' in text. + +![](images/ccde58569d5ea08f8d6a197584160322359da01a35b28a40d8dfaa9f853a8caa.jpg) +(b) No jitter + +![](images/15d9519ae519fceb85b1d56162de07e7c76fb7c372a2e7003e40a40428607cfc.jpg) +(c) No ST-argmax + +We conduct ablation studies to see the effects of applying jitter and Straight-Through (ST) argmax to the soft attention mechanism in BVAE-TTS, and the results are shown in Figure 4. Here, since jitter is included in ST-argmax (jitter is applied to the output of the arg max), the ablation study of not using ST-argmax represents when BVAE-TTS is trained using a normal soft attention mechanism. + +The most noticeable differences appear in the attention maps that they learn. As shown in the first row of Figure 4-(a), (b), applying jitter shows the effectiveness for BVAE-TTS to learn well-aligned attention maps. It results in using more accurate duration labels to train the duration predictor, which leads to more natural speech. We observe that BVAE-TTS without applying jitter still generates a clear speech even though it is a little unnatural, where it obtains a 3.68 MOS on the LJSpeech dataset. As shown in the bottom mel-spectrogram of Figure 4-(c), the BVAE-TTS without ST-argmax technique just generates a stuttering sound. + +As shown in Figure 4-(a), although the BVAE-TTS also does not learn the perfect attention map, BVAE-TTS successfully generates a mel-spectrogram at inference. Since the text is forced to be used monotonically in the duration-based generation, it makes the model more robust to the attention errors while making fewer pronouncing mistakes. In addition, when using the duration predictor, it is also possible to locally control the speed of speech by adjusting the predicted durations. The experiment on the speed control is included in Appendix D. + +# 5 DISCUSSION + +To overcome the limitations that the autoregressive (AR) TTS models have, various non-AR architectures have been recently proposed. On one hand, there have been feed-forward neural networks such as ParaNet (Peng et al., 2020), and FastSpeech 1, 2 (Ren et al., 2019; 2020), which use knowledge distillation or additional duration labels and acoustic features. Although they succeeded in enabling their models to predict the lengths of the target mel-spectrograms, the feed-forward architectures did not fit the one-to-many mapping problems in TTS. Therefore, FastSpeech (Ren et al., 2019) uses as targets mel-spectrograms that the AR teacher model generates. This is because much of the diversity in original mel-spectrograms has been eliminated in the mel-spectrograms generated by the AR teacher model. Besides, FastSpeech 2 (Ren et al., 2020) even directly uses additional pre-obtained acoustic features such as pitch and energy to relax the one-to-many mapping nature in TTS. In contrast to the models, it can be seen that BVAE-TTS is asked to solve one-to-one mapping problems during training because there is only one possible target for the reconstruction task. As a result, BVAE-TTS can generate natural and diverse samples while learning latent features in mel-spectrograms. + +On the other hand, there have been generative flow-based non-AR TTS models such as Flow-TTS (Miao et al., 2020) and Glow-TTS (Kim et al., 2020). While their speech quality is comparable to that of AR TTS models, flow-based generative models usually have a problem that they require a lot of model parameters. In the models, the dimensions of the hidden representations in the flow networks should be the same through the whole network, and their bipartite flow requires many layers and larger hidden size because of its lack of expressiveness (Ping et al., 2019; Lee et al., 2020). Contrary to flow-based TTS models, our BVAE-TTS is free from the above issue. In this work, by designing BVAE-TTS in hierarchical architecture with varying hidden dimensions, we can outperform the flow-based TTS model, Glow-TTS in both speech quality and speed, while having a much smaller model size. + +# 6 CONCLUSION + +In this work, we propose BVAE-TTS, which is the first VAE-based non-AR TTS model that generates a mel-spectrogram from a text in parallel. To use the BVAE architecture in text-to-speech, we combine BVAE with an attention mechanism to utilize a text, and to extract duration labels for the training of the duration predictor. In experiments, BVAE-TTS achieves to generate speech $27\mathrm{x}$ faster than Tacotron 2 with similar speech quality, and also outperforms Glow-TTS in terms of both speech quality and inference time with $58\%$ fewer parameters. Since our VAE-based TTS model shows competitive performance and has many advantages over the previous non-AR TTS models, we hope it becomes a good starting point for future VAE-based TTS research. + +# ACKNOWLEDGMENTS + +K. Jung is with ASRI, Seoul National University, Korea. This work was supported by the Ministry of Trade, Industry & Energy (MOTIE, Korea) under the Industrial Technology Innovation Program (No. 10073144). This research was results of a study on the "HPC Support" Project, supported by the 'Ministry of Science and ICT' and NIPA. + +# REFERENCES + +Dzmitry Bahdanau, Kyunghyun Cho, and Yoshua Bengio. Neural machine translation by jointly learning to align and translate. In 3rd International Conference on Learning Representations, ICLR 2015, San Diego, CA, USA, May 7-9, 2015, Conference Track Proceedings, 2015. URL http://arxiv.org/abs/1409.0473. +Wei-Ning Hsu, Yu Zhang, Ron J Weiss, Heiga Zen, Yonghui Wu, Yuxuan Wang, Yuan Cao, Ye Jia, Zhifeng Chen, Jonathan Shen, et al. Hierarchical generative modeling for controllable speech synthesis. In International Conference on Learning Representations, 2018. + +Keith Ito and Linda Johnson. The lj speech dataset. https://keithito.com/LJ-Speech-Dataset/, 2017. + +Jaehyeon Kim, Sungwon Kim, Jungil Kong, and Sungroh Yoon. Glow-tts: A generative flow for text-to-speech via monotonic alignment search. arXiv preprint arXiv:2005.11129, 2020. +Diederik P. Kingma and Jimmy Ba. Adam: A method for stochastic optimization. In ICLR (Poster), 2015. URL http://arxiv.org/abs/1412.6980. +Durk P Kingma and Prafulla Dhariwal. Glow: Generative flow with invertible 1x1 convolutions. In Advances in neural information processing systems, pp. 10215-10224, 2018. +Durk P Kingma, Tim Salimans, Rafal Jozefowicz, Xi Chen, Ilya Sutskever, and Max Welling. Improved variational inference with inverse autoregressive flow. In Advances in neural information processing systems, pp. 4743-4751, 2016. +Sang-gil Lee, Sungwon Kim, and Sungroh Yoon. Nanoflow: Scalable normalizing flows with sublinear parameter complexity. arXiv preprint arXiv:2006.06280, 2020. +Naihan Li, Shujie Liu, Yanqing Liu, Sheng Zhao, and Ming Liu. Neural speech synthesis with transformer network. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 33, pp. 6706-6713, 2019. +Lars Maaloe, Marco Fraccaro, Valentin Lievin, and Ole Winther. Biva: A very deep hierarchy of latent variables for generative modeling. In Advances in neural information processing systems, pp. 6551-6562, 2019. +Chenfeng Miao, Shuang Liang, Minchuan Chen, Jun Ma, Shaojun Wang, and Jing Xiao. Flowts: A non-autoregressive network for text to speech based on flow. In ICASSP 2020-2020 IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP), pp. 7209-7213. IEEE, 2020. +Takeru Miyato, Toshiki Kataoka, Masanori Koyama, and Yuichi Yoshida. Spectral normalization for generative adversarial networks. In International Conference on Learning Representations, 2018. URL https://openreview.net/forum?id=B1QRgziT-. +Jongseok Park, Kyubyong & Kim. g2pe. https://github.com/Kyubyong/g2p, 2019. +Kainan Peng, Wei Ping, Zhao Song, and Kexin Zhao. Non-autoregressive neural text-to-speech. In Proceedings of the 37th International Conference on Machine Learning, pp. 10192-10204. PMLR, 2020. +Wei Ping, Kainan Peng, Andrew Gibiansky, Sercan O Arik, Ajay Kannan, Sharan Narang, Jonathan Raiman, and John Miller. Deep voice 3: 2000-speaker neural text-to-speech. Proc. ICLR, pp. 214-217, 2018. +Wei Ping, Kainan Peng, Kexin Zhao, and Zhao Song. Waveflow: A compact flow-based model for raw audio. arXiv preprint arXiv:1912.01219, 2019. +Ryan Prenger, Rafael Valle, and Bryan Catanzaro. Waveglow: A flow-based generative network for speech synthesis. In ICASSP 2019-2019 IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP), pp. 3617-3621. IEEE, 2019. +Yi Ren, Yangjun Ruan, Xu Tan, Tao Qin, Sheng Zhao, Zhou Zhao, and Tie-Yan Liu. Fast speech: Fast, robust and controllable text to speech. In Advances in Neural Information Processing Systems, pp. 3171-3180, 2019. +Yi Ren, Chenxu Hu, Tao Qin, Sheng Zhao, Zhou Zhao, and Tie-Yan Liu. Fastspeech 2: Fast and high-quality end-to-end text-to-speech. arXiv preprint arXiv:2006.04558, 2020. +Jonathan Shen, Ruoming Pang, Ron J Weiss, Mike Schuster, Navdeep Jaitly, Zongheng Yang, Zhifeng Chen, Yu Zhang, Yuxuan Wang, Rj Skerrv-Ryan, et al. Natural tts synthesis by conditioning wavenet on mel spectrogram predictions. In 2018 IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP), pp. 4779-4783. IEEE, 2018. +Casper Kaae Sønderby, Tapani Raiko, Lars Maaløe, Søren Kaae Sønderby, and Ole Winther. Ladder variational autoencoders. In Advances in neural information processing systems, pp. 3738-3746, 2016. + +Jose Sotelo, Soroush Mehri, Kundan Kumar, João Felipe Santos, Kyle Kastner, Aaron C. Courville, and Yoshua Bengio. Char2wav: End-to-end speech synthesis. In 5th International Conference on Learning Representations, ICLR 2017, Toulon, France, April 24-26, 2017, Workshop Track Proceedings. OpenReview.net, 2017. URL https://openreview.net/forum?id=B1VWyySKx. +Ilya Sutskever, Oriol Vinyals, and Quoc V Le. Sequence to sequence learning with neural networks. In Advances in neural information processing systems, pp. 3104-3112, 2014. +Hideyuki Tachibana, Katsuya Uenoyama, and Shunsuke Aihara. Efficiently trainable text-to-speech system based on deep convolutional networks with guided attention. In 2018 IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP), pp. 4784-4788. IEEE, 2018. +Arash Vahdat and Jan Kautz. Nvae: A deep hierarchical variational autoencoder. arXiv preprint arXiv:2007.03898, 2020. +Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N Gomez, Lukasz Kaiser, and Illia Polosukhin. Attention is all you need. In Advances in neural information processing systems, pp. 5998-6008, 2017. +Yuxuan Wang, R.J. Skerry-Ryan, Daisy Stanton, Yonghui Wu, Ron J. Weiss, Navdeep Jaitly, Zongheng Yang, Ying Xiao, Zhifeng Chen, Samy Bengio, Quoc Le, Yannis Agiomyrgiannakis, Rob Clark, and Rif A. Saurous. Tacotron: Towards end-to-end speech synthesis. In Proc. Interspeech 2017, pp. 4006-4010, 2017. doi: 10.21437/Interspeech.2017-1452. URL http://dx.doi.org/10.21437/Interspeech.2017-1452. +Heiga Zen, Viet Dang, Rob Clark, Yu Zhang, Ron J. Weiss, Ye Jia, Zhifeng Chen, and Yonghui Wu. LibriTTS: A Corpus Derived from LibriSpeech for Text-to-Speech. In Proc. Interspeech 2019, pp. 1526-1530, 2019. doi: 10.21437/Interspeech.2019-2441. URL http://dx.doi.org/10.21437/Interspeech.2019-2441. +Zhen Zeng, Jianzong Wang, Ning Cheng, Tian Xia, and Jing Xiao. Alignnts: Efficient feed-forward text-to-speech system without explicit alignment. In ICASSP 2020-2020 IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP), pp. 6714-6718. IEEE, 2020. +Richard Zhang. Making convolutional networks shift-invariant again. In Proceedings of the 36th International Conference on Machine Learning, ICML 2019, 9-15 June 2019, Long Beach, California, USA, volume 97 of Proceedings of Machine Learning Research, pp. 7324-7334. PMLR, 2019. URL http://proceedings.mlr.press/v97/zhang19a.html. +Ya-Jie Zhang, Shifeng Pan, Lei He, and Zhen-Hua Ling. Learning latent representations for style control and transfer in end-to-end speech synthesis. In ICASSP 2019-2019 IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP), pp. 6945-6949. IEEE, 2019. + +# A DETAILS ON BVAE-TTS + +# A.1 ALGORITHMS + +Algorithm 1: Pseudo-code of BVAE-TTS training +Data: +x,y: a mel-spectrogram, a phoneme sequence +Q,K,V, $\mathbf{V}_{\mathrm{exp}}$ query, key, value, and expanded value matrices +h,hexp: hidden representations, expanded hidden representations +BVAE-TTS[b,l]: an $l$ -th BVAE layer in $b$ -th BVAE block. PEquery,PEkey: positional encoding vectors for query and key +A: a soft attention map obtained before applying the ST-argmax technique +D: phoneme durations extracted from the attention map + $\hat{D}$ : phoneme durations predicted by the duration predictor + $\alpha$ : a warm-up constant +Result: + $\hat{\mathbf{x}}$ : a reconstructed mel-spectrogram +Ltotal,Lrecon, $\mathcal{L}_{KL},\mathcal{L}_{dur},\mathcal{L}_{guide}$ total loss, and losses that make up the total loss +K,V<-TextEncoder(y); + $h\gets \mathrm{PreNet}(\mathbf{x})$ +for $b\gets 0$ to $B - 1$ do if $b \% 2 = = 1$ then h $\leftarrow$ Downsample (h); end for $l\gets 0$ to $L - 1$ do h, $\Delta \mu_{k_1},\Delta \Sigma_{k_1}\gets \mathrm{BVAE - TTS}[b,l].$ BottomUp (h); BVAE-TTS[b,l]. $\Delta \mu_{k_1}\gets \Delta \mu_{k_1};$ BVAE-TTS[b,l]. $\Delta \Sigma_{k_1}\gets$ Softplus( $\Delta \Sigma_{k_1}$ ); end +end +Q