L EARNING TO B ALANCE : B AYESIAN M ETA -L EARNING FOR I MBALANCED AND O UT - OF - DISTRIBUTION T ASKS
A BSTRACT
While tasks could come with varying the number of instances and classes in realistic settings, the existing meta-learning approaches for few-shot classiﬁcation assume that the number of instances per task and class is ﬁxed.
Due to such restriction, they learn to equally utilize the meta-knowledge across all the tasks, even when the number of instances per task and class largely varies.
Moreover, they do not consider distributional difference in unseen tasks, on which the meta-knowledge may have less usefulness depending on the task relatedness.
To overcome these limitations, we propose a novel meta-learning model that adaptively balances the effect of the meta-learning and task-speciﬁc learning within each task.
Through the learning of the balancing variables, we can decide whether to obtain a solution by relying on the meta-knowledge or task-speciﬁc learning.
We formulate this objective into a Bayesian inference framework and tackle it using variational inference.
We validate our Bayesian Task-Adaptive Meta-Learning (Bayesian
TAML) on multiple realistic task- and class-imbalanced datasets, on which it signiﬁcantly outperforms existing meta-learning approaches.
Further ablation study conﬁrms the effectiveness of each balancing component and the Bayesian learning framework.
I NTRODUCTION
Despite the success of deep learning in many real-world tasks such as visual recognition and machine translation, such good performances are achievable at the availability of large training data, and many fail to generalize well in small data regimes.
To overcome this limitation of conventional deep learning, recently, researchers have explored meta-learning (Schmidhuber, 1987; Thrun & Pratt, 1998) approaches, whose goal is to learn a model that generalizes well over distribution of tasks, rather than instances from a single task, in order to utilize the obtained meta-knowledge across tasks to compensate for the lack of training data for each task.
However, so far, most existing meta-learning approaches (Santoro et al., 2016; Vinyals et al., 2016;
Snell et al., 2017; Ravi & Larochelle, 2017; Finn et al., 2017; Li et al., 2017) have only targeted an artiﬁcial scenario where all tasks participating in the multi-class classiﬁcation problem have equal number of training instances per class.
Yet, this is a highly restrictive setting, as in real-world scenarios, tasks that arrive at the model may have different training instances (task imbalance), and within each task, the number of training instances per class may largely vary (class imbalance).
Moreover, the new task may come from a distribution that is different from the task distribution the model has been trained on (out-of-distribution task) (See (a) of Figure 1).
Under such a realistic setting, the meta-knowledge may have a varying degree of utility to each task.
Tasks with small number of training data, or close to the tasks trained in meta-training step may want to rely mostly on meta-knowledge obtained over other tasks, whereas tasks that are out-of-distribution or come with more number of training data may obtain better solutions when trained in a task-speciﬁc
[Figure]
manner.
Furthermore, for multi-class classiﬁcation, we may want to treat the learning for each class differently to handle class imbalance.
Thus, to optimally leverage meta-learning under various imbalances, it would be beneﬁcial for the model to task- and class-adaptively decide how much to use from the meta-learner, and how much to learn speciﬁcally for each task and class.
To this end, we propose a novel Bayesian meta-learning framework, which we refer to as Bayesian
Task-Adaptive Meta-Learning (Bayesian TAML), that learns variables to adaptively balance the effect of meta- and task-speciﬁc learning.
Speciﬁcally, we ﬁrst obtain set-representations for each task, which are learned to convey useful statistics about the task or class distribution, such as mean, variance, and cardinality (the number of elements in the set), and then learn the distribution of three balancing variables as the function of the set: 1) task-dependent learning rate multiplier , which decides how far away to deviate from the meta-knowledge, when performing task-speciﬁc learning.
Tasks with higher shots could beneﬁt from taking gradient steps afar, while tasks with few shots may need to stay close to the initial parameter.
2) class-dependent learning rate , which decides how much information to use from each class, to automatically handle class imbalance where the number of instances per class can largely vary.
3) task-dependent modulator for initial model parameter , which modiﬁes the shared initialization for each task, such that each task can decide how much and what to use from the shared initial model parameter and what to ignore based on its set representation.
This is especially useful when handling out-of-distribution task, which may need to ignore some of the meta-knowledge.
We validate our model on CIFAR-FS and miniImageNet dataset, as well as a new dataset that consists of heterogeneous datasets, under a scenario where every class in each episode can have any number of shots, that leads to task and class imbalance, and where the dataset at meta-test time is different from that of meta-training time.
The experimental results show that our Bayesian TAML signiﬁcantly improves the performance over the existing approaches under these realistic scenarios.
Further analysis of each component reveals that the improvement is due to the effectiveness of the balancing terms for handling task and class imbalance, and out-of-distribution tasks.
To summarize, our contribution in this work is threefold:
• We consider a novel problem of meta-learning under a realistic task distribution, where the number of instances across classes and tasks could largely vary, or the unseen task at the meta-test time is largely different from the seen tasks.
• For effective meta-learning with such imbalances, we propose a Bayesian task-adaptive meta-learning (Bayesian TAML) framework that can adaptively adjust the effect of the meta-learner and the task-speciﬁc learner, differently for each task and class.
• We validate our model on realistic imbalanced few-shot classiﬁcation tasks with a varying number of shots per task and class and show that it signiﬁcantly outperforms existing meta-learning models.
R ELATED W ORK
Meta-learning Meta-learning (Schmidhuber, 1987; Thrun & Pratt, 1998) is an approach to learn a model to generalize over a distribution of task.
The approaches in general can be categorized into either memory-based, metric-based, and optimization-based methods.
A memory-based approach (Santoro et al., 2016) learns to store correct instance and label into the same memory slot and retrieve it later, in a task-generic manner.
Metric-based approaches learn a shared metric space (Vinyals et al., 2016; Snell et al., 2017).
Snell et al.
(2017) deﬁnes the distance between the instance and the class prototype, such that the instances are closer to their correct prototypes than to others.
As for optimization-based meta-learning, MAML (Finn et al., 2017) learns a shared initialization parameter that is optimal for any tasks within few gradient steps from the initial parameter.
Meta-SGD (Li et al., 2017) improves upon MAML by learning the learning rate differently for each parameter.
For effective learning of a meta-learner, meta-learning approaches adopt the episodic training strategy (Vinyals et al., 2016) which trains and evaluates a model over a large number of tasks, which are called meta-training and meta-test phase, respectively.
However, existing approaches only consider an artiﬁcial scenario which samples the classiﬁcation of classes with exactly the same number of training instances, both within each episode and across episodes.
On the other hand, we consider a more challenging scenario where the number of shots per class and task could vary at each episode, and that the task given at meta-test time could be an out-of-distribution task.
Task-adaptive meta-learning The goal of learning a single meta-learner that works well for all tasks may be overly ambitious and leads to suboptimal performances for each task.
Thus recent approaches adopt task-adaptively modiﬁed meta-learning models.
Oreshkin et al.
(2018) proposed to learn the temperature scaling parameter to work with the optimal similarity metric.
Qiao et al.
(2018) also suggested a model that generates task-speciﬁc parameters for the network layers, but it only trains with many-shot classes, and implicitly expects generalization to few-shot cases.
Rusu et al.
(2018) proposed a network type task-speciﬁc parameter producer, and Lee & Choi (2018) proposed to differentiate the network weights into task-shared and task-speciﬁc weights.
Our model also aims to obtain task-speciﬁc parameter for each task, but is rather focused on learning how to balance between the meta-learning and task-/class-speciﬁc learning.
Probabilistic meta-learning
Recently, a probabilistic version of MAML has been proposed (Finn et al., 2018), where they interpret a task-speciﬁc gradient update as a posterior inference process under variational inference framework.
Kim et al.
(2018) proposed Bayesian MAML with a similar motivation but with a stein variational inference framework and chaser loss.
Gordon et al.
(2018) proposed a probabilistic meta-learning framework where the parameter for a novel task is rapidly estimated under decision theoretic framework, given a set representation of a task.
The motivation behind these works is to represent the inherent uncertainty in few-shot classiﬁcation tasks.
Our model also uses Bayesian modeling, but it focuses on leveraging the uncertainties of the meta-learner and the gradient-direction in order to balance between meta- and task- or class-speciﬁc learning.
L EARNING TO B ALANCE
We ﬁrst introduce notations and brieﬂy recap the model-agnostic meta-learning (MAML) by Finn et al.
Suppose a task distribution p ( τ ) that randomly generates task τ consisting of a training set
D τ = { X τ , Y τ } and a test set ˜ D
τ = { ˜ X τ , ˜ Y τ } .
Then, the goal of MAML is to meta-learn the initial model parameter θ as a meta-knowledge to generalize over the task distribution p ( τ ) , such that we can easily obtain the task-speciﬁc predictor θ τ in a single (or a few) gradient step from the initial θ .
Toward this goal, MAML optimizes the following gradient-based meta-learning objective:
[Equation]
where α denotes stepsize and L denotes empirical loss such as negative log-likelihood of observations.
Note that by meta-learning the initial point θ , the task-speciﬁc predictor θ τ = θ − α ∇ θ L ( θ ; D τ ) can minimize the test loss L ( · ; ˜ D τ ) even with D τ consisting of only a few samples.
We can easily extend the Eq.
(1), such that we obtain θ τ with more than one inner-gradient steps from the initial θ .
However, the existing MAML framework has the following limitations that prevent the model from efﬁciently solving real-world problems involving class/task imbalance and out-of-distribution tasks.
Class imbalance.
MAML does not provide any framework to handle class imbalance within each task.
Therefore, classes with large number of training instances (head classes) may dominate the task-speciﬁc learning during the inner-gradient steps, yielding low performance on classes with fewer shots (tail classes).
Task imbalance.
The model has a ﬁxed number of inner-gradient steps and stepsize α across all tasks, which prevents the model from adaptively deciding how much to resort to
the meta-knowledge or how much to learn from the given dataset, depending on the number of the training examples per task.
Out-of-distribution tasks.
The model assumes that the initial model parameter θ will be equally useful for the unseen tasks, but for unseen tasks that are signiﬁcantly different from the previously seen tasks, the initial parameter may be less useful.
3. T ASK -A DAPTIVE M ETA -L EARNING (TAML)
As shown in Figure 1 for the concepts, we introduce three balancing variables ω τ , γ τ , z τ to tackle each problem mentioned above.
How to generate these variables will be described in Section 4.
Also, see the experimental section for how to generate the realistic tasks with class and task imbalance.
Tackling class imbalance.
To handle class imbalance, we vary the learning rate of class-speciﬁc gradient for each inner-optimization step.
Speciﬁcally, for class c = 1 , . .
, C , we introduce a set of class-speciﬁc scalars ω τ = ( ω τ 1 , . . .
, ω τC ) ∈ [0 , 1] C , which are multiplied to each of the class-speciﬁc gradients ∇ θ L ( θ ; D τ 1 ) , . . .
, ∇ θ L ( θ ; D τC ) , where D τc is the set of instances and labels for class c .
We expect ω τc to be large for tail-classes with small number of training instances, such that they could be considered more in the inner-optimization steps.
We generate ω τ with Softmax function, and denote the input to the function as ˜ ω τ .
Tackling task imbalance.
To control whether the model parameter for the current task stays close to the initial parameter or deviate far from it, we introduce task-dependent learning-rate multipliers γ τ = ( γ τ 1 , . .
. , γ τL ) ∈ [0 , ∞ )
L , such that for each layer l = 1 , . . .
, L , the learning rate becomes γ τ 1 α, γ τ 2 α, . . .
, γ τL
α 1 .
We expect γ τ to be large for large tasks, such that they rely more on taskspeciﬁc updates, while small tasks use small γ τ to beneﬁt more from the meta-knowledge.
To amplify the step-size different between large and small tasks, we generate γ τ with an exponential function, and denote the input to the function as ˜ γ τ .
Tackling out-of-distribution tasks.
Finally, we introduce z τ which modulates the initial parameter θ for each task.
We expect z τ to learn to relocate the initial θ to a new starting point, such that out-of-distribution (OOD) tasks can deviate much from the shared initialization θ if the current initialization is suboptimal for the given task.
Speciﬁcally, we use z τ = 1 + ˜ z
τ for the channel of the network weights and z τ = ˜
z τ for the biases, which modify the initial parameters as follows: θ 0 ← θ ◦ z τ for the weights and θ 0 ← θ + z τ for the biases, where θ 0 denotes the new initialization modulated by z τ .
We denote this operation as θ ∗ z τ .
A uniﬁed framework.
Finally, we assemble all these components together into a single uniﬁed framework.
With a slight abuse of notations, the update rule can be written as follows:
[Equation]
[Equation]
[Equation]
where α is a multi-dimensional global learning rate vector that is learned (Li et al., 2017), and the multiplication operator ◦ is appropriately deﬁned.
The last step θ K corresponds to the task-speciﬁc predictor θ τ .
3. B AYESIAN T ASK -A DAPTIVE M ETA -L EARNING
We now introduce the variational inference framework for the input of the three balancing variables, that we previously denote as ˜ ω τ , ˜ γ τ ,
˜ z τ .
Bayesian modeling allows to incorporate randomness in the posterior of those variables. In MAML framework, such randomness generates the ensemble diverse task-speciﬁc predictors, which allows to effectively exploit the information in the given dataset D τ . Bayesian modeling also allows to ﬁnd more robust latent structures of those balancing variables.
We let the three variables share the same inference network pipeline to minimize the computational cost.
Firstly, deﬁne X τ = { x τn } N τ n =1 and Y τ = { y τn } N τ n =1 for training, and ˜ X
τ = { ˜ x τm } M τ m =1 and ˜ Y
τ =
{ ˜ y τm } M τ m =1 for test.
Let φ τ denote the collection of ˜ ω τ , ˜ γ τ and ˜ z
τ for uncluttered notation.
Then, inspired by Gordon et al.
and Finn et al.
(2018), we deﬁne the generative process for metalearning framework as follows for each task τ
(See Figure 2):
[Equation] [Equation]
for the complete data likelihood.
Note that the deterministic θ is shared across all the tasks.
V ARIATIONAL I NFERENCE
[Figure]
[Figure]
The goal of learning for each task τ is to maximize the conditional loglikelihood of the joint dataset ˜ D τ and D τ : log p ( ˜ Y τ , Y τ | ˜
X τ , X τ ; θ ) .
However, solving it involves the true posterior p ( φ τ |D τ , ˜ D τ ) , which is intractable.
Thus, we resort to amortized variational inference with a tractable form of approximate posterior q ( φ τ |D τ , ˜ D τ ; ψ ) parameterized by ψ .
Further, similarly to Ravi & Beatson (2018), we drop the dependency on the test dataset ˜ D
τ for the approximate posterior, in order to make the two different pipelines consistent; one for metatraining where we observe the whole test dataset, and the other for meta-testing where the test labels are unknown.
The form of our approximate posterior is now q ( φ τ |D τ ; ψ ) .
It greatly simpliﬁes the inference framework, while ensuring to have a valid lower bound of the log evidence.
Also, considering that performing the inner-gradient steps with the training dataset D τ automatically maximizes the training log-likelihood in MAML framework, we slightly modify the objective so that the expected log-likelihood term only involves the test examples with the appropriate scaling factor.
The resultant form of the approximated lower bound that suits for our meta-learning purpose is as follows:
[Equation]
We assume q ( φ τ |D τ ; ψ ) fully factorizes for each variable and also for each dimension as well:
[Equation]
where we assume that each single dimension of q ( φ τ |D τ ; ψ ) follows univariate Gaussian having trainable mean and variance.
We also let each dimension of prior p ( φ τ ) factorize into N (0 , 1) , such that the KL-divergence can have the especially simple closed form (Kingma & Welling, 2014).
The ﬁnal form of the meta-training minimization objective with Monte-Carlo (MC) approximation for the expectation in Eq.
(5) is as follows:
[Equation]
where φ τs ∼ q ( φ τ |D τ ; ψ ) .
We implicitly assume the reparameterization trick for φ τ to obtain stable and unbiased gradient estimate w.r.t.
ψ (Kingma & Welling, 2014).
We set the MC sample size to S = 1 for meta-training for computational efﬁciency.
When meta-testing, we perform MC approximation with sufﬁciently large sample size (e.g. S = 10 ):
[Equation]
or we may naively approximate by taking the expectation inside for computational efﬁciency:
[Equation]
In the experimental section, we show that Eq.
(8) largely outperforms Eq.
[Figure]
4. D ATASET ENCODING
The main challenge in modeling our variational distribution q ( φ τ |D τ ; ψ ) is to decide how to reﬁne the training dataset D τ into informative representation, which is not trivial.
This inference network should capture all the necessary statistical information to recognize any imbalances in the dataset D τ .
Mean-pooling (Edwards & Storkey, 2016) or sum-pooling (Zaheer et al., 2017) is frequently used as a practical set-encoder, where each instance in the set is transformed by the shared nonlinearity, and then averaged or summed together to generate a single vector summarizing the set, followed by an additional nonlinearity.
However, for the classiﬁcation dataset D τ which is the set of (class) sets , those non-hierarchical pooling methods will perform poorly as they ignore the label information.
Therefore, we use a two-layer hierarchical set encoder which ﬁrst encodes each class as a set of samples and then encodes the set as the set of classes (see the Appendix B for the justiﬁcation).
However, there is an additional limitation of mean pooling when using it to describe a task: it does not recognize the number of elements in the set 2 .
This could be a critical limitation in recognizing the imbalances in the given task.
Therefore we explicitly input the number of elements into the set encoder.
Yet, the set cardinality alone is insufﬁcient in capturing the distribution of the dataset.
Suppose that we have a set containing replications of a single instance.
Then, although the set has only limited information, the set encoding cannot recognize it and will overestimate the information.
To prevent this, we encode the variance of the set as well.
Based on this intuition, we deﬁne the set encoder StatisticsPooling( · ) that generates the concatenation of the set statistics such as mean, variance, and cardinality.
We use this encoder to ﬁrst encode each class, and then the whole set of classes as follows:
[Equation]
for classes c = 1 , . . .
, C .
X τc is the collection of class c examples in task τ .
NN 1 and NN 2 are some neural networks parameterized by ψ .
The vector v τ ﬁnally summarizes the entire dataset D τ for few-shot classiﬁcation.
Note that the class-speciﬁc balancing variables ˜ ω τ 1 , . . .
, ˜ ω τC are generated from s 1 , . . .
, s C , and other task-speciﬁc balancing variables ˜ γ τ and ˜
z τ are generated from v τ with additional layers (See Figure 3).
E XPERIMENTS
We next validate our method on multiple benchmark datasets with more realistic task distribution.
Datasets We validate our method on the following benchmark datasets.
CIFAR-FS:
This dataset (Bertinetto et al., 2019) is a variant of CIFAR-100 dataset that consists of 100 general object categories.
Each class comes with 600 examples, each of which is a color image that contains 32 × 32 pixels.
We split the dataset into 64 / 16 / 20 classes for training/validation/test.
SVHN:
This dataset (Netzer et al., 2011) is frequently used as an OOD dataset for CIFAR-10 and CIFAR-100.
It consists of 26 , 032 color images of 32 × 32 pixels, from 10 digits classes.
miniImageNet: This dataset (Vinyals et al., 2016) is a subset of the ImageNet dataset (Russakovsky et al., 2015).
It consists of total 100 classes, each of which has 600 images resized into 84 × 84 .
We split the dataset into subsets containing 64 / 16 / 20 classes for training/validation/test.
CUB:
This dataset contains
[Table] [Table]
11 , 788 images of 200 bird species.
We resize the images into 84 × 84 .
We split the dataset into 100 / 50 / 50 classes for training/validation/test.
Since this dataset is ﬁne-grained, we regard it as an out-of-distribution dataset of the coarse-grained miniImageNet dataset.
Realistic task distribution To generate realistic task distribution p ( τ ) , we ﬁrst randomly sample
C = 5 classes from the whole set of classes.
Then with 0.5 probability, we sample N c ∼ U (1 , 50) independently for each class c = 1 , . . .
, C , in order to simulate class imbalance .
Moreover, with the other 0.5 probability, we again sample N c ∼ U (1 , 50) but apply the same single sample to all the classes, in order to simulate task imbalance .
We set the number of query examples to 15 for each class.
Experimental setup For all our experiments, we use 4-block convolutional neural networks with 32 channels, following Finn et al.
For all the baselines and our model, we perform earlystopping based on the meta-validation set performance.
We set the number of inner-gradient steps to 5 for training and 10 for testing, for all the gradient-based models.
See the Appendix A for more details about the experimental setup.
5. M AIN RESULTS
Any-shot classiﬁcation Table 1 shows the results of the baselines and our model under this realistic task distribution with both class and task imbalance.
We ﬁrst observe that the gradient-based baselines (MAML, ABML, and MT-NET) all fail in this any-shot classiﬁcation setting.
However, Meta-SGD largely outperforms them, demonstrating the effectiveness of meta-learning the element-wise learning rates for any-shot classiﬁcation.
Prototypical Networks perform relatively well on in-distribution (ID) tasks but underperform Meta-SGD on out-of-distribution (OOD) tasks.
This is because metric-based models like Prototypical Networks do not the take gradient steps for OOD tasks, such that the novel information in the dataset cannot be effectively incorporated into each task-speciﬁc predictor.
Finally, we observe that our Bayesian TAML signiﬁcantly outperforms all the baselines, on both ID and
OOD datasets.
Bayesian TAML performs especially well on OOD datasets.
This is because when the given task largely differs from the meta-knowledge, the model is able to deviate far from the meta-knowledge; however this is difﬁcult for other baselines.
Multi-dataset classiﬁcation
We further test our model under a more challenging setting where tasks could come from a highly heterogeneous dataset (Triantaﬁllou et al., 2019).
We meta-train the models with Aircrafts, Quickdraw and VGG-Flower dataset, and meta-test with the three datasets plus two additional datasets for OOD tasks - Trafﬁc Signs and Fashion-MNIST.
We see from Tablethat Bayesian TAML also largely outperforms baselines in this setting.
While prototypical Networks performs relatively well for this multi-dataset classiﬁcation due to its ﬂexibility in learning the metric space, our Bayesian TAML effectively combines the advantage of both metric-based and gradient-based approaches, by introducing the balancing variables that can ﬂexibly modulate the gradient steps.
See the Appendix for the detailed experimental setup.
5. E FFECTIVENESS OF THE B ALANCING V ARIABLES
We now validate the effectiveness of the three balancing variables to clearly show their effectiveness.
z τ for handling distributional shift.
z τ modulates the initial model parameter θ , and decides what and how much to use from the meta-knowledge θ based on the relatedness between the initial θ and the task at hand.
We validate the effectiveness of this balancing variable by examining the performance of the baseline methods and our models using datasets (SVHN, CUB) that are highly heterogeneous from the meta-training datasets (CIFAR-FS, miniImageNet).
The results in Tableshow that our model with only z τ can effectively handle these out-of-distribution (OOD) tasks.
We further observe that z τ relocates the initial θ far from the initial parameter for these OOD tasks given at meta-test time (Figure 4), with larger displacements for highly heterogeneous tasks (Figure 4, right).
This allows the model to either stick to, or deviate from the meta-knowledge based on the similarity between the tasks given at the meta-training and meta-test time.
[Table]
γ τ and z τ for handling task imbalance.
We then examine how the two balancing variables, γ τ and z τ handle inter-task imbalance where tasks used for meta-learning have largely different number of instances.
Figure 5(a) shows the performance of the baseline models and our models with each of the balancing variables, when the number of instances per task varies from 5 to 2000 .
We observe that our Bayesian z -TAML
and Bayesian γ -TAML largely outperform Meta-SGD, especially by large degree when the number of instances per task is large.
Figure 5(b) shows that the effectiveness of z τ largely depends on the number of MC samples used in Eq.
(8), demonstrating the importance of incorporating uncertainties in random initializations for handling task imbalance.
We further observe from Figure 5(c) that the task-dependent learning rate multiplier γ τ exponentially grows as the number of instances per task increases.
This agrees with our intuition that larger tasks should take larger inner-gradient steps, to learn more from the given task rather than resorting to meta-knowledge.
[Figure]
ω τ for handling class imbalance.
ω τ rescales the class-speciﬁc gradients to handle class imbalance where the number of instances per class (i.e. shot) largely varies.
Table 4 shows the results under the varying degree of class imbalance across the task distribution.
We observe that Bayesian ω -TAML outperforms Meta-SGD, especially by larger degree under higher class imbalance.
Notably,
Bayesian ω -TAML outperforms a heuristic balancing method which divides each class-speciﬁc gradient by the cardinality of each class set (Meta-SGD with 1 /N ).
The accuracy improvements over
Meta-SGD in Figure 6 demonstrate that this heuristic balancing method overly emphasizes the tail classes with few training instances, thereby deteriorating the performance on classes with sufﬁciently large number of instances.
On the other hand, our Bayesian ω -TAML learns the appropriate balancing variables which allow to obtain large performance gains on all classes.
[Table] [Table]
5. M ORE ABLATION STUDIES
Effectiveness of Bayesian modeling We further demonstrate the effectiveness of Bayesian modeling by comparing it with the deterministic version of our model (Deterministic TAML), where three balancing variables are no longer stochastic.
We apply (cid:96) 2 regularization on the variables with coefﬁcients that are equivalent to the KL-divergence in Eq.
The results in Table 5 show that
the
Bayesian TAML signiﬁcantly outperforms its deterministic counterpart, especially with larger gap on the OOD task (SVHN).
Figure 7 further shows that the balancing variable γ τ for handling task imbalance, more sensitively reacts on Bayesian TAML than on Deterministic TAML, which suggests that Bayesian modeling ampliﬁes the effect of the balancing variables
[Table]
[Figure]
[Table]
Dataset encoding Finally, we perform an ablation study of the proposed task encoding network.
The results in Table 6 show that the proposed hierarchical encoding scheme for classiﬁcation dataset, with set cardinality and variance is signiﬁcantly more effective than simple mean-pooling methods (Zaheer et al., 2017; Edwards & Storkey, 2016) 4 .
C ONCLUSION
We propose Bayesian TAML that learns to balance the effect of meta-learning and task-adaptive learning, to consider meta-learning under a more realistic task distribution where each task and class can have varying number of instances.
Speciﬁcally, we encode the dataset for each task into hierarchical representations, and use it to modulate the original parameter, learning rate, and the classspeciﬁc gradients.
We use a Bayesian framework to infer the posterior of these balancing variables, and propose an effective variational inference framework to solve for them.
Our model outperforms existing meta-learning methods when validated on imbalanced few-shot classiﬁcation tasks.
Further analysis of each balancing variable shows that each variable effectively handles task imbalance, class imbalance, and out-of-distribution tasks.
We believe that our work makes a meaningful step toward application of meta-learning to real-world problems.
Acknowledgements This work was supported by Google AI Focused Research Award, Samsung
Research Funding Center of Samsung Electronics (No.
SRFC-IT1502-51), the Engineering Research
Center Program through the National Research Foundation of Korea (NRF) funded by the Korean
Government MSIT (NRF-2018R1A5A1059921), and the Institute of Information & communications
Technology Planning & Evaluation (IITP) grant funded by the Korea government(MSIT)
(No.20190-00075, and Artiﬁcial Intelligence Graduate School Program (KAIST)).
A E XPERIMENTAL S ETUP A. B ASELINES
We describe the baseline models and our task-adaptive learning to balance model.
1) MAML.
The Model-Agnostic Meta-Learning (MAML) model by Finn et al.
(2017), which aims to learn the global initial model parameter, from which we can take a few gradient steps to get task-speciﬁc predictors.
2) ABML.
This model interprets MAML under hierarchical Bayesian framework, but they propose to share and amortize the inference rules across both global initial parameters as well as the task-speciﬁc parameters.
3) MT-NET.
A gradient-based meta-learning model proposed by Lee & Choi (2018).
The model obtains a task-speciﬁc parameter only w.r
t. a subset of the whole dimension (M-Net), followed by a linear transformation to learn a metric space (T-Net) 4) Meta-SGD.
A base MAML with the learnable learning-rate vector (without any restriction on sign) element-wisely multiplied to each step inner-gradient (Li et al., 2017).
5) Prototypical Networks.
A metric-based few-shot classiﬁcation model proposed by Snell et al.
The model learns the metric space based on Euclidean distance between class prototypes and query embeddings.
6) Bayesian TAML.
Our model to balance model that can adaptively balance between meta- and task-speciﬁc learners for each task and class.
A.
A NY - SHOT CLASSIFICATION .
We describe more detailed settings for any-shot classiﬁcation.
CIFAR-FS and SVHN: We train all models for 50 K steps with meta-batch size set to 4 .
The learning rate is set to 0 .
001 for all the baselines and our models.
We set the inner stepsize to 0 .
01 for
MAML, MT-NET, and ABML, which we empirically veriﬁed to perform better than other candidates.
miniImageNet and CUB:
For all models, the number of meta-training iterations is set to 80 K and we set the meta-batch size to 1 .
The learning rate is set
to
for all the baselines and our models.
Inner stepsize is set to
for
MAML,
MT-NET and ABML
A. M ULTI - DATASET C LASSIFICATION
For multi-dataset classiﬁcation, we construct a subset of the whole collection of the Meta-Dataset (Triantaﬁllou et al., 2019).
We resize the images into to 32 × 32 pixels.
We generate each episode with the maximum number of training instances for each class set to 50 .
For each task, We uniformly select one dataset among Aircrafts, Quickdraw and VGG-Flower and randomly sample 10 classes from the dataset for each task.
In meta-test phase, we test our model on additional out-of-distribution datasets,
Trafﬁc Signs and Fashion-MNIST including three in-distribution datasets.
Aircraft:
We split this dataset (Maji et al., 2013) into 70/15/15 for training/validation/test withexamples for each class.
Quick Draw: We split this dataset (Jonas Jongejan & Fox-Gieg, 2016) into 241/52/52 for training/validation/test with randomly sampled 200 examples for each class.
VGG Flower: This dataset (Nilsback & Zisserman, 2008) contains 40 between 258 images for each class and we split this dataset into 71/16/15 for training/validation/test.
Trafﬁc Signs: This dataset (Houben et al., 2013) has only test dataset with 43 classes.
Each class has 900 examples.
Fashion-MNIST: We use test dataset of Fashion-MNIST (Xiao et al., 2017) in meta-test phase.
This dataset has 10 classes with 1000 examples.
We keep the number of classes for each task, meta-batch size, meta-training iterations, and learning rate as 10 , 3 , 60 K , and 0 .
001 , respectively for all models.
We set the inner learning rate to 0 .
A. I NFERENCE NETWORK ARCHITECTURE
We describe the network architecture of the inference network that takes a classiﬁcation dataset as an input and generates three balancing variables as output.
Shared encoder NN 1 : X τ 1 , . . .
, X τC → s 1 , . . .
, x C 3 × 3 Conv2d with 10-dim and ReLU 2 × 2 Max pool 3 × 3 Conv2d with 10-dim and ReLU 2 × 2 Max pool fc layer with 64-dim
Statistics Pooling for each class c = 1 , . .
, C .
fc layer with 4-dim (across the statistics) and ReLU
Shared encoder NN 2 : s 1 , . . .
, s C → v τ fc layer with 128-dim and ReLU fc layer with 32-dim
Statistics Pooling over all the class representations fc layer with 4-dim (across the statistics) and ReLU
Generate ω τ : s τ 1 , . . .
, s τC → ( µ τω 1 , σ τω 1 ) , . .
, ( µ τω C , σ τω C ) fc layer with 64-dim and ReLU fc layer to generate ( µ τω c , σ τω c ) for each class c = 1 , . . .
, C .
Generate γ τ : v τ → ( µ τγ 1 , σ τγ 1 ) , . .
, ( µ τγ L , σ τγ L ) fc layer with 64-dim and ReLU fc layer to generate ( µ τγ l , σ τγ l ) for each layer l = 1 , . . .
, L .
Generate z τ : v τ → µ τ z , σ τ z fc layer with 64-dim and ReLU fc layer to generate ( µ τ z , σ τ z ) for the output channels
B J USTIFICATION FOR S ET - OF -S ETS STRUCTURE .
Based on the previous justiﬁcation of DeepSets (Zaheer et al., 2017), we can easily justify the Set-ofSets structure proposed in the main paper as well, in terms of the two-level permutation invariance properties required for any classiﬁcation dataset.
The main theorem of DeepSets is:
Theorem 1.
A function f operating on a set X ∈ X is a valid set function (i.e. permutation invariant), iff it can be decomposed as f ( X )
=
ρ 2 ( (cid:80) x ∈ X ρ 1 ( x )) , where ρ 1 and ρ 2 are appropriate nonfcities.
See (Zaheer et al., 2017) for the proof.
Here we apply the same argument twice as follows.
A function f operating on a set of representations { s 1 , . . .
, s C } (we assume each s c is an output from a shared function g ) is a valid set function (
i
e. permutation invariant w.r.t.
the order of { s 1 , . . .
, s C } ), iff it can be decomposed as f ( { s 1 , . . .
, s C } )
=
ρ 2 ( (cid:80) C c =1 ρ 1 ( s c )) with appropriate nonfcities ρ 1 and ρ 2 . 2.
A function g operating on a set of examples { x c, 1 , . . .
, x c,N } is a valid set function (i
e. permutation invariant w.r
t. the order of { x c, 1 , . .
, x c,N } ) iff it can be decomposed as g ( { x c, 1 , . . .
, x c,N } )
=
ρ 4 ( (cid:80) Ni =
ρ 3 ( x c,i )) with appropriate nonfcities ρ 3 and ρ 4 .
Inserting s c = g ( { x c, 1 , . . .
, x c,N } ) into the expression of f , we arrive at the following valid composite function operating on a set of sets:
[Equation]
Let F denote the composite of f and (multiple) g and let NN 2 denote the composite of ρ 1 and ρ 4 .
Further deﬁne NN 1 := ρ 3 and NN 3 := ρ 2 .
Then, we have
[Equation]
where C is the number of classes and N is the number of examples per class.
See Section A.4 for the actual encoder structure.
C A BLATION S TUDY ON H IGHER - ORDER S TATISTICS
[Table]
While our framework does not place any restriction on selecting the statistics for set encoding, we perform further ablation study on the effectiveness of higher-order statistics for our speciﬁc experimental setting.
We see from Table 7 that the higherorder statistics such as element-wise sample skewness and kurtosis improve the performance given sample mean and diagonal covariance.
However, the set cardinality seems more effective than those statistics as it could be the most direct and relevant criteria for detecting imbalances in a set.