MOPRO: WEBLY SUPERVISED LEARNING WITH MOMENTUM PROTOTYPES
Year: 2021

Abstract:
We propose a webly-supervised representation learning method that does not suffer from the annotation unscalability of supervised learning, nor the computation unscalability of self-supervised learning. Most existing works on weblysupervised representation learning adopt a vanilla supervised learning method without accounting for the prevalent noise in the training data, whereas most prior methods in learning with label noise are less effective for real-world large-scale noisy data. We propose momentum prototypes (MoPro), a simple contrastive learning method that achieves online label noise correction, out-of-distribution sample removal, and representation learning. MoPro achieves state-of-the-art performance on WebVision, a weakly-labeled noisy dataset. MoPro also shows superior performance when the pretrained model is transferred to down-stream image classification and detection tasks. It outperforms the ImageNet supervised pretrained model by +10.5 on 1-shot classification on VOC, and outperforms the best self-supervised pretrained model by +17.3 when finetuned on 1% of ImageNet labeled samples. Furthermore, MoPro is more robust to distribution shifts. Code and pretrained models are available at https://github.com/ salesforce/MoPro.

heading: 1 INTRODUCTION
text: Large-scale datasets with human-annotated labels have revolutionized computer vision. Supervised pretraining on ImageNet (Deng et al., 2009) has been the de facto formula of success for almost all state-of-the-art visual perception models. However, it is extremely labor intensive to manually annotate millions of images, which makes it a non-scalable solution. One alternative to reduce annotation cost is self-supervised representation learning, which leverages unlabeled data. However, self-supervised learning methods (Goyal et al., 2019; He et al., 2019; Chen et al., 2020a; Li et al., 2020b) have yet consistently shown superior performance compared to supervised learning, especially when transferred to downstream tasks with limited labels.
With the help of commercial search engines, photo-sharing websites, and social media platforms, there is near-infinite amount of weakly-labeled images available on the web. Several works have exploited the scalable source of web images and demonstrated promising results with weblysupervised representation learning (Mahajan et al., 2018; Sun et al., 2017; Li et al., 2017; Kolesnikov et al., 2020). However, there exists two competing claims on whether weakly-labeled noisy datasets lead to worse generalization performance. One claim argues that the effect of noise can be overpowered by the scale of data, and simply applies standard supervised learning method on web datasets (Mahajan et al., 2018; Sun et al., 2017; Li et al., 2017; Kolesnikov et al., 2020). The other claim argues that deep models can easily memorize noisy labels, resulting in worse generalization (Zhang et al., 2017; Ma et al., 2018). In this paper, we show that both claims are partially true. While increasing the size of data does improve the model’s robustness to noise, our method can substantially boost the representation learning performance by addressing noise.
There exists a large body of literature on learning with label noise (Jiang et al., 2018; Han et al., 2018; Guo et al., 2018; Tanaka et al., 2018; Arazo et al., 2019; Li et al., 2020a). However, existing methods have several limitations that make them less effective for webly-supervised representation learning. First, most methods do not consider out-of-distribution (OOD) samples, which is a major
source of noise in real-world web datasets. Second, many methods perform computation-heavy procedures for noise cleaning (Jiang et al., 2018; Li et al., 2019; 2020a), or require access to a set of samples with clean labels (Vahdat, 2017; Veit et al., 2017; Lee et al., 2018), which limit their scalability in practice.
We propose a new method for efficient representation learning from weakly-labeled web images. Our method is inspired by recent developments in contrastive learning for self-supervised learning (He et al., 2019; Chen et al., 2020a; Li et al., 2020b) We introduce Momentum Prototypes (MoPro), a simple component which is effective in label noise correction, OOD sample removal, and representation learning. A visual explanation of our method is shown in Figure 1. We use a deep network to project images into normalized low-dimensional embeddings, and calculate the prototype for a class as the moving-average embedding for clean samples in that class. We train the network such that embeddings are pulled closer to their corresponding prototypes, while pushed away from other prototypes. Images with corrupted labels are corrected either as another class or as an OOD sample based on their distance to the momentum prototypes.
We experimentally show that:
• MoPro achieves state-of-the-art performance on the upstream weakly-supervised learning task. • MoPro substantially improves representation learning performance when the pretrained model is
transferred to downstream image classification and object detection tasks. For the first time, we show that weakly-supervised representation learning achieves similar performance as supervised representation learning, under the same data and computation budget. With a larger web dataset, MoPro outperforms ImageNet supervised learning by a large margin.
• MoPro learns a more robust and calibrated model that generalizes better to distribution variations.

