# A Rapid Bridge Crack Detection Method Based on Deep Learning
## 2 Materials and Methods
### The Theory of DCGAN  
The GAN was first proposed by [PERSON] in 2014 [PERSON] (2014), aiming to produce generated samples that are nearly consistent with the distribution of real data, which belongs to the category of unsupervised learning [PERSON] (2014). GANs have attracted a large number of researchers and have subsequently achieved many research results in computer vision fields such as image synthesis, style transfer, image repair, and object detection [PERSON] (2014). DCGAN combines CNN with GAN, which greatly improves the stability of GAN and the effect of the output results. DCGAN usually consists of a generator and discriminator.  
(1) Generator  
The primary objective of the generator is to understand and absorb the attributes present in the training data. It accomplishes this by aligning the random noise distribution with the actual distribution of the training data under the guidance of the discriminator. This process enables the generator to produce synthetic data that closely resemble the characteristics observed in the training dataset. The training objective function can be expressed as follows:  
\[G^{*}=\text{arg}\;\underset{G}{\text{min}}\;Div(P_{data(x)},P_{G}) \tag{1}\]  
In the equation, \(P_{data}\) and \(P_{G}\) are the real and generated data distributions, respectively, and \(Div()\) is the difference between the distributions.  
(2) Discriminator  
The primary role of the discriminator is to differentiate between real and generated data produced by the generator while providing feedback to the generator. Both networks undergo iterative training, where their capabilities grow simultaneously until the generated network is capable of producing data that can deceive the discriminator. This process focuses on refining the discerning abilities of the discriminator and enhancing the generative potential of the network. Finally, a certain balance will be reached in terms of the capabilities of the generator and discriminator. The training objective function can be expressed as follows:  
\[D^{*}=\text{arg}\;\underset{D}{\text{max}}\;Div(P_{G},P_{data}) \tag{2}\]  
The true likelihood of the input sample is manifested in the discriminator objective function value, reflecting a binary classification challenge. The formula for the training objective function can be articulated as follows:  
\[V(G,D)=E_{X\sim P_{data(x)}}\left[\log D(x)\right]+E_{Z\sim P_{Z(z)}}[\log(1- D(G(z))] \tag{3}\]  
In the equation, \(E_{X\sim P_{data(x)}}\) and \(E_{Z\sim P_{Z(z)}}\) are the real data \(x\) and the noise \(z\) expectations, respectively; \(D(x)\) is the output of the real data \(x\); and \(G(z)\) represents the noise \(z\) through the generator.  
Suppose that in a continuous space, Equation (3) can be expressed as:  
\[V(G,D)=\int_{x}\left[P_{data(x)}\log(D(x)+P_{G}(x)\log(1-D(x)))\right]dx \tag{4}\]  
For the integrand function \(F(x)\),  
\[F(x)=P_{data(x)}\log D(x)+P_{G}\log(1-D(x)) \tag{5}\]  
While \(P_{data}\) and \(P_{G(x)}\) are arbitrary non-zero real numbers, Equation (5) obtains the maximum value when Equation (6) is satisfied. Equation (6) can be expressed in the following form:  
\[D^{*}=\frac{P_{data}(x)}{P_{data}(x)+P_{G}(x)} \tag{6}\]Equation (7) can be obtained by taking Equation (6) into Equation (4):  
\[V(G,D)=-2\log 2+2 JSD(P_{data}||P_{G}) \tag{7}\]  
In the equation, \(JSD(P_{data}||P_{G})\) is the \(JS\) divergence between \(P_{data}\) and \(P_{G}\). The more similar \(P_{data}\) and \(P_{G}\) are, the smaller the \(JS\) divergence; conversely, the more different \(P_{data}\) and \(P_{G}\) are, the larger the \(JS\) divergence.  
Considering the generator and the discriminator together, the objective function of DCGAN can be expressed as:  
\[\min_{G}\max_{D}V(G,D)=E_{X\sim P_{data(x)}}[\log D(x)]+E_{Z\sim P_{Z(z)}}[ \log(1-D(G(z)))] \tag{8}\]