Pseudo-supervised image clustering based on meta-features

Stable semantics is a prerequisite for achieving excellent image clustering. However, most current methods suffer from inaccurate class semantic estimation, which limits the clustering performance. For the sake of addressing the issue, we propose a pseudo-supervised clustering framework based on meta-features. First, the framework mines meta-semantic features (i.e., meta-features) of image categories based on instance-level features, which not only preserves instance-level information but also ensures the semantic robustness of meta-features. Ulteriorly, we propagate pseudo-labels to its global neighbor samples with meta-features as the center, which effectively avoids the accumulation of errors caused by the misclassification of samples at the cluster boundary. Finally, we exploit the cross-entropy loss with label smoothing to optimize the pseudo-label optimization network. This optimization method not only achieves a direct mapping from features to stable semantic labels, but also effectively avoids suboptimal solutions caused by multi-level optimization. Extensive experiments demonstrate that our method significantly outperforms twenty-one competing clustering methods on six challenging datasets.


Introduction
To reduce the reliance on a large amount of labeled data, clustering has once again attracted attention.Traditional clustering methods, such as K-means [1] and spectral clustering [2], have been widely used in various tasks.However, traditional clustering can only process low-dimensional data, and cannot effectively process high-dimensional data such as images and videos.For the above problems, deep clustering [3] is proposed, which maps the raw data to a nonlinear embedding space to obtain distinguishable features for clustering tasks.In addition, DAC [4], DCCM [5], and IIC [6] propose different methods to learn discriminative label features under different constraints.PICA [7] learns the most plausible semantic clustering solutions by partitioning confidence maximization.Although these methods have achieved good classification results, the learned features still lack stable semantic information.
For the sake of obtaining more stable semantics for clustering tasks, CC [8] adopts both instance-level and cluster-level contrastive learning to achieve good semantic clustering.Furthermore, GCC [9] employs KNN to compose the feature vector obtained by image encoding and constructs a contrastive loss function from the perspective of graph nodes.GCC applies a lightweight network to achieve good semantic clustering results.Although the above two methods both consider cluster-level information, instance-level and clusterlevel features are optimized separately using different loss functions, which is difficult to achieve the optimal classification effect.Different from the above work, as shown in Fig. 1a, SCAN [10] is proposed to mine the nearest neighbors of each instance sample in the embedding space.Meanwhile, SCAN assigns the same pseudo-labels to adjacent samples to train the classifier, which achieves sound performance.
However, samples on the clustering boundary may be incorrectly classified as the wrong class owing to the semantic inconsistency of neighboring samples.In addition, alternate runs of incorrect labels will lead to the accumulation of errors in the classifier.In light of these defects, we propose a pseudosupervised clustering method based on meta-features.The method not only considers instance-level semantics, but also abstracts stable semantic features (i.e., meta-features), as well as propagates semantic information to global nearest neighbor samples in the form of pseudo-labels.Specifically, as shown in Fig. 1b, we first employ a pre-trained contrastive learning model to obtain instance features.Next, we abstract the meta-features that can represent the categories for a more stable semantic feature of clustering.Afterward, we assign the same pseudo-label to the neighboring samples in a batch with the meta-feature as the center, which effectively avoids the possible semantic inconsistency of the neighboring samples of the instance.Finally, we correct the pseudo-labels by a cross-entropy loss with label smoothing, which effectively alleviates the error accumulation.Compared with previous methods, our method not only considers category semantic information but also can effectively solve the problem of error accumulation caused by the inconsistency of instance neighbors.Furthermore, compared to CC and GCC methods, our method accomplishes a direct mapping from features to stable semantic labels, avoiding suboptimal solutions from multi-level optimization.
The main contributions of this paper are as follows: 1. To ensure the semantic stability of the clustering labels, we propose a method based on meta-features assigning pseudo-labels to the global nearest neighbors.The meta-features consider both instance-level semantics and category semantics, and then pseudo-labels are assigned

