Hard Mixtures of Experts for Large Scale Weakly Supervised Vision

Sam Gross, Marc'Aurelio Ranzato, Arthur Szlam

This paper from Facebook AI Research (FAIR) explores a practical way to scale up computer vision models to handle the massive, messy datasets found on the web. As we move from millions to hundreds of millions of images, standard Convolutional Neural Networks (CNNs) are starting to "underfit"—they simply don't have enough capacity to learn everything the data has to offer.

The authors propose using a Hard Mixture of Experts (MoE) approach to break through this capacity ceiling without making training or inference computationally prohibitive.

TL;DR

The authors demonstrate that "hard" mixture of experts—where each image is routed to exactly one specialized sub-network—is a highly effective way to scale vision models for datasets with hundreds of millions of images. This approach allows for massive model capacity (billions of parameters) that can be trained in parallel and evaluated efficiently, significantly outperforming standard CNNs on large-scale hashtag prediction tasks.

What Problem Does This Paper Address?

Training state-of-the-art CNNs usually involves fitting a model onto a single GPU or a small cluster. However, as datasets like YFCC100M (100 million images) become common, these models are becoming the bottleneck. There are two main issues:

  1. Memory & Parallelization: It is difficult to train models that are too large for a single GPU's memory.
  2. Underfitting: Evidence suggests that standard architectures (like ResNet-50) are actually too small to capture the complexity of web-scale, weakly supervised data (e.g., images labeled with noisy hashtags).

While "Mixture of Experts" (MoE) is an old idea, it was historically difficult to implement because splitting data among experts often led to "data fragmentation," where no single expert had enough data to learn well.

Methods

The authors propose a "hard" MoE architecture. Unlike "soft" MoE, which might combine outputs from many experts, this model picks exactly one.

  1. The Gater ($T$): They first train a standard "generalist" CNN. They take the features from the last hidden layer, reduce them via PCA, and perform K-means clustering to create $K$ clusters. This gater then routes any new image to the expert associated with the nearest cluster.
  2. The Experts ($H_i$): Each expert is its own CNN (e.g., a ResNet-18). Because the gater is "hard," each expert only sees a specific subset of the data during training.
  3. Architecture Variants:
    • Independent Decoders: Each expert has its own final classification layer. This is easiest to parallelize (Figure 1).
  4. Shared Decoder: All experts feed into a single, shared final layer ($D$). This forces the experts to map images into a unified embedding space, which is crucial if you want to use the model for transfer learning (Figure 2).

Figure 1: A mixture of experts model with separate decoders Figure 2: A mixture of experts model with a shared decoder

Datasets

  • YFCC100M: ~100 million Flickr images with hashtags. This is the primary benchmark for scaling.
  • Instagram Food: A massive, proprietary dataset of 440 million images used for anecdotal evidence of scaling.
  • ImageNet: 1.2 million images. Used as a control to show that MoE doesn't necessarily help when the dataset is "small."
  • Transfer Tasks: Various smaller datasets (MIT Indoor, CUB Birds, Oxford Flowers) used to test how well the learned features generalize.

Key Insights and Ideas

  • Scale Solves Fragmentation: The authors find that at the scale of 100M+ images, data fragmentation is no longer a problem. Even when splitting the data 50 ways, each expert still sees millions of images—plenty for robust training.
  • Routing by Feature, Not Class: In multi-label settings (hashtags), an image might belong to many categories. Routing based on the visual feature space (clustering) is more effective than routing based on class labels.
  • Efficiency: Because only one expert is active per image, a model with 50 experts only costs about 2x the computation of a base model (gater + 1 expert), but has nearly 50x the parameters.
  • Capacity is King: The "Oracle" experiment (where the model is told which expert is best using the ground truth) shows that the experts do learn specialized knowledge, but the gater is the weak link. There is significant untapped potential in better routing.

Key Results

  • Significant Gains on YFCC100M: A ResNet-18 MoE with 100 experts achieved a q@10 of 23.82%, nearly doubling the 12.41% of a standard ResNet-18.
  • Beating Deeper Models: A ResNet-18 MoE-50 (50 experts) outperformed a standard ResNet-50, despite being much faster to train due to parallelization.
  • Transfer Learning: Using the shared decoder variant, the MoE model provided better features for downstream tasks, particularly for fine-grained classification like Birds and Flowers (Table 2).
  • ImageNet Limitation: The MoE did not significantly improve results on ImageNet. This confirms that MoE is a tool for the "big data" regime where model capacity is the primary constraint.
Figure 4: Number of parameters vs. test accuracy. MoE models (orange) scale much better than standard ensembles.

Limitations and Future Work

  • Gating Bottleneck: The gater is trained separately and fixed. The authors' "Oracle" results suggest that if the gater were better (or trained end-to-end), performance could jump significantly.
  • Data Hunger: This method is inherently data-inefficient. Each expert only sees a fraction of the data. It is a "brute force" scaling method that relies on the availability of nearly infinite cheap, weakly labeled data.
  • Cluster Imbalance: The current method doesn't force clusters to be the same size. As seen in Figure 5, some experts end up with much less data than others, which could lead to uneven specialization.
Figure 5: Distribution of images per cluster, showing non-trivial utilization but significant variance in size.

Summary updated

BibTeX
@inproceedings{gross2017hard,
  author = {Sam Gross and Marc'Aurelio Ranzato and Arthur Szlam},
  title = {{Hard Mixtures of Experts for Large Scale Weakly Supervised Vision}},
  booktitle = {IEEE/CVF Conference on Computer Vision and Pattern Recognition},
  year = {2017},
  url = {https://openreview.net/forum?id=r1WFe6W_br},
}
Figure