## 2 Proposed Methods
### Construction of Gear End Defect Dataset
#### 2.1.2 Data Augmentation  
In order to generate sufficient image data for CNN training, we utilized DCGAN and traditional data augmentation. In the original dataset, each category contained 10 images, and an image processing algorithm was used to individually adjust each image to the size of 224 \(\times\) 224 \(\times\) 3 to fulfill network structure requirements. In the DCGAN used in this work, \(G\) consisted of a fully connected layer and three deconvolutional layers that used modified linear units (ReLU) as the activation function for the first three layers of the network, and the final output layer network used hyperbolic tangent (Tanh) activation functions, and the hyperparameters of the generator model are shown in Table 1. \(D\) consisted of four convolutional layers and a fully connected layer, all of which employ Leaky ReLU as the activation function. The hyperparameters of the discriminant model are shown in Table 2. At the same time, both of the above network models used batch normalization to accelerate the convergence speed of neural networks. Figure 4: Example of a gear end face defect datasets: (**A1–A5**) Normal; (**B1–B5**) stain; (**C1–C5**) scratch; (**D1–D5**) circle; (**E1–E5**) breakage. The training of DCGAN can be seen as a process of alternating optimization of two subnets, and the discriminant needs some real picture data as the basis, so as to better generate the corresponding image. In our case, because the original dataset was so small, we used random oversampling (ROS) to increase the single round of training samples to 200 images. It is important to note here that the duplicate was a sample of a single image in a category, rather than copying multiple of them. The reason is that the gear defects are very small and not easy to distinguish, any two images in one category with different defect distributions as input will make the data generated by the G network contain large noise, and when the image is ROS-expanded and then used as input, the network can also generate a high-quality defect image after multiple iterations. During training, the network used a learning rate of 0.0001, a batch size of 8, and 1000 iterations. Figure 5 below is an example of a scratch defect, after 10 iterations, 100 iterations, 500 iterations, and 1000 iterations of the effect, where Figure 5a-d is the effect map generated by original inputting, and Figure 5e-h is the effect map generated by ROS inputting. It is intuitively apparent that the image of the original inputting cannot converge after 1000 iterations, and the image generated after ROS inputting is gradually closer to the real image, containing the corresponding defect characteristics that can be used to train the defect classification model. Using DCGAN, the dataset was expanded from the original 50 images to 500 images, increasing in size by a factor of 9. \begin{table}
\begin{tabular}{c c c c c c} \hline \hline
**Number** & **Layer Name** & **Channel** & **Kernel Size** & **Stride** &
\begin{tabular}{c} **Activation** \\ **Function** \\ \end{tabular} \\ \hline
1 & Fully connected layer & 256 & - & - & ReLU \\
2 & Deconvolution layer & 128 & \(5\times 5\) & \(1\times 1\) & ReLU \\
3 & Deconvolution layer & 64 & \(5\times 5\) & \(2\times 2\) & ReLU \\
4 & Deconvolution layer & 3 & \(5\times 5\) & \(2\times 2\) & Tanh \\ \hline \hline \end{tabular}
\end{table} 
Table 1: Structure of generative model. Figure 5: Scratch defect image generation effect: (**a**) 10 steps by original; (**b**) 200 steps by original; (**c**) 500 steps by original; (**d**) 1000 steps by original; (**e**) 10 steps by ROS; (**f**) 200 steps by ROS; (**g**) 500 steps by ROS; (**h**) 1000 steps by ROS. The image data generated after DCGAN training iteration simulated the data distribution of real samples, and the image quality was high. However, due to the small original dataset, the generated data were highly similar to the original data.