Mining neighbors
Fig. 1 The motivation of the proposed nearest-neighbor clustering based on meta-features.The clustering in Fig. 1a is based on instance neighbors, where the nearest neighbor samples of each instance are given the same pseudo-label and used to train the classifier.Although this approach has achieved great success, it is difficult to obtain stable semantic features and is prone to error accumulation due to misclassification at the boundaries.As shown in Fig. 1b, to solve the above problems, we propose global nearest neighbor clustering based on metafeatures.We select semantically stable meta-features by confidence samples in the batch range.Then, we assign the same pseudo-labels to the global nearest neighbors of the meta-features and apply them to train the classifier.Notably, we further employ label smoothing to handle the noise introduced by the pseudo-labels and avoid overconfidence in the model to the global nearest neighbors of the meta-features to improve the semantic stability of clustering.2. Our method optimizes pseudo-labels using cross-entropy loss with label smoothing directly, which effectively avoids sub-optimal solutions resulting from the optimizations with multiple loss functions.3. Extensive experimental results show that the pseudosupervised clustering framework based on meta-features proposed in this paper has excellent performance.
The remainder of the paper is arranged as follows: the next section introduces related work and a comparative analysis with our method, the following section elaborates the details of each part of our model and how the model works, the next section presents the datasets we adopt, and the details of our experiment.Finally, we summarize our work.

Unsupervised representation learning model
In recent years, contrastive learning has made significant progress and it can correctly capture discriminative features without any manual annotations.For example, MoCo [11] regards contrastive learning as a dictionary loop and builds a dynamic dictionary with a queue and movable averaged encoders.MoCov2 [12] modifies MoCo by utilizing MLP projection heads and more data augmentations.SimCLR [13] simplifies the recently proposed contrastive self-supervised learning algorithm without the need for a dedicated architecture or memory library.SimCLRv2 [14] shows that larger self-supervised models are more efficiently labeled.SwAV [15] does not directly compare two augmented views but uses one view to predict the code and assigns the other view to a set of learnable prototypes.Although these methods can learn outstanding feature representations, the information of the instance is not stable enough in the clustering.It remains a challenge to mine and apply stable properties for pleasant clustering assignments.

Deep clustering
Deep learning enables large-scale deep feature extraction through hierarchical nonlinear mapping capabilities.As a result, deep clustering algorithms are becoming a research hotspot in the field of unsupervised learning.For example, DEC [16] uses K-means [1] for pre-trained image features to initialize the clustering centers, and then fine-tunes the model to learn from the confident clustering assignment to sharpen the obtained prediction distribution.JULE [17] jointly optimizes the CNN in a recurrent manner, where merging operations of agglomerative clustering are conducted in the forward pass and representation learning is performed in the backward pass.DAC [4], DDC [18], and DCCM [5] alternately update the clustering assignment and the similarity between samples during training.However, they are susceptible to inconsistent estimations in the neighborhoods and thus suffer from severe error propagation during training.
There are some works that combine deep representation learning [19][20][21][22][23][24] with traditional clustering methods [25][26][27][28][29].Most recent researches are based on clustering assignments that maximize mutual information.For example, IIC [6] is proposed to learn cluster assignment by maximizing the mutual information between images and their augmentations.DCDC [30] recommends Contrastive learning through samples and class views for better representing characteristics.However, this clustering method relies on initialization and is likely locked to low-level features.SCAN [10] firstly proposes a two-stage scheme, which finds the nearest neighbors for each feature by Contrastive self-supervised learning in the first stage.And in the second stage, it forces adjacent features to possess similar distribution probabilities.In the above process, they assign the same pseudo-labels to the neighboring embedding features of each instance.While this approach has achieved great success, there are still the following disadvantages.As depicted in Fig. 1a, on the one hand, instance-based clustering lacks stable semantics.On the other hand, this method causes error accumulation.Combined with the analysis of the above methods, we find that the current deep clustering moduses have two shortcomings.One is lack of stable semantic supervision signals, the other is that the previous clustering frameworks are indirect optimizations, which leads to sub-optimal solutions.Unlike the mentioned methods, we utilize pseudo-supervised optimization clustering to construct stable semantic pseudo-labels in the second clustering stage.Our approach effectively reduces the error accumulation problem at the classification boundary and improves the accuracy of clustering.

