Impact of Disentanglement on Pruning Neural Networks
Deploying deep learning neural networks on edge devices, to accomplish task
specific objectives in the real-world, requires a reduction in their memory
footprint, power consumption, and latency. This can be realized via efficient
model compression. Disentangled latent representations produced by variational
autoencoder (VAE) networks are a promising approach for achieving model
compression because they mainly retain task-specific information, discarding
useless information for the task at hand. We make use of the Beta-VAE framework
combined with a standard criterion for pruning to investigate the impact of
forcing the network to learn disentangled representations on the pruning
process for the task of classification. In particular, we perform experiments
on MNIST and CIFAR10 datasets, examine disentanglement challenges, and propose
a path forward for future works.
Carl Shneider, Peyman Rostami, Anis Kacem, Nilotpal Sinha, Abd El Rahman Shabayek, Djamila Aouada
# Impact of Disentanglement on Pruning Neural Networks

###### Abstract

Deploying deep learning neural networks on edge devices, to accomplish task specific objectives in the real-world, requires a reduction in their memory footprint, power consumption, and latency. This can be realized via efficient model compression. Disentangled latent representations produced by variational autoencoder (VAE) networks are a promising approach for achieving model compression because they mainly retain task-specific information, discarding useless information for the task at hand. We make use of the Beta-VAE framework combined with a standard criterion for pruning to investigate the impact of forcing the network to learn disentangled representations on the pruning process for the task of classification. In particular, we perform experiments on MNIST and CIFAR10 datasets, examine disentanglement challenges, and propose a path forward for future works.

## I Introduction

Advances in deep learning have accelerated the state-of-the-art in computational sensing across research domains, finding wide application in tasks encompassing object detection [1, 2], pose estimation [3, 4, 5], classification [6], reconstruction [7], segmentation [8, 9], time series prediction [10, 11], and 3D modelling [12, 13]. Surpassing a top performing deep neural network (DNN) on image-level and pixel-level tasks on a benchmark dataset often comes at the cost of an increased number of model parameters, floating point operations (FLOPS), volume of training data, and graphical processing unit (GPU) resources. This trend poses a challenge for the deployment of these pre-trained DL models for real-time inference on resource constrained edge devices, with low computing power and memory, where a reduction in the model's memory footprint (i.e., RAM and storage requirements), power consumption, and latency, is essential. With the objective of reducing the model size of an existing pre-trained base model, while maintaining a comparable level of metric performance (e.g., accuracy, precision, recall, etc.) to that of the original model, different techniques of neural network compression have been proposed. These include quantization [14], knowledge distillation [15], low-rank matrix factorization [16], and pruning [17].

Quantization compresses the original network by reducing the number of bits required to represent each weight [18]. This reduces the range of data values while retaining most of the information for comparable model accuracy but under certain conditions can lead to a drop in performance. In knowledge distillation, the knowledge from a pre-trained, larger and more complex model, known as the teacher model, is transferred to a smaller network, known as the student network. Limitations of this approach arise from the side of the student network whose architecture needs to be designed and usually remains fixed. Low-rank factorization can be applied to both convolutional and fully connected layers. Applying tensor decomposition to the convolutional layers makes the inference process faster while the factorization of the matrices in the dense layer makes the model's memory footprint lighter. A limitation of this approach is that the proper factorization and rank selection process is challenging to implement in practice and is computationally more intensive. Pruning is used for network sparsification by removing redundant and non-essential parameters, contributing to reduced model size (i.e., smaller memory footprint) and improved latency (i.e., lower bandwidth). Pruning can produce either unstructured or structured network sparsification patterns. Unstructured pruning involves setting weight values to zero, as in convolutional parameters in a convolutional neural network (CNN) or connections between neurons in a fully convolutional neural network (FCNN). A drawback of unstructured pruning is that most machine learning frameworks and hardware cannot accelerate sparse matrices' computation. Structured pruning includes kernel/channel pruning, filter pruning (i.e., neurons in FCNNs), and layer pruning. Although a more structured sparsification pattern leads to an accelerated neural network, the accuracy drops [18]. Pruning has proven successful at maintaining the level of performance of the original pre-trained network while discarding superfluous information contained in the specified network structures described above. Nevertheless, given a specific task, the challenge of selecting which parts of the network to prune remains open, with several criteria proposed to rank the relative importance of the respective components. These criteria include pruning the weight magnitude or the gradient magnitude, and whether to prune globally or locally.

Neural network compression can be assisted by disentangling latent representations because a representation which is disentangled for a particular dataset is one which is sparse over the transformations present in that data [19]. Disentangled representations are representations that capture the underlying factors of variation that generated the data, especially those explanatory factors that are relevant to the task. Disentangling as many factors as possible while discarding as little information about the data as is practical for the task at hand, is a robust approach to feature learning [20]. In this work, instead of proposing a new pruning criterion, we use a standard low-magnitude criterion for local, unstructured pruning and investigate the impact of enforcing the network to learn disentangled representations on the pruning process. The intuition here is that if the network is learning disentangled representations then this would be reflected by the neural network itself which would make pruning more effective. Specifically, we make use of the Beta-VAE [21] framework combined with the aforementioned standard criterion for pruning to investigate the impact of forcing the network to learn disentangled representations on the pruning process for the task of classification. Our contributions are two-fold:

* we provide preliminary analysis on the impact of disentanglement on pruning neural networks for the task of classification,
* we perform experiments on MNIST and CIFAR10 datasets for this objective.

## II Proposed Method

