# Assessment of Laser Joining Quality by Visual Inspection, Computer Simulation, and Deep Learning
## 2 Experiments
### Deep Learning Experiment  
Given the importance of reliable training for DL, large amounts of data were collected prior to the DL process. To construct the dataset, a series of images of specimens welded under conditions of 3, 4, and 5 J/mm was acquired. A charge-coupled device (CCD) camera (STC-SC3 POE; Sentech) with a resolution of 640 \(\times\) 480 was installed and a GigE connection was used for image collection. A linear translation stage (DDSM100/M; Thorlabs) was used for precise specimen translation (Figure 3). The specimens were transferred on a linear translation stage at a rate of 0.8 mm/s, and image data were acquired every 100 ms with 10 ms of exposure time. For each condition, approximately 1700-1900 sets of data were collected, and up to 28,500 images were used in the DL process. The images collected for each condition were divided into two categories, \"Good\" and \"Fail\", for the quality assessment. The acquired images had a resolution of 648 \(\times\) 494, which was re-adjusted to 227 \(\times\) 227 to match the input format of the DL algorithm (AlexNet). As shown in Figure 5, the straightness of the edges in the weld beads was used to assess the weld quality as \"Good\" or \"Fail\" by visual inspection. The DL algorithm was implemented  
Figure 3: Progressive image acquisition process. in MATLAB (ver. 2019b; MathWorks Inc.) using the DL toolbox and an NVIDIA GPU (RTX 2070). The MATLAB Parallel Computing Toolbox was used for implementation. The parallel computation was performed using CUDA (ver. 10.2; NVIDIA) to improve the speed of the algorithm by exploiting parallelism. The DL-based image processing algorithm was in turn based on an AlexNet CNN. A special program was coded to recognize videos and images, even if the image size or position was randomly placed. The AlexNet CNN consisted of 5 convolutional layers and 3 fully connected layers. For this research, the AlexNet was modified and the details of the DL process structure of DL are described in Figure 4.  
The modified DL architecture consists of 8 layers, which include 5 convolutional layers and 3 fully connected layers. It uses Rectified Linear Units (ReLU) for lower error and faster convergence. The maximum number of repetitions was set at 30 and the mini-batch size was set to 128 from the preliminary DL research. Based on a series of training processes, it took less than a second to evaluate the welding quality when the algorithm was pretrained on 28,500 photographs using a spatial gray-level dependence matrix (SGDM). Overall, the predictive accuracy reached approximately 99% through repeated learning. The pretrained network, as described in Figure 4, was adapted to our welding bead data. To apply the developed deep learning algorithm, we created a custom training loop using automatic differentiation. In a commercial deep learning toolbox provided by MATLAB and the initialization process was conducted for the weights and biases, which are given by the internal function--the \"WeightsInitializer\" and \"BiasInitializer\" properties of the layers, respectively. To minimize the loss function for the convergence, the standard gradient descent algorithm was used to update the network parameters, such as weights and biases, and basic mathematical equations. In addition, to expedite the converging time and increase accuracy, the stochastic gradient descent with momentum algorithm was used to evaluate the gradient and update the parameters using a subset of the training welding data. The mini-batch size and the maximum number of epochs were optimized for accuracy. The basic governing equation is described in Equation (4):  
\[\theta_{i+1}=\theta_{i-\alpha}\
abla E(\theta_{i})+\gamma(\theta_{i}-\theta_{i -1}), \tag{4}\]  
where \(i\) is the iteration number, \(\alpha>0\) is the learning rate, \(\theta\) is the parameter vector, \(E(\theta)\) is the loss function, and \(\gamma\) determines the contribution of the previous gradient step to the current iteration.