Method
We present our approach in the following sections.Firstly, we pre-train a contrastive representation learning model to obtain features.After acquiring the features, we compute meta-features and construct a pseudo-label optimization network to achieve semantic clustering.The detailed procedure of our method is shown in Fig. 2 and Algorithm 1.

Feature extraction network
Considering that some previous end-to-end deep clustering methods are susceptible to network initialization, we utilize the MoCo [11] to obtain instance semantic information.MoCo is proposed to replace the memory with a momentum Fig. 2 Framework of our proposed method.The framework consists of a feature extraction network and a label optimization network based on meta-features.Where, the feature extraction network is applied to acquire instance features, and the label optimization network based on meta-features is resorted to map features to labels.Specifically, we obtain the instance features to find the nearest neighbors based on feature similarity, and further take the feature-weighted average of confident samples as meta-features.Meanwhile, we find the global nearest neighbors of the meta-features and assign the same pseudo-labels to the meta-features as well as their global neighboring samples.Finally, we utilize pseudo-labels to train the classifier.After each iteration, the classifier learns more semantic information than before encoder, which applies a dynamic updating sequence q to store the characteristics of previous iterations, and we further leverage the pretrained model to extract instance-level features.
We define samples, augmented samples and their corresponding labels as: s, s ,u, and u respectively.And as for MoCo work, we will have the following form: where sim() is a similarity function similar to cosine similarity, θ is an adjustable temperature parameter, and M is the queue size.The loss has one positive sample and M negative samples.Since the queue q does not require a gradient, M can be set large enough, which is beneficial to the feature extraction.

Pseudo-label optimization network
Inspired by "label as representation" [8], we consider image classification as a process of distinguishing samples through assigning corresponding semantic labels.And we adopt a method similar to supervised learning in this work, which directly maps features to stable semantic labels.Precisely, the Pseudo-label optimization network consists of pseudo-label annotation based on meta-features, classifier optimization, and label smoothing.

Pseudo-label annotation based on meta-features
Our task is to divide the dataset χ into pre-defined classes S without any manual labeling.Specifically, the pre-trained contrastive learning network is used as our feature extraction network f ( ).The input is composed of two parts: the one is the raw data x, which is input to the network to obtain the embedded feature; the other is augmented data R(x).Next, x is dropped to the network f ( ), and we can obtain the embedded feature f (x), simultaneously, R(x) is dropped to the network f ( ) and we can acquire f (R(x)).Afterwards, f (R(x)) is fed to the classifier which is composed of two MLP layers and then the classifier outputs the predicted probability P k .Finally, we select the K features with the highest confidence in the same semantic class.
where k ∈ [1, 2, . . ., S], i ∈ [1, 2, . . ., K ], τ is the confident ratio, n represents the number of images of a certain class.In the embedding space, we select a certain class of embedding features with the K highest probability based on the cosine similarity measure.We regard the K samples with the highest probability as confidence samples, at last, the weighted average of confidence embedding features is used as the meta-feature f Metak of class, where f Metak guarantees the class semantic of the metafeatures.After obtaining the meta-features, we search for neighboring embedding features and ulteriorly assign the same pseudo-labels to the neighboring features.
where N t ( ) represents the global nearest neighbor of the sample.l k is the pseudo-label assigned to the neighbors of the meta-feature.It should be noted that to reduce the amount of calculation, the recent neighbor samples we mentioned are samples within a batch.The number of neighbors m in the global neighbor is set to m = N /C.Among them, N is the number of samples within a batch and C is the number of class.

Classifier optimization
The pseudo-label optimization network is designed to train a classifier that maps embedding features to pseudo-labels.
It is different from previous work by mining instancelevel semantic similarity or focusing on clustering.Pseudosupervised classification is based on meta-features that preserve instance-level distinguishing information and take into account semantic inconsistencies caused by distance measures at classification boundaries.Pseudo-label annotation based on meta-features, pseudo-label construction, and classifier optimization are a dynamic optimization process.Specifically, we optimize the classifier by minimizing the cross-entropy loss, and the optimized classifier is involved in the selection of confident samples, meta-feature construction, and pseudo-label assignment in the next iteration.Through multiple iterative optimizations, the classifier learns a good mapping of features and pseudo-labels.