heading: 2 RELATED WORK

heading: 2.1 WEBLY-SUPERVISED REPRESENTATION LEARNING
text: A number of prior works exploit large web datasets for visual representation learning (Divvala et al., 2014; Chen & Gupta, 2015; Joulin et al., 2016; Mahajan et al., 2018; Sun et al., 2017; Li et al., 2017; Kolesnikov et al., 2020). These datasets contain a considerable amount of noise. Approximately 20% of the labels in the JMT-300M dataset (Sun et al., 2017) are noisy, whereas 34% of images in the WebVision dataset (Li et al., 2017) are considered outliers. Surprisingly, most prior works have chosen to ignore the noise and applied vanilla supervised method, with the claim that the scale of data can overpower the noise (Mahajan et al., 2018; Sun et al., 2017; Li et al., 2017). However, we show that supervised method cannot fully harvest the power of large-scale weakly-labeled datasets.
Our method achieves substantial improvement by addressing noise, and advances the potential of webly-supervised representation learning.

heading: 2.2 LEARNING WITH LABEL NOISE
text: Learning with label noise has been widely studied. Some methods require access to a small set of clean samples (Xiao et al., 2015; Vahdat, 2017; Veit et al., 2017; Lee et al., 2018; Zhang et al., 2020), and other methods assume that no clean labels are available. There exist two major types of approaches. The first type performs label correction using predictions from the network (Reed et al., 2015; Ma et al., 2018; Tanaka et al., 2018; Yi & Wu, 2019; Yang et al., 2020). The second type separates clean samples from corrupted samples, and trains the model on clean samples (Han et al., 2018; Arazo et al., 2019; Jiang et al., 2018; Wang et al., 2018; Chen et al., 2019; Li et al., 2020a). However, existing methods have yet shown promising results for large-scale weakly-supervised representation learning. The main reasons include: (1) most methods do not consider OOD samples, which commonly occur in real-world web datasets; (2) most methods are computational-heavy due to co-training (Han et al., 2018; Li et al., 2020a; Jiang et al., 2018; 2020), iterative training (Tanaka et al., 2018; Yi & Wu, 2019; Wang et al., 2018; Chen et al., 2019), or meta-learning (Li et al., 2019; Zhang et al., 2019).
Different from existing methods, MoPro achieves both label correction and OOD sample removal on-the-fly with a single step, based on the similarity between an image embedding and the momentum prototypes. MoPro also leverages contrastive learning to learn a robust embedding space.

heading: 2.3 SELF-SUPERVISED REPRESENTATION LEARNING
text: Self-supervised methods have been proposed for representation learning using unlabeled data. The recent developments in self-supervised representation learning can be attributed to contrastive learning. Most methods (He et al., 2019; Chen et al., 2020a; Oord et al., 2018; Wu et al., 2018) leverage the task of instance discrimination, where augmented crops from the same source image are enforced to have similar embeddings. Prototypical contrastive learning (PCL) (Li et al., 2020b) performs clustering to find prototypical embeddings, and enforces an image embedding to be similar to its assigned prototypes. Different from PCL, we update prototypes on-the-fly in a weakly-supervised setting, where the momentum prototype of a class is the moving average of clean samples’ embeddings. Furthermore, we jointly optimize two contrastive losses and a cross-entropy loss.
Current self-supervised representation learning methods are limited in (1) inferior performance in low-shot task adaptation, (2) huge computation cost, and (3) inadequate to harvest larger datasets. We show that weakly-supervised learning with MoPro addresses these limitations.

heading: 3 METHOD
text: In this section, we delineate the details of our method. First, we introduce the components in our representation learning framework. Then, we describe the loss functions. Finally, we explain the noise correction procedure for label correction and OOD sample removal. A pseudo-code of MoPro is provided in appendix B.

