# Detecting and Measuring Defects in Wafer Die Using GAN and YOLOv3
## Appendix A
### Descriptions of the YOLOv3  
The network structure of YOLOv3 is shown in Figure 14. With DarkNet53 as its backbone, the model used a series of \(1\times 1\) and \(3\times 3\) convolution layers for feature extraction without a pooling layer and a fully connected layer. YOLOv3 introduced a residual block, which adds the corresponding dimensions of the input and the output feature maps to control the magnitude of the gradient propagate and alleviate the vanishing gradient problem faced by the deep network. In addition, the feature pyramid network (FPN) structure was used for multiscale detection effects. After the input image passed through DarkNet53, the feature map generated by Yoloblock was taken for two purposes. The first was to generate feature map 1 with a size of \(13\times 13\) after passing through the \(3\times 3\) and the \(1\times 1\) convolution layer. The second use was to add an upsampling layer after passing through the \(1\times 1\) convolutional layer, and to splice it with the output result of the intermediate layer of the DarkNet53 network, which generated feature map 2 with a size of \(26\times 26\). After the same loop, feature map 3 with a size of \(52\times 52\) was generated. \(13\times 13\), \(26\times 26\), and \(52\times 52\) are the number of grid cells of the output feature maps for each scale. The depth of these output feature maps, was set as \(B\times 5\), where \(B\) represented the number of predicting bounding boxes for each scale, set here as 3. The number 5 represented the 5 levels of \(x\), \(y\), \(w\), \(h\), and confidence that must be predicted for each bounding box, where \(x\) and \(y\) represent the shift levels between the predicted bounding box center and the upper left corner of the grid cell; \(w\) and \(h\) represent the ratio of the width and height of the predicted bounding box to the width and height of the entire image; confidence represents the confidence value of the defect. The depth of the feature map output for traditional YOLOv3 needs to include the probability of the predicted bounding box of each grid cell for \(C\) categories, so its depth should be \(B\times(5+C)\). However, this research only sought to classify the single problem of particle defects, so the prediction of \(C\) could be omitted. During training, YOLOv3 used the modified loss function and the back-propagation algorithm to learn the weights, as shown in Equation (A2). The loss function of YOLOv3 was originally composed of three parts, namely coordinate prediction error, intersection over union (IoU) error, and classification error [19]. However, since this research focused on the single classification problem, the classification error could be omitted. \[ \begin{split}\text{Loss}=\lambda_{\text{\emph{cond}}}\sum\limits_ {i=0}^{S^{2}}\sum\limits_{j=0}^{B}\mathbf{i}_{ij}^{obj}[(x_{i}-\hat{x}_{i})^ {2}+\left(y_{i}-\hat{y}_{i}\right)^{2}]+\lambda_{\text{\emph{cond}}}\sum \limits_{i=0}^{S^{2}}\sum\limits_{j=0}^{B}\mathbf{i}_{ij}^{obj}[\left(\sqrt{w _{i}}-\sqrt{w_{i}}\right)^{2}+\left(\sqrt{h_{i}}-\sqrt{\hat{h}_{i}}\right)^{2} ]\\ +\sum\limits_{i=0}^{S^{2}}\sum\limits_{j=0}^{B}\mathbf{i}_{ij}^{obj }(C_{i}-\hat{C}_{i})^{2}+\lambda_{\text{\emph{mod}}}\sum\limits_{i=0}^{S^{2} }\sum\limits_{j=0}^{B}\mathbf{i}_{ij}^{noobj}(C_{i}-\hat{C}_{i})^{2}\end{split} \] (A2)  
The first two terms in Equation (A2) represent the coordinate prediction error, and \(\lambda_{\text{\emph{cond}}}\) was the weight hyperparameter given in advance. Since the number of grid cells that did not contain objects far exceeded the number of grid cell that contained objects, the loss of confidence without objects would be great. In order to reduce the impact of this problem on the network, it was generally assumed to be 5. \(\hat{I}_{ij}^{obj}\) described the predicted bounding box \(j\) of the grid cell \(i\) had an indicator function containing objects.