Redesigning the Classification Layer by Randomizing the Class Representation Vectors

Gabi Shalev, Gal Lev Shalev, Yossi KeshetOpenReview 2020

TL;DR

This paper proposes a simple yet effective modification to the classification layer of neural networks: fixing randomly initialized class representation vectors instead of learning them. This approach surprisingly boosts accuracy and improves model robustness by preventing the implicit encoding of visual similarities between classes, which can hinder convergence and performance in standard methods.

What Problem Does This Paper Address?

Deep learning models for image classification typically consist of an encoder that generates a feature vector for an image, and a classification layer that projects this vector onto learned "class vectors" to determine the final class scores. The standard training process optimizes both the encoder and these class vectors simultaneously to minimize a loss function (like cross-entropy). While effective, this "dot-product maximization" or "cosine-similarity maximization" approach can implicitly learn visual similarities between classes within the class vectors themselves. The authors argue that this can be detrimental, leading to decreased inter-class separability (making it harder to distinguish between similar classes), reduced intra-class compactness (making representations of the same class more spread out), and even preventing models from converging, particularly in cosine-similarity based methods.

Methods

The core contribution of this paper is the proposal to fix the class representation vectors during training. Instead of learning these vectors alongside the image encoder, the authors initialize them randomly (often normalized to lie on a hypersphere) and keep them constant throughout the training process. This effectively "invalidates" any visual similarities that might have been learned by the standard training procedure.

The paper analyzes this approach in the context of two common classification layer strategies:

  1. Dot-Product Maximization: The standard method where the dot product between the image feature vector and class vectors is maximized.
  2. Cosine-Similarity Maximization: A variation that normalizes both image and class vectors to encourage better separation and compactness.

For both methods, they compare models where class vectors are learned ("non-fixed") versus models where they are randomly initialized and fixed ("fixed").

Datasets

The authors evaluated their methods on several standard image classification datasets:

  • STL-10
  • CIFAR-10
  • CIFAR-100
  • Tiny ImageNet

For generalization tests, they used:

  • CIFAR-10.1 (a subset of CIFAR-10)
  • Open Images V4 (for STL-10 and CIFAR-100 generalization)

Key Insights and Ideas

  • Learned Class Vectors Encode Undesirable Similarities: The paper provides strong evidence that learned class vectors in standard models implicitly capture visual similarities. For instance, vectors for "car" and "truck" might be close in the learned space, leading to confusion.
  • Fixing Class Vectors Boosts Accuracy: By randomizing and fixing class vectors, the models are forced to rely more on the image encoder to create discriminative features, leading to improved classification accuracy across various datasets and architectures.
  • Improved Inter-Class Separability and Intra-Class Compactness: The fixed class vector approach demonstrably increases the distance between representations of different classes and pulls together representations of the same class, leading to more robust and discriminative features.
  • Convergence Fix for Cosine-Similarity: For cosine-similarity maximization, which often struggles to converge without a scaling factor, fixing the class vectors allows convergence even with a scaling factor of 1, leading to significantly better performance and improved intra-class compactness.
  • Robustness and Generalization Unaffected: Crucially, fixing the class vectors does not negatively impact the model's ability to generalize to unseen data or its robustness to common image corruptions (like noise, compression, and blur).

Key Results

  • Accuracy Gains: Fixing class vectors led to accuracy improvements of up to 4% in absolute terms for dot-product maximization models. For cosine-similarity maximization, the gains were even more dramatic, with fixed models achieving up to 53% higher accuracy than non-fixed models when using a scaling factor of 1.
  • Correlation between Class Vector Closeness and Misclassification: The paper shows a strong positive correlation between the cosine-similarity of learned class vectors and the number of misclassifications between those classes.
  • High Intra-Class Compactness with Fixed Vectors: Fixed cosine-maximization models achieved an average cosine-similarity of around 0.95 between image vectors and their predicted class vectors, indicating highly compact representations.
  • Robustness Maintained: Table 6 shows that fixed models performed comparably or even slightly better than non-fixed models across various image corruptions.

Limitations and Future Work

  • Hyperparameter Tuning: While the paper mentions that fixed class vectors can allow for higher learning rates, detailed analysis of hyperparameter tuning for fixed vs. non-fixed models is not the primary focus.
  • Random Initialization Strategy: The paper uses normalized random vectors. Exploring different initialization strategies for these fixed vectors could be a future direction.
  • Theoretical Understanding: While empirical results are strong, a deeper theoretical understanding of why fixing class vectors leads to such consistent improvements across different metrics could be explored further.

The authors suggest that their findings could benefit previous works that adopted cosine-maximization methods and used scaling factors for convergence, implying that fixing class vectors might offer a more principled and effective alternative.

Summary updated

BibTeX
@misc{shalev2020redesigning,
  author = {Gabi Shalev and Gal Lev Shalev and Yossi Keshet},
  title = {{Redesigning the Classification Layer by Randomizing the Class Representation Vectors}},
  year = {2020},
  eprint = {2011.08704},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2011.08704},
  howpublished = {OpenReview},
}
Figure