summaries: They are proposing a meta-learning method inspired by previous method, MAML. Their idea is separating the parameters in to two groups of context and shared parameters. The context parameters are learned through back-propagation of inner-loop and represents embedding for individual task. Shared-parameters on the other hand are shared between all tasks, and are learned in the outer-loop.  CAML is a gradient-based meta-learning method closely related to MAML. It divides model parameters into disjoint sets of task-specific parameters $\phi$ which are adapted to each task and task-independent parameters $\theta$ with are meta-learned across tasks. $\phi$ are then interpreted as an embedding and fed as input to the model (parameterized by $\theta$). Experiments demonstrate that this approach performs on par with MAML while adapting far fewer parameters. An additional benefit is that this approach is less sensitive to the adaptation learning rate and is easier to implement and faster to compute.
abstractText: We propose CAML, a meta-learning method for fast adaptation that partitions the model parameters into two parts: context parameters that serve as additional input to the model and are adapted on individual tasks, and shared parameters that are meta-trained and shared across tasks. At test time, the context parameters are updated with one or several gradient steps on a task-specific loss that is backpropagated through the shared part of the network. Compared to approaches that adjust all parameters on a new task (e.g., MAML), our method can be scaled up to larger networks without overfitting on a single task, is easier to implement, and saves memory writes during training and network communication at test time for distributed machine learning systems. We show empirically that this approach outperforms MAML, is less sensitive to the task-specific learning rate, can capture meaningful task embeddings with the context parameters, and outperforms alternative partitionings of the parameter vectors.
references.authors: Marcin Andrychowicz Misha Denil Sergio Gomez Matthew W Hoffman David Pfau Tom Schaul Brendan Shillingford Nando De Freitas
references.title: Learning to learn by gradient descent by gradient descent
references.venue: In Advances in Neural Information Processing Systems,
references.authors: Matthias Bauer Mateo Rojas-Carulla Jakub Bartlomiej Swikatkowski Bernhard Scholkopf Richard E Turner
references.title: Discriminative k-shot learning using probabilistic models
references.venue: arXiv preprint arXiv:1706.00326,
references.authors: Samy Bengio Yoshua Bengio Jocelyn Cloutier Jan Gecsei
references.title: On the optimization of a synaptic learning rule
references.venue: In Preprints Conf. Optimality in Artificial and Biological Neural Networks,
references.authors: Jeff Donahue Yangqing Jia Oriol Vinyals Judy Hoffman Ning Zhang Eric Tzeng Trevor Darrell
references.title: Decaf: A deep convolutional activation feature for generic visual recognition
references.venue: In International conference on machine learning,
references.authors: Chelsea Finn Pieter Abbeel Sergey Levine
references.title: Model-agnostic meta-learning for fast adaptation of deep networks
references.venue: arXiv preprint arXiv:1703.03400,
references.authors: Chelsea Finn Tianhe Yu Tianhao Zhang Pieter Abbeel Sergey Levine
references.title: One-shot visual imitation learning via meta-learning
references.venue: arXiv preprint arXiv:1709.04905,
references.authors: Chelsea Finn Kelvin Xu Sergey Levine
references.title: Probabilistic model-agnostic meta-learning
references.venue: arXiv preprint arXiv:1806.02817,
references.authors: Spyros Gidaris Nikos Komodakis
references.title: Dynamic few-shot visual learning without forgetting
references.venue: In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition,
references.authors: Jonathan Gordon John Bronskill Matthias Bauer Sebastian Nowozin Richard E Turner
references.title: Decisiontheoretic meta-learning: Versatile and efficient amortization of few-shot learning
references.venue: arXiv preprint arXiv:1805.09921,
references.authors: Erin Grant Chelsea Finn Sergey Levine Trevor Darrell Thomas Griffiths
references.title: Recasting gradient-based metalearning as hierarchical bayes
references.venue: arXiv preprint arXiv:1801.08930,
references.authors: Kaiming He Xiangyu Zhang Shaoqing Ren Jian Sun
references.title: Delving deep into rectifiers: Surpassing human-level performance on imagenet classification
references.venue: In Proceedings of the IEEE international conference on computer vision,
references.authors: Diederik P Kingma Jimmy Ba
references.title: Adam: A method for stochastic optimization
references.venue: arXiv preprint arXiv:1412.6980,
references.authors: Iasonas Kokkinos
references.title: Ubernet: Training a universal convolutional neural network for low-, mid-, and high-level vision using diverse datasets and limited memory
references.venue: In CVPR,
references.authors: Yoonho Lee Seungjin Choi
references.title: Gradient-based meta-learning with learned layerwise metric and subspace
references.venue: In International Conference on Machine Learning,
references.authors: Zhenguo Li Fengwei Zhou Fei Chen Hang Li
references.title: Meta-sgd: Learning to learn quickly for few shot learning
references.venue: arXiv preprint arXiv:1707.09835,
references.authors: Volodymyr Mnih Koray Kavukcuoglu David Silver Andrei A Rusu Joel Veness Marc G Bellemare Alex Graves Martin Riedmiller Andreas K Fidjeland Georg Ostrovski
references.title: Human-level control through deep reinforcement learning
references.authors: Alex Nichol John Schulman
references.title: Reptile: a scalable metalearning algorithm
references.venue: arXiv preprint arXiv:1803.02999,
references.authors: Boris N Oreshkin Alexandre Lacoste Pau Rodriguez
references.title: Tadam: Task dependent adaptive metric for improved few-shot learning
references.venue: arXiv preprint arXiv:1805.10123,
references.authors: Ethan Perez Florian Strub Harm De Vries Vincent Dumoulin Aaron Courville
references.title: Film: Visual reasoning with a general conditioning layer
references.venue: arXiv preprint arXiv:1709.07871,
references.authors: Siyuan Qiao Chenxi Liu Wei Shen Alan L Yuille
references.title: Few-shot image recognition by predicting parameters from activations
references.venue: CoRR, abs/1706.03466,
references.authors: Sachin Ravi Hugo Larochelle
references.title: Optimization as a model for few-shot learning
references.venue: In International Conference on Learning Representations (ICLR),
references.authors: Marek Rei
references.title: Online representation learning in recurrent neural language models
references.venue: arXiv preprint arXiv:1508.03854,
references.authors: Andrei A Rusu Dushyant Rao Jakub Sygnowski Oriol Vinyals Razvan Pascanu Simon Osindero Raia Hadsell
references.title: Meta-learning with latent embedding optimization
references.venue: arXiv preprint arXiv:1807.05960,
references.authors: Steindór Sæmundsson Katja Hofmann Marc Peter Deisenroth
references.title: Meta reinforcement learning with latent variable gaussian processes
references.venue: arXiv preprint arXiv:1803.07551,
references.authors: Jürgen Schmidhuber
references.title: Evolutionary Principles in Self-referential Learning: On Learning how to Learn: the Meta-meta-meta...-hook
references.authors: John Schulman Sergey Levine Pieter Abbeel Michael Jordan Philipp Moritz
references.title: Trust region policy optimization
references.venue: In International Conference on Machine Learning,
references.authors: Daniel L Silver Ryan Poirier Duane Currie
references.title: Inductive transfer with context-sensitive neural networks
references.venue: Machine Learning,
references.authors: Jake Snell Kevin Swersky Richard Zemel
references.title: Prototypical networks for few-shot learning
references.venue: In Advances in Neural Information Processing Systems,
references.authors: Oriol Vinyals Charles Blundell Tim Lillicrap Daan Wierstra
references.title: Matching networks for one shot learning
references.venue: In Advances in Neural Information Processing Systems,
references.authors: Nicolai Wojke Alex Bewley Dietrich Paulus
references.title: Simple online and realtime tracking with a deep association metric
references.venue: In Image Processing (ICIP),
references.authors: Fengwei Zhou Bin Wu Zhenguo Li
references.title: Deep meta-learning: Learning to learn in the concept space
references.venue: arXiv preprint arXiv:1802.03596,
sections.heading: 1 INTRODUCTION
sections.text: A key challenge in meta-learning is fast adaptation: learning on previously unseen tasks fast and with little data. In principle, this can be achieved by leveraging knowledge obtained in other, related tasks. However, the best way to do so remains an open question.
  A popular recent method for fast adaptation is model agnostic meta learning (MAML) (Finn et al., 2017a), which learns a model initialisation, such that at test time the model can be adapted to solve the new task in only a few gradient steps. MAML has an interleaved training procedure, comprised of inner loop and outer loop updates that operate on a batch of tasks at each iteration. In the inner loop, MAML learns task-specific parameters by performing one gradient step on a task-specific loss. Then, in the outer loop, the model parameters from before the inner loop update are updated to reduce the expected loss across tasks after the inner loop update on the individual tasks. Hence, MAML learns a model initialisation that, at test time, can generalise to a new task after only a few gradient updates.
  However, while MAML adapts the entire model to the new task, many transfer learning algorithms adapt only a fraction of the model (Kokkinos, 2017), keeping the rest fixed across tasks. For example, representations learned for images can be transferred to different image classification domains (Donahue et al., 2014) or reused for object tracking in videos (Wojke et al., 2017). This suggests that some model parameters can be considered task independent and others task specific. Adapting only some model parameters can make learning faster and easier, as well as mitigate overfitting and catastrophic forgetting.
  To this end, we propose context adaptation for meta-learning (CAML), a new method for fast adaptation via meta-learning. Like MAML, CAML learns a model initialisation that can quickly be adapted to new tasks. However, unlike MAML, it adapts only a subset of the model parameters to the new task. While restricting adaptation in this way is straightforward, it raises a key question: how should we decide which parameters to adapt and which to keep fixed? The main insight behind CAML is that, for many fast adaptation problems, the inner loop reduces to a task identification problem, rather than learning how to solve the whole task, which is typically infeasible with only a few gradient updates. Thus, it suffices if the part of the model that varies across tasks is an additional input to the model, and is independent of its other inputs.
  These additional inputs, which we call context parameters (see Figure 1), can be interpreted as a task embedding that modulates the behaviour of the model. This embedding is learned via backpropagation during the inner loop of a meta-learning procedure similar to MAML, while the rest of the model is updated only in the outer loop. This allows CAML to explicitly optimise the task-independent parameters ✓ for good performance across tasks, while ensuring that the task-specific context parameters can quickly adapt to new tasks.
  This separation of task solver and task embedding has several advantages. First, the size of both components can be chosen appropriately for the task. In particular, the network can be made expressive enough without overfitting to a single task in the inner loop, which we show empirically MAML is prone to. Model design and architecture choice also benefit from this separation, since for many practical problems we have prior knowledge of which aspects vary across tasks and hence how much capacity the context parameter should have. Like MAML, our method is model-agnostic, i.e., it can be applied to any model that is trained via gradient descent. However, CAML is easier to implement: assigning the correct computational graphs for higher order gradients is done only on the level of the context parameters, avoiding manual access and operations on the network weights and biases. Furthermore, parameter copies are not necessary which saves memory writes, a common bottleneck for running on GPUs. CAML can also help distributed machine learning systems, where the same model is deployed to different machines and we wish to learn different contexts concurrently. Network communication is often the bottleneck, which is mitigated by only sharing the (gradients of) context parameters.
  We show empirically that CAML outperforms MAML on a regression and classification task and performs similarly on a reinforcement learning problem, while adapting significantly fewer parameters at test time. We observe that CAML is less sensitive to the inner-loop learning rate, and can be scaled up to larger networks without overfitting. We also demonstrate that the context parameters represent meaningful embeddings of tasks, confirming that the inner loop acts as a task identification step.
