Take One Gram of Neural Features, Get Enhanced Group Robustness

Simon Roburin, Charles Corbière, Gilles Puy, Nicolas Thome, Matthieu Aubry, Renaud Marlet, Patrick Pérez

TL;DR

Researchers have developed GRAMCLUST, a two-stage framework that automatically identifies hidden groups within a dataset to improve model robustness against "spurious correlations" (like always seeing cows on grass). By using Gram matrices—a tool typically reserved for artistic style transfer—to cluster data into "pseudo-groups," the method achieves state-of-the-art performance without requiring any expensive manual group annotations for training or hyperparameter tuning.

What Problem Does This Paper Address?

Standard machine learning models are usually trained using Empirical Risk Minimization (ERM), which assumes the training and test data come from the exact same distribution. However, real-world data often contains spurious correlations: accidental patterns that a model might exploit as a shortcut.

A classic example is a dataset where most cows are pictured on grass and most camels are in the desert. An ERM-trained model might simply learn to recognize "grass" to identify a cow. While this works for the majority of the data, the model fails miserably on "minority groups," such as a cow standing on a beach.

Existing solutions for "group robustness" (making sure the model performs well even on these rare cases) usually require humans to manually label every image with its environment (e.g., "grass," "sand," "water"). This is incredibly expensive and often impossible if the spurious factors are unknown. The authors of this paper set out to achieve group robustness without any group labels, even for validation.

Methods

The authors propose a two-stage approach called GRAMCLUST:

  1. Unsupervised Group Discovery:
    • First, they train a small "identification model" for just a few epochs. Because models tend to learn easy, spurious shortcuts early in training, this model becomes a "bias detector."
    • They extract features from intermediate layers of this model and compute Gram matrices. In the world of Style Transfer, Gram matrices are known to capture the "style" (textures, colors, backgrounds) of an image rather than its "structure" (the actual object).
  2. To make this computationally feasible for large datasets, they use random projections to squash these high-dimensional matrices into smaller vectors.
  3. Finally, they use simple k-means clustering on these vectors to partition the data into "pseudo-environments."
  4. Robust Optimization:
    • With these discovered pseudo-groups, they train the final classifier using Group Distributionally Robust Optimization (GroupDRO). Instead of minimizing the average error, GroupDRO forces the model to minimize the error of the worst-performing group, ensuring the model can't ignore the minority cases.
Figure 1: Overview of the proposed GRAMCLUST approach for robust classification with un- supervised group discovery. (1) We first extract deep image features using an identification model and (2) we cluster the training dataset based on Gram matrices of images features; (3) Then, we train the targeted classifier with a robust optimization that exploits the assigned pseudo-group labels. Consequently, GRAMCLUST properly classifies samples in minority groups, e.g. cows and camels in unusual environments – in contrast to standard Empirical Risk Minimization (ERM) training.

Datasets

The authors evaluated their method on three standard benchmarks for spurious correlations:

  • Waterbirds: Birds (land vs. water) superimposed on land or water backgrounds.
  • CelebA: A large-scale celebrity face dataset. The task is hair color classification, but it's plagued by a gender bias (e.g., only 2% of blondes in the set are male).
  • COCO-on-Places-224: Objects from the COCO dataset placed on various backgrounds from the Places365 dataset, creating complex, multi-background spurious correlations.

Key Insights and Ideas

  • Gram Matrices as Environment Detectors: The most clever insight is repurposing Gram matrices. Because they capture second-order statistics of neural activations, they are mathematically equivalent to minimizing the Maximum Mean Discrepancy (MMD) between distributions. This makes them perfect for grouping images that share similar "environmental" distributions (like all images with grassy backgrounds).
  • The "Early Bird" Bias: The method relies on the fact that ERM models are "lazy"—they pick up on easy spurious correlations within the first few epochs. By freezing the model early, the researchers turn a common weakness of deep learning into a tool for discovery.
  • Fully Unsupervised Hyperparameter Tuning: Most "unsupervised" methods actually cheat by using a small set of labeled data to tune their settings. The authors introduce GRAMCLUST-cv, which uses the discovered pseudo-groups even for cross-validation, making it truly label-free.
Figure 2: Illustration of the proposed dataset partition. An identification model Φ with parame- ters ω is trained for a limited number T of epochs with ERM to fit groups with easy-to-learn spurious correlations. Then, for each image xi ∈X, we extract intermediate features φl at layer l and com- pute their Gram matrix Gl with a random projection. These projected Gram matrix representations are used as features to cluster the training dataset Dtrain in E′ environments.

Key Results

As shown in the comparative results table, GRAMCLUST consistently outperforms other methods that don't use group labels:

  • CelebA Breakthrough: On the massive CelebA dataset, GRAMCLUST improved worst-group accuracy by +24.3 points over standard ERM. It also significantly outperformed recent baselines like JTT and GEORGE.
  • Beating the "Oracle": Surprisingly, on the Waterbirds dataset, GRAMCLUST (85.3% worst-group accuracy) actually outperformed GroupDRO (83.9%), even though GroupDRO was given the true human-annotated group labels. The authors suggest this is because human labels can be ambiguous, while Gram matrices capture the actual visual distribution shifts more accurately.
  • Scalability: Unlike some competing methods (like EIIL), GRAMCLUST scaled easily to the 200,000+ images in the CelebA dataset thanks to the random projection step.
Table 1: Comparative results on Waterbirds, CelebA and COCO-on-Places-224. Worst-group (w-g) and average (avg) test accuracies (% mean and std.) for Waterbirds and CelebA datasets; systematically-shifted (shift) and in-distribution (in-dis) test-set accuracies (% mean and std.) for COCO-on-Places-224 dataset. Experiments are with ResNet-50 models. Underlined and bold type indicate respectively best and per-block best performance (with significance p < 0.05 according to paired t-test on five runs). Methods are grouped according to their need for ground-truth group labels on train and/or val set; proposed GRAMCLUST-cv is the only one requiring none.

Limitations and Future Work

  • Reliance on Visual Style: Since the method uses Gram matrices, it is best suited for spurious correlations tied to visual "style" (backgrounds, textures, colors). It might struggle with purely semantic spurious correlations that don't have a distinct visual signature.
  • Number of Clusters: While the method is relatively robust, the user still needs to choose the number of clusters ($E'$). The authors found that 2 clusters worked well for their tests, but more complex real-world data might require more sophisticated cluster selection.
  • Future Directions: The authors suggest that exploring automatic discovery of groups in non-artificial, real-world data is the next major frontier for this line of research.

Summary updated

BibTeX
@inproceedings{roburin2023take,
  author = {Simon Roburin and Charles Corbière and Gilles Puy and Nicolas Thome and Matthieu Aubry and Renaud Marlet and Patrick Pérez},
  title = {{Take One Gram of Neural Features, Get Enhanced Group Robustness}},
  booktitle = {International Conference on Learning Representations},
  year = {2023},
  url = {https://openreview.net/forum?id=24quGic59-},
}
Figure