Empower parameterized generative adversarial networks using a novel particle swarm optimizer: algorithms and applications

In this paper, a novel parameterized generative adversarial network (GAN) is proposed where the parameters are introduced to enhance the performance of image segmentation. The developed algorithm is applied to the image-based crack detection problem on the thermal data obtained through the non-destructive testing process. A new regularization term, which contains three tunable hyperparameters, embedded into the objective function of the GAN in order to improve the contrast ratio of certain areas of the image so as to benefit the crack detection process. To automate the selection of the optimal hyperparameters of the GAN, a new particle swarm optimization (PSO) algorithm is put forward where a neighborhood-based velocity updating strategy is developed for the purpose of thoroughly exploring the problem space. The proposed PSO-based GAN algorithm is shown to 1) work well in detecting cracks on the thermal data generated by the eddy current pulsed thermography technique; and 2) outperforms other conventional GAN algorithms.


Introduction
The past few years have witnessed the rapid development of deep learning techniques owing to their practical application insights [45,47,48,51]. Serving as a popular deep learning algorithm, the generative adversarial network (GAN) has been successfully applied to a wide range of applications (e.g., image processing, image super-resolution, and image synthesis) because of its strong abilities in data generation and feature extraction [23,42]. The training process of a GAN can be regarded as a minimax two-player game, where the generator aims to produce samples as real as possible and the discriminator aims to distinguish the generated sample and the real sample. Although it has been widely applied to various real-world applications, the original GAN suffers from the collapse problem.
To improve the generalization ability of the GAN and alleviate the collapse problem, considerable effort has been devoted to developing GAN variants [3,8,43,44,54]. Some representative GAN variants have been proposed by introducing regularization terms into the loss function, such as the information maximizing GAN (InfoGAN) [3], and the latent optimization for GAN (LOGAN) [44]. For example, the InfoGAN has been proposed in [3] where the mutual information has 1 3 been utilized for learning hidden representations. In addition, a designed regularization term has been added in the loss function of the InfoGAN for improving the convergence rate of the algorithm. The pix2pix tool has been developed in [8] to handle the image-to-image translation task, where a designed regularization term has been introduced in the conditional GAN (CGAN) to improve the quality of the generated image. As a follow-up study, the pix2pixHD method has been presented in [43] where the feature matching loss has been utilized in the CGAN for high-resolution image synthesis and semantic manipulation. Motivated by the above discussions, a seemingly natural idea is to deploy a specific regularization term into the loss function of the GAN with hope to improve the generalization ability of the GAN for real world applications.
It is worth pointing out that the performance of deep learning algorithms is highly dependent on the hyperparameters which are generally selected according to experimental experience. During the past few decades, the selection of the hyperparameters has attracted an ever-increasing research interest, which can be treated as an optimization problem [35]. Due to their strong abilities in discovering the global optimum, the evolutionary computation approaches (such as the particle swarm optimization (PSO) algorithm, the simulated annealing algorithm, and the genetic algorithm) are popular for tackling the hyperparameter optimization problem. Among the evolutionary computation approaches, the PSO algorithm has received much research attention because of its easy implementation and competitiveness in finding a satisfactory solution with a reasonable convergence rate, see e.g., [21,24].
Recently, the PSO algorithms have been successfully employed in optimizing the parameters of deep learning algorithms [11,22,30,35,40]. Unfortunately, the standard PSO algorithm suffers from the premature convergence problem and may easily be trapped in the local optimal solutions. To overcome the premature convergence problem, it is of practical significance to develop PSO variants with improved search capability. During the evolution process, all the particles are forced to explore around their own best positions and the global best position searched by the whole swarm. It seems natural to develop a new PSO algorithm which utilizes the neighborhood information to update the global best position according to the currently global best position and a certain number of particles that are close to the currently global best position. By exploiting the neighborhood of the global best position, the possibility of being trapped in the local optima could be decreased, which alleviates the premature convergence problem. In this paper, the developed neighborhood-based PSO algorithm is adopted to optimize the hyperparameters of the GAN for further crack detection on the non-destructive testing (NDT) data [5,9,41]. The developed parameterized GAN can be utilized for fault detection and structural health management of the oil pipeline, the gas pipeline and the aircraft.
The main contributions can be highlighted as follows: (1) a neighborhood-based PSO algorithm is utilized to optimize the hyperparameters of the GAN; (2) a specific regularization term is designed to improve the generalization performance of the GAN, which could enhance the contrast ratio of the images; and (3) the proposed PSO-based GAN method is applied to crack detection by using the eddy current pulsed thermography (ECPT) technique on the thermal data for the first time.
The rest of this paper is organized as follows. Section 2 introduces the background of the GAN. The framework of the proposed method is also provided. Main results are presented in Sect. 3, in which the experiment data is also discussed. Finally, conclusions are drawn and future research directions are discussed in Sect. 4.

