# Self-Improving Generative Artificial Neural Network for Pseudorehearsal Incremental Class Learning
## 3 Proposal  
Our proposed neural network system, \"_Self-Improving Generative Artificial Neural Network_\" (SIGANN) (Available at [[https://github.com/dmelladoc/SIGANN](https://github.com/dmelladoc/SIGANN)]([https://github.com/dmelladoc/SIGANN](https://github.com/dmelladoc/SIGANN))), consists of 3 major sub-structures: A classifier, a generator and a novelty detector working in conjunction in order to learn and identify unknown data from a starting subset of a dataset, and training itself to learn new classes. For both the classifier and generator, we implemented a semi-supervised AAE model, based on the structure presented in [36] for semi-supervised training, and added the novelty detector.  
To incrementally train SIGANN, we train the classifier and generator at the same time, as in a standard AAE model; then fit the mean activations for each initial class on our novelty detector by inferring from the training set at the end of the training process. On inference, the novelty detector checks if new information belongs to a new class. If so, it temporarily stores the sample for future training, as the generator starts sampling a set of previous knowledge representations for the next training step. This set is used in conjunction with all newly detected samples, and the categorical output layer from the classifier is expanded to add the new class. Finally, the network is trained for a defined number of epochs, learning new information without loss of previous knowledge.  
The complete operation of our method is presented in Algorithm 1 and the structure of the semi-supervised AAE model used in conjunction with the novelty detector is shown in Figure 1. In the following subsections we explain each module.  
Figure 1: SIGANN model, using a Semi-supervised adversarial autoencoder structure.  
```
1:Set of initial data \(X_{train}\) and output classes \(y_{train}\in\{1,\dots,C\}\)
2:Uniform Distribution Generator \(Z=\mathcal{U}(-\sqrt{3},\sqrt{3})\) of sample length \(n\)
3:Train Adversarial Autoencoder: \(\hat{X},\hat{z},\hat{y}=AAE(X_{train},y_{train},Z)\)
4:for c=1,..., C do
5: Get Mean Activation of trained samples \(\mu_{c}=mean(\hat{y}\in c)\)
6: Compute distance of each output of class \(c\): \(d_{c}=|\hat{y}_{c}-\mu_{c}|\)
7: Fit \(d_{c}\) to Weibull distribution \(\mathcal{W}_{c}\) and get parameters \(\rho_{c}=(\kappa_{c},\lambda_{c})\)
8:while Receiving new data \(X_{new}\)do
9: Evaluate samples of data \(X_{new}\) on inference: \(\hat{y}=AAE_{enc}(X_{new})\)
10: Revise OpenMax activation of data: \(y^{\star}=\text{OpenMax}(\hat{y},\rho,\epsilon=0.95)\)
11:if\(y^{\star}=C+1\)then
12: Store input \(X^{\star}\) and output \(y^{\star}\)
13: Generate samples \(X_{gen}\) from classes \(y_{gen}\in\{1,\dots,C\}\)
14: Evaluate generated samples: \(\hat{y}_{gen}=AAE_{enc}(X_{gen})\)
15:if\(\hat{y}_{gen}=y_{gen}\) and \(P(\hat{y}_{gen}=c|X)>0.9\)then
16: Store \(X_{gen},y_{gen}\)
17:else
18: Discard \(X_{gen},y_{gen}\) and Re-generate
19: Update Number of classes: \(C=C+1\)
20: Re-train Adversarial Autoencoder with new and generated data: \(\hat{X},\hat{z},\hat{y}=AAE(X_{gen}+X^{\star},y_{gen}+y^{\star},Z)\)
21: Fit new class and samples to Weibull distribution
22:
```  
**Algorithm 1** SIGANN Model training.