Git Product home page Git Product logo

Comments (7)

guangzhili avatar guangzhili commented on August 29, 2024 2

@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.

from pytorch-pruning.

MrLinNing avatar MrLinNing commented on August 29, 2024

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

from pytorch-pruning.

XUHUAKing avatar XUHUAKing commented on August 29, 2024

@MrLinNing _modules will return OrderedDict() object which does not support indexing, try this instead:
_, conv = list(model._modules.items())[layer_index]

from pytorch-pruning.

RgZhangLihao avatar RgZhangLihao commented on August 29, 2024

@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
fine_tuner.prune()
File "finetune.py", line 227, in prune
model = prune_vgg16_conv_layer(model, layer_index, filter_index)
File "/home/share2/zhanglihao/pytorch-pruning/prune.py", line 14, in prune_vgg16_conv_layer
_, conv = list(model._modules.items())[layer_index]
IndexError: list index out of range

Can you help me? Thanks!

from pytorch-pruning.

XUHUAKing avatar XUHUAKing commented on August 29, 2024

@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.

from pytorch-pruning.

fbiying87 avatar fbiying87 commented on August 29, 2024

@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!

from pytorch-pruning.

Pyramiding avatar Pyramiding commented on August 29, 2024

@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 ?

from pytorch-pruning.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.