{'fraction_non_alphanumeric': 0.04003899449899032, 'fraction_numerical': 0.012742845205765616, 'mean_word_length': 4.754006410256411, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Enhancing Prototypical Few-Shot Learning by Leveraging the Local-Level Strategy

Aiming at recognizing the samples from novel categories with few reference samples, few-shot learning (FSL) is a challenging problem. We found that the existing works often build their few-shot model based on the image-level feature by mixing all local-level features, which leads to the discriminative location bias and information loss in local details. To tackle the problem, this paper returns the perspective to the local-level feature and proposes a series of local-level strategies. Specifically, we present (a) a local-agnostic training strategy to avoid the discriminative location bias between the base and novel categories, (b) a novel local-level similarity measure to capture the accurate comparison between local-level features, and (c) a local-level knowledge transfer that can synthesize different knowledge transfers from the base category according to different location features. Extensive experiments justify that our proposed local-level strategies can significantly boost the performance and achieve 2.8%-7.2% improvements over the baseline across different benchmark datasets, which also achieves state-of-the-art accuracy.


INTRODUCTION
Few-shot learning aims to recognize samples from novel categories with only a few labeled samples. Existing methods can be roughly divided into two main streams: (a) Metricbased approaches [1,2,3,4,5,6,7] focus on learning an appropriate feature space for both base and novel categories, and then classify the query data according to their distance between support data on the feature space. ProtoNet [3] proposes to build a prototype for each category and recognize by the nearest neighbor rule. The recent FEAT [8] also proposes to refine the prototype by a Transformer module, and Deep-EMD proposes a high-complexity distance. (b) Optimizationbased approaches [9,10,11,12,13] focus on improving the transferability of the fully trained model and transferring the knowledge of base categories to novel categories. For example, [12,13] propose an attention module to refine query features/prototypes by the knowledge of the base category. Although these methods have achieved encouraging success, we observe that they often follow the common routine in the traditional image classification task, i.g., extracting the image-level feature vector by global pooling [14] and then building their models on the image-level feature space. Under the fully supervised training by a large amount of labeled data, global pooling can improve the performance by driving the model to focus attention on the local features considered discriminative and suppress the features on the insignificant location. For example, in Fig. 1 (b), the high-weight local features are only distributed at concentrated locations. However, these discriminative features are distributed in different locations for different categories. We call this difference discriminative location bias. Few-shot learning requires the model to recognize the object belonging to the novel category. Hence, the discriminative location bias will cause the model to overpay attention to the location beneficial to the base category while ignoring the discriminative features of the novel category. As shown in Fig. 1 (b), the model trained with global pooling only pays attention to the insignificant location on the novel category images, resulting in the wrong classification.
To avoid the discriminative location bias, we first propose a local-level classification loss and a local-level regularization loss to realize local-agnostic training (LAT), which forces the model to pay attention to all locations instead of only the discriminative location. As shown in Fig. 1 (c), the high-weight local features from the model trained with the LAT strategy can cover the complete object of novel categories.
Furthermore, during the inference phase, the image-level features of the novel category are either misled by the discriminative location bias (from the model trained with global pooling) or confused by too much information (from the model trained with LAT strategy). Meanwhile, the image-level feature vector also destroys the local details in the image. Therefore, we further propose two local-level strategies during inference for a comprehensive understanding of novel category images. First, we propose a hybrid local-level similarity measure (LSM) to measure the similarity between local-level features accurately, composed of local distance and matching distance. Then, we propose a local-level knowledge transfer (LKT), which can synthesize the different knowledge transfers from base categories for different location features.
Extensive experiments justify that our proposed locallevel strategies can significantly boost the few-shot performance. On the ProtoNet [3] baseline, it achieve 2.8%-7.2% improvements. Compared with the competitive works, it doesn't require the complex algorithm [5] or additional model [7,8] but still achieves the state-of-the-art accuracy.

BACKGROUND KNOWLEDGE
Given disjoint category sets {C base , C val , C novel } and the corresponding datasets {D base , D val , D novel }, the objective of few-shot learning (FSL) is to train a robust model on D base which can generalize well on D novel with few reference samples per category. The reference data is called the support set and the recognized data is called the query set. Generally, the model is evaluated by the N -way K-shot episode classification [4] in FSL. In each episode, a support set S and a query set Q are sampled from D novel with the same N categories, where S contains K examples for each category with available labels. Then, the evaluation metric is defined as the average accuracy on Q under multiple episodes. In this work, we use the setting in [4], i.e., N = 5, K ∈ {1, 5} and Q randomly samples 15 examples for each category. We build our model on top of ProtoNet [3], which is a popular metric-based method due to its simplicity and effectiveness. In each episode, the ProtoNet first computes a prototype (center) for each class in S, where f Θ means the embedding extractor, S c means the subset of S with label c and | · | means the set size. After that, the probability distribution of the query image I q is predicted by the distance function D and softmax function σ,  Fig. 2. Overview of framework: The red and blue arrows mean the process in the training and inference phase respectively. We also mark the proposed enhancement in yellow.

METHODOLOGY
In this section, we describe the model architecture with localagnostic training objective (Sec. 3.1), the local-level similarity measure (Sec. 3.2), and the local-level knowledge transfer (Sec. 3.3) in order. The overview of our framework is depicted in Fig. 2. In particular, we mark the position of three proposed strategies in the framework by yellow, and the local-agnostic training and local-level knowledge transfer are visualized in Fig. 3 and Fig. 4 in detail.

Framework
Model Architecture: Our model consists of an embedding extractor φ and a classifier f W . Specifically, we use ResNet-12 [15] with four blocks as the extractor and extract the feature map from the last block φ (4) (I) for classification. The classifier f W : R d×w×h → R c×w×h consists of a 1x1 convolution function W ∈ R d×c without bias and a softmax function σ, which classifies each local feature on the last feature map for the local-level classification: Training Objective: We adopt the episode-based training [3] to avoid the over-fitting on D base . In each training, an N -way K -shot episode E that is considered as both support set and query set was sampled. As shown in Fig. 3, the training objective consists of the image-level similarity loss L S , as well as the local-level classification L C and regularization loss L R for local-agnostic training. The image-level similarity loss aims to minimize the intra-class distance and maximize the inter-class distance in the feature space, which is defined as where l is cross-entropy function, σ is softmax function, the P c is the prototype of category c computed by Eq. 1, and the distance function D is described in Sec. 3  to the discriminative location bias. To avoid the problem, we first replace the image-level classification loss with the locallevel classification loss (Eq. 5). It optimizes the classification loss for each location on the feature map, which encourages the model to focus on all location features, whether high or low discrimination. Specifically, we use a 1x1 convolution function described above as the classifier, and the local-level classification loss is computed by the cross-entropy l: Then, we propose a local-level regularization loss L R , which further avoids the discriminative location bias by punishing the model for paying too much attention to some location features. Specifically, we adopt the L 2 -norm of each local feature to evaluate the attention of the model to this location. Thus the local-level regularization loss is defined as where V ar means the variance across all local features. The final optimization objective is the sum of three losses:

Local-level Similarity Measure
Different from the image-level feature, the local-level feature is structural, so the similarity between local-level features should also consider their spatial structures. DeepEMD [5] proposed to compute the minimal spatial matching between local-level features, but this destroys the original spatial structure. MetaOptNet [11] and MCT [2] directly compare the spatial similarity, but it may not be accurate when the object posture and position vary. Different from them, we consider both the original spatial structures and the minimal spatial matching, which are visualized in Fig. 2. For each feature map x ∈ R d×w×h , after normalizing them by Eq. (8), we first directly compare the spatial similarity of local-level features between query sample and prototype p by local distance d L : Then we propose a simple minimum matching distance d M between local-level features to capture the correct comparison when object position and posture vary, which is defined as The final distance between the feature map and prototype is defined as the weighted sum of the two distances: Local-level Classificatoin Transfer Fig. 4. The process of LKT. "Transfer" means to replace each local feature as the weighted sum of the base knowledge.

Local-level Knowledge Transfer
In FSL, the semantic information of novel datasets is unavailable during training, which leads the distribution of the novel category samples difficult to converge in the feature space. [12,13] propose an attention module to refine the distribution of novel samples by the similarity with the base category. Different from them, we argue that the image-level feature cannot correctly describe the semantic information of the novel category sample (Sec. 1). Thus we introduce the local-level knowledge transfer during inference that refines all the location features separately. Specifically, we adopt the convergent classifier weight W (described in Sec. 3.1) as the knowledge (prototype) of base categories. As shown in Fig. 4, for each sample from D novel , we first compute a D base similar-version φ s (I) for the feature map φ (4) (I), on which each location feature is computed by the probability-weighted sum of W , Then, the local-level feature is refined as the weighted sum of the similar-version and original-version after normalization:

EXPERIMENTS
In this section, we evaluate the proposed local-level strategies (LLS), composed of the comparison with related works (Sec. 4.2) and the ablation studies (Sec. 4.3). In addition, we also adopt horizontal flip and random crop as data augmentation in the training phase. During training, the model is trained by an SGD optimizer for 50,000 episodes, in which N and K are set to 15 and 9. For TieredImageNet, we also adopt a batch-based pre-training step with only locallevel classification loss followed by the episode-based training, in which the learning rates are initialized to 0.1 and 0.01 with the decay of factor 0.1 at every 20,000 episodes. For other datasets, the learning rate is initialized to 0.1 and declines to 0.006 and 0.0012 at 30,000 episodes and 45,000 episodes, respectively. The balanced factor in Eq. (7) is set to λ S = 0.2, λ R = 0.0001. Other hyper-parameters are selected by the dataset validation, resulting in γ = 0.6, β = 0.8 for MiniImage, γ = 0.4, β = 0.9 for TieredImageNet, and γ = 0.2, β = 0.5 for CIFAR-FS.

Comparison with the State-of-the-art Methods
Tab. 1 shows the comparison with the latest methods. For a fair comparison, we report the model backbone and the average accuracy with 95% confidence interval over 1,000 episodes. As shown in Tab. 1, LLS can significantly boost the performance of the baseline ProtoNet with up 2.8%-7.2% on all benchmark datasets. Compared with competitive FEAT [8], Multi-Proto [7], and DeepEMD [5] adopting extra Transformer module, BERT module, and high-complexity distance metric respectively, we only adopt the simple ProtoNet framework and light-weight strategies, but still achieve the state-ofthe-art accuracy on all benchmark datasets.

Ablation Studies
Tab. 2 shows the ablation studies of three local-level strategies: local-agnostic training (LAT), local-level similarity measure (LSM), and local-level knowledge transfer (LKT). The performance when none of them is adopted can be regarded as our baseline, which is re-implemented from Pro-toNet [3]. As can be seen, the proposed LLS can achieve performance improvements of 3.7%-7.2% on the two datasets.  Table 2. Ablation studies of three local-level strategies with 1,000 episodes on MiniImageNet and CIFAR-FS.

CONCLUSION
In this paper, we focus on the local-level feature and propose a series of local-level strategies to enhance the few-shot image classification by avoiding the discriminative location bias and information loss in local details. Extensive experiments show that the proposed local-level strategies can achieve significant improvements with 2.8%-7.2% over the baseline, which also achieves the state-of-the-art accuracy. We hope our proposed new perspective on the local-level feature can inspire future works in few-shot learning.