sections.heading: 2 BACKGROUND: META-LEARNING FOR FAST ADAPTATION
sections.text: We consider settings where the goal is to learn models that can quickly adapt to a new task with only little data. To this end, learning on the new task is preceded by meta-learning on a set of related tasks. Here we describe the meta-learning problem for supervised and reinforcement learning, as well as the method MAML.
sections.heading: 2.1 PROBLEM SETTING
sections.text: In few-shot learning problems, we are given distributions over training tasks ptrain(T ) and test tasks ptest(T ). Training tasks can be used to learn how to adapt fast to any of the tasks with little per-task data, and evaluation is done on previously unseen test tasks. Unless stated otherwise, we assume that ptrain = ptest and refer to both as p. Tasks in p typically share some structure, so that transferring knowledge between tasks speeds learning. During each meta-training iteration, a batch of N tasks T = {Ti}Ni=1 is sampled from p. Supervised Learning. In a supervised learning setting, we learn a model f that maps data points x 2 X that have a true label y 2 Y to predictions ŷ 2 Y . A task Ti is defined as a tuple Ti = (X ,Y,L, q), where X is the input space, Y is the output space, L(y, ŷ) is a task-specific loss function, and q(x, y) is a distribution over labelled data points. We assume that all data points are drawn i.i.d. from q. Different tasks can be created by changing any element of Ti. Training in the supervised meta-learning setting proceeds over meta-training iterations, where for every task Ti 2 T from the current batch, we sample two datasets Dtraini (for training) and Dtesti from qTi :
  Dtrain i
  = {(x, y)i,m}M train i
  m=1 , Dtesti = {(x, y)i,m} M
  test i
  m=1, (1)
  where (x, y) ⇠ qTi . M traini and M testi are the number of training and test datapoints, respectively. The training data is used to update f , and the test data is then used to evaluate how good this update was, and adjust f or the update rule accordingly.
  Reinforcement Learning. In a reinforcement learning (RL) setting, we aim to learn a policy ⇡ that maps states s 2 S to actions a 2 A. Each task corresponds to a Markov decision process (MDP): a tuple Ti = (S,A, r, q, q0), where S is a set of states, A is a set of actions, r(st, at, st+1) is a reward function, q(st+1|st, at) is a transition function, and q0(s0) is an initial state distribution. The goal is to maximise the expected cumulative reward J under ⇡,
  J (⇡) = Eq0,q,⇡
  " H 1X
  t=0
  t r(st, at, st+1) # , (2)
  where H 2 N [1 is the horizon and 2 [0, 1] is the discount factor. Again, different tasks can be created by changing any element of Ti.
  During each meta-training iteration, for every task Ti 2 T from the current batch, we first collect a trajectory ⌧
  train i = {s0, a0, r0, s1, a1, r1, . . . , sM traini 1, aM traini 1, rM traini 1, sM traini } , (3) where the initial state s0 is sampled from q0, the actions are chosen by the current policy ⇡, the state transitions according to q, and M train
  i is the number of environment interactions available, We unify several episodes in
  this formulation: if the horizon H is reached within the trajectory, the environment is reset using q0. Once the trajectory is collected, this data is used to update the policy. Another trajectory ⌧ test
  i is then collected by rolling
  out the updated policy for M test i time steps. This test trajectory is used to evaluate the quality of the update on that task, and to adjust ⇡ or the update rule accordingly.
  Evaluation for both supervised and reinforcement learning problems is done on a new (unseen) set of tasks drawn from p (or ptest if the test distribution of task is different). For each such task, the model is updated using L or J and only few datapoints (Dtrain or ⌧ train). Performance of the updated model is reported on Dtest or ⌧ test.
sections.heading: 2.2 MODEL-AGNOSTIC META-LEARNING
sections.text: One method for few-shot learning is model-agnostic meta-learning (Finn et al., 2017a, MAML). Here, we describe the application of MAML to a supervised learning setting. MAML learns an initialisation for the parameters ✓ of a model f✓ such that, given a new task, a good model for that task can be learned with only a small number of gradient steps and data points. In the inner loop, MAML computes new task-specific parameters ✓i (starting from ✓) via one1 gradient update,
  ✓i = ✓ ↵r✓ 1
  M i
  train
  X
  (x,y)2Dtraini
  LTi(f✓(x), y) . (4)
  For the meta-update in the outer loop, the original model parameters are then updated with respect to the performance after the inner-loop update, i.e.,
  ✓ ✓ r✓ 1
  N
  X
  Ti2T
  1
  M i test
  X
  (x,y)2Dtesti
  LTi(f✓i(x), y) . (5)
  The result of training is a model initialisation ✓ that can be adapted with just a few gradient steps to any new task that we draw from p. Since the gradient is taken with respect to the parameters ✓ before the inner-loop update (4), the outer-loop update (5) involves higher order derivatives in ✓.
sections.heading: 3 FAST CONTEXT ADAPTATION VIA META-LEARNING
sections.text: We propose to partition the model parameters into two parts: context parameters that are adapted in the inner loop on an individual task, and parameters ✓ that are shared across tasks and meta-learned in the outer loop. In the following we describe the training procedure for supervised and reinforcement learning problems. Pseudo-code is provided in Appendix A.
sections.heading: 3.1 SUPERVISED LEARNING
sections.text: At every meta-training iteration and for the current batch T of tasks, we use the training data Dtrain i as follows. Starting from 0, which can either be fixed or meta-learned as well (we often choose 0 = 0; see Section 3.4), we learn task-specific parameters i via one gradient update:
  i = 0 ↵r 1
  M train i
  X
  (x,y)2Dtraini
  LTi(f 0,✓(x), y) . (6)
  While we only take the gradient with respect to , the updated parameter i is also a function of ✓, since during backpropagation, the gradients flow through the model. Once we have collected the updated parameters i for all sampled tasks, we proceed to the meta-learning step, in which ✓ is updated:
  ✓ ✓ r✓ 1
  N
  X
  Ti2T
  1
  M test i
  X
  (x,y)2Dtesti
  LTi(f i,✓(x), y) . (7)
  This update includes higher order gradients in ✓ due to the dependency on (6). 1We outline the method for one gradient update here, but several gradient steps can be performed at this point as well.
  Figure 1: Context adaptation. A network layer hl is augmented with additional context parameters (red), which are initialised to 0 before each adaptation step. The context parameters are updated by gradient descent during each inner loop and during test time. The network parameters ✓ (green) are only updated in the outer loop and shared across tasks. Hence, they stay fixed at test time. By initialising to 0, the network parameters associated with the context parameters (blue) do not affect the output of the layer before adaptation. After the first adaptation step they are used to modulate the rest of the network in order to solve the new task.
sections.heading: 3.2 REINFORCEMENT LEARNING
sections.text: During each iteration, for a current batch of MDPs T = {Ti}Ni=1, we proceed as follows. Given 0 (see Section 3.4), we collect a rollout ⌧ train
  i by executing the policy ⇡ 0,✓. We then compute task-specific parameters i via
  one gradient update: i = 0 + ↵r J̃Ti(⌧ traini ,⇡ 0,✓), (8)
  where J̃ (⌧,⇡) is an objective function given by any gradient-based reinforcement learning method that uses trajectories ⌧ produced by a parameterised policy ⇡ to update that policy’s parameters, such as TRPO (Schulman et al., 2015) or DQN (Mnih et al., 2015). After updating the policy, we collect another trajectory ⌧ test
  i to evaluate
  the updated policy, where actions are chosen according to the updated policy ⇡ i,✓.
  After doing this for all tasks in T, we continue with the meta-update step. Here, we update the parameters ✓ to maximise the average performance across tasks (after individually updating for them),
  ✓ ✓ + r✓ 1
  N
  X
  MDPi2T J̃Ti(⌧ testi ,⇡ i,✓). (9)
  This update includes higher order gradients in ✓ due to the dependency on (8).
sections.heading: 3.3 CONDITIONING ON CONTEXT PARAMETERS
sections.text: Since are independent of the network input, we need to decide where and how to condition the network on them. For an output node h(l)
  i at a fully connected layer l, this can for example be done by simply concatenating
  to the inputs to that layer:
  h (l) i = g
  0 @ JX
  j=1
  ✓ (l,h) j,i h (l 1) j
  + KX
  k=1
  ✓ (l, ) k,i 0,k + b
  1
  A , (10)
  where g is a non-linear activation function, b is a bias parameter, ✓(l,h) j,i
  are the weights associated with layer input h(l 1)
  j , and ✓(l, ) k,i are the weights associated with the context parameter 0,k. This is illustrated in Figure
  1. The context parameters can be added at any layer. In our experiments, we add at the first layer for fully connected networks.
  Other conditioning methods can be used with CAML as well. E.g., for convolutional networks, we use the feature-wise linear modulation FiLM method (Perez et al., 2017) for image classification experiments (Section 5.2). FiLM conditions by doing an affine transformation on the feature maps: given context parameters and a convolutional layer that outputs M feature maps {hi}Mi=1, FiLM applies a linear transformation to each feature map FiLM(hi) = ihi+ , where the parameters , 2 RM are a function of the context parameters. We use a fully connected layer [ , ] = P K
  k=1 ✓ (l, ) k,i
  0,k+b with the identity function at the output. In our experiments, we found it helps performance to add the context parameters not at the first layer, but after a few convolutions (in our case, after the third out of four convolution operations).
sections.heading: 3.4 CONTEXT PARAMETER INITIALISATION
sections.text: When learning a new task, the context parameters have to be initialised to some value, 0. We argue that, instead of meta-learning this initialisation as well, a fixed 0 is sufficient: in (10), if both ✓ (l, ) j,i
  and 0 are meta-learned, the learned initialisation of can be subsumed into the bias parameter b, and 0 can be set to a fixed value. The same holds for conditioning when using FiLM layers. A key benefit of CAML is therefore that it is easy to implement, since the initialisation of the context parameters does not have to be meta-learned and parameter copies are not required. We set 0 = 0 in our implementation, which gives the additional opportunity for visual inspection of the learned context parameters (see Sections 5.1 and 5.3).
sections.heading: 3.5 LEARNING RATE
sections.text: Since the context parameters are inputs to the model, the gradients at this point are not backpropagated further through any other part of the model. Furthermore, because learning and ✓ is decoupled, the inner loop learning rate can effectively be meta-learned by the rest of the model. This makes the method robust to the initial learning rate that is chosen for the inner loop, as we show empirically in Sections 5.1 and 5.3.
sections.heading: 4 RELATED WORK
sections.text: Meta-learning, or learning to learn, has been explored in various ways in the literature. One general approach is to learn the algorithm or update function itself (a.o., Schmidhuber (1987), Bengio et al. (1992), Andrychowicz et al. (2016), Ravi and Larochelle (2017)). Another approach is to meta-learn a model initialisation such that the model can perform well on a new task after only few gradient steps, such as MAML (Finn et al., 2017a). Other such methods are REPTILE (Nichol and Schulman, 2018) which does not require second order gradient computation and Meta-SGD (Li et al., 2017), which learns the per-parameter inner loop learning rate. Recent work (Grant et al., 2018; Finn et al., 2018) also considers Bayesian interpretations of MAML. The main difference to our work is that we consider to only adapt a small number of parameters in the inner learning loop / at test time, and that these parameters come in the form of input context parameters.
  In Finn et al. (2017b) the authors augment the model with additional biases to improve the performance of MAML in a robotic manipulation setting. In contrast, we update only the context parameters in the inner loop, and initialise them to 0 before adaptation to a new task. A similar approach to ours, but in the context of neural language models, was done by Rei (2015). However, they do not consider the application of the method to the variety of domains covered by this paper (something briefly explored in the appendix of Finn et al. (2017a)).
  Lee and Choi (2018) propose a framework to learn which parameters of the network to update in MAML, called MT-Nets. These learn a T-net and an M-Net. The M-net is a mask which decides which parameters to update in the inner loop, and is sampled (from a learned probability distribution) for each new task. The T-net is responsible for learning the task-specific update direction and step size. The idea of dynamic partitioning is attractive however it results in a more complex meta learning algorithm. In this work we consider a simpler, more interpretable alternative where the task-specific and shared parameters are disjoint sets.
  Other meta-learning methods are also motivated by the fact that learning in a high-dimensional parameter space can pose practical difficulties, and fast adaptation in lower dimensional space is easier (e.g., Sæmundsson et al. (2018); Zhou et al. (2018)). Rusu et al. (2018) propose to learn a low-dimensional latent generative representation of (some of) the model parameters and perform gradient-based adaptation on a new task in this space, instead of the high-dimensional parameter space. Our method is similar but instead attempts to learn a latent representation of the task by backpropagating through the inner loss.
  Context features as a component of inductive transfer were first introduced by Silver et al. (2008), who use a one-hot encoded task-specifying context as input to the network (which is not learned but predefined). They show that this works better than learning a shared feature extractor and having separate heads for all tasks. Learning a task embedding itself has been also explored, e.g., by Oreshkin et al. (2018), who use the task’s training set to condition the network via FiLM (Perez et al., 2017) parameters. By contrast, we learn the context parameters via backpropagation through the same network that is used to solve the task.
sections.heading: 5 EXPERIMENTS
sections.text: In this section we empirically evaluate CAML. Our extensive experiments aim to demonstrate three qualities of our method. First, adapting a small number of input parameters during the inner loop is sufficient to yield performance equivalent to or better than MAML in a range of regression, classification and reinforcement learning tasks. Like in MAML, it is possible to continue learning by performing several gradient update steps at test time, even when training using only one gradient step. Second, CAML is robust to the task-specific learning rate and scales well to more expressive networks without overfitting. Third, an embedding of the task emerges in the context parameters solely via backpropagation through the original inner loss. The implementation and scripts to reproduce the results are available at [blinded for review].
sections.heading: 5.1 REGRESSION
sections.text: We start with the regression problem of fitting sine curves, using the same setup as Finn et al. (2017a) to allow a direct comparison. A task is defined by the amplitude and phase of the sine curve, and is generated by uniformly sampling the amplitude from [0.1, 0.5] and the phase from [0,⇡]. For training, ten labelled datapoints (uniformly sampled from x 2 [ 5, 5]) are given for each task for the inner loop update. Per meta-update we iterate over a batch of 25 tasks and perform gradient descent on a mean-squared error (MSE) loss. We use a neural network with two hidden layers and 40 nodes each and ReLU non-linearities. During testing we present the model with ten datapoints from 1000 newly sampled tasks and measure MSE over 100 test points.
  CAML uses the same training procedure and architecture but adds context parameters. To allow a fair comparison, we add the same number of additional inputs to MAML, an extension that was also done by Finn et al. (2017b). These additional parameters are meta-learned together with the rest of the network, which can improve performance due to a more expressive gradient. Our method differs from this formulation in that we update only the context parameters in the inner loop, and reinitialise them to zero for each new task. In the outer loop, we only update the shared parameters.
  Table 1 shows that CAML outperforms the original MAML (with no additional inputs) significantly, and MAML with the same network architecture by a small margin. This performance gain is possible even though at test time, CAML adapts only 2-5 parameters, instead of around 1600. To test the hypothesis that it suffices to adapt only input parameters per task, we also compare to alternative parameter partitions in Table 2. In parallel partitioning, we choose a strict subset of the nodes of each layer for task-specific adaptation, and meta-learn the rest. In stacked partitioning, we choose one or several layers for task-specific adaptation, and meta-learn the other layers. The results confirm that partitioning on context parameters is key to success: the other variants perform worse, often significantly so. A recent method was proposed by Lee and Choi (2018), where they also partition the network to adapt only part of it on a specific task – the partitioning mask, however, is learned. They
  test their method on the regression task as well, but we outperform the numbers they report significantly (not shown, since we believe this might be due to implementational details). In the next section we will see that on few-shot classification, this approach achieves comparable performance to our method.
  MAML is known to keep learning after several gradient update steps. We test this on our method as well, with the results shown in Figure 2 for up to 10 gradient steps. CAML outperforms MAML even after taking several gradient update steps, and is more stable, as indicated by the size of the confidence intervals and the monotonic learning curve.
  As described in Section 3.4, CAML has the freedom to scale the gradients at the context parameters since they are inputs to the model and trained separately. Figure 4 plots the inner learning rate against the norm of the gradient of the context parameters at test time. We can see that the weights are adjusted so that lower learning rates bring about larger context parameter gradients and vice-versa. This results in the method being extremely robust to learning rates as confirmed by Figure 5. We plot the performance while varying the learning rate from 10 7 to 102. CAML is robust to changes in learning rate while MAML performs well only in a small range. Work by Li et al. (2017) shows that MAML can be improved by learning a parameter-specific learning rate, which, however, introduces a lot of additional parameters.
  CAML’s performance on the regression task correlates with how many variables are needed to encode the tasks. In these experiments, two parameters vary between tasks, which is exactly the context parameter dimensionality at which CAML starts to perform well (the optimal encoding is three dimensional, as phase is periodic). This suggests CAML may indeed learn task descriptions in the context parameters. Figure 3 illustrates this by plotting the value of the learned inputs against the amplitude/phase of the task in the case of two context parameters. The model learns a smooth embedding in which interpolation between tasks is possible.
sections.heading: 5.2 CLASSIFICATION
sections.text: To evaluate CAML on a more challenging problem, we test it on the competitive few-shot image classification benchmark Mini-Imagenet (Ravi and Larochelle, 2017). In N -way K-shot classification. a task is a random selection of N classes, for each of which the model gets to see K examples. From these it must learn to classify unseen images from the N classes. The Mini-Imagenet dataset consists of 64 training classes, 12 validation classes, and 24 test classes. During training, we generate a task by selecting N classes at random from the 64 classes and training the model on K examples of each, i.e., a batch of N ⇥K images. The meta-update is done on a set of unseen images of the same classes.
  On this benchmark, MAML uses a network with four convolutional layers with 32 filters each and one fully connected layer at the output (Finn et al., 2017a). We use the same network architecture, but with between 32 and 512 filters per layer. We use 100 context parameters and add a FiLM layer (see Section 3.3) that conditions on these after the third convolutional layer. The parameters of the FiLM layer are meta-learned with the rest of the network, i.e., they are part of ✓. All our models were trained with two gradient steps in the inner loop and evaluated with two gradient steps (note: MAML was trained with five inner-loop gradient steps and evaluated with ten gradient steps). The inner learning rate was set to 1.0. Following Finn et al. (2017a), we ran each experiment for 60K meta-iterations and selected the model with the highest validation accuracy for evaluation on the test set.
  Table 3 shows our results on Mini-Imagenet held-out test data for 5-way 1-shot and 5-shot classification. We compare to a number of existing meta-learning approaches that use convolutional neural networks, including MAML. Our largest model (512 filters) clearly outperforms MAML, and outperforms the other methods on the 1-shot classification task. On 5-shot classification, the best results are obtained by prototypical networks (Snell et al., 2017), a method that is specific to few-shot classification and works by computing distances to prototype representations of each class. Our smallest model (32 filters) under-performs MAML (within the confidence intervals). As we can see, CAML benefits from increasing model expressiveness: since we only adapt the context parameters in the inner loop per task, CAML can substantially increase the network size, without overfitting during the inner loop update. We tested scaling up MAML to a larger network size as well (see Table 3), but found that this hurt accuracy. The table only compares CAML to approaches that use conventional convolutional neural networks. Approaches that use much deeper, residual networks (e.g., Gidaris and Komodakis (2018), (Bauer et al., 2017), (Oreshkin et al., 2018), (Qiao et al., 2017)) can achieve higher accuracies. To the best of our knowledge, the LEO method by Rusu et al. (2018) is the current state of the art
  with 60% and 75.7% accuracy on 1 and 5-shot respectively. Our method can be readily applied to deep residual networks as well, and we leave this exploration for future work. Table 3 also shows the first order approximation of our largest models, where the gradient with respect to ✓ is not backpropagated through the inner loop update of the context parameters . As expected, this results in a lower accuracy (a drop of 1 2%) , but we are still able to outperform MAML with a first-order version of our largest network.
  Thus, CAML can achieve much higher accuracies than MAML by increasing the network size, without overfitting. Our results are obtained by only adjusting 100 parameters at test time, instead of > 30, 000 like MAML.
sections.heading: 5.3 REINFORCEMENT LEARNING
sections.text: To demonstrate the versatility of CAML, we also perform preliminary reinforcement learning experiments on a 2D Navigation task, also introduced by Finn et al. (2017a). In this domain, the agent moves in a 2D world using continuous actions. At each timestep it is given a negative reward proportional to its distance from a pre-defined goal position. Each task is defined by a new unknown goal position.
  We follow the same procedure as Finn et al. (2017a). Goals are sampled from an interval of (x, y) = [ 0.5, 0.5]. At each step we sample 20 tasks for both the inner and outer loops and testing is performed on 40 new unseen tasks. We perform learning for 500 iterations and the best performing policy during training is then presented with new test tasks and allowed two gradient updates. For each update, the total reward over 20 rollouts per task is measured. We use a two-layer network with 100 units per layer and ReLU non-linearities to represent the policy and a linear value function approximator. For CAML we use five context parameters at the input layer.
  In terms of performance (Fgure 6a) we can see that the two methods are highly competitive. MAML performs better after the first gradient update after it is surpassed by CAML. Figure 6b, which plots performance for several learning rates, shows that CAML is again less sensitive to the inner loop learning rate. Only when using a learning rate of 0.1 is MAML competitive in performance. Furthermore, CAML adapts 5 parameters whereas MAML adapts around 10, 000 parameters.
  As with regression, the optimal task embedding is low dimensional enough to plot. We therefore apply CAML with two context parameters and plot how these correlate with the actual position of the goal for 200 test tasks. Figure 6c shows that the context parameters obtained after two policy gradient updates represent a disentangled embedding of the actual task. Specifically, context parameter 1 appears to encode the y position of the goal, while context parameter 2 encodes the x position. Hence, CAML can learn compact potentially interpretable task embeddings via backpropagation through the inner loss.
sections.heading: 6 CONCLUSION AND FUTURE WORK
sections.text: In this paper we introduced CAML, a meta-learning approach for fast adaptation that introduces context parameters in addition to the model’s parameters. The context parameters are used to modulate the whole network during the inner loop of meta-learning, while the rest of the network parameters are adapted in the outer loop and shared across tasks. On regression, our method outperforms MAML and is superior to naive approaches to partitioning network parameters. We also showed that CAML is highly competitive with state of the art methods on few shot classification using CNNs. In addition to this, we experimented extensively with some unique properties that specifically arise from the way that our method is formulated, such as robustness to learning rate and the emergence of task embeddings at the context parameters. Another interesting extension would be to inspect the context parameter representations learned by CAML on the Mini-Imagenet benchmark using advanced dimensionality reduction techniques.
  In this paper we performed some preliminary RL experiments. We are interested in extending CAML to more challenging problems and explore its role in allowing for smart exploration in order to identify the task at hand. It would also be interesting to consider probabilistic extensions along the lines of PLATIPUS (Finn et al., 2018) where the context parameters include uncertainty about the task.
  Finally, the intriguing empirical properties of CAML detailed in this work will be the base of more theoretical investigations in the future.
sections.heading: A PSEUDO-CODE
sections.text: Algorithm 1 CAML for Supervised Learning Require: Distribution over tasks p(T ) Require: Step sizes ↵ and Require: Initial model f 0,✓ with ✓ initialised randomly and 0 = 0
  1: while not done do 2: Sample batch of tasks T = {Ti}Ni=1 where Ti ⇠ p 3: for all Ti 2 T do 4: Dtrain
  i ,Dtest i ⇠ qTi
  5: 0 = 0 6: i = 0 ↵r 1
  M train i
  P
  (x,y)2Dtraini
  LTi(f 0,✓(x), y)
  7: end for 8: ✓ ✓ r✓ 1N P Ti2T 1 M test i P (x,y)2Dtesti LTi(f i,✓(x, y)) 9: end while
  Algorithm 2 CAML for RL Require: Distribution over tasks p(T ) Require: Step sizes ↵ and Require: Initial policy ⇡ 0,✓ with ✓ initialised randomly and 0 = 0
  1: while not done do 2: Sample batch of tasks T = {Ti}Ni=1 where Ti ⇠ p 3: for all Ti 2 T do 4: Collect rollout ⌧ train
  i using ⇡ 0,✓
  5: i = 0 + ↵r J̃Ti(⌧ traini ,⇡ 0,✓) 6: Collect rollout ⌧ test
  i using ⇡ i,✓
  7: end for 8: ✓ ✓ + r✓ 1N P Ti2T J̃Ti(⌧ testi ,⇡ i,✓) 9: end while
sections.heading: B EXPERIMENTS
sections.text: B.1 CLASSIFICATION
  For Mini-Imagenet, our model takes as input images of size 84⇥ 84⇥ 3 and has 5 outputs, one for each class. The model has four modules that each consist of: a 2D convolution with a 3⇥3 kernel, padding 1 and 128 filters, a batch normalisation layer, a max-pooling operation with kernel size 2, if applicable a FiLM transformation (only at the third convolution, details below), and a ReLU activation function. The output size of these four blocks is 5⇥ 5⇥ 128, which we flatten to a vector and feed into one fully connected layer. The FiLM layer itself is a fully connected layer with inputs and a 256-dimensional output and the identity function at the output. The output is divided into and , each of dimension 128, which are used to transform the filters that the convolutional operation outputs. The context vector is of size 100 (other sizes tested: 50, 200) and is added after the third convolution (other versions tested: at the first, second or fourth convolution).
  The network is initialised using He et al. (2015) initialisation for the weights of the convolutional and fully connected weights (including the FiLM layer weights). The bias parameters are initialised to zero, except at the FiLM layer.
  We use the Adam optimiser for the meta-update step with an initial learning rate of 0.001. This learning rate is annealed every 5, 000 steps by multiplying it by 0.9. The inner learning rate is set to 0.1 (other hyperparameters tested: 1.0, 0.01).
  For Mini-Imagenet, we use a meta batchsize of 4 and 2 tasks for 1-shot and 5-shot classification respectively. For the batch norm statistics, we always use the current batch – also during testing. I.e., for 5-way 1-shot classification the batch size at test time is 5, and we use this batch for normalisation.
sections.heading: C PRACTICAL TIPS
sections.text: C.1 IMPLEMENTATION
  The context parameters can be added to any network, and do not require direct access to the rest of the network weights like MAML. In PyTorch this can be done as follows. To add CAML parameters to a network, it is necessary to first initialise them to zero when the model is initialised:
  self.context_params = torch.zeros(size=[self.num_context_params], requires_grad=True)
  Add a way to reset the context parameters to zero (e.g., a method that just does the above). During the forward pass, add the context parameters to the input by concatenating it (when using a fully connected network):
  x = torch.cat((x, self.context_params.expand(x.shape[0], -1)), dim=1)
  (This is for fully connected networks. We refer the reader to our implementation for how to use FiLM to condition CNNs.) To correctly set the computation graph for the outer loop, it is necessary to assign the context parameters manually with their gradient. In the inner loop, compute the gradient:
  grad = torch.autograd.grad(task_loss, model.context_params, create_graph=True)[0]
  The option create graph will make sure that you can take the gradient of grad again. Then, update the context parameters using one gradient descent step
  model.context_params = model.context_params - lr_inner * grad
  If you now do another forward pass and compute the gradient of the model parameters ✓ (for the outer loop), these will include higher order gradients because grad above includes gradients of ✓, and because we kept the computation graph via the option grad. To see how to train CAML and aggregate the meta-gradient over several tasks, see our implementation at [blinded for review].
  C.2 HYPERPARAMETER SELECTION
  The choice of network architecture/size and context parameters can be guided by domain knowledge. E.g., for the few-shot image classification problem, an appropriate model is a deep convolutional model. For the context parameters, it is important to make sure they are not underparameterised. CAML can deal with larger than necessary context parameters (see Table 1), however, at some point it would probably overfit to the current task in the inner loop. We have not experienced this in practise though. Regarding learning rates, we suggest to start with an inner loop learning rate of 1 and the Adam optimiser (Kingma and Ba, 2014) with the standard learning rate of 0.001 for the outer loop
  For CNNs, we found that adding the context parameters not at the input layer, but after several (in our case after the third out of four) convolutions works best. We believe this is because the lower-level features that the first convolutions extract are useful for any image classification task, and we only want our task embedding to influence the activations at the deeper layers. In our experiments we used a FiLM network with no hidden layers. We tried deeper versions, but this resulted in inferior performance.
  We also tested to add context parameters at several layers instead of only one. However, in our experience this resulted in similar (regression and RL) or worse (in the case of CNNs) performance.