heading: 3.1 REPRESENTATION LEARNING FRAMEWORK
text: Our proposed framework consists of the following components. Figure 2 gives an illustration.
• A noisy training dataset {(xi, yi)}ni=1, where xi is an image and yi ∈ {1, ...,K} is its class label. • A pseudo-label ŷi for each image xi, which is its corrected label. Details for generating the
pseudo-label is explained in Sec 3.3. • An encoder network, which maps an augmented image x̃i to a representation vector vi ∈ Rde .
We experiment with ResNet-50 (He et al., 2016) as the encoder, where the activations of the final global pooling layer (de = 2048) are used as the representation vector. • A classifier (a fully-connected layer followed by softmax) which receives the representation vi as input and outputs class predictions pi.
• A projection network, which maps the representation vi into a low-dimensional embedding zi ∈ Rdp (dp = 128). zi is always normalized to the unit sphere. Following SimCLR (Chen et al., 2020a), we use a MLP with one hidden layer as the projection network. • Momentum embeddings z′i generated by a momentum encoder. The momentum encoder has the same architecture as the encoder followed by the projection network, and its parameters are the moving-average of the encoder’s and the projection network’s parameters. Same as in MoCo (He et al., 2019), we maintain a queue of momentum embeddings of past samples. • Momentum prototypes C ∈ Rdp×K . The momentum prototype of the k-th class, ck, is the normalized moving-average embedding for samples with pseudo-label ŷi = k.

heading: 3.2 CONTRASTIVE LOSS
text: As illustrated in Figure 1, we aim to learn an embedding space where samples from the same class gather around its class prototype, while samples from different classes are seperated. We achieve it with two contrastive losses: (1) a prototypical contrastive loss Lpro which increases the similarity between an embedding and its corresponding class prototype, (zi, cŷi), in contrast to other prototypes; (2) an instance contrastive loss Lins which increases the similarity between two embeddings of the same source image, (zi, z′i), in contrast to embeddings of other images. Specifically, the contrastive losses are defined as:
Lipro = − log exp(zi · cŷi/τ)∑K k=1 exp(zi · ck/τ) , Liins = − log exp(zi · z′i/τ)∑R r=0 exp(zi · z′r/τ) , (1)
where τ is a temperature parameter, and ŷi is the pseudo-label. We use R negative momentum embeddings to construct the denominator of the instance contrastive loss.
We train the classifier with cross-entropy loss, using pseudo-labels as targets.
Lice = − log(p ŷi i ) (2)
We jointly optimize the contrastive losses and the classification loss. The training objective is:
L = n∑ i=1 (Lice + λproLipro + λinsLiins) (3)
For simplicity, we set λpro = λins = 1 for all experiments.

heading: 3.3 NOISE CORRECTION
text: We propose a simple yet effective method for online noise correction during training, which cleans label noise and removes OOD samples. For each sample, we generate a soft pseudo-label qi by
combining the classifier’s output probability pi with si, a class probability distribution calculated using the sample’s similarity w.r.t the momentum prototypes:
qi = αpi + (1− α)si, ski = exp(zi · ck/τ)∑K k=1 exp(zi · ck/τ) . (4)
where the combination weight is simply set as α = 0.5 in all experiments.
We convert qi into a hard pseudo-label ŷi based on the following rules: (1) if the highest score of qi is above certain threshold T , use the class with the highest score as the pseudo-label; (2) otherwise, if the score for the original label yi is higher than uniform probability, use yi as the pseudo-label; (3) otherwise, label it as an OOD sample.
ŷi =  argmaxk q k i if maxk q k i > T , yi elseif q yi i > 1/K,
OOD otherwise. (5)
We remove OOD samples from both the cross-entropy loss and the prototypical contrastive loss so that they do not affect class-specific learning, but include them in the instance contrastive loss to further separate them from in-distribution samples. Examples of OOD images and corrected pseudo-labels are shown in the appendices.

