Abstract
This paper presents a neural network-based end-to-end clustering framework. We design a novel strategy to utilize the contrastive criteria for pushing data-forming clusters directly from raw data, in addition to learning a feature embedding suitable for such clustering. The network is trained with weak labels, specifically partial pairwise relationships between data instances. The cluster assignments and their probabilities are then obtained at the output layer by feed-forwarding the data. The framework has the interesting characteristic that no cluster centers need to be explicitly specified, thus the resulting cluster distribution is purely data-driven and no distance metrics need to be predefined. The experiments show that the proposed approach beats the conventional two-stage method (feature embedding with k-means) by a significant margin. It also compares favorably to the performance of the standard cross entropy loss for classification. Robustness analysis also shows that the method is largely insensitive to the number of clusters. Specifically, we show that the number of dominant clusters is close to the true number of clusters even when a large k is used for clustering.
Introduction
Traditional clustering in deep learning is usually a two-stage process: first, a network is trained to learn a low-dimensional feature representation (embedding), and then a separate algorithm like k-means is applied to those features. This approach is often suboptimal because the feature learning stage is not "aware" of the final clustering goal, and the choice of a distance metric (like Euclidean distance) assumes a specific geometry that may not be natural for the data.
To overcome these limitations, this paper introduces an end-to-end framework that performs clustering directly at the output layer. By training on "weak labels"—specifically pairwise similarities—the model learns feature embeddings and cluster assignments simultaneously. This eliminates the need for separate clustering algorithms or predefined distance metrics.
Methodology
The proposed framework treats the Softmax output of a neural network as a probability distribution over potential clusters rather than fixed class labels. The network is optimized using a novel contrastive objective.
Contrastive KL-Divergence Loss
Instead of standard Cross-Entropy, the model uses Kullback-Leibler (KL) divergence to measure the similarity between the output distributions of data pairs:
- Similar Pairs: The network minimizes the KL divergence, forcing the cluster probabilities of the two points to become identical.
- Dissimilar Pairs: The network employs a hinge loss to push the KL divergence above a certain margin, ensuring the points are assigned to different clusters.
Training and Efficiency
The model is trained using pairwise constraints (e.g., "Point A and Point B belong to the same group"). To maintain computational efficiency, the authors implemented a "cost layer" strategy. Rather than using a standard Siamese architecture that requires multiple forward passes for every pair, each image in a mini-batch is processed once. All possible pairwise relationships within the batch are then computed in the loss layer, significantly accelerating the training process.
Experimental Results
The researchers evaluated the approach on the MNIST and CIFAR-10 datasets, simulating partial knowledge by sampling only a fraction of possible pairwise relationships.
- Superior Performance: On CIFAR-10, the end-to-end approach outperformed the traditional two-stage baseline (embedding + k-means) by a massive margin, showing 15% to 50% better purity depending on the number of constraints.
- The "Self-Pruning" Effect: A striking finding is the model's robustness to the parameter $k$ (the number of clusters). If the network is tasked with finding 100 clusters in a dataset with only 10, it tends to populate ~10 dominant clusters and leaves the remaining output nodes empty, effectively discovering the true data distribution.
- Clustering as Classification: The results suggest that pairwise relationships are a powerful alternative to categorical labels; with a full set of constraints, this clustering method performs almost as well as standard supervised classification.
Conclusion
This framework demonstrates that neural networks can perform effective, data-driven clustering by optimizing for pairwise constraints. By bypassing the need for explicit cluster centers and fixed distance metrics, the model achieves higher purity and greater robustness than traditional methods. Future work will explore deploying this loss function within deeper architectures like ResNets and scaling the approach to larger, more complex datasets.
Summary updated