Method
In this paper, the GAN is adopted to deal with the thermal data for crack detection by using the ECPT technique. The ECPT is a popular NDT method, in which the specimen is heated by using the eddy current. The ECPT process is recorded by a thermal imager. The spatial features (such as the crack, and the distance between the specimen and the thermal imager) are analyzed to construct the thermal images so as to justify whether the detecting point is a crack or not. In this section, the background information of the original GAN is provided. Then, the objective function of the modified GAN is introduced. The developed PSO-based hyperparameter optimization strategy and the training procedure of the modified GAN are also presented.

The background of the GAN
The original GAN consists of a generative network (also known as the generator) and a discriminative network (which is also called as the discriminator). The generator aims to produce the samples as real as possible, and the purpose of the discriminator is to distinguish the real samples and the so-called fake samples obtained by the generator.
The objective function of the conventional GAN is given as follows: where z is random noise; x represents the reference sample; G(⋅) is the generator; D(⋅) is the discriminator; ℙ data (x) indicates that the x is selected from the distribution ℙ data ; and ℙ z (z) indicates that z is selected from the distribution ℙ z . The main purpose of the conventional GAN is to pursue:

The modified GAN
In the original GAN, the input of the generator is random noise (which obeys the Gaussian distribution), and the input of the discriminator is the real sample and the so called fake sample generated by the generator. In this paper, the GAN is applied to the crack detection on the thermal data obtained by using the ECPT technique. The temperature of the specimen for each spatial point is a data flow when the specimen is heated by the pulsed eddy current in an ECPT system [55]. The input of the generator is the detected thermal signal of one spatial point in the specimen. To be specific, the thermal signal utilized in this paper represents the temperature of the corresponding spatial point in the specimen during the NDT process. The output of the generator is a single pixel value, which is utilized to reconstruct the thermal image of the specimen. The input of the discriminator is the fake sample and the real sample (which is the corresponding pixel value in the detected thermal image). An example of the detected thermal information of a spatial point is shown in Fig. 1.
To enhance the contrast ratio of the reconstructed image, a designed regularization term is added in the objective function of the modified GAN. The objective function of the modified GAN is shown in Eq. (3): where 1 is the penalty factor of the objective function (1); 2 and 3 are the parameters of a sigmoid function which is used to adjust the output value of the generator; var(z) is the variance of z; is a constant value; and J(D, G) indicates the objective function (1).
As shown in Fig. 1, the temperature of the spatial point changes during the heating process. In fact, the heating energy of the crack area is higher than that of normal areas due to the excitation of the eddy current. In this case, the temperature curve of the spatial points that belongs to the crack area is different from that of the normal area. In this paper, the temperature curve of each spatial point is utilized to extract the features of the acquired thermal data. In the developed GAN, a designed penalty term is introduced in the loss function to enhance the temperature curve features of the crack information. Furthermore, the term is a sigmoid function, which contains two hyperparameters: 2 and 3 . The characteristics of nonlinear and monotonicity of the sigmoid function could benefit the training process of the modified GAN by adjusting the hyperparameters.
In this paper, we aim to develop a new PSO algorithm that automates the optimal selection of the hyperparameters i (i = 1, 2, 3) so as to solve:

PSO-based hyperparameter optimization
In the designed objective function equation (3), the weights and biases of the generator and the discriminator are denoted by g and d , respectively. g and d are optimized by using the Adam optimization algorithm. In this paper, three hyperparameters ( 1 , 2 and 3 ) of the GAN are chosen by using our developed PSO algorithm instead of manually selecting the parameters according to experimental experience.
The optimization process of the proposed objective function is depicted in Fig. 2, where each curve indicates a set of parameters. It can be seen in Fig. 2 that suitable parameters should lead to the minimal fitness value for the weights of the network ( g ) and the penalty factors ( ).

