# Semi-Supervised Medical Image Classification Combined with Unsupervised Deep Clustering
## 3 Method
### Unsupervised Phase
#### 3.2.1 Unsupervised Clustering Framework  
Figure 4 describes our basic process in the unsupervised learning phase. Different augmentations of the same image are input into the network, and then the output results are clustered separately. The clustering results are used as pseudo-labels to update the network parameters. Our framework regularizes the centroid distribution of different clusters to improve the clustering effect and make better use of unlabeled data.  
We denote unlabeled data as \(x=\{x_{1},\ldots,x_{N}\}\), \(y_{i}(i=1,2,\ldots N)\) represents the corresponding pseudo-label, \(f_{\theta}\) represents the parameterized model, \(\text{A}^{\prime}(\cdot)\) represents the augmentation function, and \(\eta\) represents the clustering center. We adopt the RandAugment [34] augmentation method in the unsupervised phase (parameters settings are the same as the experiment on cifar10). The optimization goal can be expressed as:  
\[\begin{split}\underset{\theta}{\text{min}}\underset{i}{\sum} \mathcal{L}(f_{\theta}(A(x_{i})),y_{i},\eta)\\ \mathcal{L}(f_{\theta}(x_{i}),y_{i},\eta)=-\log\left(\frac{e^{-d( f_{\theta}(x_{i})\eta_{j})}}{\sum_{j}e^{-d(f_{\theta}(x_{i})\eta_{j})}}\right)\end{split} \tag{5}\]  
Here \(d(\cdot,\cdot)\) represents cosine distance.  
We design a parallel network structure consisting of an online network and a target network. Two different augmentations of the same image are input into the online network and target network. The obtained vectors are then clustered, and a clustering center is assigned to each image xi. This process does not depend on labels at all. Usually, unsupervised models eventually collapse into prone mode and output invalid solutions without any constraints. To prevent this situation, the usual practice is to add reconstruction loss [42; 43], or explicitly constrain the uniform distribution of samples of all kinds [17]. Inspired by Contrastive Learning [15; 44], we make the online network and target network not share weights but update their parameters by momentum. This keeps differences  
Figure 4: Overview of our unsupervised deep clustering framework. \(\text{A}_{1}(\text{x})\) and \(\text{A}_{2}(\text{x})\) are the outputs of x after augmentation. \(\text{p}(y_{1}|x_{1})\) and \(\text{p}(y_{2}|x_{2})\) are the results of clustering. \(\text{p}(z_{1}|x_{1})\) and \(\text{p}(z_{1}|x_{1})\) are the results of overclustering. The online network (above) and the target network (below) update the parameters in momentum. Image feature representation is clustered by the k-means method to get the pseudo-label. The over-clustering head is used to assist the training process, and only the output head is used in the test.  
between them at all times, providing motivation for continuous updating. Specifically, the parameters of the two networks are recorded as \(\theta_{p}\) and \(\theta_{q}\), and we update \(\theta_{q}\) by:  
\[\theta_{q}\gets m\theta_{q}+(1-m)\theta_{p} \tag{6}\]  
where \(m\) is a hyperparameter representing momentum. The greater the value of \(m\), the slower the updating speed. In our experiment, \(m=0.99\).