Authors: Leelavathi Raja, Amirreza Eshraghi, Vinay Prabhakar, Mark Blacher, Han Bao, Yutong Wang
Organizations: Illinois Institute of Technology · Modular · Friedrich Schiller University Jena · The Institute of Statistical Mathematics & Tohoku University & RIKEN AIP
The familywise (FW) loss for multiclass classification, introduced by Duchi, Ruan, and Khosravi, achieves universal equivalence to the 0-1 loss, and thus has stronger theoretical properties than cross entropy (CE). Prior work, however, left open whether FW is as computationally efficient as CE. First, on the theoretical side, we prove that the FW gradient can be computed in O(K) time, where K is the number of classes. Second, on the practical side, we develop optimized kernels for computing the forward and backward passes of FW which outperform CE in terms of speed on both CPU and GPU.
Figures & tables
Figure 1: An illustrative example (per-sample) of Algorithm 2 . The input vector consists of eight logits, with r=2 bits processed per pass, resulting in 2r=4 bins represented by different colors. After determining the initial threshold (Stage 1), the remaining logits are copied to the candidate buffer (Stage 2) and then partitioned into radix bins (Stage 3). The bins are successively accepted or refined until the stopping condition is reached, yielding the final maximizing κˉ .
Figure 2: GPU runtime across different numbers of classes K and values of σ . Radix FW (FW_CUDA), naive FW (FW_naive), top-k FW (FW_topk), and PyTorch cross-entropy (CE) are compared. Mean κˉ represents the average maximizing κˉ across N=32 samples for K2 to K6 . Median execution time over 200 timed trials after 20 warm-up iterations.
Figure 3: CPU loss and gradient computation time across different class counts K and sparsity regimes (batch size 32, two threads). We compare our single-pass threshold search (FW_CPU) against PyTorch cross-entropy (CE) and the naive implementation (FW_naive). Lines are medians and bands are the 20–80 quantiles.
Figure 4: ( Left ) Test accuracy vs wall clock time on MNIST using the example code provided by GDTUO ( Chandra et al., 2022 ) . ( Middle ) Test accuracy versus epoch on training ResNet18 using the DoG optimizer ( Ivgi et al., 2023 ) . ( Right ) Validation accuracy vs epoch on ImageNet using Prodigy Mishchenko and Defazio (2024) . Total wall clock times for both training runs are ∼ 48600 seconds.
Appendix figures & tables6 assets
Supplementary material from the paper’s appendix.
Appendix
Figure 5: (Left) Simulated logits z∼N(0,0.1) with K=10000 (thus σ=1000 in the notation of Theorem C.1 ). For each blue dot, the x-coordinate is κ/K and the y-coordinate is Hκ (subsampled to avoid clutter). The thick blue ribbon is the limiting curve as K→∞ . (Right) κˉ versus σ . The blue line is the prediction of Theorem C.1 with the actual σ .
# datasets where loss won
# features
<30
≥30
FW
22
15
CE
44
9
Both
20
10
Total
86
34
Appendix
Table 1: Performance of familywise loss vs cross entropy loss-trained linear classifiers on the 90 datasets panel subset of the UCI dataset from Arora et al. (2020)
Figure 6: Laplace distribution
Figure 7: Mixed Gaussian distribution
Figure 8: CPU loss and gradient computation time for Laplace logits with mean 0 and standard deviation σ (batch size 32, AVX-512, two threads). Lines are medians and bands are the 20–80 quantiles.
Figure 9: CPU loss and gradient computation time for mixture logits: each logit is drawn from N(0,1) or from N(2,σ2) with probability 1/2 each (batch size 32, AVX-512, two threads). Lines are medians and bands are the 20–80 quantiles.
Cross-entropy (CE) is the default training loss for supervised classification, but its sample efficiency is limited when labels are scarce. Existing remedies primarily act on the data side, via augmentation, synthesis, or transfer from pretrained models; the training objective itself is rarely revisited. We revisit it here. Drawing on the classical observation that generative classifiers reach their asymptotic error with fewer samples than discriminative ones, we propose Generative Cross-Entropy (GenCE), a drop-in replacement for CE that introduces a generative learning principle into a standard discriminative network without altering the architecture or fitting a separate density model. GenCE follows from a Bayesian rewrite of the class-conditional likelihood and, in the mini-batch approximation, reduces to normalizing each sample's softmax score against the model's predictions on the batch, coupling the training signal across examples sharing a class. We extend the proper-scoring-rule framework to such non-local losses and prove that GenCE is strictly proper under a mild completeness condition: its population risk is uniquely minimized at the true posterior. Across three datasets, on two architectures and in both balanced small-data and class-imbalanced regimes, GenCE outperforms CE and other widely used losses, while also producing better-calibrated probabilities and stronger out-of-distribution detection.
In real-world applications of multiclass classification models, misclassification in an important class (e.g., stop sign) can be significantly more harmful than in other classes (e.g., no parking). Thus, it is crucial to improve the recall of an important class while maintaining overall accuracy. For this problem, we found that improving the separation of important classes relative to other classes in the feature space is effective. Existing methods that give a class-sensitive penalty for cross-entropy loss do not improve the separation. Moreover, the methods designed to improve separations between all classes are unsuitable for our purpose because they do not consider the important classes. To achieve the separation, we propose a loss function that explicitly gives loss for the feature space, called class-sensitive additive angular margin (CAMRI) loss. CAMRI loss is expected to reduce the variance of an important class due to the addition of a penalty to the angle between the important class features and the corresponding weight vectors in the feature space. In addition, concentrating the penalty on only the important class hardly sacrifices separating the other classes. Experiments on CIFAR-10, GTSRB, and AwA2 showed that CAMRI loss could improve the recall of a specific class without sacrificing accuracy. In particular, compared with GTSRB's second-worst class recall when trained with cross-entropy loss, CAMRI loss improved recall by 9%.
Loss functions play a central role in supervised classification. Cross-entropy (CE) is widely used, whereas the mean absolute error (MAE) loss can offer robustness but is difficult to optimize. Interpolating between the CE and MAE losses, generalized cross-entropy (GCE) has recently been introduced to provide a trade-off between optimization difficulty and robustness. Existing formulations of GCE result in a non-convex optimization over classification margins that is prone to underfitting, leading to poor performances with complex datasets. In this paper, we propose a minimax formulation of generalized cross-entropy (MGCE) that results in a convex optimization over classification margins. Moreover, we show that MGCEs can provide an upper bound on the classification error. The proposed bilevel convex optimization can be efficiently implemented using stochastic gradient computed via implicit differentiation. Using benchmark datasets, we show that MGCE achieves strong accuracy, faster convergence, and better calibration, especially in the presence of label noise.
Kartheek Bondugula, Santiago Mazuelas, Aritz Pérez +1
Basque Center for Applied Mathematics, Bilbao, Spain · Ikerbasque, Basque Foundation for Science · Johns Hopkins University, Baltimore, USA