Label smoothing
We minimize the cross-entropy loss to optimize the classification network.At the same time, considering the inevitable introduction of noise in the pseudo-label annotation process, we apply label smoothing to tune our model from overconfidence to noise prediction.The label smoothing specifies soft labels by adding uniform noise and improving prediction calibration.Given a sample with a label and its corresponding label (x, l k ) ∈ χ , we inject noise into all classes in the following manner: where α denotes the label smoothing parameter and p is calculated by applying the logit vector z output from the penultimate layer of the model to the softmax function: We use a loss function L to force each image and its neighbors to be classified together.This loss function L maximizes their dot product after softmax, driving the network to produce consistent and differentiated predictions.We encourage the model to predict the target class with a probability close to 1 and the non-target class with a probability close to 0. In other words, the value of the target class in the final predicted logit vector will tend to infinity, causing the model to learn toward infinitely increasing the logit difference between the predicted correct and incorrect labels.However, excessive logit differences can lead to a lack of adaptability and overconfidence in model predictions.We use label smoothing to reduce the difference between the positive and negative sam-

Datasets
In experiments, we evaluate our proposed method on six datasets that are widely used for deep clustering.It contains five small datasets CIFAR-10, CIFAR-100, STL-10, Tiny-ImageNet and ImageNet-10, and a large scale dataset ImageNet-1K.
CIFAR-10/100: A natural image dataset with 50,000 samples and 10,000 test samples respectively, where CIFAR-10 contains 10 classes and CIFAR-100 contains 100 classes.STL-10: A dataset from ImageNet containing 500/800 training/test images from 10 classes and additional 100,000 samples from several unknown classes.Tiny-ImageNet: A very challenging dataset with 200 classes and the dataset has 100,000/10,000 training/test images.
ImageNet-10: A subset of ImageNet, this dataset contains 10 randomly selected subclasses with a total of 13,000 images.
ImageNet-1K: A large-scale hand-annotated dataset containing more than 1.2 million images in 1,000 classes.
A brief statistics of six datasets are summarized in Table 1.To verify the effectiveness of our method, we use the following clustering setup: we train and test on the entire dataset for CIFAR-10/100, and set 20 superclasses as ground-truth labels for CIFAR-100.We cluster STL-10 using 13,000

Evaluation metrics
We use three widely used clustering performance metrics, including normalized mutual information (NMI), accuracy (ACC), and adjusted rand index (ARI), to evaluate our method.All these metrics scale from 0 to 1.The higher the value of these indicators have, the better the cluster performance is.

Experimental setup
Our method is implemented by PyTorch 1.The entropy term weight is set to 5.After the pre-trained model is trained for 1200 epochs, the parameter is frozen and used for feature extraction.The clustering head is trained for 200 epochs.The confident ratio τ is set to 0.6.The label smoothing parameter α is set to 0.1.For evaluating the class assignment, the Hungarian method is used to map the best bijection permutation between the predictions and ground truth.

Comparison on small datasets
We evaluate our method on three challenging image benchmarks and compare it with 21 representative state-of-the-art clustering methods, including traditional methods (such as K-means [1], SC [2], AC [31], NMF [32]), deep learning methods (such as AE [33], DAE [34], DCGAN [35], DeCNN ).On the low-resolution dataset CIFAR-10, our method is close to GCC (84.7% vs. 85.6%), but still better than the other methods.It is obvious that the clustering performance of high-resolution images is generally better than that of low resolution in our method.In section "Reliance on backbone network", we add the experimental effects of using different backbones.

Comparison on large scale dataset ImageNet-1K
To demonstrate the clustering performance of our method on large-scale datasets, we perform experiments on ImageNet-1K.For a fair comparison, the same pre-trained weights of MoCov2 [12] are used in experiments as in SCAN.We adopt ResNet50 as our Backbone and conduct experiments on a Telsa A100 80G graphics card.It should be noted that the parameters compared in the report come from the SCAN report, where SimCLR [13] is the result obtained after finetuning with 1% of the labeled data.The experimental results are shown in Table 3, where we report the performance of the different methods in fully supervised, semi-supervised, and unsupervised situations.Our method far outperforms supervised learning as an unsupervised learning method (41.3% vs. 25.4%).In particular, our accuracy improves by 1.4% over SCAN (41.3% vs. 39.9%).This shows the superiority of our method on large-scale datasets.

