Skip to content

How to set threshold for pruning? #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Ariel-JUAN opened this issue Nov 19, 2018 · 1 comment
Open

How to set threshold for pruning? #2

Ariel-JUAN opened this issue Nov 19, 2018 · 1 comment

Comments

@Ariel-JUAN
Copy link

Ariel-JUAN commented Nov 19, 2018

Hi, thanks for sharing the great work. I get the weight distribution for my own project, and here is my weight distribution:
image
I wonder what threshold should I set? I am confused......

@Ariel-JUAN Ariel-JUAN changed the title How to draw weight distribution? How to set threshold for pruning? Nov 19, 2018
@Ariel-JUAN
Copy link
Author

Ariel-JUAN commented Nov 20, 2018

Hi, thanks for sharing the great work again. I spent some time reading your source code. I have something confused. I prune the model under the threshold, and then what I need to do is finetune the model. I saw you provide deploy_pruned_model.py,
`

weight_matrices, biases = classifier.sess.run([classifier.weight_matrices,
                                           classifier.biases])
sparse_layers = []
for weights, bias in zip(weight_matrices, biases):

values, indices = pruning_utils.get_sparse_values_indices(weights)
shape = np.array(weights.shape).astype(np.int64)
sparse_layers.append(pruning_utils.SparseLayer(values=values.astype(np.float32),
                                               indices=indices.astype(np.int16),
                                               dense_shape=shape,
                                               bias=bias))

sparse_classifier = network_sparse.FullyConnectedClassifierSparse(
                        input_size=config_sparse.input_size,
                        n_classes=config_sparse.n_classes,
                        sparse_layers=sparse_layers,
                        model_path=config_sparse.model_path,
                        activation_fn=config_sparse.activation_fn)

`
It looks like the weights equals==0 are still in model, so the model size won't be small, right?
And tf.matmul(net, weights) to get output step by step. If the model is ResNet this kind of multi-branch, it looks like it doesn't work==
If you have time, please take a look at it and reply me, thanks~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant