To Learn Effective Features: Understanding the Task-Specific Adaptation of MAML

1 INTRODUCTION . Few-shot learning , aiming to learn from few labelled examples , is a great challenge for modern machine learning systems . Meta learning , an effective way for tracking this challenge , enables the model to learn general knowledge across a distribution of tasks . Various ideas of meta learning have been proposed to address the few-shot problems . Gradient-based meta learning ( Finn et al . ( 2017 ) ; Nichol et al . ( 2018 ) ) learns the meta-parameters that can be quickly adapted to new tasks by few gradient descent steps . Metric-based meta learning ( Koch et al . ( 2015 ) ; Vinyals et al . ( 2016 ) ; Snell et al . ( 2017 ) ) proposes to learn a metric space by comparing different datapoints . Memorybased meta learning ( Santoro et al . ( 2016 ) ) can rapidly assimilate new data and leverage the stored information to make predictions . Model Agnostic Meta-Learning ( MAML ) ( Finn et al . ( 2017 ) ) is one of the most well-known gradient-based meta learning algorithms , that learns the meta-initialization parameters through the inner optimization loop and the outer optimization loop . For a given task , the inner loop is to perform fast adaptation in several gradient descent steps with the support datapoints , while the outer loop to generalize the updated model to the query datapoints . With the learned meta-initialization , the model can be quickly adapted to the unseen tasks with few labelled samples . Following the MAML algorithm , many significant variants ( Finn et al . ( 2018 ) ; Rusu et al . ( 2018 ) ; Oreshkin et al . ( 2018 ) ; Bertinetto et al . ( 2018 ) ; Lee et al . ( 2019b ) ) are studied under the few-shot setting . To understand how the MAML works , Raghu et al . ( 2019 ) conduct a series of experiments and claim that rather than rapid learning and adaptation , the learned meta-initialization has already absorbed the high-quality features prior , thus the representations after fine-tuning are almost the same for the coming unseen tasks . Also , the task specific head of MAML at training facilitates the learning of better features . In this paper , we further design more representative experiments and present a formal argument to explain the importance of the task specific adaptation . Actually , the multi-step taskspecific adaptation , making the body and head have similar classification capabilities , can provide better gradient descent direction for the features learning of body . We also notice that for both the gradient-based methods ( e.g . MAML ( Finn et al . ( 2017 ) ) , MetaOptNet ( Lee et al . ( 2019b ) ) ) and metric-based methods ( e.g . Prototypical Networks ( Snell et al . ( 2017 ) ) ) that attempt to learn a taskspecific head using the support datapoints , the adaptation is a common mode for features learning of body but varied in different methods . Based on our analysis , we first propose a new training paradigm to find a decision plane ( linear classifier ) for guidance with no gradient descent step during the inner loop and get more supporting conclusions . Moreover , we devise another training paradigm that removes the inner loop and trains the model with only the query datapoints . Specifically , inspired by contrastive representation learning ( Oord et al . ( 2018 ) ; Chen et al . ( 2020 ) ; He et al . ( 2020 ) ) , we exploit the inter-samples relationship of query set to find a guidance for the body across different tasks . This meta contrastive learning algorithm even achieves competitive results comparable to some state-of-the-art methods . In total , our contributions can be listed as follows : 1 . We present sufficient experiments and formal argument to explore the impact of the taskspecific adaptation for body features learning and discuss the general formula for other gradient-based and metric-based meta-learning approaches . 2 . We devise a training algorithm to obtain a decision plane with no gradient descent step during the inner loop , named as Random Decision Planes ( RDP ) , and get more supporting conclusions . 3 . Unlike prior gradient-based methods , we propose the Meta Contrastive Learning ( MCL ) algorithm to exploit the inter-samples relations instead of training a task-specific head during the inner loop . Even without the task-specific adaptation for guidance , our algorithm still achieve better results with even less computation costs . 4 . We empirically shows the effectiveness of the proposed algorithm with different backbones on four benchmark datasets : miniImageNet ( Vinyals et al . ( 2016 ) ) , tieredImageNet ( Ren et al . ( 2018 ) ) , CIFAR-FS ( Bertinetto et al . ( 2018 ) ) and FC100 ( Oreshkin et al . ( 2018 ) ) . 2 RELATED WORKS . MAML ( Finn et al . ( 2017 ) ) is a highly influential gradient-based meta learning algorithm for fewshot learning . The amazing experiment results on several public few-shot datasets have proved its effectiveness . Following the core idea of MAML , there are numerous works to handle the data insufficiency problem in few-shot learning . Some works ( Oreshkin et al . ( 2018 ) ; Vuorio et al . ( 2019 ) ) introduce the task-dependent representations via conditioning the feature extractor on the specific task to improve the performance . Sun et al . ( 2019 ) also employ the meta-learned scaling and shifting parameters for transferring from another large-scale dataset . Others ( Grant et al . ( 2018 ) ; Finn et al . ( 2018 ) ; Lee et al . ( 2019a ) ) study this problem from the perspective of Bayesian approach . Unlike prior methods , we provide two training paradigms , one with no gradient descent step during the inner loop and another removing the inner loop and exploiting the inter-sample relations for training . Recent works also explore the key factors that makes the meta-learned model perform better than others at few-shot tasks . Chen et al . ( 2019 ) discovers that a deeper backbone has a large effect on the success of meta learning algorithm , while Goldblum et al . ( 2020 ) finds that the meta learning tends to cluster object classes more tightly in feature space for those methods that fix the backbone during the inner loop ( Bertinetto et al . ( 2018 ) ; Rusu et al . ( 2018 ) ) . A very recent work ( Raghu et al . ( 2019 ) ) argues that the meta-trained model can be applied to new task due to the high-quality features prior learned by the meta-initialized parameters rather than rapid learning . In this paper , we further study the impact of the task-specific adaptation for feature learning . Based on the analysis , we devise two algorithms , Random Decision Planes ( RDP ) and Meta Contrastive Learning ( MCL ) requiring less computation cost but still with competitive performance . 3 MODEL-AGNOSTIC META LEARNING ( MAML ) . The MAML aims to learn the meta-initialized parameters θ for the coming unseen tasks through the inner optimization loop and the outer optimization loop . Under the N -way-K-shot setting , for a task Tb sampled from the task distribution P ( T ) , we have a support set of N ×K examples T sb and a query set T qb , where N is the number of sampled class and K is the number of instances for each class . During the inner loop , with the support set T sb , we perform fast adaptation in several gradient descent steps and obtain the task-specific parameters θtTb where t is the number of gradient descent steps , given by : θtTb = θ t−1 Tb − α∇θt−1Tb LT sb ( θ t−1 Tb ) ( 1 ) where α is the step size for inner loop and LT sb ( θ t−1 Tb ) denoted as the loss on the support set T sb after t − 1 steps . With the query set T qb , we compute the meta loss on the task-specific parameters θtTb and backward to update the meta-initialized parameters θ , given by θ = θ − β∇θ 1 B B∑ b=1 LT qb ( θ t Tb ) ( 2 ) where β is the learning rate and B is the number of sampled tasks in a batch . 4 IMPACT OF TASK-SPECIFIC ADAPTATION . 4.1 THE MULTI-STEP TASK-SPECIFIC ADAPTATION IS IMPORTANT .. To explore the effectiveness of MAML , Raghu et al . ( 2019 ) have conducted sufficient experiments , indicating that the network body ( the representation layers ) has already absorbed the high-quality features prior . During meta-testing , instead of fine tuning on the network head ( the classifier ) , simply building the prototypes with the support set can achieve comparable performance to MAML . Raghu et al . ( 2019 ) also shows that the task specificity of head at training can facilitate feature learning and ensure good representation learning in the network body . In our work , we show that besides the task specificity of head , the multi-step adaptation is also essential , and further study the role of network body and head during meta-training . We devise several methods using different training regimes : ( 1 ) Multi-Task , where all the tasks simply share one common head and the model is trained in a traditional way without inner loop adaptation ; ( 2 ) Multi-Head , where different tasks are equipped with different heads for task specificity and the model is trained in a traditional way without inner loop adaptation ; ( 3 ) Almost No Inner Loop ( ANIL ) , where the network body is fixed during the inner loop ; ( 4 ) Body Outer Loop , Head Inner Loop ( BOHI ) , where the network body is updated only by the outer loop and the head is adapted only during the inner loop , making the head ’ s meta-initialized parameters unchanged . More algorithms ’ details can be found in Appendix B , and implementation details can be found in Appendix C.1 . Following Raghu et al . ( 2019 ) , we employ the cosine similarities between prototypes and the query datapoints to evaluate the quality of features learned . As Table 1 shows , even equipped with taskspecific head , the Multi-Head training still performs worse than the standard MAML algorithm by a large margin , indicating the multi-step adaptation of MAML is helpful for features learning . The results of Multi-Head and Multi-Task show the importance of multi-step task-specific adaptation . As the results shown in Table 1 , the ANIL training remains effective comparable to the standard MAML algorithm , indicating that the task-specific adaptation of network body is unnecessary to learn good features . More interestingly , the BOHI training that keeps the meta-initialization of head unchanged even performs better than MAML , further demonstrating that good features learning depends on the multi-step task-specific adaptation of head during inner loop more than updating the meta-initialization of head in outer loop . Also , the ANIL and BOHI have similar performance , indicating that compared with learned prior knowledge in head , the inner loop adaptation , as a guidance , contributes more to the features learning . More experimental results can be found in Appendix C.2 . 4.2 WHY IS MULTI-STEP TASK-SPECIFIC ADAPTATION IMPORTANT ? . Having observed that the MAML algorithm outperforms the Multi-Task training by a large margin and the multi-step task-specific adaptation is important for features learning , we extend our analysis to explore the reason why the inner loop adaptation is essential for MAML at different stages of meta training . Specifically , we freeze the initialized MAML model and model at 5,000 iterations , sample validation tasks from the task distribution , and record the test accuracy of model in different inner loop steps . Both the body accuracy based on prototypes construction and head accuracy based on fine-tuning are given in Figure 1 and Figure 2 , where “ Task ID ” stands for different tasks . As the results shows , at different stages of meta training , the head accuracy increases significantly in the first few adaptation steps since the model has learnt the correspondence between sample and label . However , at the beginning of training , there is only a small improvement on the body accuracy after first adaptation step . In Figure 2 , as the model converges , the body accuracy even decreases in the first few adaptation steps . In the following steps , with the task-specific adaptation of head , the network body then learns better representations , further demonstrating that the multi- Algorithm 1 The Random Decision Planes ( RDP ) Algorithm for N-way-K-shot learning Input : Network Body fθ , Learning Rate β , Task Distribution P ( T ) Perform the Gram-Schmidt method on random metrices to get the classifier set P = { Wi } np i=1 while not done do Sample a batch of tasks { Tb } Bb=1 , where Tb ∼ P ( T ) for b ∈ { 1 , ... , B } do Sample the support set T sb = { ( xsi , ysi ) } N×K i=1 and query set T qb = { ( x q i , y q i ) } N×K i=1 from task Tb . for each sample x in { T sb , T q b } do z = ‖fθ ( x ) ‖ end for define CrossEntropyLoss ( H , D ) as the cross entropy loss on the features representations set D with head H . W ? = arg min W∈P CrossEntropyLoss ( W , { ( zsi , ysi ) } N×K i=1 ) Lb = CrossEntropyLoss ( W ? , { ( zqi , y q i ) } N×K i=1 ) end for θ = θ − β∇θ 1B ∑B b=1 Lb end while step task-specific adaptation , making the body and head have similar classification capabilities , can be regarded as a guidance to provide better gradient descent direction for the feature learning of body . To understand this intuitive argument better , we consider a sample ( x , y ) for few-shot classification where the cross entropy loss is employed , formulated as : Lc = −log ( exp ( w > y h ) ∑ k exp ( w > k h ) ) = −w > y h + log ( ∑ k exp ( w > k h ) ) ( 3 ) where { w1 , w2 , ... , wk } is the weights of the classifier head , h is the body representation of x . The gradients of loss Lc with respect to the body representation h are denoted by , ∂Lc ∂h = −wy + ∑ kwkexp ( w > k h ) ∑ k exp ( w > k h ) = −wy + w̄ ( 4 ) where w̄ is exactly the weighted average of the weights { w1 , w2 , ... , wk } . As shown in Equation 4 , a reasonable direction for the network body to minimize the target lossLc is to make the representation h closer to the corresponding class weight wy , given by h = h + λ ( wy − w̄ ) . As the model converges , in the first few adaptation steps , there is a significant margin between the performance of head and body , and the classifier weights contain little knowledge about correspondence between samples and labels and differences between different classes . With the low-performance head , this updating rule for body may lead to a decline in the quality of features , which also explains why the simpler BOHI , ANIL even performs better than MAML in Table 1 . After several adaptation steps during the inner loop , the body then receives the useful guidance for features learning from the taskspecific head since wy can better express its corresponding class . The formulation above shows that the multi-step task-specific adaptation , making the body and head have similar classification capabilities , can provide better gradient descent direction for the features learning of body .

Summary: In this paper, the authors investigate the inner-loop optimization mechanism of meta-learning algorithms. The analysis shows the effectiveness of the multi-step adaptation and (1) the key of meta-learning is how to design a well-differentiated classifier. They then propose Random Decision Planes (RDP) and Meta Contrastive Learning (MCL) and achieve comparable performance with existing methods.