Anchor-based Nearest Class Mean Loss for Convolutional Neural Networks

Fusheng Hao, Jun Cheng, Lei Wang, Xinchao Wang, Jianzhong Cao, Xiping Hu, Dapeng TaoarXiv 2018

TL;DR

This paper introduces a new loss function for training Convolutional Neural Networks (CNNs) that explicitly enforces discriminative features by mapping training samples to fixed "anchor" points representing class centers. This "Anchor-based Nearest Class Mean Loss" (NCM) offers a simpler and more effective way to achieve intra-class compactness and inter-class separability compared to existing methods, leading to improved classification performance.

What Problem Does This Paper Address?

Deep learning models, particularly CNNs, excel at learning powerful feature representations. However, standard loss functions like Softmax don't explicitly encourage these features to be discriminative. This means that while CNNs can learn to classify, the learned features might not be optimally separated for different classes, making them less robust or harder to use for downstream tasks. Existing methods that try to enforce discriminative features, such as contrastive or triplet losses, often require careful sampling of data pairs or triplets, which can be computationally expensive and scale poorly with the number of training samples. Large-margin softmax losses also introduce many hyperparameters that are difficult to tune. The authors aim to address this by developing a loss function that directly enforces feature discriminability without these drawbacks.

Methods

The core innovation is the introduction of anchors: predefined, fixed vectors that serve as class centers. Instead of learning class centers from potentially noisy or sparse mini-batches (as in some prior work), these anchors are set once and remain constant throughout training. The proposed loss functions, Anchor-based Nearest Class Mean Loss (NCM), constrain the CNN's output features to be as close as possible to their corresponding class anchor.

Two specific loss functions are proposed:

  • Cosine-based NCM (C-NCM): Measures similarity using the cosine distance.
  • Euclidean-based NCM (E-NCM): Measures similarity using the Euclidean distance.

These loss functions are designed to be optimized efficiently using standard batch stochastic gradient descent (SGD). The anchors themselves are selected based on two principles: they have unit norm (lie on a hypersphere) and are spaced apart with a large angle between them to maximize inter-class separation.

Datasets

The proposed methods were evaluated on three standard image classification benchmarks:

  • MNIST: A dataset of handwritten digits.
  • CIFAR10: A dataset of small color images in 10 classes.
  • CIFAR100: A dataset of small color images in 100 classes.

The paper also mentions experiments on CIFAR10 with data augmentation (CIFAR10+).

Key Insights and Ideas

  • Fixed Anchors Simplify Training: By using fixed anchors instead of dynamically computed class means, the training process avoids issues related to noisy or insufficient samples in mini-batches, leading to more stable convergence.
  • Explicit Discriminative Constraint: Directly pulling features towards fixed anchors provides a strong, explicit signal for learning discriminative representations, unlike the implicit encouragement from Softmax.
  • No Hyperparameter Tuning for Anchors: The anchors are selected based on geometric principles (unit norm, large angles), eliminating the need to tune hyperparameters related to class centers or margins, making the method easier to deploy.
  • E-NCM's Stricter Constraint: The Euclidean-based NCM (E-NCM), which enforces both proximity to the anchor and implicitly a unit norm for the features (due to the anchor's unit norm), appears to provide even stronger constraints, leading to better performance in some cases, especially with data augmentation.

Key Results

  • Improved Accuracy: The proposed E-NCM and C-NCM loss functions achieve competitive or superior results compared to baseline SoftMax and state-of-the-art methods like L-Softmax on MNIST, CIFAR10, and CIFAR100.
  • CIFAR100 Performance: E-NCM achieved the lowest error rate of 28.14% on CIFAR100, which was 1.39% lower than L-Softmax.
  • Data Augmentation Benefits: Both C-NCM and E-NCM benefit significantly from data augmentation and dropout, outperforming SoftMax even more in these scenarios.
  • Faster Convergence: The loss functions converge within approximately 10 epochs on the MNIST dataset.
  • Visualization: Visualizations on MNIST show that C-NCM and E-NCM effectively pull deep features towards their respective anchors, demonstrating the loss function's effectiveness.

Limitations and Future Work

  • Overfitting Potential: The authors acknowledge that directly mapping samples to anchors might lead to overfitting, especially with limited training data. They address this by introducing data augmentation and dropout layers in their experiments.
  • Anchor Selection: While the principles for anchor selection are outlined, the specific method of meshgridding angles and computing coordinates is a practical implementation detail. Further research could explore more sophisticated anchor selection strategies.
  • Generalizability of Anchor-based Methods: The paper demonstrates the effectiveness of anchor-based NCM for classification. Future work could explore its application to other tasks like retrieval or verification where discriminative features are crucial.
  • Differentiable Metrics: The paper notes that any differentiable distance metric can be used, suggesting potential for exploring novel metrics beyond Euclidean and cosine.

Summary updated

BibTeX
@misc{hao2018anchor,
  author = {Fusheng Hao and Jun Cheng and Lei Wang and Xinchao Wang and Jianzhong Cao and Xiping Hu and Dapeng Tao},
  title = {{Anchor-based Nearest Class Mean Loss for Convolutional Neural Networks}},
  year = {2018},
  eprint = {1804.08087},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1804.08087},
}
Figure