Open jagadeesh09 opened 6 years ago
@jagadeesh09 The type of parameter "bias" in torch.nn.Conv2d should be bool(Check API at http://pytorch.org/docs/master/nn.html), but conv.bias is FloatTensor, change to bias = True if conv.bias is not None, otherwise False.
Hi , I meet the problem, can your help me solved it
Accuracy : 0.9852
Number of prunning iterations to reduce 67% filters 5
Ranking filters.
Layers that will be prunned {0: 4, 2: 10, 5: 6, 7: 7, 10: 24, 12: 19, 14: 18, 17: 59, 19: 62, 21: 58, 24: 71, 26: 87
Prunning filters..
Traceback (most recent call last):
File "finetune.py", line 270, in <module>
fine_tuner.prune()
File "finetune.py", line 228, in prune
model = prune_vgg16_conv_layer(model, layer_index, filter_index)
File "/home/linning/pytorch_test/pytorch-pruning/prune.py", line 14, in prune_vgg16_conv_layer
_, conv = model._modules.items()[layer_index]
TypeError: 'odict_items' object does not support indexing
@MrLinNing _modules
will return OrderedDict()
object which does not support indexing, try this instead:
_, conv = list(model._modules.items())[layer_index]
@XUHUAKing I met this problem, but I don't know how to solve it:
Accuracy: 0.98
Number of prunning iterations to reduce 67% filters 5
Ranking filters..
Layers that will be prunned {28: 59, 24: 139, 26: 135, 21: 54, 17: 55, 19: 52, 14: 11, 12: 5, 10: 2}
Prunning filters..
Traceback (most recent call last):
File "finetune.py", line 269, in
Can you help me? Thanks!
@RgZhangLihao I am not sure of your error because I didn't meet this when I ran my own modified program.
However, in my program, I added constraint
if module.weight.data.size(0) <= 1: #skip pruning this layer
when cutting filters, to ensure during the pruning, I would not delete an entire layer, which may affect the layer index within your model in the future and cause your error.
This is just my guess, hope this help.
@XUHUAKing I have the same issue with the list index out of the range. Can you share the prune.py script with me, as I don't know where to put the if condition exactly. Thanks!
@jagadeesh09 The type of parameter "bias" in torch.nn.Conv2d should be bool(Check API at http://pytorch.org/docs/master/nn.html), but conv.bias is FloatTensor, change to bias = True if conv.bias is not None, otherwise False.
If I want to use trained bias parameters, how to do ?
Hi
I have encountered this error while running the code. After getting the information about the filters which are to be pruned, while pruning the filters this issue occured.