# A Framework for Frugal Supervised Learning with Incremental Neural Networks
## 2 Materials and Methods
### Learning and Control  
#### 2.3.1 Learning Algorithm  
Let \(S=\{(\mathbf{x}_{1},y_{1}),\ldots,(\mathbf{x}_{n},y_{n})\}\) be a dataset with \(\mathbf{x}\in\mathbb{R}^{m}\) and \(y\in\{k_{1},\ldots,k_{c}\}\) a class label. Samples are successively presented to the INN with their class label. Each time the algorithm meets a new class, it creates a new prototype with the first sample that was met with the class. For each \(\mathbf{x}\), the algorithm searches the closest prototype \(P_{best}\) with respect to a similarity measure \(\delta\). If \(Class(\mathbf{x})\
eq Class(P_{best})\), a new prototype is created. Otherwise, two conditions are checked:  
* \(\delta(P_{best},\ \mathbf{x})\leq s_{inf}\), with \(s_{inf}\in\mathbb{R}^{+}\) the influence threshold. In this case, the sample is said to be under the influence of its best prototype.
* \(\delta(P_{best},\ \mathbf{x})-\delta(P_{second},\mathbf{x})>s_{conf}\), with \(s_{conf}\in\mathbb{R}^{+}\) the confusion threshold and \(P_{second}\) the second-best prototype of \(\mathbf{x}\) such as \(Class(P_{second})\
eq Class(P_{best})\). In this case, it is said that there is no confusion.  
In one of the conditions is not met, then a new prototype is created. Otherwise, the weights of the best prototype are updated to bring it closer to the passing sample. The described algorithm is a _winner-takes-all_ algorithm, as only the winning prototype is activated and updated. Alternatives exist where prototypes in the surroundings of the winning prototype are also updated. A flowchart of the learning algorithm is proposed in Figure 2.  
Figure 2: Flowchart for the learning algorithm. Each sample is processed once. At each step, a prototype can either be created or updated. When all samples have been processed, the classifier is composed of all of the \(P_{best}\) prototypes.  
Algorithm  
The implemented learning algorithm (Algorithm 1) is proposed as follows:  
```
1.  Feed the classifier with a sample \(\mathbf{x}\) and its label \(y\)
2.  Search for \(P_{best}\) so that \(\delta(P_{best},\mathbf{x})\) is minimal
3.  Search for \(P_{second}\) so that \(\delta(P_{second},\mathbf{x})\) is minimal and that \(Class(P_{second})\
eq Class(P_{best})\)
4.  If: \[\left\{\begin{array}{l}\delta(P_{best},\ \mathbf{x})\leq s_{inf}\\ \delta(P_{best},\ \mathbf{x})-\delta(P_{second},\mathbf{x})>s_{conf}\\ Class(P_{best})=Class(\mathbf{x})\end{array}\right.\] Then update \(P_{best}\): \[\forall i\in\{1,\dots,m\},\ w_{i}\gets w_{i}+\alpha*(x_{i}-w_{i}),\text{ with }P_{best}=\{w_{1},\dots,w_{m}\}\text{ and }\mathbf{x}=\{x_{1},\dots,x_{m}\}\]
5.  Else create a new prototype: \(\forall i\in\{1,\dots,m\},\ w_{1}^{\prime}\gets x_{i}\text{ with }P=\{w_{1}^{\prime},\dots,w_{m}^{\prime}\}\) \(Class(P)\gets Class(\mathbf{x})\)
```  
**Algorithm 1**Learning algorithm  
Each time the algorithm encounters a new class, it creates a new prototype with the first sample presented for this class. Once all the patterns have been presented, the model is composed of all the prototypes learned by the algorithm and can be either used in generalization or relearned (by presenting it with other patterns).  
The INN has three control hyperparameters: the influence threshold \(s_{inf}\), the confusion threshold \(s_{conf}\), and the update coefficient \(\alpha\), which controls how close \(P_{best}\) will be brought to the passing \(\mathbf{x}\). These control hyperparameters address the stability-plasticity dilemma, i.e., considering new samples while not forgetting old ones.