# Assembly Quality Detection Based on Class-Imbalanced Semi-Supervised Learning
## 3 Results
### Training Settings and Metrics  
The teacher and student were initialized by the pre-trained weights of DenseNet121 on ImageNet [36], and 100 epochs were performed with the mini-batch size of 16, where the batch size of labeled data was 8. Because the number of unlabeled images was no less than the labeled images, in every epoch, labeled images were iterated unlimited times until every unlabeled image was iterated once. We used stochastic gradient descent (SGD) to optimize the network, with a learning rate of 0.1, weight decay of 0.0001, and momentum of 0.9. The maximum value of EMA coefficient \(\mu_{0}\) of the teacher model was 0.999. To obtain the certainty values of teacher model predictions, we used MC dropout five times, and the ramp-up coefficient \(\beta\) was 2. For the LDAM, parameter A was tuned so that the maximum margin was 0.5. For CCL, \(\delta\) was set to 0.5. Random augmentations applied to training data included random horizontal flipping and color jitter of brightness and contrast. After random augmentations, all images were resized to 224 \(\times\) 224 before being sent to the network.  
We used two common metrics in class-imbalanced learning to evaluate the performance of the model on the test set: balanced accuracy (bACC) [37] and geometric mean score (GM) [38], which are arithmetic and geometric mean scores, respectively, defined as  
\[\text{bACC}=\frac{1}{C}\sum_{c=1}^{C}\frac{TP_{c}}{N_{c}}, \tag{12}\]  
\[\text{G}-\text{Mean}=\prod_{c=1}^{C}\sqrt[1]{\frac{TP_{c}}{N_{c}}}, \tag{13}\]  
where \(N_{c}\) represents the sample number of class c, and \(TP_{c}\) represents the sample number both belonging to class c and predicted to be class c.  
We trained the proposed and conventional methods for comparison on the training sets with the labeled fraction \(\varepsilon\) of 10%, 20%, and 50%. Then the classification performances were compared on the test dataset. Conventional methods included: supervised learning with limited labeled data; The standard mean teacher method; The mean teacher method with three commonly used class-imbalanced learning strategies: (1) re-weighting: the loss of each sample was re-weighted by the inverse of the sample number of the corresponding class, and re-normalized to make the average weight in the mini-batch was 1; (2) resampling: the sampling probability of each sample was inversely proportional to the sample number in its class; (3) focal loss [39]: the loss of the relatively correctly classified sample was reduced, and the loss of the difficult and incorrectly classified sample was increased. To ensure fair comparisons, all methods adopted the DenseNet121 model structure and the same hyper-parameters as the proposed method, such as pre-training initialization, labeled data batch size, and the optimization method mentioned above. All the training and testing experiments were repeated ten times, and the experimental results on the test set were averaged. The algorithm in this paper was implemented using Python toolkit PyTorch, and experiments were carried out on a computer with Intel Core I5-8500 @ 3.00 GHz CPU and 12G NVIDIA Titan RTX GPU.