The PSO algorithm
Inspired by a metaphor of social interaction (such as fish schooling and birds flocking), the PSO algorithm has been developed for solving various optimization problems owing to its easy implementation and relatively fast convergence rate. In recent years, the PSO algorithm has received an everincreasing interest due to its wide application potential. Each particle represents a candidate solution of the optimization problem.
Note that all the particles move at a certain speed in a D-dimensional search space. The velocity and position of the ith particle at the kth iteration are denoted by two vectors, which are the velocity vector respectively. According to swarm intelligence, the position of each particle is automatically updated towards two positions, where one position is the personal best position found by the particle itself (pbest) denoted by , and the other one is the global best position among the whole swarm (gbest) represented by p g = (p g1 , p g2 , ⋯ , p gD ) . The velocity and the position of the ith particle at the ( k + 1)th iteration are updated as follows: where k is the current iteration number; w is the inertia weight; c 1 and c 2 are the acceleration coefficients called as the cognitive parameter and the social parameter, respectively; and r 1 and r 2 are two random numbers which are uniformly distributed over the interval [0, 1].

The neighborhood-based PSO algorithm
As a powerful evolutionary computation algorithm, the PSO algorithm has been successfully applied to a variety of optimization problems. To alleviate the premature convergence problem, some variant PSO algorithms focus on the modification of the parameters, such as the PSO algorithm with linear decreasing inertia weight and the PSO algorithm with time-varying acceleration coefficients. Despite adjusting the parameters, some PSO variants have been proposed by designing topological structures [10,34,37]. For example, the widely used topological structures (consisting of all, ring, and clusters) have been adopted in [10] to update the velocity of the particles. In [34], a fully informed PSO algorithm has been put forward where each particle is adjusted according to its neighborhood information. In the standard PSO algorithm, all the particles are motivated to explore the search space based on personal best position of each particle and the global best position searched by the entire swarm. Motivated by variant PSO algorithms that utilize the neighborhood information, a seemingly natural idea is to explore around the discovered global best position based on the nearby particles.
In recent years, the neighbourhood information has been adopted to enhance the search capability of the PSO algorithms [16,34,37]. For example, a fully informed PSO algorithm has been proposed in [34], where the neighbourhood information of each particle is employed in the velocity updating model. In [16,37], the particles are updated using the information of local best positions. To summarize, the aforementioned variant PSO algorithms employ the neighbourhood of all the particles, which makes it time-consuming to update the personal best particle and the global best particle during the population evolution process. As such, there is a need to put forward a new PSO algorithm which not only utilizes the neighbourhood information of the particle but also has relatively fast convergence rate.
In this paper, a neighborhood-based PSO algorithm is put forward where the neighborhood information of the global best position is employed for updating the velocity of the particles. In the proposed algorithm, a certain number of particles (which are close to the global best position) and the currently global best position are employed for updating the global best position. The designed neighborhood-based PSO algorithm has the capability of searching around the global best position at each iteration, which contributes to a thorough exploration of the problem space and may increase the possibility of escaping from the local optima.
Assume that there are several particles near the global optimal position and these particles are randomly distributed in the solution space. Based on this assumption, the neighborhood information around the currently global best position is employed to search for a candidate solution through the solution space. The neighborhood-based searching process of the introduced PSO algorithm is displayed in Fig. 3.
In this paper, p g in equation (5) is updated as follows: The space of the feasible solution

Solution space
The particle The prediction solution The neighborhood particles The optimal particle where the distance is determined by L 2 norm; and n is the number of the neighborhood points; F( * ) is the objective function of the corresponding optimization problem: Comparing with the velocity updating strategy of the standard PSO, the neighborhood-based updating strategy is capable of approaching the optimal solution with a faster convergence rate, which could benefit the hyperparameter optimization for deep learning techniques. It should be noted that the L 2 norm has the ability of searching the solutions evenly in the target region compared with other norms, such as L 1 norm or L ∞ norm. In this case, the L 2 norm is employed to measure the distance between p g (k) and its neighborhood points.

The hyperparameter optimization of the modified GAN
In this paper, the proposed neighborhood-based PSO algorithm is employed to optimize the hyperparameters ( 1 , 2 and 3 ) of the modified GAN. By using the optimized hyperparameters, the parameters of the modified GAN are then updated by employing the gradient descent method. The flowchart of the training process is depicted in Fig. 4.
In Fig. 4, after the initialization process, the neighborhood-based PSO algorithm is first implemented for a certain number of iterations to obtain a proper set of hyperparameters. Then, the gradient-descent-based optimization algorithm is employed to optimize the parameters of the modified GAN for a certain number of epochs with the chosen hyperparameters. The whole process stops when the value of the objective function reaches the threshold and the pseudocode is shown as Algorithm 1. In the training process of the modified GAN, the neighborhood-based PSO algorithm operates first to initialize the hyperparameters of the modified GAN. Then, the parameters of the modified GAN are tuned by using the Adam optimizer. Note that the parameters of the GAN remain the same when updating the loss function. In this case, the neighborhood-based PSO algorithm can be applied to optimize the parameters of other GAN variants, such as the Wasserstein GAN and the least squares GAN. Iteration is over?
Output the optimal g , The generator is obtained

