# Generative Adversarial Networks in Retinal Image Classification
## 3 The Method
These images have dimensions of 28 \(\times\) 28 \(\times\) 1, which are passed as arguments (width, height, and depth) to the function. In constructing the discriminator model, we employ Conv2D, BatchNormalization, and LeakyReLU layers twice for downsampling. Then, we utilize the Flatten layer and apply dropout. Finally, in the last layer, we use the sigmoid activation function to produce a single value for binary classification. The discriminator model comprises a total of 213,633 parameters, out of which 213,249 parameters are trainable, while 384 parameters are non-trainable. The computation of loss plays a crucial role in training both the generator and discriminator models in DCGAN or any GAN architecture. Specifically, for the considered DCGAN, we employ the modified minimax loss, utilizing the binary cross-entropy (BCE) loss function. There are two separate losses that we need to calculate: one for the discriminator and another for the generator. In terms of the discriminator loss, since the discriminator receives two groups of images (real and fake), we compute the loss for each group separately and then combine them to obtain the overall discriminator loss:  
\[TotalDloss=loss\_from\_real\_images+loss\_from\_fake\_images\]  
With regard to the generator loss, rather than training G to minimize \(log(1-D(G(z))\), i.e., the probability that D classifies fake images as fake, we consider training G with the aim of maximizing \(logD(G(z))\), i.e., the probability that D incorrectly classifies the fake images as real: for this we exploit the modified minimax loss. For both the generator and discriminator models, we utilize the Adam optimizer with a learning rate of 0.0002. As mentioned previously, we employ the binary cross-entropy loss function for both the discriminator and generator. The training process involves training the models for a total of 50 epochs. \begin{table}
\begin{tabular}{c c c c} \hline \hline \# & **Layer (Type)** & **Output Shape** & **Param \#** \\ \hline
1 & dense (Dense) & (None, 12,544) & 1,266,944 \\ \hline
2 &
\begin{tabular}{c} batch\_normalization \\ (BatchNormalization) \\ \end{tabular} & (None, 12,544) & 50,176 \\ \hline
3 & re\_lu (ReLU) & (None, 12,544) & 0 \\ \hline
4 & reshape (Reshape) & (None, 7, 7, 256) & 0 \\ \hline
5 &
\begin{tabular}{c} conv2d\_transpose \\ (Conv2 DTranspose) \\ \end{tabular} & (None, 14, 14, 128) & 819,328 \\ \hline
6 &
\begin{tabular}{c} batch\_normalization\_1 \\ (BatchNormalization) \\ \end{tabular} & (None, 14, 14, 128) & 512 \\ \hline
7 & re\_lu\_1 (ReLU) & (None, 14, 14, 128) & 0 \\ \hline
8 &
\begin{tabular}{c} conv2d\_transpose\_1 \\ (Conv2 DTranspose) \\ \end{tabular} & (None, 28, 28, 64) & 204,864 \\ \hline
9 &
\begin{tabular}{c} batch\_normalization\_2 \\ (BatchNormalization) \\ \end{tabular} & (None, 28, 28, 64) & 256 \\ \hline
10 & re\_lu\_2 (ReLU) & (None, 28, 28, 64) & 0 \\ \hline
11 & conv2d (Conv2D) & (None, 28, 28, 1) & 1601 \\ \hline \hline \end{tabular}
\end{table} 
Table 1: Model generator. \begin{table}
\begin{tabular}{c c c} \hline \hline \# & **Layer (Type)** & **Output Shape** & **Param \#** \\ \hline
1 & conv2d\_1 (Conv2D) & (None, 14, 14, 64) & 1664 \\ \hline
2 &
\begin{tabular}{c} batch\_normalization\_3 \\ (BatchNormalization) \\ \end{tabular} & (None, 14, 14, 64) & 256 \\ \hline
3 &
\begin{tabular}{c} leaky\_re\_lu \\ (LeakyReLU) \\ \end{tabular} & (None, 14, 14, 64) & 0 \\ \hline
4 & conv2d\_2 (Conv2D) & (None, 7, 7, 128) & 204,928 \\ \hline
5 &
\begin{tabular}{c} batch\_normalization\_4 \\ (BatchNormalization) \\ \end{tabular} & (None, 7, 7, 128) & 512 \\ \hline
6 &
\begin{tabular}{c} leaky\_re\_lu\_1 \\ (LeakyReLU) \\ \end{tabular} & (None, 7, 7, 128) & 0 \\ \hline
7 & flatten (Flatten) & (None, 6272) & 0 \\ \hline
8 & dropout (Dropout) & (None, 6272) & 0 \\ \hline
9 & dense\_1 (Dense) & (None, 1) & 6273 \\ \hline \hline \end{tabular}
\end{table} 
Table 2: Model discriminator.