heading: 3.4 MOMENTUM PROTOTYPES
text: For each class k, we calculate its momentum prototype as a moving-average of the normalized embeddings for samples with pseudo-label k. Specifically, we update ck by:
ck ← Normalize(mck + (1−m)zi), ∀i ∈ {i | ŷi = k}, (6) where Normalize(c) = c/ ‖c‖2. The momentum coefficient m is set 0.999 in our experiments.

heading: 4 EXPERIMENTS

heading: 4.1 DATASET FOR UPSTREAM TRAINING
text: We use the WebVision (Li et al., 2017) dataset as the noisy training data. It consists of images automatically crawled from Google and Flickr, using visual concepts from ImageNet as queries. We experiment with three versions of WebVision with different sizes: (1) WebVision-V1.0 contains 2.44m images with the same classes as the ImageNet-1k (ILSVRC 2012) dataset; (2) WebVisionV0.5 is a randomly sampled subset of WebVision-V1.0, which contains the same number of images (1.28m) as ImageNet-1k; (3) WebVision-V2.0 contains 16m images with 5k classes.

heading: 4.2 IMPLEMENTATION DETAILS
text: We follow standard settings for ImageNet training: batch size is 256; total number of epochs is 90; optimizer is SGD with a momentum of 0.9; initial learning rate is 0.1, decayed at 40 and 80 epochs; weight decay is 0.0001. We use ResNet-50 (He et al., 2016) as the encoder. For MoProspecific hyperparameters, we set τ = 0.1, α = 0.5, T = 0.8 (T = 0.6 for WebVision-V2.0). The momentum for both the momentum encoder and momentum prototypes is set as 0.999. The queue to store momentum embeddings has a size of 8192. We apply standard data augmentation (crop and horizontal flip) to the encoder’s input, and stronger data augmentation (color changes in MoCo (He et al., 2019)) to the momentum encoder’s input. We warm-up the model for 10 epochs by training on all samples with original labels, before applying noise correction.

heading: 4.3 UPSTREAM TASK PERFORMANCE
text: In Table 1, we compare MoPro with existing weakly-supervised learning methods trained on WebVision-V1.0, where MoPro achieves state-of-the-art performance. Since the training dataset
has imbalanced number of samples per-class, inspired by Kang et al. (2020), we perform the following decoupled training steps to re-balance the classifier: (1) pretrain the model with MoPro; (2) perform noise correction on the training data using the pretrained model, following the method in Section 3.3; (3) keep the pretrained encoder fixed and finetune the classifier on the cleaned dataset, using square-root data sampling (Mahajan et al., 2018) which balances the classes. We retrain the classifier for 15 epochs, using a learning rate of 0.01 which is decayed at 5 and 10 epochs. Surprisingly, we also find that a vanilla cross-entropy method with decoupled classifier re-balancing can also achieve competitive performance, outperforming most existing baselines.

heading: 5 TRANSFER LEARNING
text: In this section, we transfer weakly-supervised learned models to a variety of downstream tasks. We show that MoPro yields superior performance in image classification, object detection, instance segmentation, and obtains better robustness to domain shifts. Implementation details for the transfer learning experiments are described in appendix C.

heading: 5.1 LOW-SHOT IMAGE CLASSIFICATION ON FIXED REPRESENTATION
text: First, we transfer the learned representation to downstream tasks with few training samples. We perform low-shot classification on two datasets: PASCAL VOC2007 (Everingham et al., 2010) for object classification and Places205 (Zhou et al., 2014) for scene recognition. Following the setup by Goyal et al. (2019); Li et al. (2020b), we train linear SVMs using fixed representations from pretrained models. We vary the number k of samples per-class and report the average result
across 5 independent runs. Table 2 shows the results. When pretrained on weakly-labeled datasets, MoPro consistently outperforms the vanilla CE method. The improvement of MoPro becomes less significant when the number of web images increases from 2.4m to 16m, suggesting that increasing dataset size is a viable solution to combat noise.
When compared with ImageNet pretrained models, MoPro substantially outperforms self-supervised learning (MoCo v2 (Chen et al., 2020b) and PCL v2 (Li et al., 2020b)), and achieves comparable performance with supervised learning when the same amount of web images (i.e. WebVision-V0.5) is used. Our results for the first time show that weakly-supervised representation learning can be as powerful as supervised representation learning under the same data and computation budget.

