Contrastive Hierarchical Clustering

Michal Znalezniak, Przemyslaw Rola, Patryk Kaszuba, Jacek Tabor, Marek Smieja

Introduction

In the realm of unsupervised learning, deep clustering has emerged as a powerful tool for organizing unlabeled data. However, most modern methods focus on "flat" partitions, splitting datasets into a fixed number of disjoint groups. This approach often requires prior knowledge of the cluster count and fails to capture the inherent semantic relationships between different categories.

CoHiClust (Contrastive Hierarchical Clustering) addresses these limitations by integrating self-supervised contrastive learning with a soft binary decision tree. This framework not only groups images into clusters but also maps out their hierarchical relationships, often outperforming state-of-the-art flat clustering models on complex image benchmarks.

The Limitations of Flat Clustering

Traditional deep clustering methods typically face two major hurdles. First, they require a pre-defined number of clusters ($k$), which is rarely known in real-world scenarios. Second, they treat all clusters as equally distinct, ignoring the fact that some categories are naturally more related than others—for instance, a "dog" cluster is semantically closer to a "cat" than to a "truck."

While hierarchical clustering (e.g., Agglomerative Clustering) can capture these relationships, it scales poorly to high-dimensional image data. CoHiClust bridges this gap by training the data representation and the hierarchy simultaneously, enabling it to handle complex, high-resolution color images.

Methods: The CoHiClust Framework

The CoHiClust architecture is built upon three primary pillars designed to optimize both the feature space and the tree structure.

The CoHiClust architecture integrates a neural backbone with a soft binary decision tree to perform joint representation learning and hierarchical clustering.
  1. Architecture: The model uses a standard backbone (such as ResNet) to generate data embeddings. These are passed to a projection head that functions as a soft binary decision tree. Rather than making a hard choice at each node, the model assigns a probability to each path, allowing for differentiable end-to-end training.
  2. CoHiLoss: This specialized contrastive loss uses the Bhattacharyya coefficient to measure path similarity. The objective is to maximize the probability that an image and its augmented version (e.g., a crop or flip) follow the same path to a leaf, while pushing distinct images toward different branches.
  3. Regularization and Pruning: To prevent the tree from collapsing into a single leaf, an entropy-based regularizer ($R_1$) ensures balanced data distribution. After initial training, a pruning strategy refines the hierarchy by removing uninformative leaves.

Key Insights: Visual vs. Semantic Similarity

One of the most compelling aspects of CoHiClust is its ability to learn intuitive hierarchies without human supervision. By analyzing the tree's structure, researchers can observe how the model prioritizes different features.

A visualization of the learned hierarchy on ImageNet-10. Note how the model groups objects like soccer balls and oranges based on shared visual characteristics like shape.

For example, in the ImageNet-10 hierarchy, "soccer balls" and "oranges" are often placed in neighboring leaves. While semantically different, they share a circular shape, indicating that the model captures fundamental visual features. Conversely, on datasets like CIFAR-10, the root of the tree consistently learns to separate biological entities (animals) from man-made objects (machines). This suggests that joint training—optimizing the neural representation and the tree boundaries together—is essential for capturing meaningful structures.

Empirical Results

CoHiClust demonstrates that a hierarchical approach does not come at the cost of accuracy. In evaluations across several benchmarks, including CIFAR-10, CIFAR-100, and ImageNet-10, the model frequently outperformed state-of-the-art flat clustering models.

On ImageNet-10, CoHiClust achieved a top accuracy of 95.3%, significantly surpassing previous leaders like CC (89.3%) and PICA (87.0%). Similarly, on CIFAR-10, it reached a Normalized Mutual Information (NMI) score of 0.779, compared to 0.705 for the leading flat model. The framework also showed strong scalability, with performance improving as the backbone architecture moved from ResNet-18 to ResNet-50.

Limitations and Future Work

Despite its successes, CoHiClust faces challenges with specific data resolutions; for instance, it performed slightly worse than the CC baseline on the STL-10 dataset (96x96 resolution). Additionally, the current pruning strategy is somewhat manual, removing one leaf per epoch. Future research could focus on more dynamic methods for determining the "natural" number of clusters or exploring non-binary tree structures to allow for even more nuanced data analysis.

Summary updated

BibTeX
@inproceedings{znalezniak2023contrastive,
  author = {Michal Znalezniak and Przemyslaw Rola and Patryk Kaszuba and Jacek Tabor and Marek Smieja},
  title = {{Contrastive Hierarchical Clustering}},
  booktitle = {ECML/PKDD},
  year = {2023},
  url = {https://openreview.net/forum?id=4GQFJNmB0F},
}
Figure