Meta-Learning with Versatile Loss Geometries
for Fast Adaptation Using Mirror Descent
Abstract
Utilizing task-invariant prior knowledge extracted from related tasks, meta-learning is a principled framework that empowers learning a new task especially when data records are limited. A fundamental challenge in meta-learning is how to quickly “adapt” the extracted prior in order to train a task-specific model within a few optimization steps. Existing approaches deal with this challenge using a preconditioner that enhances convergence of the per-task training process. Though effective in representing locally a quadratic training loss, these simple linear preconditioners can hardly capture complex loss geometries. The present contribution addresses this limitation by learning a nonlinear mirror map, which induces a versatile distance metric to enable capturing and optimizing a wide range of loss geometries, hence facilitating the per-task training. Numerical tests on few-shot learning datasets demonstrate the superior expressiveness and convergence of the advocated approach.
Index Terms— Meta-learning, bilevel optimization, mirror descent, loss geometries
1 Introduction
The success of deep learning relies heavily on large-scale and high-dimensional models, which require extensive training using a large number of data. However, this “data-driven learning” approach is not feasible in applications where data are scarce due to costly data collection and labelling process. Examples of such applications include drug discovery [1], machine translation [2], and robot manipulation [3].
In contrast, meta-learning offers a powerful approach for learning a task in data-limited setups. Specifically, meta-learning extracts task-invariant prior information from a collection of given tasks, that can subsequently aid learning of a new, albeit related task. Although this new task may have limited training data, the prior serves as a strong inductive bias that effectively transfers knowledge to aid its learning. In image classification for instance, a feature extractor learned from a collection of given tasks can act as a common prior, and thus benefit a variety of other image classification tasks.
Depending on how this “data-limited learning” is performed, meta-learning algorithms can be categorized into neural network (NN)- and optimization-based ones. In NN-based ones, the per-task learning is viewed as an NN map** from its training data to task-specific model parameters [4, 5]. The prior information is encoded in the NN weights, which are shared and optimized across tasks. With the universality of NNs in approximating complex map**s granted, their black-box structure challenges their reliability and interpretability. On the other hand, optimization-based meta-learning alternatives interpret “data-limited learning” as a cascade of a few optimization iterations (a.k.a. adaptation) over the model parameters. The prior here is captured by the shared hyperparameters of the iterative optimizer. A representative of these alternatives is the model-agnostic meta-learning (MAML) [6], which views the prior as a learnable task-invariant initialization of the optimizer. By starting from an informative initial point, the model parameters can rapidly converge to local minima within a few gradient descent (GD) steps. Building upon MAML, a series of variants have been proposed to learn different priors [7, 8, 9].
While optimization-based meta-learning has been proven effective numerically, recent studies suggest that its generalization and stability heavily rely on convergence of per-task optimization [7, 9]. This motivates one to grow the number of descent iterations. However, this can be infeasible as the overall complexity of meta-learning scales linearly with the number of GD steps [7]. Besides, using accelerated first-order optimizers, such as Adam [10], introduces extra backpropagation complexity when optimizing the prior. To improve the per-task convergence without markedly adding to the complexity, another line of research focuses on second-order optimization using a learnable precondition matrix having simple form [11, 12, 13, 14, 15, 16]. In fact, the precondition matrix captures the local quadratic curvature of the training loss, and linearly transforms the gradient based on this curvature. To acquire more expressive preconditioners, recent advances suggest replacing the linear matrix multiplication with a nonlinear NN transformation [17]. However, convergence of this NN-manipulated GD is an uncharted territory.
The present work advocates learning a generic distance metric induced by a strictly increasing nonlinear mirror map, which enables efficient optimization over generic loss geometries. All in all, our contribution is three-fold.
-
i)
Broadening linear preconditioners with guaranteed per-task convergence.
-
ii)
Blockwise inverse autoregressive flow (blockIAF) ensuring monotonicity and scalability of the mirror map.
-
iii)
Numerical tests showing superior performance and improved convergence compared to linear preconditioners.
2 Problem setup
To enable “data-limited learning” of a new task, meta-learning forms task-invariant priors using a collection of given tasks indexed by . Each task comprises a dataset consisting of data-label pairs, which are split into a training subset , and a disjoint validation subset . The new task, indexed by , contains a training subset , and a set of test data for which the corresponding labels are to be predicted. The key premise of meta-learning is that all the aforementioned tasks share related model structures or data distributions. Thus, one can postulate a large model shared across all tasks, along with distinct model parameters per individual task. But since the cardinality can be much smaller than , learning a task by directly optimizing over is impractical. Fortunately, since is considerably large, a task-invariant prior can be learned using to render per-task learning well posed.
Letting denote the vector parameter of the prior, the meta-learning objective can be formulated as a bilevel optimization problem. The lower-level trains each task-specific model by optimizing using and from the upper-level. The upper-level adjusts by evaluating the optimized on the validation sets . The two levels depend on each other and yield the following nested objective
(1a) | ||||
(1b) |
where is the loss function capturing each task-specific model fit, and is the regularizer accounting for the task-invariant prior. From the Bayesian viewpoint, and represent the negative log-likelihood (nll), , and the negative log-prior (nlp) , where and ( denotes transpose). Bayes’ rule then implies ; is the maximum a posteriori (MAP) estimator.
Reaching the global optimum is generally infeasible because the task-specific model is nonlinear. Hence, a prudent remedy is to rely on an approximate solver obtained by a tractable optimizer. For instance, MAML replaces (1b) with a -step GD minimizing the nll:
(2) |
where indexes iterations; initialization ; approximate solver ; and denotes the step size. Although in MAML, it has been shown that the GD solver satisfies [18]
where the precision matrix is determined by , , and . This indicates that MAML’s optimization strategy (2) is approximately tantamount to an implicit Gaussian prior probability density function (pdf) , with the task-invariant initialization serving as the mean vector. Alongside implicit priors, their explicit counterparts have also been investigated with various prior pdfs [7, 9].
For both implicit and explicit priors, numerical studies [11, 13] and theoretical analyses [7, 9] demonstrate that the gradient error for optimizing in (1a) relies on the convergence accuracy of relative to a stationary point. In addition, employing a large or complicated optimizers could prohibitively escalate the overall complexity for solving (2). As a consequence, attention has been directed towards preconditioned GD (PGD) solvers, as in the update
(3) |
where parametrizes , and the prior parameter is augmented as . To ensure (3) incurs affordable complexity after preconditioning, must have a simple enough structure so that incurs computational complexity . Examples of such structures include diagonal [11, 12], block-diagonal [13, 14], and NN-based [15] matrices. A more generic preconditioner can be formed by replacing the linear transformation with a nonlinear NN [17], but unfortunately convergence of this alternative iterate may not be guaranteed.
Essentially, GD conducts a pre-step greedy search with a quadratic loss approximation. To see this, let . Using this linearization of at , the GD update reduces to (cf. (2))
(4) |
where dependencies on are dropped hereafter for notational brevity. The term implies the isotropic approximation , while (3) refines the approximation as a more informative matrix (if invertible). This quadratic local approximation is particularly effective when is large and is small, which gradually ameliorates to a stationary point. In meta-learning however, the standard setup relies on a small (e.g., or ) and a sufficiently large , so that the model can quickly adapt to the task with low complexity. This tradeoff highlights the need for learning more expressive loss geometries.
3 Loss Geometries using Mirror Descent
Instead of quadratic approximations of the local loss induced by certain norms (e.g., and ), our fresh idea is a data-driven distance metric that captures a broader spectrum of loss geometries. This is accomplished by learning the so-termed “mirror map,” which will be introduced first. All the proofs are delegated to Appendix A.
3.1 Modeling the loss geometry using the mirror map
To generalize the (P)GD, we will replace the -norm in (4) with a generic metric to arrive at
(5) |
where is the Bregman divergence, and the associated distance-generating function is strongly convex to ensure the existence and uniqueness of the minimizer. As a result, is strictly increasing, and thus invertible111When is discontinuous but is proper, the inverse is defined as , where is the Fenchel conjugate of .. Then, applying the optimality condition leads to the mirror descent (MD) update
(6) |
The invertible , dubbed mirror map, connects in the primal space to in the dual space under the endowed metric . As a special case, when choosing , it is easy to verify that (6) boils down to (2) due to the self-duality of the -norm. Likewise, (3) can be obtained with , where reduces to a linear map**. Function reflects our prior knowledge about the geometry of . In particular, letting (even when is not strong convex) in (5) gives , which is precisely the original nll minimization solved in (2) and (3). Thus, an ideal choice of would yield (up to a constant) within a sufficiently large region around .
Different from past works that rely on a simple preselected to model loss geometries, we here acquire a data-driven by learning a strictly increasing that best fits the given tasks. Interestingly, (6) can be reformulated to yield an update of the dual vector as
(7) |
with and . Hence, it suffices to learn a strictly increasing and a task-invariant dual initialization , thus removing the need for directly calculating .
3.2 Learning the inverse mirror map via blockIAF
Inspired by this observation, a prudent option is to model as an inverse autoregressive flow (IAF) [19]. The notable benefit of IAF lies in its efficient parallelization of forward computation, that makes it considerably faster than computing its inverse. However, directly applying the dimension-wise IAF to the high-dimensional will incur prohibitively high complexity of . For this reason, we introduce a novel blockIAF model that effectively reduces complexity by performing block-wise (nonlinear) autoregression on a low-dimensional space encoding . To this end, let be a partition of the index set , and denote the subvector of restricted to the block . The blockIAF model transforms to through
(8a) | ||||
(8b) |
where nonlinearity is positive and upper bounded (e.g., logistic function), are the scale and shift of , and denote learnable encoder and decoder for the -th block, and is the Hadamard (element-wise) product. In our implementation, and are multilayer perceptrons (MLPs) with ReLU activations. To further reduce complexity, all linear layers in MLPs are implemented by tensor mode product [13]. This technique is equivalent to a low-rank Kronecker approximation to MLPs’ weight matrices. This lowers the per-step MD complexity to .
The following theorem characterizes two important properties of the proposed blockIAF model.
Theorem 1.
Let be the blockIAF model (3.2). For any partition , is strictly increasing, that is
(9) |
Moreover, there exists a constant such that
(10) |
Theorem 1 asserts that with , one ensures the desired strict monotonicity, and strong convexity of the induced (by noting that ). As a result, the per-task optimization (7) enjoys the standard convergence guarantee of MD. Although the convergence rate of MD is in the same order as GD, it outperforms GD markedly in the constant factor when is large [20], and relies on more relaxed assumptions [21].
Method | Lower-level optimizer | Loss geometry model | -class accuracies | |
---|---|---|---|---|
-shot | -shot | |||
MAML [6] | GD | identity matrix | ||
MetaSGD [11] | PGD | diag. matrix | ||
MT-net [14] | PGD | block diag. matrix | ||
WarpGrad [15] | PGD | NN-based low-rank matrix | ||
MetaCurvature [13] | PGD | block diag. & Kron. (low-rank) matrix | ||
MetaKFO [17] | NN-transformed GD | NN-based gradient transformation | ||
ECML [16] | PGD | Gauss-Newton approximation | ||
This paper’s method | MD | blockIAF-based mirror map |
The meta-learning objective (2) is solved using alternating optimization. With denoting the blockIAF parameters, let be the prior parameter vector. In the -th iteration of (1a), the optimizer has access to provided by its last iteration, and a batch of randomly sampled tasks . The optimizer first solves for each leveraging the -step MD (7). Then, is updated using mini-batch stochastic GD with step size :
A summary of the algorithm can be found in Appendix B.
4 Numerical tests
Here we compare the empirical performance of optimization-based meta-learning using different lower-level optimizers, on the standard few-shot classification dataset miniImageNet [22], where “shots” signify the per-class training data for each . The task-specific model is a standard -layer convolutional NN (CNN) [22, 6]. Each layer comprises a convolution of channels, batch normalization, ReLU activation, and max pooling module. After the convolutional layers, a linear regressor with softmax activation is appended to perform classification. Subset is formed by the weight indices of the -th CNN layer. The autoregression in (8b) implies that “how to optimize weights of the -th layer” depends on “how weights of previous layers have been optimized.” This choice enables blockIAF to model the optimization dependency of high-level features (e.g., textures and patterns) on low-level ones (e.g., colors and edges). Test setups and hyperparameters can be found in Appendix C.
Table 1 lists various loss geometry models, where classification accuracy on new tasks is the figure of merit. For fairness, MAML is the backbone of all methods. By utilizing a more versatile loss geometry model, our approach outperforms the state-of-the-art ones by a large margin.
To further gauge the performance gain achieved by our novel approach, Fig. 1 visualizes the convergence of averaged on random new tasks. The proposed method results in faster convergence to a lower and more stable nll compared with all three competitors. Moreover, Fig. 0(a) reveals that both the proposed method and MetaCurvature improve the initialization compared to MAML and MetaSGD. This confirms that convergence and generalization of (1a) relies on the convergence accuracy of [7, 9]. Fig. 0(b) further illustrates that although the initial gradients of different methods have comparable norms , our method can make better use of the gradient, leading to a rapid reduction of the nll as well as its gradient norm at . This improved gradient utilization highlights our method’s superior modeling of loss geometries.
5 Conclusions and outlook
Versatile loss geometry models can accelerate the lower-level convergence in meta-learning. A novel BlockIAF model is introduced to learn the inverse mirror map induced by a strongly convex . The resultant algorithm generalizes preconditioning-based meta-learning, captures versatile loss geometries, and improves lower-level convergence. Effectiveness of the novel approach was validated on a standard few-shot dataset. Future research includes bi-level convergence guarantees for the proposed method, and development of more expressive yet scalable inverse mirror maps.
References
- [1] Han Altae-Tran, Bharath Ramsundar, Aneesh S. Pappu, and Vijay Pande, “Low data drug discovery with one-shot learning,” ACS Central Science, vol. 3, no. 4, pp. 283–293, 2017.
- [2] Jiatao Gu, Yong Wang, Yun Chen, Kyunghyun Cho, and Victor OK Li, “Meta-learning for low-resource neural machine translation,” arXiv preprint arXiv:1808.08437, 2018.
- [3] Ignasi Clavera, Anusha Nagabandi, Simin Liu, Ronald S. Fearing, Pieter Abbeel, Sergey Levine, and Chelsea Finn, “Learning to adapt in dynamic, real-world environments through meta-reinforcement learning,” in Proc. Int. Conf. Learn. Represent., 2019.
- [4] Sachin Ravi and Hugo Larochelle, “Optimization as a model for few-shot learning,” in Proc. Int. Conf. Learn. Represent., 2017.
- [5] Nikhil Mishra, Mostafa Rohaninejad, Xi Chen, and Pieter Abbeel, “A simple neural attentive meta-learner,” in Proc. Int. Conf. Learn. Represent., 2018.
- [6] Chelsea Finn, Pieter Abbeel, and Sergey Levine, “Model-agnostic meta-learning for fast adaptation of deep networks,” in Proc. Int. Conf. Mach. Learn., 2017, vol. 70, pp. 1126–1135.
- [7] Aravind Rajeswaran, Chelsea Finn, Sham M Kakade, and Sergey Levine, “Meta-learning with implicit gradients,” in Proc. Adv. Neural Inf. Process. Syst., 2019, vol. 32.
- [8] Kwonjoon Lee, Subhransu Maji, Avinash Ravichandran, and Stefano Soatto, “Meta-learning with differentiable convex optimization,” in Proc. IEEE/CVF Conf. on Comp. Vis. and Pat. Recog., 2019.
- [9] Yilang Zhang, Bingcong Li, Shijian Gao, and Georgios B. Giannakis, “Scalable bayesian meta-learning through generalized implicit gradients,” in Proc. AAAI Conf. Artif. Intel., 2023, vol. 37(9), pp. 11298–11306.
- [10] Diederik P. Kingma and Jimmy Ba, “Adam: A method for stochastic optimization,” in Proc. Int. Conf. Learn. Represent., 2015.
- [11] 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.
- [12] Boyan Gao, Henry Gouk, Hae Beom Lee, and Timothy M Hospedales, “Meta mirror descent: Optimiser learning for fast convergence,” arXiv preprint arXiv:2203.02711, 2022.
- [13] Eunbyung Park and Junier B Oliva, “Meta-curvature,” in Proc. Adv. Neural Inf. Process. Syst., 2019, vol. 32.
- [14] Yoonho Lee and Seung** Choi, “Gradient-based meta-learning with learned layerwise metric and subspace,” in Proc. Int. Conf. Mach. Learn., 2018, vol. 80, pp. 2927–2936.
- [15] Sebastian Flennerhag, Andrei A. Rusu, Razvan Pascanu, Francesco Visin, Hujun Yin, and Raia Hadsell, “Meta-learning with warped gradient descent,” in Proc. Int. Conf. Learn. Represent., 2020.
- [16] Markus Hiller, Mehrtash Harandi, and Tom Drummond, “On enforcing better conditioned meta-learning for rapid few-shot adaptation,” in Proc. Adv. Neural Inf. Process. Syst., 2022, vol. 35, pp. 4059–4071.
- [17] Sébastien M. R. Arnold, Shariq Iqbal, and Fei Sha, “When maml can adapt fast and how to assist when it cannot,” in Proc. Int. Conf. Artif. Intel. and Stats., 2021, vol. 130, pp. 244–252.
- [18] Erin Grant, Chelsea Finn, Sergey Levine, Trevor Darrell, and Thomas Griffiths, “Recasting gradient-based meta-learning as hierarchical Bayes,” in Proc. Int. Conf. Learn. Represent., 2018.
- [19] Durk P Kingma, Tim Salimans, Rafal Jozefowicz, Xi Chen, Ilya Sutskever, and Max Welling, “Improved variational inference with inverse autoregressive flow,” in Proc. Adv. Neural Inf. Process. Syst., 2016, vol. 29.
- [20] Aharon Ben-Tal, Tamar Margalit, and Arkadi Nemirovski, “The ordered subsets mirror descent optimization method with applications to tomography,” SIAM Journal on Optimization, vol. 12, no. 1, pp. 79–108, 2001.
- [21] Zhengyuan Zhou, Panayotis Mertikopoulos, Nicholas Bambos, Stephen Boyd, and Peter W Glynn, “Stochastic mirror descent in variationally coherent optimization problems,” in Proc. Adv. Neural Inf. Process. Syst., 2017, vol. 30.
- [22] Oriol Vinyals, Charles Blundell, Timothy Lillicrap, koray kavukcuoglu, and Daan Wierstra, “Matching networks for one shot learning,” in Proc. Adv. Neural Inf. Process. Syst., 2016, vol. 29.
- [23] Ashish Bora, Ajil Jalal, Eric Price, and Alexandros G. Dimakis, “Compressed sensing using generative models,” in Proc. Int. Conf. Mach. Learn., Doina Precup and Yee Whye Teh, Eds., 2017, vol. 70, pp. 537–546.
Appendix
Appendix A Proof of Theorem 1
Theorem 1 (Restated).
Let denote the blockIAF model (3.2). For any partition , is strictly increasing, that is
Moreover, there exists a constant such that
Proof.
Let denote a permutation of , and the permutation matrix under , where is the submatrix of the identity restricted to the columns indexed by .
Consider the partial derivatives (cf. (3.2))
(11) |
It can be verified that the Jacobian of the permuted parameters is block-upper-triangular, with the -th diagonal block given by . It thus holds that , or equivalently, , which implies that
(12) |
Letting , it holds for
(13) |
where the inequality follows from (12).
Next, upper bounding , we will show that for some constant . To obtain the inverse , notice that (8a) can be readily rewritten as
where is the element-wise division. Similar to (11), it can be easily verified that the Jacobian is also block-upper-triangular, with -th diagonal block .
As a result, we have that
which completes the proof. ∎
Appendix B Summary of the algorithm
Appendix C Numerical setups
This section elaborates further on the dataset and setups of the numerical tests.
The miniImageNet dataset is a few-shot classification dataset comprising natural images from classes, each containing samples. All images are cropped and resized to , as suggested by [4]. The classes are disjointly divided into groups with corresponding size , and , which are available to the meta-training, meta-validation, and meta-testing phases, respectively. The task setups follow from the standard -class -shot few-shot learning protocol [4, 6]. In particular, per task contains classes randomly drawn from the dataset, each consisting of labeled data. It is easy to see that . Likewise, is constructed in a manner akin to , albeit with each class comprising labeled data.
The hyperparameters used in the tests are the same as those used by MAML [6], and are listed in Table 2. Our implementation relies on PyTorch, and codes are available at https://github.com/zhangyilang/MetaMirrorDescent.
Hyperparameter | Notation | Value |
---|---|---|
Lower-level iterations | ||
Lower-level learning rate | ||
Upper-leve iterations | ||
Upper-level learning rate | ||
Upper-level SGD batch size |
All the MLPs used in blockIAF have three fully-connected layers with ReLU nonlinearity, and with the weight matrix of each layer Kronecker factorized [13]. Let be the size of the original tensor corresponding to the vector , where is the total order of the tensor, and . Each layer of the encoder outputs a tensor with dimensionality of half size. This implies that the output tensor of the -th layer of has size . The decoder first vectorizes and concatenates the embeddings provided by , maps this concatenated embedding vector to , and recovers the tensor to by performing the inverse size operations of ; that is, its -th layer changes the tensor size from to .
Appendix D Complexity analysis
Next, complexity comparison is implemented to justify the effectiveness of the introduced blockIAF model. To showcase the computational efficiency, numerical complexities are assessed using the 5-class 5-shot miniImageNet dataset. In the test, the blockIAF-based mirror map incurs a increase of forward and backpropagation time compared to the basic GD update in MAML. This slight increment confirms the claimed low complexity of the proposed approach.