Experimental results
In this paper, the developed PSO-based GAN is exploited for the crack detection of the ECPT NDT images. In this section, experiment setup is first introduced and experimental results are then presented.

Experiment setup
In NDT, the thermography technique is widely used for crack detection. Particularly, the ECPT approach is one of the most popular NDT methods for subsurface crack detection. In the ECPT technique, the eddy current is excited in the specimen and the temperature of the crack area will be increased because the density of the eddy current is higher than that of the normal area. The heating process is recorded by using a thermal imager, which is shown in Fig. 5. It should be pointed out that it is difficult to identify the shape of the cracks by using the ECPT technique because the thermal energy in the material is transferred during the heating process. The ECPT detection system is depicted in Fig. 6. The alternating current is generated by a power device to drive the heating coil, which excites the eddy current in the specimen. The thermal imager is employed to record the heating process with a high sampling rate. It should be noted that the specimen could be placed under or on the heating coil. Fig. 6 (b) shows the experimental specimen with the cracks with different sizes, which is made of stainless steel. Some of the cracks with big size are through-hole.

Experiment data
In the experiment, the through-hole crack and the general crack are used for the crack detection. A typical frame of the thermal image used for the training of the GAN is shown in Fig. 7. It can be seen that the crack with a bigger size is the through-hole crack and the smaller one is a general crack.
The pre-processing process is adopted to produce the real sample for training the discriminator. Notice that it is difficult to obtain a high-quality thermal image during the ECPT process. To obtain a relatively satisfactory thermal image of the specimen, the pre-processing process is adopted where the pro-processed image is utilized as the real sample for training the discriminator. In this paper, the real sample is the binarized thermal image where the pixel value of a crack point is "1" and the other non-crack points are with the pixel value of "0". An example of the real samples is depicted in Fig. 8. In order to extract the features of the crack in the thermal data, a series of the thermal signal is utilized as the input of the generator. Each thermal signal corresponds to a pixel point in the thermal image. The thermal signal and its corresponding real sample constitute a pair of training data. As shown in Fig. 7, the size of an acquired thermal image is 480 × 640 , and the total number of pixel points in this image is 307200. In total, there are 307200 pairs of training data.
The testing data (which includes three general cracks) is extracted from other area of the specimen. A typical thermal image of the testing data is shown in Fig. 9. We can see in   Fig. 9 that the pixel value of crack area is small by comparing with the normal area. In addition, the obtained thermal image is corrupted by the noise, which makes it difficult to use a threshold to extract the crack area. In such a case, it is very hard to accurately extract the shape of the crack.
In the experiment of training the conventional GAN, the parameters 1 , 2 and 3 are manually selected. In the experiment that employs the PSO-based method, 1 , 2 and 3 are randomly initialized in the range of [-10, 10]. The parameters of PSO are set up as follows: the inertia weight is set to be w = 0.7298 ; the acceleration coefficients are c 1 = 1.4962 and c 2 = 1.4962 ; r i (i = 1, 2) are random numbers which are uniformly distributed in [0, 1]; the number of neighborhood points corresponding to the global point is n = 3 ; the search range of hyperparameters i (i = 1, 2, 3) is in the range of (0, 2]; the number of the particles is set to be 30. These parameters are selected depending on experimental experience.
In this paper, the architecture of the GAN is a fully connected neural network. The detailed information of the modified GAN is listed as follows: • Information: Layers : 12;

