Improving Domain Generalization for Sound Classification with Sparse Frequency-Regularized Transformer

Honglin Mu, Wentian Xia, Wanxiang Che

TL;DR

Researchers have introduced FRITO (Frequency-RegularIzed TransfOrmer), a novel Transformer architecture that improves sound classification on "unseen" data by restricting the model's attention to specific frequency bands. By limiting the receptive field and using a sparse implementation, FRITO achieves state-of-the-art generalization performance while being 20% faster and 21% more memory-efficient than standard attention models.

What Problem Does This Paper Address?

Sound classification models often fail when deployed in the real world because of domain shift. A model trained on high-quality studio recordings might fail when it encounters audio from a cheap smartphone microphone or a noisy city square. This is often because the model "overfits" to the specific frequency distortions or ambient characteristics of the training devices rather than learning the core features of the sound itself.

While Convolutional Neural Networks (CNNs) have traditionally dominated this field, Transformers (like ViT) have recently shown superior performance. However, the "all-to-all" nature of Transformer self-attention makes them even more prone to picking up on global "shortcuts" in the data, leading to poor generalization on out-of-distribution (OOD) datasets.

Methods

The authors propose FRITO, which modifies the self-attention mechanism to act as a regularizer. The key components are:

  1. Local Frequency Attention: Instead of allowing every patch of an audio spectrogram to attend to every other patch, FRITO restricts a patch's "sight" to its neighbors along the frequency dimension. This prevents the model from relying on distant, potentially spurious frequency correlations.
  2. Global Frequency Attention: To ensure the model doesn't lose the "big picture," the authors add Global Tokens (GTok). These tokens can see the entire sequence and act as a central hub for information, allowing the model to perform classification based on a holistic view of the audio.
  3. Sparse Implementation: The authors realized that if the attention is restricted to local blocks (when the overlap factor $v=1$), the computation can be mathematically simplified. They implemented a sparse version that processes these blocks independently, significantly reducing the computational overhead.

Datasets

The model was evaluated on two major benchmarks:

  • Nsynth: A large-scale dataset of musical notes. The authors re-split this to test generalization by training only on acoustic instruments and testing on electronic and synthetic ones.
  • TAU 2020 (DCASE): An acoustic scene classification dataset (e.g., "metro," "shopping mall") recorded across multiple different devices. The test set includes "unseen" virtual devices to specifically measure generalization.

Key Insights and Ideas

  • Receptive Field as Regularization: Just as CNNs benefit from limited receptive fields to avoid overfitting, Transformers can be "tamed" by masking their attention. Restricting the field specifically along the frequency dimension is crucial for audio because device-specific distortions are often frequency-dependent.
  • Efficiency via Sparsity: Usually, sparse Transformers are used to handle very long sequences. Here, the authors use sparsity to improve generalization. The fact that it also makes the model 20% faster is a significant "free lunch" for edge deployment.
  • Global Tokens are Essential: Local attention alone isn't enough for classification. The global tokens serve as the "glue" that allows the model to integrate local frequency features into a final decision.

Key Results

  • Superior Generalization: On the Nsynth dataset, FRITO achieved an overall accuracy of 0.307, outperforming both the standard Vision Transformer (0.301) and the specialized PaSST model (0.285).
  • Robustness to Unseen Devices: On the TAU 2020 dataset, FRITO showed a 3.5% improvement over ResNet and a 0.5% improvement over PaSST on unseen recording devices (S4–S6).
  • Performance Gains: The sparse version of FRITO provided a 14% speedup in inference and a 21% reduction in memory usage compared to a vanilla Vision Transformer.

Limitations and Future Work

The authors acknowledge that while their method works empirically, a rigorous theoretical foundation for why specific receptive field sizes (the $r$ and $v$ parameters) work better than others is still missing.

Future work will likely focus on:

  • Deriving a mathematical relationship between the receptive field size and generalization performance.
  • Exploring more complex masking strategies that might adapt to the content of the audio.
  • Testing the architecture on a wider variety of audio tasks beyond scene and instrument classification.

Summary updated

BibTeX
@inproceedings{mu2023improving,
  author = {Honglin Mu and Wentian Xia and Wanxiang Che},
  title = {{Improving Domain Generalization for Sound Classification with Sparse Frequency-Regularized Transformer}},
  booktitle = {ICME},
  year = {2023},
  doi = {10.1109/icme55011.2023.00193},
}
Figure