## 3 Materials and Methods
### CGAN for COVID-19 CXR Image Generation
#### 3.2.3 The Proposed CGAN Architecture  
Based on the theories of the CGAN presented earlier, we constructed a customized CGAN that uses CXR images from the original dataset to generate new images. The loss scores were calculated based on the following equation:  
\[ \begin{array}{cc}\underset{\text{G}}{\text{min}}&\underset{\text{D}}{\text{ max}}&\text{V}(D,G)=\text{E}_{x\sim Pdata}\ (x)[\log D(x|y)]+\text{E}_{z\sim Pz}\ (z)[\log(1-D(G(z|y)))]\end{array}  \tag{1}\]  
where \(D(x\ |\ y)\) is the discriminator's estimate of the probability that a real data instance (\(x\)) is real for a given class (\(y\)), and \(D(G(z\ |\ y))\) is the discriminator's estimate of the probability that a fake instance is real for a given class (\(y\)). The specific architectures of the CGAN generator and discriminator networks are shown in Figures 4 and 5, respectively. As shown in Figure 4, the generator (\(G\)) contains a total of 18 layers: an input layer (noise), a project and reshape layer (proj), an embedding layer (embed), a concatenation layer (concat), five transposed convolutional layers (tconv1-tcon5), four batch normalization layers (bnorm1-bnorm4) [37], four rectified linear unit (ReLU) layers (relu1-relu4), and a hyperbolic tangent layer (tanh). In particular, the network converts a noise vector of 100 samples into 4 \(\times\) 4 \(\times\) 256 arrays using project and reshape and then up-scales the resulting arrays to 128 \(\times\) 128 \(\times\) 3 using a series of transposed convolution layers with batch normalization and ReLU layers. Notably, the number of the transposed convolutional neural networks as well as the filter number and sizes, i.e., 5, were chosen carefully so that the generated images were 128 \(\times\) 128. If the desired size is different, then the number of the transposed convolutional neural networks will differ as well. For example, if the desired size is 64 \(\times\) 64, then there will be four transposed convolutional neural networks instead of five. The network converts a noise vector of 100 samples into 4 \(\times\) 4 \(\times\) 512 arrays using the project and reshape layer. Then, it converts the categorical labels to embedding vectors and reshapes them to a 4 \(\times\) 4 array. After, the network concatenates the resulting images from the two inputs along the channel dimension to a 4 \(\times\) 4 \(\times\) 512 array. Next, it up-scales the resulting arrays to 128 \(\times\) 128 \(\times\) 3 using a series of transposed convolutional layers with batch normalization and ReLU layers. The discriminator (\(D\)), as shown in Figure 5, contains 24 layers: an input layer (in), an embedding layer (embed), a concatenation layer (concat), six convolutional layers  
Figure 4: The proposed architecture of the CGAN generator. The generator takes a noise vector and image labels and up-samples the generated images using five transposed convolutional layers. (tconv1-tcon6), six dropout layers (drop, drop1-drop5) [38], four batch normalization layers (bnorm2-bnorm5), and five leaky rectified linear unit layers (lrelu1-lrelu5). The addition of the dropout layers in the discriminator networks helps to reduce the capacity of the network during training and to avoid overfitting. The CGAN was trained with the original dataset described in Section 3.2.2 using the configurations shown in Table 2. The number of epochs was chosen based on the experiment so that we obtained reasonable image quality. To increase the stability of the CGAN, the generator and discriminator learning rates were not equal. To validate the images generated by the CGAN, the train on synthetic, test on real (TSTR) method [40] was applied. In this method, the generated images are used to train a \begin{table}
\begin{tabular}{l c} \hline \hline
**Number of Epochs** & 2000 \\ \hline
**Mini Batch Size** & 64 \\ \hline
**Optimizer** & Adam [39] \\ \hline
**Learning rate of Generator** & 0.0002 \\ \hline
**Learning rate of Discriminator** & 0.0001 \\ \hline \hline \end{tabular}
\end{table} 
Table 2: Parameter configuration of the CGAN network.