Results and discussions
To verify the effectiveness of the proposed PSO-based GAN method for crack detection, the original GAN is utilized for comparison. It should be noted that all the experiments are conducted with the same initial parameters. The size of each thermal image is 480 × 640 . In total, 307200 thermal samples (signals) can be used as the input of the generator during the training process. For each iteration, 100 signals are randomly selected from the training dataset.
The experiment results of the original GAN for crack detection by using the ECPT NDT technique are shown in Fig. 10. It can be seen that the background noise is reduced which indicates the effectiveness of the original GAN. Nevertheless, it can be observed that there are still some corrupted areas around the cracks, which are produced by the excited eddy current in the non-crack areas. Additionally, the shape of the real crack area cannot be accurately extracted due to the heat transfer in the material. To conclude, the produced result by using the original cannot be used to accurately detect the cracks.
The second experiment is conducted by using the modified GAN with a newly designed loss function, and results are shown in Fig. 11. In this experiment, the hyperparameters of the modified GAN are chosen as 1 = 0.4 , 2 = 1.4 and 3 = 0.6.
In Fig. 11, the pixels of the crack area are enhanced prominently. It should be noted that the pixel values of the noise around the crack are relatively large comparing with that of other non-crack areas. To sum up, the introduced regularization term in the loss function contribute to the enhancement of the contrast ratio.
In the second experiment, the hyperparameters are determined depending on the experimental experience. Notice that the hyperparameters selected for the second experiment are not the optimal ones. To further improve the performance of the modified GAN, the fine-tuned hyperparameters of the network are determined, and the results are shown in Fig. 12. Here, the hyperparameters are set up as 1 = 0.01 , 2 = 0.1 and 3 = 0.05 . It can be seen in Fig. 12 that the background noise is almost reduced and the pixel values of  Fig. 13. In this experiment, the hyperparameters optimized by the developed neighborhood-based PSO algorithm are 1 = 0.5 , 2 = 0.75 and 3 = 0.1 . We can see that the noise around the crack area is largely reduced by comparing with the results in Fig. 12. The shape of the crack is accurately extracted in Fig. 13. Furthermore, Fig. 13 presents a more accurate crack shape comparing with the real crack in the specimen shown in Fig. 6. Results shown that the proposed neighborhood PSO algorithm is capable of discovering the optimal hyperparameters for training the GAN. Comparing with the manually hyperparameter selection method, the proposed algorithm is capable of searching the optimal solution in a fast and accurate way. The updating process of the hyperparameters is shown in Fig. 14. Notice that the hyperparameters are updated once for every 100 iterations in Fig. 14. In addition, the perturbation of each parameter becomes small, which indicates that the result approaches the optimal solution.
The error between the generated sample and the real sample is shown in Fig. 15. The sigmoid function is employed as the activation function for the output layer of the discriminator. It can be seen in Fig. 15 that the training error of the network converges very fast by using the hyperparameters optimized by the PSO algorithm. The running time comparison of the conventional GAN and the PSO-based GAN is shown in Fig. 16. In the experiment, the network is trained by 26 epochs with the batch size of 1000. It can be seen in Fig. 16 that there is little difference between the conventional GAN and the PSO-based GAN at each epoch. According to the CPU timer, the running time of the conventional GAN is 517.238s, and the running time of the PSO-based GAN is 635.439s. The training process becomes stable after running 1500 iterations as shown in Fig. 15. In this case, the employment of the PSO algorithm will not cause the timeconsuming problem in training the GAN.

Crack
The edge of the crack To summarize, we can draw the conclusion that the PSObased GAN performs well for the crack detection on the ECPT NDT data. The shortcomings of the proposed GANbased crack-detection method are listed as follows: 1. the labels of the data should be manually provided; and 2. a large amount of data is required to train an effective network.
The proposed GAN-based crack detection algorithm enhances the contrast ratio of the thermal images which benefits the crack detection on ECPT data. Actually, the proposed method can be applied to other data that have same features as the ECPT data. Specifically, the features of the crack area are different from that of the normal area. For example, the developed method can be employed for crack detection on magnetic optical imaging data and ultrasonic testing data.

Conclusion
In this paper, a novel PSO-based GAN approach has been put forward for ECPT crack detection. A designed regulation term has been introduced in the objective function of the modified GAN so as to enhance the contrast ratio of the reconstructed image. The neighborhood-based PSO algorithm has been developed to automatically select the hyperparameters of the modified GAN, where a neighborhood updating strategy has been proposed to make full use of the neighborhood information of the global best position. Finally, experiments have been conducted to verify the effectiveness of the PSO-based GAN approach. Experimental results have demonstrated the superiority of the proposed method over the original GAN and the modified GAN (with manually selected hyperparameter) for crack detection on the ECPT NDT data. In the future, we aim to: (1) employ
Open Access This article is licensed under a Creative Commons Attribution 4.0 International License, which permits use, sharing, adaptation, distribution and reproduction in any medium or format, as long as you give appropriate credit to the original author(s) and the source, provide a link to the Creative Commons licence, and indicate if changes were made. The images or other third party material in this article are included in the article's Creative Commons licence, unless indicated otherwise in a credit line to the material. If material is not included in the article's Creative Commons licence and your intended use is not permitted by statutory regulation or exceeds the permitted use, you will need to obtain permission directly from the copyright holder. To view a copy of this licence, visit http:// creat iveco mmons. org/ licen ses/ by/4. 0/.