A T HEORETICAL A NALYSIS OF THE N UMBER OF S HOTS IN F EW -S HOT L EARNING
A BSTRACT
Few-shot classiﬁcation is the task of predicting the category of an example from few labeled examples.
The number of labeled examples per category is called the number of shots (or shot number).
Recent works tackle this task through metalearning, where a meta-learner extracts information from observed tasks during meta-training to quickly adapt to new tasks during meta-testing.
In this formulation, the number of shots exploited during meta-training has an impact on the recognition performance at meta-test time.
Generally, the shot number used in meta-training should match the one used in meta-testing to obtain the best performance.
We introduce a theoretical analysis of the impact of the shot number on Prototypical
Networks, a state-of-the-art few-shot classiﬁcation method.
From our analysis, we propose a simple method that is robust to the choice of shot number used during meta-training, which is a crucial hyperparameter.
The performance of our model trained for an arbitrary meta-training shot number shows great performance for different values of meta-testing shot numbers.
We experimentally demonstrate our approach on different few-shot classiﬁcation benchmarks.
I NTRODUCTION
Human cognition has the impressive ability of grasping new concepts from exposure to a handful of examples (Yger et al., 2015).
In comparison, while modern deep learning methods achieve unprecedented performances with very deep neural-networks (He et al., 2016; Szegedy et al., 2015), they require extensive amounts of data to train, often ranging in the millions.
Few-shot learning aims to bridge the sample-efﬁciency gap between deep learning and human learning in ﬁelds such as computer vision, reinforcement learning and speech recognition (Santoro et al., 2016; Ravi &
Larochelle, 2017; Finn et al., 2017; Vinyals et al., 2016; Wang et al., 2019a).
These methods fall under the framework of meta-learning, in which a meta-learner extracts knowledge from many related tasks (in the meta-training phase) and leverages that knowledge to quickly learn new tasks (in the meta-testing phase).
In this paper, we focus on the few-shot classiﬁcation problem where each task is deﬁned as a N -way classiﬁcation problem with k samples (shots) per class available for training.
Many meta-learning methods use the episodic training setup in which the meta-learner iterates through episodes in the meta-training phase.
In each episode, a task is drawn from some population and a limited amount of support and query data from that task is made available.
The meta-learner then learns a task-speciﬁc classiﬁer on the support data and the classiﬁer predicts on the query data.
Updates to the meta-learner is computed based on the performance of the classiﬁer on the query set.
Evaluation of the meta-learner (during a phase called meta-testing) is also carried out in episodes in a similar fashion, except that the meta-learner is no longer updated and the performance on query data across multiple episodes is aggregated.
In the episodic setup, the selection of k during meta-training time can have signiﬁcant effects on the learning outcomes of the meta-learner.
Intuitively, if support data is expected to be scarce, the meta-learner needs to provide strong inductive bias to the task-speciﬁc learner as the danger of overﬁtting is high.
In contrast, if support data is expected to be abundant, then the meta-learner can provide generally more relaxed biases to the task-speciﬁc learner to achieve better ﬁtting to the task data.
Therefore it is plausible that a meta-learner trained with one k value can be suboptimal at adapting to tasks with a different k value and thus exhibit meta-overﬁtting to k .
In experiments, k is often simply kept ﬁxed between meta-training and meta-testing, but in real-world usage, one cannot expect to know beforehand the amount of support data from unseen tasks during deployment.
In this paper we will focus on Prototypical networks (Snell et al., 2017), a.k.a.
ProtoNet.
ProtoNet is of practical interest because of its ﬂexibility: a single trained instance of ProtoNet can be used on new tasks with any k and N .
However, ProtoNet exhibits performance degradation when the k used in training does not match the k used in testing.
First, we will undertake a theoretical investigation to elicit the connection from k to a lower bound of expected performance, as well as to the intrinsic dimension of the learned embedding space.
Then, we conduct experiments to empirically verify our theoretical results across various settings.
Guided by our new understanding of the effects of k , we propose an elegant method to tackle performance degradation in mismatched k cases.
Our contributions are threefold:
• We provide performance bounds for ProtoNets given an embedding function.
From which, we argue that k affects learning and performance by scaling the contribution of intra-class variance.
• Through VC-learnability theory, we connect the value of k used in meta-training to the intrinsic dimension of the embedding space.
The most important contribution of this paper (introduced in Section 3.3) is a new method that improves upon vanilla ProtoNets by eliminating the performance degradation in cases where the k is mismatched between meta-training and meta-testing.
Our evaluation protocol more closely adheres to real-world scenarios where the model is exposed to different numbers of training samples.
B ACKGROUND 2. P ROBLEM SETUP
The few-shot classiﬁcation problem considered in this paper is set up as described below.
Consider a space of classes C with a probability distribution τ , N classes c
= { c 1 , ..., c N } are sampled i.i.d. from τ to form a N -way classiﬁcation problem.
For each class c i , k support data are sampled from class-conditional distribution S i
= { s x 1 , .., s x k } iid ∼ P ( x | Y ( x ) =
c i ) , where x ∈ R D , D denotes the dimension of data, and Y ( x ) denotes the class assignment of x .
Note that we assume that Y ( x ) is singular (e.g. each x can only have 1 label), and does not depend on N (e.g. a data point with a label “cat” will always have the label “cat”), in contrast to y deﬁned below.
Additionally, the set Q = { q x 1 , ..., q x l } containing l query data is sampled from the joint distribution 1 N (cid:80) Ni
=1 P ( x | c i ) .
For each x , let y ∈ { 1 , ..., N } denote its label in the context of the few-shot classiﬁcation task.
Deﬁne ˆ S
i
=
( s x 1 , y = i ) , ..., ( s x k , y = i ) } as the augmented set of supports for class c i , and denote the union of support sets for N classes as S =
(cid:83) Ni
=
ˆ S i .
The few-shot classiﬁcation task is to predict y for each x in Q given S .
During meta-training, the ground truth label for Q is also available to the learner.
2. M ETA - LEARNING SETUP
Meta-learning approaches train on a distribution of tasks to obtain information that generalizes to unseen tasks.
For few-shot classiﬁcation, a task is determined by which classes are involved in the
N -way classiﬁcation task.
During meta-training, the meta-learner observes episodes of few-shot classiﬁcation tasks consisting of N classes, k labelled samples per class, and l unlabelled samples, as previously described.
The collection of all classes observed during meta-training forms the metatraining split D tr = { tr c 1 , ..., tr c R } .
Critically, we assume that every unseen class that the learner is evaluated upon (during meta-testing) is also drawn from the same distribution τ
2. P ROTOTYPICAL N ETWORKS
ProtoNets (Snell et al., 2017) compute E -dimensional embeddings for all samples in S and Q .
The embedding function φ : R D
→ R E is usually a deep network.
The prototype representation for each class is formed by averaging the embeddings for all supports of said class: φ ( S i )
= 1 k (cid:80) x ∈ S
i φ ( x ) .
Classiﬁcation of any input x (e.g. x ∈ Q ) is performed by computing the softmax over squared
Euclidean distances of the input point’s embedding to the prototypes.
Let ˆ y denote the prediction of the classiﬁer for one of the categories j ∈ { 1 , · · · , N } :
[Equation]
, where (cid:107) v (cid:107)
[Equation]
E (cid:88)
d = v
[Equation]
d (1)
The parameters of the embedding functions are learned through meta-training.
Negative log-likelihood
J ( φ ) = − log ( p (ˆ y = y | x )) of the correct class y is minimized on the query points through SGD.
As explained in (Law et al., 2019), ProtoNets can be seen as a metric learning approach optimized for the supervised hard clustering task (Law et al., 2016).
The model φ is learned so that the representations of similar examples (i.e. belonging to a same category) are all grouped into the same cluster in R E .
We propose in this paper a subsequent metric learning step which learns a linear transformation that maximizes inter-to-intra class variance ratio.
P ROPOSED METHOD
We ﬁrst present theoretical results explaining the effect of the shot number on ProtoNets, and then introduce our method for addressing performance degradation in cases of mismatched shots.
3. R ELATING k TO LOWER BOUND OF EXPECTED ACCURACY
To better understand the role of k on the performance of ProtoNets, we study how it contributes to the expected accuracy across episodes when using any kind of ﬁxed embedding function ( e.g. the embedding function obtained at the end of the meta-training phase).
With I denoting the indicator function, we deﬁne the expected accuracy R as:
[Equation]
Deﬁnitions:
Throughout this section, we will use the following symbols to denote the means and variances of embeddings under different expectations:
[Equation]
Remark.
µ c is the expectation of the embedding conditioned on class c .
µ is the (full) expectation of the embedding, which can be expressed as the expectation of µ c over classes.
Σ is the variance of class means in the embedding space - it can be interpreted as the signal of the input to the classiﬁer, as larger Σ implies larger distances between classes.
Σ c is the expected intra-class variance - it represents the noise in the above signal.
Modelling assumptions of ProtoNets:
The use of the squared Euclidean distance and softmax activation in ProtoNets implies that classiﬁcation with ProtoNets is equivalent to a mixture density estimation on the support set with spherical Gaussian densities (Snell et al., 2017).
Speciﬁcally, we adopt the modelling assumptions that the distribution of φ ( x ) given any class assignment is normally distributed ( p ( φ ( x ) | Y ( x ) = c ) =
N ( µ c , Σ c ) ), with equal covariance for all classes in the embedding space ( ∀ ( c, c (cid:48) ) , Σ c = Σ c (cid:48) ) 3 .
We present the analysis for the special case of episodes with binary classiﬁcation ( i.e. with N = 2 ) for ease of presentation, but the conclusion can be generalized to arbitrary N > 2 (see appendix).
Also, as noted in Section 2.1, we assume equal likelihood between the classes.
We would like to emphasize that the assignment of labels can be permuted freely and the classiﬁer’s prediction would not be affected due to symmetry.
Hence, we only need to consider one case for the ground truth label without loss of generality.
Let a and b denote any pair of classes sampled from τ .
Let x be drawn from a , and overload a and b to also indicate the ground truth label in the context of that episode
[Equation]
then equation 2 can be written as:
[Equation]
Additionally, noting that p (ˆ y = a ) can be expressed as a sigmoid function σ :
[Equation] [Equation]
We can express equation 3 as a probability:
[Equation]
We will introduce a few auxiliary results before stating the main result for this section.
Proposition 1.
From the one-sided Chebyshev’s inequality, it immediately follows that:
[Equation]
In Lemma 1 and Lemma 2, we derive the expectation and variance of α when conditioned on the classes sampled in a episode.
Then, in Theorem 3, we compose them into the RHS of Propositionthrough law of total expectation.
Lemma 1.
Consider space of classes C with sampling distribution τ , a, b iid ∼ τ .
Let S =
{ S a , S b }
S a
=
{ a x 1 , ..., a x k } , S b = { b x 1 , ..., b x k } , k ∈ N is the shot number, and Y ( x ) = a .
Deﬁne φ ( S a ) (cid:44) 1 k (cid:80) x ∈ S a φ ( x ) and φ ( S b ) (cid:44) 1 k (cid:80) x
∈ S
b φ ( x ) .
Consider Σ as deﬁned earlier.
Assume p ( φ ( x ) | Y ( x ) =
c ) =
N ( µ c , Σ c ) and Σ c = Σ c (cid:48) for any choice of c, c (cid:48) ∈ C , then,
[Equation]
, and
[Equation]
Lemma 2.
Under the same notation and assumptions as Lemma 1, additionally invoking deﬁnition for Σ c , then,
[Equation]
The proofs of the above lemmas are in the appendix.
With the results above, we are ready to state our main theoretical result in this section.
Theorem 3.
Under the conditions where Lemma 1 and 2 hold, we have:
[Equation]
Proof.
First, we use decompose the Var( α ) term in proposition 1 by Law of Total Expectation.
[Equation]
Hence, Proposition 1 can also be expressed as
[Equation]
Finally
[Equation]
we arrive at Theorem 3 by plugging Lemma 1 and 2 into equation 10.
Several observations can be made from Theorem 3:
The shot number k only appears in the ﬁrst two terms of the denominator, implying that the bound saturates quickly with increasing k .
This is also in agreement with the empirical observation that meta-testing accuracy has diminishing improvements when more support data is added.
By observing the degree of terms in equation 7 (and treating the last term of the denominator as a constant , it is clear that increasing k will decrease the sensitivity (magnitude of partial derivative) of this lower bound to Σ
c
, and increase its sensitivity to
Σ
If one postulates that meta-learning updates on φ are similar to gradient ascent on
this accuracy lower bound, then learning with smaller k
emphasizes minimizing
noise
, while learning with
higher k
emphasizes
maximizing signal.
In conclusion, these observations give us a plausible reason for the performance degradation observed in mismatched shots: when an embedding function has been optimized (trained) for k train >
k test , the relatively high Σ c is ampliﬁed by the now smaller k , resulting in degraded performance.
Conversely, an embedding function trained for k train <
k test already has small Σ c , such that increasing k during testing has further diminished improvement on performance.
3. I NTERPRETATION IN TERMS OF VC DIMENSION
In any given episode, a nearest neighbour prediction is performed from the support data (with a ﬁxed embedding function).
Therefore, a PAC learnability interpretation of the relation between the number of support data and complexity of the classiﬁer can be made.
Speciﬁcally, for binary classiﬁcation, classical PAC learning theory (Vapnik et al., 1994) states that with probability of at least 1 − δ , the following inequality on the difference between empirical error err train (of the support samples) and true error err true holds for any classiﬁer h :
[Equation]
Where D is the VC dimension, and k is the number of support samples per class 4 .
Under this binary classiﬁcation setting, the predictions of prototypical network are equal to σ ( α ) as shown earlier.
Denoting z c = φ ( S c ) and z c (cid:48) =
φ ( S c (cid:48) ) , we can manipulate α as follows:
[Equation]
From equation 12, the prototypes form a linear classiﬁer with offset in the embedding space.
The
VC dimension of this type of classiﬁer is 1 + d where d is the intrinsic dimension of the embedding space (Vapnik, 1998).
In ProtoNets, the intrinsic dimension of the embedding space is not only inﬂuenced by network architecture, but more importantly determined by the parameter themselves, making it a learned property.
For example, if the embedding function can be represented with a linear transformation φ ( x ) =
Φ · x , then the intrinsic dimension of the embedding space is upper bounded by the rank of Φ (since all embeddings must lie in the column space of Φ ).
Thus, the number of support samples required to learn from an episode is proportional to the intrinsic dimension of the embedding space.
We hypothesize that an embedding function optimal for lower shot (e.g. one-shot) classiﬁcation affords fewer intrinsic dimensions than one that is optimal for higher shot (e.g. 10-shot) classiﬁcation.
3. R ECONCILING SHOT DISCREPANCY THROUGH EMBEDDING SPACE TRANSFORMATION
Observations in Section 3.2 reveal that an ideal φ would have an output space whose intrinsic dimension d is as small as possible to minimize the right-hand side of equation 11 but just large enough to allow low err train ; the balance between the two objectives is dictated by k .
Similarly, observations in Section 3.1 suggest that an ideal φ would balance between minimizing Σ c and maximizing Σ also according to k .
As a result, when there is discrepancy between meta-training shots and meta-testing shots 5 , accuracy at meta-test time will suffer.
A naive solution is to prepare many embedding functions trained for different shots, and select the embedding function according to the availability of label data at test-time.
However, this solution is computationally burdensome as it requires multiple models to be trained and stored.
Instead, we want to train and store a single model, and then adapt the embedding function’s variance characteristics and the embedding space dimensionality to achieve good performance for any test shot.
Linear Discriminant Analysis (LDA) is a dimensionality reduction method suited for downstream classiﬁcation (Fukunaga, 1990).
Its goal is to ﬁnd a maximally discriminating subspace (maximum inter-class variance and minimal intra-class variance) for a given classiﬁcation task.
Theoretically, performance can be maximized in each individual episode by computing the LDA transformation matrix using support samples of that episode.
LDA computes the eigenvectors of the matrix S µ S − 1 , where S µ is the covariance matrix of prototypes and S is the class-conditional covariance matrix.
In practice, S µ and S cannot be stably estimated in few-shot episodes, preventing the direct application of LDA.
We propose an alternative which we call Embedding Space Transformation (EST).
The purpose of EST is to perform dimensionality reduction on the features, while also improving the ratio in
Theorem 3.
This is a different goal from LDA because Theorem 3 demonstrates that the expected performance across many episodes can be improved by maximizing Σ and minimizing Σ c .
Similar to
LDA, EST works by applying a linear transformation
[Equation]
13) to the outputs of the embedding function.
Here, V ∗ is a linear transformation computed using D tr after meta-training has completed.
To compute V ∗ , we ﬁrst iterate through all classes in D tr and compute their in-class means and covariance matrices in the embedding space.
We can then ﬁnd the covariance of means Σ µ , and the mean of covariances Σ s across D tr .
Finally, V ∗ is computed by taking the leading eigenvectors of Σ µ − ρ Σ s - the difference between the covariance matrix of the mean and the mean covariance matrix with weight parameter ρ .
The exact procedure for computing
V ∗ is presented in the appendix.
E XPERIMENTS AND RESULTS
In this section, our ﬁrst two experiments aim at supporting our theoretical results in Sections 3. and 3.2, while our third experiment demonstrates the improvement of EST on benchmark data sets over vanilla ProtoNets.
To illustrate the applicability of our results to different embedding function architectures, all experiments are performed with both a vanilla 4-layer CNN (as in (Snell et al., 2017)) and a 7-layer Residual network (He et al., 2016).
Detailed description of the architecture can be found in the appendix.
Experiments are performed on three data sets: Omniglot (Lake et al., 2015), mini-imagenet (Vinyals et al., 2016), and tiered-imagenet (Ren et al., 2018).
We followed standard data processing procedures which are detailed in the appendix.
4. T RAINING SHOTS AFFECT VARIANCE CONTRIBUTION
The total variance observed among embeddings of all data points can be seen as a composition of inter-class and (expected) intra-class variance based on the law of total variance ( Var[ x
] = E [Var( x | c )]
+ Var( E [ x | c ]) =
E [Σ c ] + Σ µ ).
Our analysis predicts that as we increase the shot number used during training, the ratio of inter-class to intra-class variance will decrease.
To verify this hypothesis, we trained ProtoNets (vanilla and residual) with a range of shots (1 to 10 on mini-imagenet and tiered imagenet, 1 to 5 on omniglot) until convergence with 3 random initializations per group.
Then, we computed the inter-class and intra-class covariance matrices across all samples in the training-set embedded by each network.
To qualify the amplitude of each matrix, we take the trace of each covariance matrix.
The ratio of inter-class to intra-class variance is presented in Figure 1: as we increase k used during training, the inter-class to intra-class variance ratio decreases.
This trend can be observed in both vanilla and residual embeddings, and across all three data sets, lending strong support to our result in Section 3.1.
Another observation can be made that the ratio between inter-class and intra-class variance is signiﬁcantly higher in the omniglot data set than the other two data sets.
This may indeed be reﬂective of the relative difﬁculty of each data set and the accuracy of ProtoNet on the data sets.
4. T RAINING SHOTS AFFECT INTRINSIC DIMENSION
We consider the intrinsic dimension (id) of an embedding function with extrinsic dimension E (operated on a data set) to be deﬁned as the minimum integer d where all embedded points of that data set lie within a d -dimensional subspace of R E (Bishop, 2006).
A simple method for estimating d is through principal component analysis (PCA) of the embedded data set.
By eigendecomposing the covariance matrix of embeddings, we obtain the principal components expressed as the signiﬁcant eigenvalues, and the principal directions expressed as the eigenvectors corresponding to those eigenvalues.
The number of signiﬁcant eigenvalues approximates the intrinsic dimension of the embedding space.
When the subspace is linear, this approximation is exact; otherwise, it serves as an upper bound to the true intrinsic dimension (Fukunaga & Olsen, 1971).
We determine the number of signiﬁcant eigenvalues by an explained-variance over total-variance criterion.
The qualifying metric is r d (cid:44) (cid:80) i ∈ [1 ,d ] λ i / (cid:80) i ∈ [1 ,E ] λ i .
In our experiments, we set the threshold for r d at 0 .
Similar to the previous experiment, we train ProtoNets with different shots to convergence.
The total covariance matrix is then computed on the training set and eigendecomposition is performed.
The approximate id is plotted for various values of k in Figure 2.
We can see a clear trend that as we increase training shot, the id of the embedding space increases.
4. E XPERIMENTS WITH EST
We evaluate the performance of EST on the three aforementioned data sets.
The performance is compared against our implementation of vanilla ProtoNets as a baseline, as well as a variant of
ProtoNets using principal components obtained from all embedding points (ProtoNet-PCA).
All methods in this section use the same set of trained ProtoNets.
As with before, networks are trained with k ∈ { 1 , ..., 5 } on Omniglot and k ∈ { 1 , ..., 10 } on mini-imagenet and tiered-imagenet.
Additionally, we also trained a mixed-shot network for each data set.
This is done by randomly selecting a value for k within the speciﬁed range for each episode, and then sampling the corresponding number of support samples.
Hyper-parameters for training are described in the appendix.
[Table] [Table]
[Table] [Table]
[Table] [Table]
Each model is evaluated on the test splits of the corresponding data sets (e.g. networks trained on
Omniglot are only evaluated on Omniglot).
Five test runs are performed per network on Omniglot to evaluate the k -shot performance ( k ∈ [1 , 5] ).
Each run consists of 600 episodes formed by 1support samples and 5 query sample per class.
The performance is aggregated across runs for the combined performance.
Similarly, on mini-imagenet and tiered-imagenet, 10 test runs are performed with support per sample k ∈ [1 , 10] , 600 episodes per run, and 15 query samples in each episode.
Model conﬁguration: Vanilla ProtoNet is used as our baseline.
We present the performance of multiple ProtoNets trained with different shots to illustrate the performance degradation issue.
ProtoNet-PCA uses principal components of the training split embeddings in place of V ∗ , with components other than the d leading ones zeroed out.
We carry out a parameter sweep on miniimagenet and set d = 60 ; the same value is used on the other two data sets.
For selecting the training shot of the embedding network, we ﬁnd that overall performance to be optimal using k = 5 .
ProtoNet-EST contains three parameters that need to be determined: ρ , d , and training shots of the embedding network.
For our experiments, we set ρ = 0 .
001 and d = 60 based on performance on mini-imagenet.
For selecting the number of training shots, we use the same strategy as before by evaluating ProtoNet-EST with all trained embedding networks and found the same trend to hold.
As an abalation study, FC-ProtoNet adds a fully connected layer to the embedding network such that the output dimension is also 60 .
Results of this variant can be found in the appendix.
EST performance results: Table 1 summarizes the performance of the evaluated methods on all data sets.
Due to space constraints, only 1-shot, 5-shot, 10-shot and 1-10 shot average performance are included.
Additional results are in the appendix.
The best performing method in each evaluation is in bold.
On Omniglot, there is no signiﬁcant difference in performance between the best performing vanilla ProtoNet and any other methods.
We attribute this to the already high accuracy of the baseline model.
On mini-imagenet and tiered-imagenet, EST-ProtoNet signiﬁcantly outperforms baseline methods and PCA-protonet in terms of average accuracy over test runs with different shots.
We observe that matching the training shot to the test shot generally provides the best performance for vanilla ProtoNets.
Also importantly, training with a mixture of different values of k does not provide optimal performance when evaluated on the same mixture of k values.
Instead, the resulting performance is mediocre in all test shots.
ProtoNet-EST provides minor improvements over the best-performing baseline method under most test shots settings.
We hypothesize that this is due to EST aligning the embedding space to the directions with high inter-class variance and low intra-class variance.
Comparison against the direct PCA approach demonstrates that the performance uplift is not entirely attributed to reducing the dimensions of the embedding space.
In conclusion, EST improves the performance of ProtoNets on the more challenging data sets when evaluated with various test shots.
It successfully tackles performance degradation when testing shots and training shots are different.
This improvement is vital to the deployment of ProtoNets in real world scenarios where the number of support samples cannot be determined in advance.
R ELATED WORK
We summarize related work on extensions of ProtoNets, on improving the few-shot classiﬁcation setup, and on analyzing theoretical properties of meta-learning methods.
Extensions of ProtoNets: Allen et al.
(2019) build upon ProtoNets by allowing each class to be represented by multiple prototypes, thereby improving the representation power of ProtoNets.
Oreshkin et al.
(2018) use a context-conditioned embedding network to produce prototypes that are aware of the other classes.
These prior works assume matched training and testing shots whereas our work focuses on setups where testing shots are not ﬁxed ( i.e. not necessarily the same as training shots).
Our work is parallel to these works in that EST can be applied on the embeddings learned by these methods.
Improvement of few-shot classiﬁcation setup: Chen et al.
(2019) extend the few-shot learning problem setup by considering domain adaptation in addition to learning novel classes.
Speciﬁcally, they look at how well models trained on mini-imagenet can perform on few-shot learning in CUB200.
Importantly, they still force the number of shots to be consistent between training time and testing time.
While their work deals with varying the domain of the episodes at test time, our work deals with varying shots.
Concurrent to our work, Triantaﬁllou et al.
(2020) further broaden the scope of few-shot learning by introducing a benchmark composed of data from various domains; methods are tested on their ability to adapt to different domains and deal with class imbalance.
We extend their work with a thorough analysis of how the number of shots affects the learning outcome, and further propose a method to overcome the negative impact of mismatched shots.
Theoretical analysis of few-shot learning: Despite the myriad of methodological improvements, theoretical work on few-shot learning has been sparse.
Wang et al.
(2019b) provide a unifying formulation for few-shot learning methods, and clearly outline the key challenge in few-shot learning through a PAC argument, but do not introduce any new theoretical results.
In contrast, our work introduces a novel bound for the accuracy of ProtoNets; this bound provides useful intuitions pertaining to how ProtoNets adapt to few-shot episodes.
Additionally, we demonstrate theoretically and experimentally that the intrinsic dimension of the embedding function’s output space varies with the number of shots as a direct consequence of the challenges outlined in the PAC argument.
To the best of our knowledge, Amit & Meir (2017) provide the only prior work to bound the error of a meta-learning agent.
Speciﬁcally, they use the generalized PAC-Bayes framework to derive an error-rate bound for a MAML-style learning algorithm (where the hypothesis class is ﬁxed).
Their main result relates the performance of the learning algorithm to both the number of tasks encountered during meta-training and the number of shots given in any task.
In contrast to our work, their result does not apply to non-parametric methods such as ProtoNets because the hypothesis class in ProtoNets can change from episode to episode depending on the number of ways.
C ONCLUSION AND FUTURE WORK
We have explored how the number of support samples used during meta-training can inﬂuence the learned embedding function’s performance and intrinsic dimensions.
Our proposed method transforms the embedding space to maximize inter-to-intra class variance ratio while constraining the dimensions of the space itself.
In terms of applications, our method can be combined other works (Oreshkin et al., 2018;
Ye et al., 2018; Rusu et al., 2019; Dong & Xing, 2018; Ren et al., 2018; Tapaswi et al., 2019) with an embedding learning component.
We believe our approach is a signiﬁcant step to reduce the impact of the shot number in meta-training, which is a crucial hyperparameter for few-shot classiﬁcation. A CKNOWLEDGMENTS
We acknowledge partial support from NSERC COHESA NETGP485577-15 and Samsung.
We thank Chaoqi Wang for discussion on the initial idea, and Cl´ement Fuji Tsang, Mark Brophy and the anonymous reviewers for helpful feedback on early versions of this paper
A A PPENDIX A. A LGORITHM FOR EST
Below is the exact procedure for computing T for embedding space transformation.
Algorithm 1 Algorithm for computing the transformation T .
L n is the number of samples belonging to class n ; µ n and Σ n are the mean and covariance of the embeddings of that class; µ T and Σ s are the average of mean embeddings and covariances; Σ µ is the covariance of the mean embeddings; V ∗ is the matrix of eigenvectors that correspoinds to the d largest eigenvalues in Λ .
Input: Training set D tr = { ( x 1 , y 1 ) , ..., ( x M , y M } , where y i ∈ { 1 , ..., N } , D n denotes the subset of D tr where ∀ y ∈ D n , y = n , embedding function φ , weighting parameter ρ , dimension parameter d .
Output: Transformation T .
Initialize µ = { 0 } Nn , Σ = { 0 } Nn , for n = 1 to N do µ [ n ] = µ n =
[Equation]
n (cid:80) (
[Equation]
[Equation]
( x i ) Σ[ n ] = 1 L n (cid:80) ( x i ,y i ) ∈D n ( φ ( x i ) − µ n )( φ ( x i ) − µ n ) T end for µ T = 1 M (cid:80) ( x i ,y i ) ∈D tr φ ( x i ) Σ µ = 1 N (cid:80) n ∈ [1 ,N ] ( µ [ n ] − µ T )( µ [ n ] − µ T ) T Σ s = 1 N (cid:80) n ∈ [1 ,N ] Σ[ n ]
Find V , Λ such that: Σ µ − ρ Σ s = V Λ V T
V ∗ =
[ v j ] for j ∈ top d of Λ
T ( z ) =
V ∗ ( z )
A. N ETWORK ARCHITECTURE
The vanilla CNN has the exact same architecture as the original ProtoNet (Snell et al., 2017).
It consists of four convolution layers with depth of 64; each convolution layer is followed by Relu activation, max-pooling, and batch normalization (Ioffe & Szegedy, 2015).
Resnet of 7 layers is constructed with one vanilla convolution layer of depth 64 followed by three residual blocks, all joined by max-pooling layers; each residual block consists of two sets of conv-batchnorm-Relu layers, of depth 128-256-256.
A. D ATA SET DESCRIPTION AND PRE - PROCESSING
Experiments are performed on three data sets: Omniglot (Lake et al., 2015), mini-imagenet (Vinyals et al., 2016), and tiered-imagenet (Ren et al., 2018).
For Omniglot experiments, we follow the same conﬁguration as in the original paper where 1200 classes augmented with rotations (4800 total) are used for training, and the remaining classes are used for testing.
For mini-imagenet experiments, we use the splits proposed by (Ravi & Larochelle, 2017) whereclasses are used for training, 16 for validation, and 20 for testing.
Mirroring the original paper, we resize all mini-imagenet images to 84x84.
No data augmentation is applied.
As most state-of-art few-shot classiﬁcation methods achieve saturating accuracies on Omniglot, and mini-imagenet’s small number of classes make claims about generalization difﬁcult, we also conduct experiments of tiered-imagenet.
Tiered-imagenet is also a subset of Imagenet1000.
Tiered-imagenet groups classes into broader categories corresponding to higher-level nodes in the ImageNet hierarchy.
It includes 34 categories, with each category containing between 10 and 30 classes.
These are split into 20 training, 6 validation and 8 testing categories.
In total, there are 351 classes in training, 97 in validation, and 160 in testing.
Preprocessing of images follow the same steps as used for mini-imagenet.
A. P ROTO N ET TRAINING
Training procedure of ProtoNets largely mirrors the protocol used by Snell et al.
On Omniglot, we train the network to convergence after 30000 episodes.
On mini-imagenet and tiered-imagenet, we monitor the performance of the network on the validation set and select the best performing checkpoint after training for 50000 episodes.
Adam (Kingma & Ba, 2014) optimizer is used with α = 0 .
9 , β = 0 .
999 , (cid:15) =
10 − 8 , and an initial learning rate of 0 .
001 that is decayed by half everyepisodes.
On Omniglot, we train with 60 classes and 5 query points per episode.
On mini-imagenet and tiered-imagenet, we train with 20 classes and 15 query points per episode.
A. D ERIVATION D ETAILS Proof of Lemma 1:
Proof.
First, from the deﬁnition of α , we split E x ,S | a,b [ α ] in to two parts and examine them separately:
[Equation]
In general, for random vector X , the expectation of the quadratic form is E [ (cid:107) X [Equation] 2 ] = Tr(Var( X ))
+ E
[ X ] T E
[ X ] .
Hence,
[Equation]
where the ﬁrst term inside the trace can be expanded as:
[Equation]
To go from (18) to (19)
[Equation]
we note that Var( X ) =
E [ XX T ] − E
[ X ] E [ X ] T and Σ c ∆ =
Var( φ ( x )) .
Hence (19) can be obtained by expanding out the ﬁrst term and taking the expectation of each resulting item.
The second term of (16) is simply:
[Equation] [Equation]
Putting them together:
[Equation] [Equation]
Similarly for ii :
[Equation] [Equation]
[Equation]
Putting together i and ii :
[Equation]
Then, since E a,b, x ,S [ α ] = E a,b [ E x ,S | a,b [ α ]] , we have:
[Equation]
Where from the second to the third line, we note that µ Ta µ a and µ Tb µ b are quadratic forms while µ Ta µ b describe a dot product between two independent randomly drawn samples which has expectation µ T µ .
For proof of Lemma 2, we ﬁrst re-state the result on quadratic forms of normally distributed random vectors by Rencher & Schaalje (2008).
Theorem 4.
Consider random vector y ∼ N ( µ , Σ) and symmetric matrix of constants
A , we have:
[Equation]
Proof of Lemma 2:
Proof.
[Equation]
From 33 to 35, we used Cauchy Schwarz inequality.
From line 35 to line
[Equation]
we use the fact that 2 ab ≤ a 2 + b 2 for all a, b ∈ R + .
By applying Theorem
[Equation]
we have:
[Equation]
µ
[Equation]
[Equation]
Finally,
E
[Equation]
Extending to N class: Let x , y denote the query data pair, and the set of N classes be denoted as c .
Let α i =
(cid:13)(cid:13)(cid:13) φ ( x ) − φ ( S i ) (cid:13)(cid:13)(cid:13) 2 − (cid:13)(cid:13)(cid:13) φ ( x ) − φ ( S y )
(cid:13)(cid:13)(cid:13) 2 .
Then we have a correct prediction ˆ y
=
y if ∀ i ∈ [1 , N ] , i (cid:54) =
y, α i > 0 .
Hence: R ( φ ) =
Pr c , x ,S ( (cid:83) N i =
i (cid:54) =
y α i > 0)
By Frechet’s inequality:
[Equation]
Noting that Theorem 3 can be applied to each term in the summation:
[Equation]
It is then clear that the observations made on the binary case also applies to the multiclass case
[Figure]
A. A DDITIONAL R ESULTS
Additionally, we experimented with directly setting the output dimension of the embedding network to 60 by adding a fully connected layer to the embedding network.
This variant of protonet performs worse than both the base variant and all other methods.
[Figure]
[Figure] [Table] [Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table] [Figure] [Table] [Figure]
[Table] [Table]
[Table] [Table] [Table]