Empirical analysis
In this section, we conduct several qualitative studies to visually analyze class confusion matrices, confidence samples, and heat maps.

Confusion matrix
As shown in Fig. 3, we visualize the confusion matrix of the three datasets.The confusion matrix of these three datasets has a clear diagonal structure, which shows that our method successfully divides the samples into different categories according to semantics.The confusion of our model mainly occurs between classes that are not easy to distinguish in reality, such as cats and dogs.And there are two reasons for the poor classification of CIFAR-10 and CIFAR-100.On the one hand, the size of these images is too small and very blurry to distinguish.On the other hand, the network cannot clarify the nuances between different categories.Especially on CIFAR-100, it is extremely difficult for the model to obtain accurate semantic discrimination features when we set 100 classes into 20 superclasses.

Image semantic visualization
As shown in Figs. 4 and 5, after completing the model training, we visualize the confidence samples of STL-10 involved in constructing meta-features.At the same time, we use the area highlighted by the heat map to indicate the location of the semantic features noticed by the model.After the maximum matching between the clustering and actual results, we find that the confidence samples constructed by the participating meta-features matched exactly with the manual annotations.For example, after maximum matching, the "horse" class successfully capture the horse class.With the most distinguishing regions in the image concentrated in different locations of the horse.The visualization results show that the confident samples selected by the model are semantically correct and all focus on the semantics of the actual labels, providing a solid basis for meta-features to assign neighbor labels.

Ablation study
Several ablation studies are used in this section to demonstrate the effect of different scenarios on our proposed approach.

Effect of label smoothing
We separately evaluate the effect of using cross-entropy loss and cross-entropy loss with label smoothing on the classification results on three datasets and provide the results in Fig. 6.As shown in Fig. 6, our model using cross-entropy loss with label smoothing in the experiment is better than directly using cross-entropy loss.On the CIFAR-10, the accuracy rate increases by 1.2%, the NMI increases by 0.5%, and the ARI increases by 0.6%.On the CIFAR-100, the accuracy rate increases by 0.7%, the NMI increases by 0.5%, and the ARI increases by 0.6%.On the STL-10, the accuracy rate increases by 1.4%, the NMI increases by 1.8%, and the ARI increases by 2.1%.The cross-entropy loss with label smoothing reduces overfitting and enhances generalization by adding noise to some extent.The experimental results  verify the effectiveness of the label smoothing strategy we use.

Effect of data augmentation
As shown in Fig. 7, to explore the impact of different data augmentations on our method, we conducted an ablation study on the STL-10 using ResNet18 as the backbone.We adopt the same weak augmentation strategy of FixMatch [40] for weak augmentation in the paper, and use the same settings as SCAN for strong augmentation.Specifically, the image is strongly augmented by composing Cutout [41] and four randomly selected transformations from RandAugment [42].In view of the fact that SCAN also employs a similar data augmentation approach, we simultaneously tested the impact of different data augmentation schemes on SCAN.As shown in Fig. 3, the left figure shows the performance of our approach using different augmentation schemes, and the right figure shows the performance of different augmentation schemes on SCAN.Overall, the effect of using different augmentations on the clustering results of the two methods is not significant.This is because both methods use pre-trained models, which already have transformation invariance.However, a detailed comparison shows that our method is slightly better than strong augmentation when using weak augmentation (86.2% vs. 85.7%).In contrast, strong Augmentation is better than weak augmentation when the same augmentation strategy is tested on SCAN (78.4% vs. 81.2%).This is related to the way pseudo-labels are constructed and assigned: in the case of SCAN, strong augmentation is used to ensure that the model learns strong consistency since pseudo-labels are assigned for each instance finding its nearest neighbors.However, the idea of stable semantics of our approach is able to not rely on strong augmentation.Firstly, the labels assigned using meta-features as centers are more robust.Secondly, assigning pseudo-labels globally for meta-features can reduce the reliance on strong consistency compared to assigning labels to each instance's nearest neighbors.Finally, the use of strong augmentation may lead to larger errors in the predictions of the classifier.

