# A Symbol Recognition System for Single-Line Diagrams Developed Using a Deep-Learning Approach
## 3 Proposed Method
### Data Generation by GANs
#### 3.3.1 Framework Structure of the DCGAN  
In this study, we used the DCGAN to create synthetic pictures of single-line diagrams. The synthetic images were then combined with the LSGAN-generated images and the actual images to increase our dataset and improve the symbol recognition algorithms. Other models improve upon DCGANs by introducing new constraints or by making adjustments. As can be seen in Figure 9, a generative adversarial network consists of a generator module (G) and a discriminator module (D). The generator's job is to translate a random dataset \(\mu\) (which it uses as a source) into a desired output dataset \(\varphi\). The random dataset \(\mu\) in a conventional GAN is usually uniform or Gaussian noise with a range of zero to one. The discriminator is used to separate the generated outputs \(\varphi\) from the actual datasets \(\varphi\)d (the targeted outputs). If the intended outputs are accepted, the discriminator's \(\mathrm{D}(\varphi\mathrm{d})=1\), while if they are rejected, \(\mathrm{D}(\mathrm{G}(\mu))=0\). Based on a cross-entropy loss function (J(D, G)), the training procedure in a GAN can be viewed as a minimization-maximization problem, as written in Equation (4):  
\[\mathrm{min}_{\mathrm{G}}\mathrm{max}_{\mathrm{D}}=\mathrm{E}_{\varphi\mathrm{ d}-\mathrm{P}_{\mathrm{data}}(\varphi\mathrm{d})}[\mathrm{logD}(\varphi_{ \mathrm{d}})]+\mathrm{E}_{\mu-\mathrm{p}\mu(\mu)}[\mathrm{log}(1-\mathrm{D}( \mathrm{G}(\mu)))] \tag{4}\]  
where \(\mathrm{p}_{\mathrm{data}}(\mathrm{d})\) is the corresponding probability data distribution for the intended outputs \(\varphi_{\mathrm{d}}\) and \(\mathrm{p}\mu(\mu)\) is a prior distribution for the random datasets \(\mu\) and \(\mathrm{p}_{\mathrm{data}}(\varphi\mathrm{d})\). The min-max process involves two steps, as expressed in Equation (5):  
\[\mathrm{J}^{(\mathrm{D})}(\varphi^{(\mathrm{G})},\varphi^{(\mathrm{D})})= \mathrm{E}_{\varphi\mathrm{d}-\mathrm{P}_{\mathrm{data}}(\varphi\mathrm{d})}[ \mathrm{logD}(\varphi_{\mathrm{d}},\varphi^{(\mathrm{D})})]+\mathrm{E}_{\mu- \mathrm{p}\mu(\mu)}[\mathrm{log}(1-\mathrm{D}(\mathrm{G}(\mu)),\varphi^{( \mathrm{G})},\varphi^{(\mathrm{D})})] \tag{5}\]  
where \(\mathrm{p}_{\mathrm{data}}(\mathrm{d})\) is the corresponding probability data distribution for the intended outputs \(\mathrm{d}\) and \(\mathrm{p}(\mathrm{d})\) is a prior distribution for the random dataset. Changing the generator by minimizing the generator function or \(\mathrm{min}_{\varphi}(\mathrm{G})\mathrm{J}^{(\mathrm{G})}\)\(\varrho^{(\mathrm{D})}\), \(\varphi^{(\mathrm{G})}\) (where \(\theta^{(\mathrm{G})}\) denotes the parameter in the cost functions of the generator and the function \(\mathrm{J}^{(\mathrm{G})}\) is differentiable), yields Equation (6):  
\[\mathrm{J}^{(\mathrm{D})}(\varphi^{(\mathrm{G})},\varphi^{(\mathrm{D})})= \mathrm{E}_{\mu-\mathrm{p}\mu(\mu)}[\mathrm{log}(1-\mathrm{D}(\mathrm{G}(\mu )))] \tag{6}\]  
According to [PERSON] et al. [32], if D and G have sufficient capacity, the min-max game has a global optimum for \(\mathrm{p}_{\mathrm{g}}(\varphi)\mathrm{p}_{\mathrm{data}}(\varphi_{\mathrm{d}})\) (where \(\mathrm{p}_{\mathrm{g}}\) is a probability distribution of the produced output \(\varphi\) when \(\mu\)-\(\mathrm{p}_{\mu}(\mu)\)). The following characteristics describe the ideal discriminator for the \(\mathrm{J}^{(\mathrm{G})}(\mathrm{G},\mathrm{D})\); Equation (7) represents the steps:  
\[\mathrm{D}^{*}_{(\varphi\mathrm{d})}=\frac{\mathrm{P}_{\mathrm{data}(\varphi \mathrm{d})}}{\mathrm{P}_{\mathrm{data}(\varphi\mathrm{d}+\mathrm{P}_{\mathrm{ g}}(\varphi))}} \tag{7}\]  
The calculation of min-max in (3) can be represented in Equation (8) as:  
Figure 9: Structure of the DCGAN.