heading: 5.2 LOW-RESOURCE TRANSFER WITH FINETUNING
text: Next, we perform experiment to evaluate whether the pretrained model provides a good basis for finetuning when the downstream task has limited training data. Following the setup by Chen et al. (2020a), we finetune the pretrained model on 1% or 10% of ImageNet training samples. Table 3 shows the results. MoPro consistently outperforms CE when pretrained on Web datasets. Compared to self-supervised learning methods pretrained on ImageNet, weakly-supervised learning achieves significantly better performance with fewer number of epochs.
Surprisingly, pretraining on the larger WebVision-V2 leads to worse performance compared to V0.5 and V1.0. This is because WebVision-V0.5 and V1.0 contain the same 1k class as ImageNet, whereas V2 also contains 4k extra classes. Hence, the representations learned from V2 are less task-specific and more difficult to adapt to ImageNet, especially with only 1% of samples for finetuning. This suggests that if the classes for a downstream task are known a priori, it is more effective to curate a task-specific weakly-labeled dataset with the same classes.

heading: 5.3 OBJECT DETECTION AND INSTANCE SEGMENTATION
text: We further transfer the pretrained model to object detection and instance segmentation tasks on COCO (Lin et al., 2014). Following the setup by He et al. (2019), we use the pretrained ResNet-50 as the backbone for a Mask-RCNN (He et al., 2017) with FPN (Lin et al., 2017). We finetune all layers end-to-end, including BN. The schedule is the default 1× or 2× in Girshick et al. (2018) Table 4 shows the results. Weakly-supervised learning with MoPro outperforms both supervised learning on ImageNet and self-supervised learning on one billion Instagram images.

