# Generative Enhancement of 3D Image Classifiers
## 5 Models and Methods
### 3D Conditional Generative Adversarial Network
While this was also found to improve the accuracy of the network, the benefit was smaller when compared to the architecture using the extended ground truth vector. The idea behind this methodology is that the generator assists the discriminator-classifier to learn to utilize realistic features that are discovered and propagated from the generator network. Therefore, it is necessary to make sure that the features learned by the generator are transferrable to the real samples from the dataset. \[\mathbf{y}^{*(i)}= \begin{cases}[0,\mathbf{y}^{(i)}]&real\\ &[1,0,0,\dots,0]&fake\end{cases}  \tag{3}\]  
For real samples, a single zero is prepended to the class label from the dataset. In the case of generated samples, the target is a \(C+1\) long vector, with the first element (the \"fake\" class) set to one and the rest to zero. Figure 4: Architecture of the whole 3D conditional generative adversarial network classifier. Generator and discriminator are connected sequentially. The discriminator is fed both real (green) and fake (orange) examples during training. Figure 3: Architecture of the generator network. Input vector \(z\) consisting of a gaussian noise vector and a condition (class) vector is expanded in a fully connected stage and then is deconvoluted three times with batch normalization and ReLU activation function in between. For the generator, the loss function is chosen to minimize the \"fake\" output of the discriminator as well as achieve the class output according to the conditioning vector provided to generate the sample. The generator loss function formula is essentially identical to the discriminator loss with a real example. The only difference is the true class vector, which is created randomly, instead of sampling it from the dataset, and used both as generator input (concatenated with noise vector) and as the target vector when compared with the discriminator output. An alternative loss function we experimented with is a modified Wasserstein loss function [46] shown in (4) and (5). \[ \begin{split} L_{D}^{w}=&\frac{1}{M}\sum_{i=1}^{M}D( \mathbf{x}^{(i)})-\frac{1}{M}\sum_{i=1}^{M}D(G(\mathbf{z}^{(i)}))-\\ &-\gamma\sum_{i=1}^{M}\sum_{j=1}^{C}\mathbf{y}_{j}^{(i)}\log( \mathbf{\hat{y}}_{j}^{(i)})\end{split}  \tag{4}\]  
\[L_{G}^{w}=\frac{1}{M}\sum_{i=1}^{M}D(G(\mathbf{z}^{(i)}))-\gamma\sum_{i=1}^{M} \sum_{j=1}^{C}\mathbf{y}_{j}^{(i)}\log(\mathbf{\hat{y}}_{j}^{(i)}) \tag{5}\]  
In these formulas, \(M\) stands for the number of samples (in a minibatch or total), \(C\) is the number of classes in the dataset, \(\mathbf{x}\) is a vector of training data samples, \(\mathbf{y}\) is a vector of one-hot encoded training data labels, \(\mathbf{\hat{y}}\) is the classifier prediction, and \(\gamma\) is a hyperparameter that is used to tune the weight of the classification loss term during training. \(D\) is the discriminator and \(G\) the generator function. The output of the discriminator function referred to as \(D\) is the logit value of the \"fake\" class output of the discriminator. This formula further decouples the discrimination and classification objectives and allows for more competition, which can be tweaked by the \(\gamma\) parameter. The ADAM optimizer [47] is used to train both generator and discriminator.