Abstract
Convolutional neural networks (CNNs) are inspired by the visual cortex of the human brain, which is made of connected regions. When a region receives an input, it extracts meaningful information and passes it on to its neighbor. A CNN copies this layered structure with several layers that extract features. In neuroscience, it is believed that the brain’s cognitive abilities come from its modular structure, meaning that it is built from separate modules.
This work proposes a framework that adds modularity to a CNN that has already been trained. The input domain of the CNN is split into functional modules, each made of different pathways, using a new method called Confusion Matrix driven Centroid Based Clustering (CMCBC). CMCBC is an unsupervised clustering technique based on the k-Medoid algorithm. It uses the confusion matrix to find how similar each pair of classes is, and it takes a medoid for every cluster instead of using a distance function.
The framework was tested on two standard datasets, MNIST and CIFAR10. On MNIST, the modular CNN reached 98.51% accuracy, compared with 99.39% for the baseline, while saving 53% of the multiplications in the network, which greatly reduces its complexity. On CIFAR10, the model reached 78.01% accuracy, 6% below the 84% baseline. After the network was retrained to align the weights further, it outperformed the baseline by 2.78% and reached 86.78% accuracy.
Introduction
The structure of a CNN is inspired by the visual cortex of the brain. In the brain, different connected regions each extract useful information from what they receive and pass it to the next region, and a CNN imitates this with several layers that extract features one after another. Neuroscientists also believe that the modular structure of the human brain, which is made of separate but cooperating parts, is the source of its cognitive abilities.
This work looks at how to bring this modular idea into an image classification network. It addresses three problems: how to split the input domain into parts, how to control the way information is routed through the network, and how to bring the modules together again.
Proposed Method
The method starts from a CNN that has already been trained to classify images. The confusion matrix of this network records, for each class, how often the network predicts every class. The large numbers on the diagonal are correct predictions, and the numbers off the diagonal show which classes are confused with each other. For the MNIST digits, Figure 1 shows the counts and Figure 2 shows the same matrix as fractions. A distance matrix is also shown in Figure 3.
The proposed CMCBC method uses this information to group similar classes into clusters. The clusters form the modules of the network. The clusters, a mask, the weights of the trained model and the training data then go into a step of retraining and runtime pruning, which gives the final pruned model (Figure 4). In this step, a pruning module sits between two layers of the network and sets some of the feature maps to zero, so that different pathways run through the network (Figure 5). The calculation for each layer is shown in Figure 6.
Figure 7 shows the structure of the network used for MNIST. It includes the runtime pruning layers (rt_pruning1 and rt_pruning2) between the convolutional layers.
Results and Discussion
The framework was tested on MNIST, a set of handwritten digits, and on CIFAR10, a set of small color pictures of ten kinds of objects. On MNIST, the modular network saved 53% of the multiplications of the original network and lost less than one percentage point of accuracy (98.51% compared with 99.39%). Figure 8 compares the accuracy of the modular network under different settings.
CIFAR10 is a harder task. Without retraining, the modular network reached 78.01% accuracy, 6% below the baseline of 84%. After retraining to align the weights further, it reached 86.78%, which is 2.78% better than the baseline. The confusion matrix for CIFAR10 (Figure 9) shows which classes are mixed up most often: cats and dogs are the clearest example. Figure 10 shows the distance matrix and Figure 11 the accuracy under different settings.
Author Contributions
- Salman Ahmad: study design of the neural network architecture and its implementation.
- Shahab U. Ansari: supervision, writing the article and article review.
- Usman Haider: study design of the neural network architecture and writing the article.
- Kamran Javed: helped in developing the neural network architecture and article review.
- Jalees Ur Rahman: study design and article review.
- Sajid Anwar: supervision, writing the article and article review.
Funding
No funds or grants were received.
Data Availability
The data used in this paper is publicly available: MNIST and CIFAR10.
Competing Interests
The authors declare no conflict of interest.