# An Improved Approach to Detection of Rice Leaf Disease with GAN-Based Data Augmentation Pipeline
## 3 Methodology and Tools
### Gan  
GAN is a generative model capable of creating high dimensional perceptual plausible objects similar in characteristics to its training data [45]. It employs two neural networks, a generator and a discriminator pitting them against each other to create new objects. The generator generates a high-dimensional perceptual object, while the discriminator distinguishes real images from the datasets or fake items created by the generator. As part of an adversarial network, training is set up as an adversarial game between two players, and training proceeds in three steps for each round and iterates as many rounds as possible [46]. The phases are explained below while Figure 4 shows the graphical illustration of the whole process. Figure 4: GAN Generator. First-phase: the generator pulls some relatively small number of dimensions from a simple distribution, which is a latent noise vector, such as a multi-dimensional uniform distribution from 0 to 1 or 1 to \(\leavevmode\
obreak\ -1\), which is used as an input to the generator that produces a sample; then, the sample is taken which is passed to the discriminator. And so the network back propagates from the loss through the output of the discriminator, but because this is a generator training step, the discriminator weight values are held and fixed (no updates). Then, the network computes the derivatives with respect to the inputs. Weights are applied to the generator such that it improves image generation. Figure 4 below illustrates the process. Intuitively, noise \((z)\) is passed to a Generator neural network \((G)\) that provides an output of \(G(z)\) with a cost function (see Equation (7)). \[\frac{1}{m}\sum_{i=1}^{m}\log\Bigl{(}1-D\Bigl{(}G\Bigl{(}z^{i}\Bigr{)}\Bigr{)}\Bigr{)} \tag{7}\]  
Second-phase: the generator creates some number of noise vectors from the latent space, then they are fed into the generator to produce some number of synthetic samples. The samples are then passed to the discriminator which distinguishes real from fake with the same notion of classification loss except that instead of trying to fool the discriminator the loss is expected to be high i.e., the model is doing a bad job if it cannot tell real from fake. The stochastic gradient descent is applied and the neural network is back-propagated to the discriminator with the weights being updated in the direction of better able to distinguish real from fake and then it stops without updating the generator Figure 5 below illustrates the process. Intuitively, the discriminator is a classifier that trains to classify fake input when \((P=0)\) with a denotation of output as \(D(G(z))\) and real input when \((P=1)\) with a denotation of output as \(D(x)\), with a cost function (see Equation (8)). \[\frac{1}{m}\sum_{i=1}^{m}\Bigl{[}\log D\Bigl{(}x^{(i)}\Bigr{)}+\log\Bigl{(}1-D \Bigl{(}G\Bigl{(}z^{(i)}\Bigr{)}\Bigr{)}\Bigr{)}\Bigr{]} \tag{8}\]  
Third-phase: samples are pulled from real images and then passed to the discriminator to make sure the discriminator is able to tell that real images are real, rather than just fake images are fake, this phase marks an end to a training round process. Hence, the whole phases are repeated over and over until eventually, the generator gets to a point where the discriminator really cannot tell real from fake at which point the training session stops. That means the generator can produce high-dimensional perceptual plausible objects. Therefore,  
Figure 5: GAN Discriminator. the final cost function is (see Equation (9)). See (Figures 6 and 7) for the GAN and the intuitive GAN process, respectively. \[\min_{G}\min_{D}V(D,G)=\mathbb{E}_{x\sim Pdata(x)}[\log D(x)]+\mathbb{E}_{z\sim P _{z}(z)}[\log(1-D(G(z)))] \tag{9}\]  
The following algorithm shows a summary implementation of the generative adversarial nets proposed in 2014 by [PERSON] et al. (2014). Algorithm 2 Mini-batch stochastic gradient descent training GAN. The number of steps to apply to the discriminator, \(k\), is a hyper-parameter and \(k=1\). Figure 6: GAN process.