pruning_with_tensorflow icon indicating copy to clipboard operation
pruning_with_tensorflow copied to clipboard

How to set threshold for pruning?

Open Ariel-JUAN opened this issue 7 years ago • 1 comments

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 avatar Nov 19 '18 07:11 Ariel-JUAN

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~

Ariel-JUAN avatar Nov 20 '18 08:11 Ariel-JUAN