# Self-Improving Generative Artificial Neural Network for Pseudorehearsal Incremental Class Learning
## 3 Proposal
### Module 3: Novelty Detector  
The novelty detector consists of the joint action of the Meta-Recognition and OpenMax algorithms. After training the AAE for a defined number of classes, we evaluate data to classify it. Generally, if a sample is from a new, unknown class, the classifier should not be able to identify it as such. Therefore, we replace the activation function of the classifier in the inference stage with an OpenMax function [42] for novelty detection. This activation function was initially designed as a replacement for SoftMax activation in open-set recognition networks. By using the _Meta-Recognition_ algorithm presented by [44] as a basis, this function fits data into a Weibull distribution to obtain the probability of each sample being on a high or low tail of the set, selecting the \(\eta\) values from the tail of the distribution. The reason for selecting the Weibull distribution is due to its versatility, where both the shape \(\kappa\) and the scale \(\lambda\) parameter, affect the shape of the probability-density-function curve, the reliability, and the failure rate. Moreover, the Weibull distribution becomes suitable when the conditions for strict randomness of the exponential distribution are not satisfied. This distribution is widely used in reliability and life data analysis (For more details see [45]). The fitting of the Weibull distribution is done using the Euclidean distance between each training sample's output activation logit, or the output from the last layer of a classifier before applying the SoftMax activation function; and the mean activation of all samples from class \(c\), obtaining the scale and shape parameters of the Weibull distribution for class \(c\). By defining \(\rho_{c}\) as these parameters, we use the Weibull CDF on the Euclidean distance between the mean activation logits of class \(\mu_{c}\) from the training set and the logits obtained on inference. We obtain this value for the top \(\alpha\) classes, obtaining weights \(\omega(x)\) for each class of the logit output. The sum difference between the original and corrected logits gives us the \"unknown logit\" which is then evaluated using the SoftMax Equation (4). \[P(z)_{j}=\frac{e^{z_{j}}}{\sum_{k=1}^{K}e^{z_{k}}}\quad j=1,\ldots,K \tag{4}\]  
We then reject the original predicted class and define element \(X\) as being from an unknown class if the probability of belonging to a known class is lower than \(\epsilon<95\%\) or if the maximumprobability belongs to the unknown class. This value of \(\epsilon\) was defined as such, as it allowed for the best performance for detection. This allows the network to measure the probability of a fooling or unknown image to be misclassified, by rejecting the probability that this data is part of a known set, allowing us to recognize if the input data is unknown, in order to store it as new information to further train the network with new data. The Meta-Recognition and OpenMax algorithms are presented in Algorithm 2 and in Algorithm 3, respectively. ```
0: Logits from the final layer from each class \(\mathbf{v}_{c}(x)=v_{1}(x)\dots v_{N}(x)\) from training phase;
0: Number of extreme values to fit \(\eta\)
1:for\(c=1\dots N\)do
2: Compute Mean Activation :\(\mu_{c}=mean\left(\mathbf{v}_{c}\right)\)
3: Fit to Weibull :\(\rho_{c}=(\kappa_{c},\lambda_{c})=\text{FitHigh}\left(\parallel\mathbf{v}_{c}- \mu_{c}\parallel,\eta\right)\)
4:return\(\mu_{c}\) and \(\rho_{c}\) for each class
```  
**Algorithm 2** Meta-Recognition Algorithm. ```
0: Logits from the final layer from each class \(\mathbf{v}_{c}(x)=v_{1}(x)\dots v_{C}(x)\) from evaluation; \(\alpha\) number of top classes to revise.