Neural Networks Regularization Through Class-wise Invariant Representation Learning

Soufiane Belharbi, Clément Chatelain, Romain Hérault, Sébastien AdamarXiv 2017 · OpenReview

Abstract

Training deep neural networks is known to require a large number of training samples. However, in many applications only few training samples are available. In this work, we tackle the issue of training neural networks for classification task when few training samples are available. We attempt to solve this issue by proposing a new regularization term that constrains the hidden layers of a network to learn class-wise invariant representations. In our regularization framework, learning invariant representations is generalized to the class membership where samples with the same class should have the same representation. Numerical experiments over MNIST and its variants showed that our proposal helps improving the generalization of neural network particularly when trained with few samples.

Introduction

Deep neural networks (DNNs) are powerful tools for learning hierarchical features, but their performance is heavily dependent on the availability of large-scale datasets. In "low-data" regimes—where only a few hundred or thousand samples are available—DNNs often struggle to generalize, leading to overfitting.

Standard training relies on backpropagation to shape hidden layers indirectly via the output layer's labels. Ideally, a network should map all instances of a specific class to a similar region in its internal feature space, regardless of superficial variations like color or orientation. However, without explicit constraints, these internal representations often remain scattered. This paper proposes a novel regularization technique to explicitly guide hidden layers toward learning class-wise invariant representations.

Proposed Method: The Hint Penalty

The core contribution of this work is the Hint Penalty ($J_H$), a regularization term designed to force hidden layers to produce similar outputs for samples belonging to the same class.

Model Decomposition

The authors decompose a neural network into two functional components: a Representation Function ($\Gamma$), consisting of the sequence of hidden layers that maps input $x$ to a feature space, and a Decision Function ($\Psi$), which maps that feature representation to a final class prediction.

Conceptual illustration of intermediate representations becoming increasingly class-invariant through successive layers.

The Regularization Term

The hint penalty is added to the standard cross-entropy loss. It calculates the average dissimilarity between every pair of samples within a mini-batch that share the same class label. By minimizing this dissimilarity, the network is forced to "tighten" the clusters of same-class representations in its hidden layers. Among various distance metrics tested, Squared Euclidean Distance (SED) was found to be the most stable and effective across different architectures.

Experimental Setup and Results

The method was evaluated on three MNIST variants: standard digits (mnist-std), digits with noise backgrounds (mnist-noise), and digits with image backgrounds (mnist-img). Training set sizes ranged from 1,000 (1k) to 50,000 (50k) samples to simulate varying data availability.

Key Results and Insights

The most significant improvements were observed in the most data-constrained scenarios. A critical finding was that regularizing the last hidden layer ($h_3$) yielded the best results. Regularizing earlier layers often degraded performance, likely because early layers must preserve diverse low-level features (edges, textures) that are shared across many classes, whereas the final hidden layer should be abstract and highly class-specific.

Error rates for MLP models with and without hint penalty regularization across different training data sizes.

As shown in the table above, the regularized model (mlp + reg.) consistently outperforms the standard MLP in low-data settings. For instance, on the 1k sample set, the error rate for $h_3$ regularization is significantly lower than the baseline. Interestingly, the benefit persists even as data size increases, indicating that the regularization does not hinder the model's capacity when data is plentiful.

Conclusion

This work demonstrates that explicitly enforcing class-wise invariance in the hidden layers of a neural network is a powerful regularization strategy for small datasets. By clustering same-class representations in the penultimate layer, the network becomes more robust to noise and generalizes better from fewer examples. Future work may explore contrastive versions of this loss to further separate different-class representations in the hidden space.

Summary updated

Abstract

Training deep neural networks is known to require a large number of training samples. However, in many applications only few training samples are available. In this work, we tackle the issue of training neural networks for classification task when few training samples are available. We attempt to solve this issue by proposing a new regularization term that constrains the hidden layers of a network to learn class-wise invariant representations. In our regularization framework, learning invariant representations is generalized to the class membership where samples with the same class should have the same representation. Numerical experiments over MNIST and its variants showed that our proposal helps improving the generalization of neural network particularly when trained with few samples. We provide the source code of our framework https://github.com/sbelharbi/learning-class-invariant-features .
BibTeX
@misc{belharbi2017neural,
  author = {Soufiane Belharbi and Clément Chatelain and Romain Hérault and Sébastien Adam},
  title = {{Neural Networks Regularization Through Class-wise Invariant Representation Learning}},
  year = {2017},
  eprint = {1709.01867},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1709.01867},
}
Figure