Neuron Coverage-Guided Domain Generalization

Chris Xing Tian, Haoliang Li, Xiaofei Xie, Yang Liu, Shiqi Wang

TL;DR

This paper introduces a novel approach to Single-Source Domain Generalization (SSDG) inspired by software testing principles. By maximizing "neuron coverage" and enforcing gradient similarity between original and augmented samples during training, the model learns more robust features. This prevents unexpected behaviors on out-of-distribution data, achieving state-of-the-art performance on benchmarks like PACS and Digits without needing multiple source domains.

What Problem Does This Paper Address?

Deep neural networks (DNNs) are notorious for failing when tested on out-of-distribution (OOD) data—samples that look different from the training set. Domain generalization attempts to solve this by training models to extract universal features across multiple source domains.

However, in many real-world scenarios, privacy issues or data collection limits mean we only have access to a single domain for training. This is the "worst-case" formulation of domain generalization. The challenge is: how do we prevent a model trained on just one domain from failing catastrophically on unseen domains, especially when we have no prior knowledge of what those unseen domains might look like?

Methods

The authors tackle this by treating the DNN like a software program, where each neuron is a functional point of code. In traditional software testing, low code coverage means hidden bugs. In a DNN, neurons that remain inactive during training are essentially "hidden bugs." If an OOD sample suddenly activates these dormant neurons during inference, it often leads to misclassification.

To fix this, the authors propose Neuron Coverage-Guided Domain Generalization (NCDG), which introduces two novel training constraints:

  1. Neuron Coverage Maximization: During training, the model actively tries to maximize the number of activated neurons. They use a bootstrapping mechanism to track which neurons are inactive at the start of an epoch and specifically push their average outputs past an activation threshold.
  2. Gradient Similarity Regularization: To ensure the network processes data logically, the authors enforce an L2 penalty on the difference between the gradients of the coverage loss for original samples and their augmented counterparts. This acts as a proxy for aligning the "data flow" between domains.

The final training objective combines the standard classification loss (cross-entropy) with the neuron coverage loss and the gradient similarity loss.

Datasets

The authors evaluated their method across a wide variety of tasks and benchmarks:

  • Digits: Trained on MNIST (source) and tested on SVHN, MNIST-M, SYN, and USPS (targets).
  • PACS: An object recognition benchmark with 7 categories across 4 domains (Photo, Art-Painting, Cartoon, Sketch).
  • CIFAR-10-C: Used to evaluate robustness against 19 different types of image corruptions at varying severities.
  • Cross-Domain Semantic Segmentation: Synthetic datasets (GTA5, SYNTHIA) used as source domains, evaluated on real-world data (CITYSCAPES).
  • Office-Home & VLCS: Used to validate the method in a more traditional Multi-Source Domain Generalization (MSDG) setting.

Key Insights and Ideas

  • Software Testing Crossover: Applying code coverage concepts to DNNs during training (rather than just using it as a post-training debugging metric) actively improves generalization.
  • Inactive Neurons are Liabilities: Neurons that never activate during training are unpredictable. Forcing them to activate and participate in the learning process regularizes the network and prevents OOD samples from triggering catastrophic, untrained pathways.
  • Gradients as Data Flow: Using the gradient of the coverage loss allows the model to align the decision-making process of original and augmented images in a fine-grained, one-to-one manner, mapping data into a neural tangent kernel space.
  • Interpretability via Network Dissection: The authors visualized the network's hidden units and found that NCDG forces the network to learn actual semantic concepts (e.g., consistently activating an "eye" unit for the "person" class across domains). Standard training baselines failed to activate these semantic units on OOD data.

Key Results

  • Digits (SSDG): Achieved 73.4% average accuracy across 4 target domains when trained only on MNIST, outperforming the strong M-ADA baseline (72.0%).
  • PACS (SSDG): Using a ResNet-18 backbone, NCDG significantly outperformed baselines. For example, when trained only on the Art-painting domain, it achieved 76.6% average accuracy on the other three domains (compared to 69.9% for the DeepAll baseline).
  • CIFAR-10-C: Improved robustness against severe corruptions, achieving 79.2% average accuracy compared to standard ERM (56.2%) and the Augmix baseline (76.6%).
  • Semantic Segmentation: Boosted mean Intersection-over-Union (mIoU) from 22.7% (baseline) to 27.0% when adapting from GTA5 to CITYSCAPES without any target domain data.
  • Multi-Source (MSDG): Proved highly competitive even when multiple source domains were available, achieving state-of-the-art averages on Office-Home (66.1%) and VLCS (76.1%).

Limitations and Future Work

  • Computational Cost: The gradient similarity loss requires a "gradient through a gradient" operation (second-order derivative) during backpropagation. This increases the computational cost of training linearly with the number of model layers. (Note: Inference time remains identical to a standard model).
  • Future Work: To mitigate the training cost, the authors suggest investigating ways to select only a partial subset of neurons for coverage maximization, rather than computing it for all neurons in the network.

Summary updated

Abstract

This paper focuses on the domain generalization task where domain knowledge is unavailable, and even worse, only samples from a single domain can be utilized during training. Our motivation originates from the recent progresses in deep neural network (DNN) testing, which has shown that maximizing neuron coverage of DNN can help to explore possible defects of DNN (i.e., misclassification). More specifically, by treating the DNN as a program and each neuron as a functional point of the code, during the network training we aim to improve the generalization capability by maximizing the neuron coverage of DNN with the gradient similarity regularization between the original and augmented samples. As such, the decision behavior of the DNN is optimized, avoiding the arbitrary neurons that are deleterious for the unseen samples, and leading to the trained DNN that can be better generalized to out-of-distribution samples. Extensive studies on various domain generalization tasks based on both single and multiple domain(s) setting demonstrate the effectiveness of our proposed approach compared with state-of-the-art baseline methods. We also analyze our method by conducting visualization based on network dissection. The results further provide useful evidence on the rationality and effectiveness of our approach.
BibTeX
@article{tian2023neuron,
  author = {Chris Xing Tian and Haoliang Li and Xiaofei Xie and Yang Liu and Shiqi Wang},
  title = {{Neuron Coverage-Guided Domain Generalization}},
  journal = {IEEE Trans. Pattern Anal. Mach. Intell.},
  year = {2023},
  doi = {10.1109/tpami.2022.3157441},
}
Figure