Consider a dataset \(\mathcal{D}=\{(x_{i},y_{i})\}_{i=1}^{N}\), \(x\) is the 2D input data and \(y\) is the corresponding label. We use the Beta-VAE framework to enforce a disentangled latent representation [21] given by

\[\begin{split}\mathcal{L}_{\text{Beta-VAE}}(\theta,\phi;x,z,\beta)=& -\beta\ \mathcal{D}_{KL}\left(q_{\phi}\left(z|x\right)\parallel p\left(z\right)\right) \\ &+\mathbb{E}_{q_{\phi}\left(z|x\right)}[\log p_{\theta}\left(x|z \right)]\end{split} \tag{1}\]

where \(p(z)\) is a prior distribution of the latent variables \(z\), \(p_{\theta}(x|z)\) is a conditional probability of \(x\) that is parametrized by a neural
network \(\theta\), and \(q_{\phi}(z|x)\) approximates the posterior with neural network parameters \(\phi\).

\[\mathcal{L}_{\text{CE}}(y)=-\sum_{i=1}^{N}y_{i}\log y_{i}^{\prime} \tag{2}\]

\[\mathcal{L}_{\text{Beta-VAE-Classif}}(\theta,\phi;x,y,z,\beta)=\mathcal{L}_{ \text{Beta-VAE}}+\mathcal{L}_{\text{CE}} \tag{3}\]

The Beta-VAE objective in Eq. 1 consists of a Kullback-Leibler (KL) divergence term (encoder part) and a pixel-wise reconstruction loss (decoder part). The penalty \(\beta\) imposes a limit on the capacity of latent information and the degree to which statistically independent latent factors are learned. Our training strategy, first involves appending a classifier head to the Beta-VAE during training as shown in Fig. 1 and augmenting the loss function in Eq. 1 with the addition of sparse categorical cross-entropy loss term given by Eq. 2 in Eq. 3. In Eq. 2, \(y^{\prime}\) is the predicted label. During inference, the reconstruction head is removed, as well as its corresponding loss term, leaving the pre-trained encoder and classification head.

## III Experiments and Discussions

Our experiments are implemented in the TensorFlow framework using MNIST and CIFAR10 datasets. The MNIST dataset consists of 70k 28x28 grayscale images of the 10 digits of which 60k are used for the training set and 10k for the test set. The CIFAR10 dataset consists of 60k 32x32 color images, labeled across 10 categories, of which 50k are used for training and 10k for testing. The Adam optimizer is used with a learning rate of \(0.001\) and data are shuffled at each epoch during training. The Beta parameter assumes values of \(\beta=\{1,3,5,10\}\) and experiments are performed with and without pruning for each of these \(\beta\) values. Initially all models are trained for 30 epochs with 2 further epochs once the reconstruction head is removed. At this stage, if pruning is applied, an additional 2 epochs are used for this purpose followed by the evaluation of the classification accuracy. We use the 'prune_low_magnitude' function in Keras with a 50% constant sparsity which is a standard low-magnitude criterion for local, unstructured pruning. The neural network architectures used for the MNIST and CIFAR10 datasets are parameterized by 69k and 2.9M parameters, respectively.

The MNIST dataset is a far easier dataset than CIFAR10 and, consequently, easier to over-train on as seen from the high accuracies attained both with the pure CNN model and Beta-VAE-Classif model up to \(\beta=10\) in Table I. The pure CNN-Classif model baseline outperforms the Beta-VAE-Classif models on both datasets because of its singular objective compared to having to optimize multiple objectives coming from several tasks. Preliminary results of several individual runs on MNIST initially hinted that at a certain degree of disentanglement \(\beta>1\) the accuracy of the pruned and unpruned models increased over the \(\beta=1\) entanglement baseline. This finding would have supported the intuition that applying disentanglement to a model initially guided by the presence of a pixel-level task, such as reconstruction, would facilitate discarding information that is not relevant for the relatively simpler, image-level task of classification. This observation may be captured by the \(\beta=5\) Beta-VAE-Classif model on the CIFAR10 dataset results since the upper range of accuracy exceeds that of the \(\beta=1\) model. The compression ratio of pruned to unpruned model are essentially the same among all models examined for each of the two datasets. The severe drop in accuracy for the \(\beta=10\) on the CIFAR10 dataset appear to be indicative of the information preference problem (i.e., posterior collapse, KL vanishing) where the disentangled representations have become independent of the observation space.

## IV Conclusion and Future Works

The preliminary results presented in this work are inconclusive and only roughly suggest that for a certain value of \(\beta\) in the Beta-VAE framework, the latent space implicitly becomes sufficiently disentangled to allow for pruning to more easily discard useless information for the task of classification. Increasing the number of epochs over which pruning is performed as well as the number of latent dimensions may improve these results. Furthermore, having ground truth disentanglement labels together with an appropriately selected metric to directly measure the degree of disentanglement for the task of classification is expected to yield more robust results. We propose to use the dSprites [22] dataset along with the mutual information gap (MIG) [23] metric for this purpose.

Fig. 1: The Beta-VAE model augmented by the addition of a classifier head. The combined model, Beta-VAE-Classif, is trained with all three loss terms given by the KL divergence, reconstruction loss, and classification loss. During inference, the reconstruction head is removed, leaving the shaded in blocks of the diagram. The notations used are described in Section II.
## V Acknowledgement

This work is supported by the Luxembourg National Research Fund (FNR), under the project reference C21/IS/15965298/ELITE.
