# Self-Attention GAN for Electromagnetic Imaging of Uniaxial Objects
## 3 Neural Network
Moreover, \(D_{\varnothing}\) represents the discriminator network, where \(\varnothing\) denotes the unknown parameter of the discriminator. The output of this network is a discriminative matrix. The generative network and the discriminator are trained alternately in a competitive manner, with each network updating in response to the other. A GAN is composed of an SRNN generator with an SA mechanism and a discriminator. First, the overall architecture of the SRNN with the SA mechanism, as shown in Figure 3, takes the image input and passes it through the encoder. The encoded image and the image processed by the SRNN are then combined and fed into the discriminator. Next, the structure of the SRNN generator with SA in Figure 4 is introduced. The SRNN generator adopts CNN architecture, which consists of a contracting network on the left and an expanding network on the right. The contracting network incorporates repeated \(3\times 3\) convolution layers, BN layers, and ReLU layers. Additionally, a \(2\times 2\) max pooling layer is introduced in the pooling layer of the contracting network. In the expanding network, \(3\times 3\) up-convolution layers, BN layers, and ReLU layers are added, followed by a \(1\times 1\) convolution layer serving as the fully connected layer. SA is incorporated at the output of SRNN to enhance the quality of the reconstructed image. Next, the SA mechanism shown in Figure 5 is described in detail. It consists of three \(3\times 3\) convolution layers, where two of them pass through a Matrix Multiplication Layer (MML) and a SoftMax layer. The MML is served as a fully connected layer. The results generated by the generator are fed into the discriminator for evaluation. Finally, the architecture of the GAN discriminator in Figure 6 is presented. It consists of one \(3\times 3\) convolution layer, three additional \(3\times 3\) convolution layers, BN layers, and ReLU layers. The discriminator receives as input the image generated by the generative network. In essence, the discriminator assigns a score based on its evaluation. This score determines whether the generative network needs to adjust its training weights. The process continues iteratively until a satisfactory equilibrium is reached. In GANs, the loss function of the generative network, denoted as \(L_{GAN}^{\text{G}}\) is defined in (35). Figure 4: Typical schematic of the SRNN generator with SA mechanism. Figure 5: SA mechanism architecture. Figure 6: The GAN’s discriminator architecture. Figure 3: Overall SRNN architecture with SA mechanism. Figure 2: Overall GAN architecture. Through repeated cycles of generation and discrimination, the model eventually reaches Nash equilibrium, enabling the generator to produce accurate dielectric tensor reconstructions of anisotropic objects. \[L_{GAN}^{G}(\theta|\varnothing)=L_{RMSE}(\theta)+\gamma L_{A}(\theta|\varnothing) \tag{35}\]  
where \(L_{RMSE}(\theta)\) represents the error between the reconstructed image and the reference image. The parameter \(\gamma\) serves as a weighting factor to balance the two loss components. \(L_{A}(\theta|\varnothing)\) denotes the adversarial loss function of the discriminator network, which is formulated as follows:  
\[L_{A}(\theta|\varnothing)=\frac{1}{N}\sum_{i=1}^{N}||D_{\varnothing}(G_{\theta }(\varepsilon_{1i})-1)|| \tag{36}\]  
\(L_{A}\) represents the scoring mechanism of the discriminator network, which evaluates whether the reconstructed image accurately reflects the true image. \(N\) denotes the number of data points included in each training batch. The loss function associated with the discriminator network in GAN is formulated as follows:  
\[L_{GAN}^{D}(\theta|\varnothing)=\frac{1}{2N}\sum_{i=1}^{N}\Bigl{(}\|D_{ \varnothing}(Y_{i})-1\|_{2}^{2}+\|D_{\varnothing}(G_{\theta}(\varepsilon_{1i}) )\|_{2}^{2}\Bigr{)} \tag{37}\]  
where \(\varnothing\) represents the unknown parametric data, and \(\varnothing\) denotes the weight parameter. \(Y_{i}\) and \(\varepsilon_{1i}\) refer to the true and generated data, respectively.