How to prune weights of a CNN (convolution neural network) model which is less than a threshold value (let’s consider prune all weights which are <= 1). I want to prune less significant weights so that accuracy won’t be degraded.
How we can achieve that for a weight file saved in .pth format in PyTorch?
In practice, in compute_mask, among other things, you will have to generate a mask that preserves all the entries in the tensor t that are above your threshold: mask = (t > 1.).to(t.dtype)