- Introduced by
- Caron, M. et al. (DeepCluster framework)
- Year
- 2018
- Type
- Self-supervised clustering
- Family
- Machine learning
What does it do?
Self-supervised K-means is a clustering approach that alternates K-means assignment with representation learning on unlabeled data.
Cluster assignments are used as pseudo-labels to update an underlying encoder, with the aim of producing clusters that become more coherent over successive rounds. No human-annotated labels are needed to train the loop, although a small labelled subset is usually required to evaluate the learned representation.
The intuition behind the method
Ordinary K-means clusters data in its raw or fixed feature space, which may not capture the structure that matters for the task. Self-supervised K-means treats the cluster assignments as free supervision: points are assigned to clusters, those assignments train an encoder, and the points are then re-clustered in the updated embedding space. Each round is intended to make the embeddings more cluster-friendly, though the loop is not guaranteed to improve them. The loop is usually run until the assignments stop changing much, and the resulting encoder can be reused for other tasks.
History
The cited paper, Caron et al. (2018), introduced DeepCluster. That method alternated K-means assignment with convolutional network training on image data and used the cluster assignments as pseudo-labels to learn visual features. 'Self-supervised K-means' is a descriptive label for this family of approaches and is not the title used in the cited paper.
When to use it
Use self-supervised K-means when you have a large pool of unlabeled data and want to discover groupings without annotation, or when you want to pretrain a representation for a downstream task at low labeling cost. It is a reasonable choice when the input is high-dimensional and a fixed feature space is unlikely to reflect the groupings you care about, such as images or learned embeddings. Do not use it when interpretable, coefficient-based models are required, when K has no clear meaning in your domain, or when labelled data can be collected at reasonable cost. In that last case, supervised classifiers are usually the stronger choice, because the pseudo-labels here are only as good as the clusters they come from.
Limitations and considerations
- K must be chosen in advance; unlike density-based methods, the procedure does not estimate the number of clusters.
- Sensitive to the initialization of centroids and encoder weights; poor initialization can lead to degenerate solutions in which some clusters collapse.
- Each round runs K-means over all embeddings and retrains the encoder, so it is considerably more expensive than plain K-means.
- Convergence is not guaranteed; assignment stability across rounds has to be monitored.
- Because the encoder learns from its own cluster labels, spurious structure present early in training can be reinforced in later rounds.
- Inherits the assumptions of K-means: Euclidean distance and roughly spherical clusters of comparable size. Pseudo-labels carry these assumptions into encoder training.
- K-means converges to a local, not necessarily global, minimum of its objective, so the final partition depends on the starting centroids.
Source conditions do not replace independent scientific review or validation by an analysis engine.
Strengths
- Uses unlabeled data to learn an encoder without annotation cost.
- The resulting encoder can be reused as an initialization or feature extractor for downstream classification or regression tasks.
- Cluster assignments are recomputed in the learned embedding space rather than the raw input space, so the partition can change as the representation changes.
- Can serve as a pretraining step before supervised fine-tuning when a labelled subset is available for evaluation.
Applications
- Unsupervised image representation learning and visual feature pretraining.
- Transfer learning initialization for downstream classification tasks with limited labelled data.
How it works
How it works
Raw inputs are passed through an encoder network or a feature extraction pipeline to produce a compact embedding for each data point. The quality of these initial embeddings affects convergence speed; random or pretrained encoders are common starting points.
Standard K-means is applied to the current embeddings to partition all data points into K clusters. The objective is to minimize, over the centroids {μ_k} for k = 1..K, the sum over all points of the squared Euclidean distance from each x_i to its nearest centroid. K is fixed in advance. Assignments and centroids are updated alternately: each point is assigned to its nearest centroid, and each centroid is then recomputed as the mean of its assigned points. Iteration continues until assignment changes fall below a chosen threshold.
Formula
\underset{\{\mu_k\}}{\arg\min} \sum_{i} \min_k \| x_i - \mu_k \|^2The cluster index that K-means assigns to each data point is used as a pseudo-label, a proxy class label created without human annotation. These pseudo-labels define a supervised classification objective for the next training step.
The encoder is retrained or fine-tuned with the pseudo-labels as targets, typically using a cross-entropy loss. The update is intended to pull points that share a cluster label toward similar embeddings and to separate different clusters. Whether the resulting embedding is more cluster-friendly is not guaranteed and has to be checked in each round.
Steps 2 through 4 are repeated for several rounds or until assignments stabilize. Changes in the encoder alter the K-means partition, and the new partition supplies the next set of pseudo-labels. Because early assignments can be wrong, the loop can reinforce mistakes as well as correct structure. Once it stops, the learned embeddings can be transferred to downstream tasks.
Common pitfalls
- Ignoring cluster degeneracy: if one or more clusters empty out, the model must be re-initialized or a reassignment strategy applied.
- Choosing K without domain guidance; silhouette scores and elbow analysis are diagnostics, not proof of the right number of clusters.
- Treating pseudo-labels as ground truth without checking cluster purity or downstream transfer accuracy.
- Skipping a representation check, such as linear evaluation on a held-out labelled subset, before using the embeddings elsewhere.
- Applying the method to very small datasets, where the alternating loop tends to fit noisy cluster assignments rather than a stable structure.
Frequently asked questions
How is self-supervised K-means different from plain K-means?
Plain K-means clusters data in a fixed feature space and produces no reusable representation. Self-supervised K-means uses the cluster assignments as pseudo-labels to train an encoder, so the embedding space changes between rounds and the resulting encoder can be used for downstream tasks.
How do I choose the number of clusters K?
Domain knowledge is the first guide. When that is unavailable, run several values of K and compare silhouette scores, the Davies-Bouldin index, or downstream performance on a small labelled probe set. There is no universally correct K; the best value depends on the structure of the data.
What stops the clusters from collapsing to a single group?
Cluster collapse is a real risk. Common mitigations include re-initializing centroids for empty clusters, balancing cluster sizes in the loss, and periodically reassigning points from large clusters to empty ones. Monitoring cluster sizes at each round is essential.
Do I need a deep neural encoder, or can I use simpler features?
A deep encoder is not strictly required, but the encoder must be trainable, because the pseudo-label update changes its weights. A fixed projection such as PCA can provide the initial embedding; if it is never trained, the loop reduces to repeated K-means on a fixed representation and does not learn new features. The benefit of the loop is largest when the encoder has enough capacity to reshape the embedding space in response to cluster feedback.
How do I evaluate the quality of the learned representations?
The standard approach is linear evaluation: freeze the encoder, train a simple linear classifier on a small labelled subset, and report its accuracy. Cluster-intrinsic metrics such as the silhouette score, and normalized mutual information against any available ground truth, are complementary diagnostics.
Related methods
Sources
Caron, M., Bojanowski, P., Joulin, A., & Douze, M. (2018). Deep Clustering for Unsupervised Learning of Visual Features. In Proceedings of the European Conference on Computer Vision (ECCV), 132–149.
Open publication referenceSelf-supervised learning. Wikipedia.
Open publication reference