heading: 5.4 ROBUSTNESS
text: It has been shown that deep models trained on ImageNet lack robustness to out-of-distribution samples, often falsely producing over-confident predictions. Hendricks et al. have curated two benchmark datasets to evaluate models’ robustness to real-world distribution variation: (1) ImageNetR (Hendrycks et al., 2020) which contains various artistic renditions of object classes from the
original ImageNet dataset, and (2) ImageNet-A (Hendrycks et al., 2019) which contains natural images where ImageNet-pretrained models consistently fail due to variations in background elements, color, or texture. Both datasets contain 200 classes, a subset of ImageNet’s 1,000 classes.
We evaluate weakly-supervised trained models on these two robustness benchmarks. We report both accuracy and the `2 calibration error (Kumar et al., 2019). The calibration error measures the misalignment between a model’s confidence and its accuracy. Concretely, a well-calibrated classifier which give examples 80% confidence should be correct 80% of the time. Results are shown in Table 5. Webly-supervised learning show significantly higher accuracy and lower calibration error. The robustness to distribution shift could come from the higher diversity of samples in Web images. Compared to vanilla CE, MoPro further improves the model’s robustness on both datasets. Note that we made sure that the training data of WebVision does not overlap with the test data.

heading: 6 ABLATION STUDY
text: We perform ablation study to verify the effectiveness of three important components in MoPro: (1) prototypical contrastive loss Lpro, (2) instance contrastive loss Lins, (3) prototypical similarity si used for noise correction (equation 4). We choose low-resource finetuning on 1% of ImageNet training data as the benchmark, and report the top-1 accuracy for models pretrained on WebVisionV0.5. As shown in Table 6, all of the three components contribute to the efficacy of MoPro.

heading: 7 CONCLUSION
text: This paper introduces a new contrastive learning framework for webly-supervised representation learning. We propose momentum prototypes, a simple component that is effective in label noise
correction, OOD sample removal, and representation learning. MoPro achieves state-of-the-art performance on the upstream task of learning from real-world noisy data, and superior representation learning performance on multiple down-stream tasks. Webly-supervised learning with MoPro does not require the expensive annotation cost in supervised learning, nor the huge computation budget in self-supervised learning. For future work, MoPro could be extended to utilize other sources of free Web data, such as weakly-labeled videos, for representation learning in other domains.

heading: APPENDIX A NOISY SAMPLE VISUALIZATION
text: In Figure 3, we show example images randomly chosen from the out-of-distribution samples filtered out by our method. In Figure 4, we show random examples where their pseudo-labels are different from the original training labels. By visual examination, we observe that our method can remove OOD samples and correct noisy labels at a high success rate.

heading: APPENDIX B PSEUDO-CODE OF MOPRO
text: Algorithm 1 summarizes the proposed method.
Algorithm 1: MoPro’s main algorithm. 1 Input: number of classes K, temperature τ , threshold T , momentum m, encoder network f(·),
projection network g(·), classifier h(·), momentum encoder g′(f ′(·)). 2 for {(xi, yi)}bi=1 in loader do // load a minibatch of noisy training data 3 for i ∈ {1, ..., b} do 4 x̃i = weak aug(xi) // weak augmentation 5 x̃′i = strong aug(xi) // strong augmentation 6 vi = f(x̃i) // representation 7 zi = g(vi) // normalized low-dimensional embedding 8 zi = g
′(f ′(x̃′i)) // momentum embedding 9 pi = h(vi) // class prediction
10 si = {ski }Kk=1, ski = exp(zi·ck/τ)∑K
k=1 exp(zi·ck/τ) // prototypical score
// noise correction 11 qi = (pi + si)/2 // soft pseudo-label 12 if maxk qki > T then 13 ŷi = argmaxk q k i 14 else if qyii > 1/K then 15 ŷi = yi 16 else 17 ŷi = OOD 18 end
// calculate losses
19 Liins = − log exp(zi·z′i/τ)∑R
r=0 exp(zi·z′r/τ) // instance contrastive loss
20 if ŷi is not OOD then 21 Lipro = − log exp(zi·cŷi/τ)∑K k=1 exp(zi·ck/τ)
// prototypical contrastive loss
22 Lice = − log(p ŷi i ) // cross entropy loss 23 else 24 Lipro = Lice = 0 25 end
// update momentum prototypes 26 cŷi ← Normalize(mcŷi + (1−m)zi) 27 end 28 L = ∑b i=1(Lice + Lipro + Liins) // total loss 29 update networks f, g, h to minimize L. 30 end

heading: APPENDIX C TRANSFER LEARNING IMPLEMENTATION DETAILS
text: For low-shot image classification on Places and VOC, we follow the procedure in Li et al. (2020b) and train linear SVMs on the global average pooling features of ResNet-50. We preprocess all images by resizing to 256 pixels along the shorter side and taking a 224 × 224 center crop. The SVMs are implemented in the LIBLINEAR (Fan et al., 2008) package.
For low-resource finetuning on ImageNet, we adopt different finetuning strategy for different versions of WebVision pretrained models. For WebVision V0.5 and V1.0, since they contain the same 1000 classes as ImageNet, we finetune the entire model including the classification layer. We train with SGD, using a batch size of 256, a momentum of 0.9, a weight decay of 0, and a learning rate of 0.005. We train for 40 epochs, and drop the learning rate by 0.2 at 15 and 30 epochs. For WebVision 2.0, since it contains 5000 classes, we randomly initialize a new classification layer with 1000 output
dimension, and finetune the model end-to-end. We train for 50 epochs, using a learning rate of 0.01, which is dropped by 0.1 at 20 and 40 epochs.
For object detection and instance segmentation on COCO, we adopt the same setup in MoCo (He et al., 2019), using Detectron2 (Girshick et al., 2018) codebase. The image scale is in [640, 800] pixels during training and is 800 at inference. We fine-tune all layers end-to-end. We finetune on the train2017 set (∼118k images) and evaluate on val2017.

heading: APPENDIX D STANDARD DEVIATION FOR LOW-SHOT CLASSIFICATION
text: Table 7 reports the standard deviation for the low-shot image classification experiment in Section 5.1.

Review summaries:
To train a model with a noisy weakly supervised training set, this paper proposed a momentum prototypes method for label noise correction and OOD sample removal. Noise correction is done by a heuristic rule, that if the prediction is confident enough or the prediction on original label is higher than uniform probability, the label will be kept otherwise it is considered as OOD sample. For training the model, this paper jointly optimizes cross entropy loss on the corrected labels, as well as contrastive loss using prototypical examples and instances.