# Generative Adversarial Networks in Retinal Image Classification
## 3 The Method  
We present the method we designed to (i) generate images related to the retina and (ii) discriminate these fake images from images obtained from real-world retina images. The first step of the proposed method is the design and the adoption of the DCGAN to generate fake images related to the retina: this step is shown in Figure 1.  
In every GAN, at least one generator (Generator in Figure 1) and one discriminator (Discriminator in Figure 1) are present. As the generator and discriminator engage in a competitive process, the generator enhances its capacity to generate images that closely align with the distribution of the training data, utilizing feedback received from the discriminator. Thus, training a GAN is a crucial process that involves two neural networks, a generator (Generator in Figure 1) and a discriminator (Discriminator in Figure 1), competing against each other to improve their performance. In the following we provide an overview of the GAN training process:  
1. Initialization: Initially, the generator and discriminator networks are initialized with random weights. 2. Objective: The objective of the generator is to create synthetic data that is indistinguishable from real data, while the discriminator's objective is to correctly classify real data as real and generated data as fake. 3. Training Loop: 1. 1. 1. 1. Evaluation: After training, the generator can be used to produce synthetic data and the discriminator can be used to assess the authenticity of data samples. The DCGAN architecture introduced the incorporation of CNNs in both the discriminator and generator components. DCGAN offers a set of architectural guidelines that aim to improve the stability of the training process [14]:  
1. Replace pooling layers with strided convolutions in the discriminator and fractional-strided convolutions in the generator;
2. Incorporate batch normalization (batchnorm) in both the generator and discriminator;
3. Avoid fully connected hidden layers in deeper architectures;
4. Apply ReLU activation for all generator layers, except the output layer which employs Tanh activation;
5. Employ LeakyReLU activation in all discriminator layers. Strided convolutions refer to convolutional layers with a stride of 2, which are utilized in the discriminator for downsampling. On the other hand, fractional-strided convolutions, or Conv2 DTranspose layers, employ a stride of 2 for upsampling in the generator. In the context of DCGAN, batch normalization (batchnorm) is leveraged in both the generator and discriminator to enhance the stability of GAN training. Batchnorm normalizes the input layer by adjusting it to have a mean of zero and a variance of one. Typically, it is applied after the hidden layer and before the activation layer. The DCGAN architecture commonly employs four activation functions: sigmoid, tanh, ReLU, and LeakyReLU. Sigmoid function is utilized in the final layer of the DCGAN discriminator since it performs binary classification, producing an output of 0 (indicating fake) or 1 (indicating real). Tanh function is similar to sigmoid but scales the output to the range \([-1,1]\), making it suitable for the generator's last layer. Consequently, input data for training should be preprocessed to fit within the range of \([-1,1]\). ReLU (rectified linear activation) returns 0 for negative input values and the input value for non-negative inputs. In the DCGAN generator, ReLU is used for all layers except the output layer, which employs tanh. LeakyReLU is an extension of ReLU that introduces a small negative slope (controlled by a constant alpha) for negative input values. The recommended value for the slope (alpha) in DCGAN is 0.2. LeakyReLU activation is used in all layers of the discriminator, except for the last layer. The training process involves simultaneous training of both the generator and discriminator networks. The initial step involves data preparation for training the DCGAN.