Skip to main content
QUICK REVIEW

[Paper Review] Differentiable Top-k Classification Learning

Felix Petersen, Hilde Kuehne|arXiv (Cornell University)|Jun 15, 2022
Anomaly Detection Techniques and ApplicationsComputer Science10 citations
TL;DR

This paper proposes a differentiable top-k cross-entropy loss that optimizes for multiple k-values simultaneously by sampling k from a learnable distribution P_K, leveraging differentiable sorting and ranking to enable end-to-end training. The method improves both top-1 and top-5 accuracy, achieving new state-of-the-art results on ImageNet-1K with publicly available models using only last-layer fine-tuning.

ABSTRACT

The top-k classification accuracy is one of the core metrics in machine learning. Here, k is conventionally a positive integer, such as 1 or 5, leading to top-1 or top-5 training objectives. In this work, we relax this assumption and optimize the model for multiple k simultaneously instead of using a single k. Leveraging recent advances in differentiable sorting and ranking, we propose a differentiable top-k cross-entropy classification loss. This allows training the network while not only considering the top-1 prediction, but also, e.g., the top-2 and top-5 predictions. We evaluate the proposed loss function for fine-tuning on state-of-the-art architectures, as well as for training from scratch. We find that relaxing k does not only produce better top-5 accuracies, but also leads to top-1 accuracy improvements. When fine-tuning publicly available ImageNet models, we achieve a new state-of-the-art for these models.

Motivation & Objective

  • To address the limitation of fixed k in top-k classification, where models are typically trained for only one k (e.g., top-1), despite evaluation using multiple k-metrics.
  • To improve model generalization and robustness by training with a distribution of k-values rather than a single fixed k.
  • To enable end-to-end differentiable training for top-k classification by integrating differentiable sorting and ranking into the loss function.
  • To demonstrate that relaxing k improves not only top-k accuracy but also top-1 performance, especially in fine-tuning scenarios.

Proposed method

  • Leverages differentiable sorting and ranking methods (e.g., SinkhornSort, DiffSortNets) to compute a probability distribution over class ranks, enabling differentiable top-k operations.
  • Defines a distribution P_K over k-values (e.g., 50% top-1, 50% top-2), allowing the model to be trained on a mixture of top-k objectives.
  • Computes the effective loss as a weighted sum of top-k probabilities using cumulative weights derived from P_K, enabling gradient flow through the ranking operation.
  • Uses the resulting probability distribution p to compute a cross-entropy loss that is differentiable with respect to network weights.
  • Employs splitter selection networks to reduce the number of layers needed for k-selection, improving efficiency.
  • Applies the loss during fine-tuning and training from scratch on CIFAR-100, ImageNet-1K, and ImageNet-21K-P to evaluate scalability and performance.

Experimental results

Research questions

  • RQ1Can training with a distribution of k-values instead of a fixed k improve both top-1 and top-5 classification accuracy?
  • RQ2Does differentiable top-k learning via differentiable sorting and ranking lead to better generalization and robustness in standard classification tasks?
  • RQ3Can the proposed loss achieve state-of-the-art performance on ImageNet-1K with minimal computational cost, such as only fine-tuning the classifier head?
  • RQ4How scalable is the method to datasets with over 10,000 classes, such as ImageNet-21K-P?
  • RQ5Does the method outperform standard top-1 cross-entropy loss even when the baseline models are already pre-trained and highly optimized?

Key findings

  • The proposed top-k loss improves both top-1 and top-5 accuracy across all evaluated datasets, including CIFAR-100, ImageNet-1K, and ImageNet-21K-P.
  • On ImageNet-1K, the method achieves a new state-of-the-art top-1 accuracy of 88.37% and top-5 accuracy of 98.68% when fine-tuning Noisy Student EfficientNet-L2.
  • The improvement of 0.2% on top-5 accuracy for ResNeXt-101 32x48d WSL corresponds to a 10% error reduction, achieved at a fraction of the cost of full retraining.
  • On ImageNet-21K-P, the method achieves over 1% absolute improvement in top-5 accuracy with only last-layer fine-tuning, demonstrating scalability to large-scale classification.
  • Significance tests confirm that the improvements are statistically significant (p < 0.01), with p-values of 0.00001 for top-1 and 0.00005 for top-5 accuracy.
  • The method consistently outperforms baseline top-1 cross-entropy loss across multiple differentiable sorting methods, with DiffSortNets and SinkhornSort showing the strongest gains.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.