Created
June 21, 2020 15:45
-
-
Save sayakpaul/892d58eadadfde68bf2b8d23711e980c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copy the kernel weights and get ranked indices of the | |
# column-wise L2 Norms | |
kernel_weights = np.copy(k_weights) | |
ind = np.argsort(np.linalg.norm(kernel_weights, axis=0)) | |
# Number of indices to be set to 0 | |
sparsity_percentage = 0.7 | |
cutoff = int(len(ind)*sparsity_percentage) | |
# The indices in the 2D kernel weight matrix to be set to 0 | |
sparse_cutoff_inds = ind[0:cutoff] | |
kernel_weights[:,sparse_cutoff_inds] = 0. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment