# Modular Dynamic Neural Network: A Continual Learning Architecture
## 3 Modular Dynamic Neural Network
### Modular Dynamic Training  
The process for the addition of a new class starts (as usual) with the network being fed a set of data samples along with a label. With this, the network will (i) process the data samples, (ii) decide where best to place the new _endpoint_, (iii) make any necessary adjustments to the existing modules, and (iv) train the necessary classifiers so that when the network is presented with data from the same class, in the future, it can identify them. Following the scheme presented in Figure 3, the right side of Figure 5 shows an example of how the network changes as classes are added over time. Here, it is shown how it can classify three classes (shown in Figure 3) (A--rose, B--cat, and C--dog), where B and C are grouped together, and then another four classes are added sequentially(D--tree, E--fish, F--bush, and G--frog), making the network capable of classifying a total, in this example, of seven classes. The positions in which new modules are placed within the network are not random. There are several procedures behind the calculation of the optimal position for a new module (some of which can be recursive). Learning a new class essentially means that the network can distinguish the new class from the ones which were previously learned. The most main goal of this class placement process is to avoid conflict or confusion between classes. In avoiding confusion between classes, the goal is to (i) group them by their similarities and then (ii) focus on their differences. This notion of grouping classes by similarities is referring to the parallel placement of modules within _nodes_, as shown in Figure 5, where, among other examples, in the network's initial state, class B is grouped in a node with class C.  
Figure 5: The right side shows the network growing progressively as modules are added and grouped. The modules highlighted in green are new and the modules highlighted in blue are pre-existing ones that needed to be retrained either to reduce confusion or to ensure that the parent _nodes_ became aware of the new module. The left side describes the steps taken for the addition of each new module (see text for details). The binary classifiers are used to see if any existing classes share any resemblance with the class being added. The procedure for checking if classes are similar is relatively similar to the classification process, but instead of just searching for the most similar class, here, the goal is to search for any classes that could be partially similar, i.e., it looks for \"somewhere\" to place the new class. Upon entering a _node_, there are \(n\) possible paths to follow, which can be a mix of _endpoints_ and/or _nodes_. The idea here is that any _node_ or _endpoint_ binary classifiers that, without any alteration, might accidentally mistake the new class for their own should be grouped with that new class and retrained so that, in future, when presented with samples of the new class, they do not repeat the same mistake. To achieve this, it is necessary to first verify which _nodes_ and or _endpoints_ share any resemblance with the new class. Therefore, the first step here is to classify all the data samples (extracted feature values) of the new class with each of the binary classifiers in the current _node_ and then use these results to decide how best to proceed. After obtaining all the current _node_'s classifier results from all the new data samples, the next step is to calculate the average confidence per classifier, which returns a single value for each _node_/_endpoint_, representing the likelihood of mistaking the new class with the existing class (or classes if it represents a _node_). It should be noted that the use of the average for this task was a natural choice, but in the future, other solutions will be investigated in order to attempt to achieve even better discrimination between classes. Next, the obtained average values are analyzed to see which classes are the most similar to the new one.