Abstract
Overfit is a fundamental problem in machine learning in general, and in deep learning in particular. In order to reduce overfit and improve generalization in the classification of images, some employ invariance to a group of transformations, such as rotations and reflections. However, since not all objects exhibit necessarily the same invariance, it seems desirable to allow the network to learn the useful level of invariance from the data. To this end, motivated by self-supervision, we introduce an architecture enhancement for existing neural network models based on input transformations, termed 'TransNet', together with a training algorithm suitable for it. Our model can be employed during training time only and then pruned for prediction, resulting in an equivalent architecture to the base model. Thus pruned, we show that our model improves performance on various data-sets while exhibiting improved generalization, which is achieved in turn by enforcing soft invariance on the convolutional kernels of the last layer in the base model. Theoretical analysis is provided to support the proposed method.
Introduction
Deep neural networks are incredibly expressive, which makes them highly susceptible to the "generalization gap"—the discrepancy between performance on training data and unseen test data. A common strategy to combat this is building models invariant to geometric transformations like rotations. However, hard-coding strict mathematical invariance can be overly restrictive, as not all objects share the same symmetries (e.g., a ball is rotationally invariant, but a car is not).
This paper introduces TransNet, a training method that allows a network to learn a useful, "soft" level of invariance directly from data. This acts as a powerful regularizer, narrowing the generalization gap without sacrificing the model's ability to recognize orientation-dependent features.
The TransNet Framework
TransNet is an architectural enhancement inspired by self-supervised learning tasks, such as predicting image rotations.
Architecture and Training
The method replaces the final fully connected layer of a standard CNN (like ResNet) with multiple parallel "heads." Each head is associated with a specific transformation from the Dihedral group $D_4$ (e.g., identity, 90° rotation). During training, an image is transformed, passed through the shared backbone, and routed to the corresponding head. The network must correctly classify the object regardless of its orientation.
Inference Variations
- Pruned TransNet (PTm-CNN): After training, all heads except the "identity" head are pruned. This results in a network with the exact same architecture and inference speed as the base model, but with superior weights.
- Full TransNet (Tm-CNN): All heads are retained. The input is processed multiple times (once per transformation), creating a parameter-efficient ensemble.
Experimental Results
The authors evaluated TransNet across five standard datasets: CIFAR-10, CIFAR-100, ImageNette, ImageWoof, and ImageNet-200.
Key Findings
- Free Accuracy Boost: Pruned TransNet models (PT2-CNN or PT3-CNN) consistently outperformed base models. On CIFAR-100, the 2-head pruned model achieved 79.33% accuracy versus the base CNN's 76.56%, with zero additional inference cost.
- Efficient Ensembling: Full TransNet models (Tm-CNN) achieved even higher accuracies, performing competitively with standard ensembles while using significantly fewer parameters.
- The "Goldilocks" Zone: While adding heads improves generalization, adding too many (e.g., 4 heads for all 90-degree rotations) can enforce too strict an invariance, potentially degrading test accuracy on certain datasets.
Analysis of Soft Invariance
The success of TransNet stems from its ability to enforce "soft invariance" on convolutional kernels, particularly in the final layers. The authors introduced a mathematical metric, the Invariance Score (IS), to quantify this. Empirical results show that TransNet drastically increases the IS of the final convolutional layer compared to a standard CNN, effectively reducing the degrees of freedom and preventing overfitting.
Conclusion
TransNet provides a simple yet effective way to improve the generalization of CNNs by learning data-driven invariance. By simply adding and then pruning classification heads, researchers can achieve significant accuracy gains at no extra computational cost during inference. Future work may involve using the Invariance Score directly as a regularization penalty to automatically tune the optimal level of invariance for any given task.
Summary updated