Effect of the hyperparameter
In this paper, τ is an important hyperparameter for selecting high-confidence samples.To select appropriate τ for selecting high-confidence samples to build meta-features, we perform experiments on the CIFAR-10 and CIFAR-100 datasets with ResNet18 as the backbone.As shown in Fig. 8, we select 10 values of τ covering from low confidence to high confidence for the two datasets respectively.The performance trends of our method on the two datasets are basically the same: when the value of τ is between 0.1 and 0.5, with the increase of τ , the accuracy of clustering has been increasing.This is because the meta-features we construct are at low confidence and cannot represent the semantic features of the category, resulting in errors in label assignment.As τ continues to grow, the semantics of meta-features continue to improve, and the clustering effect also improves.When τ is between 0.5 and 0.8, the samples participating in the construction of meta-features not only have high confidence, but also a large number of samples ensure the semantic representation of the category, and the clustering performance reaches a relatively stable state.When τ is greater than 0.8, although there are a small number of high-confidence samples participating in the construction of meta-features, the reduction in the number of samples participating in the construction of meta-features causes the semantic instability of meta-features, which in turn results in poor clustering performance.

Reliance on backbone network
To examine how much our model relies on the backbone network, we test two ResNets of different depths and report the results in Table 2. (*) represents that we adopt ResNet34 as the backbone and (**) represents that we adopt ResNet18 as the backbone.It can be seen from the comparison that the representation ability of the backbone network contributes to the clustering performance.On datasets with smaller image sizes such as CIFAR-10 and CIFAR-100, the clustering performance using ResNet18 is better than that using ResNet34.This is because ResNet18 has sufficient representation ability to extract discriminative features on datasets with smaller image sizes, and using a deeper network is prone to overfitting.On datasets with larger image sizes, such as STL-10, ImageNet-10, and Tiny-ImageNet, the clustering performance of ResNet34 with stronger representation is better than that of ResNet18 as backbone.

Conclusion
The unstable semantic pseudo-labels assignment severely limits the performance of image clustering.In this paper, we first propose the concept of "meta-features", which are stable features with sufficient stable semantic information.At the same time, we combine instance features with discriminative information and class semantic features for achieving deep clustering with stable semantics.Meanwhile, we propose a pseudo-supervised clustering algorithm based on metafeatures.The framework adopts stable features to assign pseudo-labels while optimizing meta-features and pseudolabels in a pseudo-supervised manner, which achieves a direct mapping from features to stable semantic labels.Experiments demonstrate that our proposed deep clustering based on meta-features significantly improves the accuracy of the classification task.Furthermore, our proposed method provides an idea to achieve stable semantic self-learning.We plan to extend it to other work and applications in future work.

Fig. 3 Fig. 4 Fig. 5
Fig. 3 Confusion matrices of three datasets.From left to right are CIFAR-10, CIFAR-100, and STL-10.The row names are the predicted class labels, and the column names are the ground-truths

Fig. 8
Fig. 8 Comparison of the clustering performance for different values of the hyperparameter τ .For both CIFAR-10 and CIFAR-100 datasets, we use the backbone of ResNet18.The primary axis represents CIFAR-100 and the secondary axis represents CIFAR-10

Table 1
Summary of datasets used for evaluation

Table 2
The clustering performance on three challenging object image benchmarks after the clustering ( ) stepIn the reported results, we report the results of our method in both ResNet18 and ResNet34 as the backbone.(*) represents that we adopt ResNet34 as the backbone and (**) represents that we adopt ResNet18 as the backbone.The top two results of the unsupervised method are shown in bold

Table 3
The clustering performance on the large dataset ImageNet-1K Effect of cross-entropy loss with label smoothing on CIFAR-10, CIFAR-100 and STL-10.ResNet34 is our backbone.The blue bars represent the classification results directly using cross-entropy loss, and the green bars represent the classification results after using label smoothing