# A Symbol Recognition System for Single-Line Diagrams Developed Using a Deep-Learning Approach
## 3 Proposed Method
### Data Generation by GANs
#### 3.3.2 Network Structure of the LSGAN
In the case where b = 1, a = 1, and c = 0, L (G) is changed to Equation (14):  
\[2\mathrm{L}(G)=\int_{X}\frac{\big{(}2\big{(}P_{g}(x)-\mathrm{P_{data}(x)P_{g}( x)}\big{)}\big{)}^{2}}{\mathrm{P_{data}(x)}\ +\ P_{g}(x)}\mathrm{dx}=X_{P_{sensor}}^{2}(\mathrm{P_{data}}\ +\ P_{g}||2\mathrm{p_{g}}) \tag{14}\]  
The cost function of the LSGAN in this situation aims to minimize the Pearson difference between p\({}_{g}\)+p\({}_{data}\) and 2p\({}_{g}\)[54]. In this study, the latter criterion is used. Pearson divergence, as well as KL divergence and JS divergence, pertain to the F-divergence family. In statistics, a branch of functions known as F divergence is used to compare two probability density functions--in this instance, the probability density for the generated data (p\({}_{g}\)(x)) and the probability density for the real data (P\({}_{data}\)(x)). The following is the basic formula for an F-divergence D\({}_{i}\):  
\[\mathrm{Df}\ (\mathrm{P_{g}(x)}||\mathrm{P_{data}(x)})=\int\mathrm{P_{g}(x)f} \Bigg{(}\frac{\mathrm{P_{data}(x)}}{\mathrm{P_{g}(x)}}\Bigg{)}\mathrm{dx} \tag{15}\]F divergence corresponds to KL divergence when f(t) = t logt. F divergence represents X\({}_{\text{Pearson}}^{2}\) divergence when f(t) = (t1)\({}^{2}\). This change has two advantages that can be seen. Firstly, LSGANs will penalize samples even though they are properly classified, in contrast to GANs which rarely lose data for samples that fall on the right side. The generated samples will travel in the direction of the decision boundary due to the penalization. Secondly, penalizing samples that are far from the decision limit can cause the generator to update with more gradients, solving the issue of vanishing gradients. LSGANs can perform more consistently as a result of the learning process [47]. Information asymmetry, or the fact that there are numerous classes in the input but only one class in the output, is another important factor in mode collapse. Therefore, the labels of the inputs, x\({}_{c}\), are used in G and D to conduct classification when we work with a conditional version of the LSGAN. In our investigation, there were two different types of samples: safe samples and unsafe samples. One-hot encoding was used to binarize the groups. For instance, the secure ones had labels [0, 1], a two-dimensional vector, and the unsafe ones had labels [1, 0]. The one-hot labels xc were added to the end of noisy signals z as the input of G, (z, x\({}_{c}\)), represented as the vector of conditional LSGANs. One-hot labels x\({}_{c}\) will be used as the input of D, also known as the vector of (x, x\({}_{c}\)), if they are added to the end of reference signals x. The main function becomes:  
\[\text{min}_{\text{D}}\text{L}_{\text{LSGAN}}(\text{D})=\tfrac{1}{2}\text{E}_ {\text{x}_{\text{o}}\text{x}\sim\text{P}_{\text{data}}(\text{x}_{\text{o}} \text{x}_{\text{c}})}\Big{[}(\text{D}(\text{x},\text{x}_{\text{c}})-1)^{2} \Big{]}+\tfrac{1}{2} \tag{16}\]  
\[\text{min}_{\text{G}}\text{L}_{\text{LSGAN}}(\text{D})=\frac{1}{2}\text{E}_{ \text{z}\sim\text{P}\text{z}(\text{z})\text{0 sc}\sim\text{P}_{\text{data}}( \text{x}_{\text{0 sc}})}\Big{[}(\text{D}(\text{G}(\text{z},\text{x}_{\text{c} }),\text{x}_{\text{c}}))^{2}\Big{]} \tag{17}\]  
It can be challenging to update the generator when the typical GAN goal functions are reduced because this can lead to gradient-loss issues. The LSGAN gets around this problem by penalizing samples based on how close they are to the decision limit, which causes the generator to update with more gradients. Additionally, theoretical research shows that the training instability of standard GANs is caused by the propensity of the objective function to seek modes, whereas the LSGAN exhibits less mode-seeking activity.