Skip to main content
QUICK REVIEW

[Paper Review] Softmax-based Classification is k-means Clustering: Formal Proof, Consequences for Adversarial Attacks, and Improvement through Centroid Based Tailoring

Sibylle Hess, Wouter Duivesteijn|arXiv (Cornell University)|Jan 7, 2020
Adversarial Robustness in Machine LearningComputer Science30 references7 citations
TL;DR

This paper formally proves that softmax-based neural network classification is mathematically equivalent to k-means clustering in the transformed feature space of the penultimate layer. By redefining the final layer using a centroid-based activation (Gauss network), the model achieves improved robustness against one-pixel adversarial attacks—reducing vulnerability by a factor of 2.7 to 6.8—while maintaining competitive accuracy and expressing reasonable doubt on outlier inputs.

ABSTRACT

We formally prove the connection between k-means clustering and the predictions of neural networks based on the softmax activation layer. In existing work, this connection has been analyzed empirically, but it has never before been mathematically derived. The softmax function partitions the transformed input space into cones, each of which encompasses a class. This is equivalent to putting a number of centroids in this transformed space at equal distance from the origin, and k-means clustering the data points by proximity to these centroids. Softmax only cares in which cone a data point falls, and not how far from the centroid it is within that cone. We formally prove that networks with a small Lipschitz modulus (which corresponds to a low susceptibility to adversarial attacks) map data points closer to the cluster centroids, which results in a mapping to a k-means-friendly space. To leverage this knowledge, we propose Centroid Based Tailoring as an alternative to the softmax function in the last layer of a neural network. The resulting Gauss network has similar predictive accuracy as traditional networks, but is less susceptible to one-pixel attacks; while the main contribution of this paper is theoretical in nature, the Gauss network contributes empirical auxiliary benefits.

Motivation & Objective

  • To formally establish the mathematical equivalence between softmax classification and k-means clustering in deep neural networks.
  • To explain the vulnerability of softmax networks to one-pixel adversarial attacks through geometric and proximity-based analysis in the transformed feature space.
  • To develop a theoretically grounded alternative to the softmax function that enhances robustness by aligning network outputs with k-means-friendly clustering behavior.
  • To enable neural networks to express reasonable doubt on out-of-distribution or adversarially perturbed inputs, improving interpretability and safety.
  • To propose a trainable, proximal optimization-based method that directly learns cluster centroids in the final layer, improving generalization and robustness.

Proposed method

  • Prove that the softmax function partitions the penultimate layer’s feature space into Voronoi-like cones, each corresponding to a class, which is mathematically equivalent to k-means clustering with centroids equidistant from the origin.
  • Formulate a new final-layer activation function—Gauss network—based on the distance from input features to learned centroids, replacing the standard softmax.
  • Introduce a proximal minimization update rule that directly optimizes the network weights to represent cluster centroids, ensuring the model learns a k-means-friendly representation.
  • Train the Gauss network using standard backpropagation with the new loss, enabling end-to-end learning while maintaining high predictive accuracy.
  • Use the Gauss confidence score as a measure of distance to the nearest class prototype, allowing the model to flag uncertain or outlier predictions.
  • Evaluate robustness using FGSM and one-pixel attacks on CIFAR-10 and MNIST, comparing accuracy, confidence, and outlier detection performance.

Experimental results

Research questions

  • RQ1Is there a formal mathematical equivalence between softmax-based classification and k-means clustering in deep neural networks?
  • RQ2Why are softmax-based networks particularly vulnerable to one-pixel adversarial attacks, and how does this vulnerability relate to the geometry of the feature space?
  • RQ3Can a restructured final layer that explicitly models cluster centroids improve robustness against small input perturbations without sacrificing accuracy?
  • RQ4To what extent can a model express reasonable doubt on adversarial or out-of-distribution inputs by measuring proximity to learned centroids?
  • RQ5How does the Lipschitz modulus of a network relate to its proximity to cluster centroids, and does this proximity independently affect robustness beyond Lipschitz continuity?

Key findings

  • The paper formally proves that softmax classification is mathematically equivalent to k-means clustering in the transformed feature space of the penultimate layer, with each class corresponding to a cone around a centroid.
  • Networks with a small Lipschitz modulus map inputs closer to their corresponding class centroids, which enhances robustness by making the feature space more k-means-friendly.
  • The Gauss network, which replaces softmax with a centroid-based activation, reduces the proportion of images vulnerable to one-pixel attacks by a factor between 2.7 and 6.8 on CIFAR-10.
  • On MNIST, the Gauss network maintains high accuracy under noise and better distinguishes prototypes (clear digits) from outliers (abstract or distorted digits), with confidence scores reflecting human perception.
  • Traditional networks assign high confidence (>0.9) to noise images, while the Gauss network assigns near-zero confidence to such outliers, demonstrating its ability to express reasonable doubt.
  • The Gauss network’s confidence scores are more uniformly distributed across the confidence spectrum (mean ~0.56), compared to traditional networks (mean ~0.98), indicating reduced overconfidence and improved calibration.

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.