Git Product home page Git Product logo

Comments (18)

eeric avatar eeric commented on July 25, 2024

so did I

from pytorch-pruning.

jacobgil avatar jacobgil commented on July 25, 2024

Hi I will check this and get back with an answer during the next few days.
What version of Pytorch are you using?

import torch
print torch.__version__

from pytorch-pruning.

eeric avatar eeric commented on July 25, 2024

0.2.0_1, mine, failed

0.1.12_2, my friend, yet he succeeded.

from pytorch-pruning.

pgadosey avatar pgadosey commented on July 25, 2024

mine is 0.2.0_1 as well...Does it have anything to do with the pytorch version?

from pytorch-pruning.

pgadosey avatar pgadosey commented on July 25, 2024

keepdim in torch.sum has a default value of None, I changed it to True and that seems to have solved the issue

from pytorch-pruning.

eeric avatar eeric commented on July 25, 2024

@pgadosey , so did, error as following,
Number of prunning iterations to reduce 67% filters 5
Ranking filters 0 times..
Layers that will be prunned {0: 2, 2: 5, 5: 6, 7: 9, 10: 26, 12: 21, 14: 20, 17: 70, 19: 60, 21: 55, 24: 64, 26: 67, 28: 107}
Prunning filters..
Traceback (most recent call last):
File "finetune.py", line 302, in
fine_tuner.prune()
File "finetune.py", line 233, in prune
model = prune_vgg16_conv_layer(model, layer_index, filter_index)
File "/home/yq/cnn/prune/pytorch-pruning/prune.py", line 33, in prune_vgg16_conv_layer
bias = conv.bias)
File "/usr/local/lib/python2.7/dist-packages/torch/nn/modules/conv.py", line 250, in init
False, _pair(0), groups, bias)
File "/usr/local/lib/python2.7/dist-packages/torch/nn/modules/conv.py", line 34, in init
if bias:
File "/usr/local/lib/python2.7/dist-packages/torch/autograd/variable.py", line 123, in bool
torch.typename(self.data) + " is ambiguous")

RuntimeError: bool value of Variable objects containing non-empty torch.FloatTensor is ambiguous

from pytorch-pruning.

BUPTLdy avatar BUPTLdy commented on July 25, 2024

@eeric
I have encountered this problem, have you fix it? Thank you

from pytorch-pruning.

eeric avatar eeric commented on July 25, 2024

@BUPTLdy , Not solved, and I sitll used torch version 0.1.12_2

from pytorch-pruning.

BUPTLdy avatar BUPTLdy commented on July 25, 2024

@eeric Thanks for your reply, I solved it by setting bias = True in file prune.py.

from pytorch-pruning.

eeric avatar eeric commented on July 25, 2024

ok, but for ResNet model, error setting

from pytorch-pruning.

eeric avatar eeric commented on July 25, 2024

@BUPTLdy, setting bias = True in file prune.py, in detail?

from pytorch-pruning.

BUPTLdy avatar BUPTLdy commented on July 25, 2024

@eeric
In lines 33 and 58 in file prune.py, change to bias = True.

from pytorch-pruning.

eeric avatar eeric commented on July 25, 2024

@BUPTLdy, oh, but it occured error for vgg convolution layer inheritance, and What is more, ResNet

from pytorch-pruning.

buttercutter avatar buttercutter commented on July 25, 2024

@eeric
In lines 33 and 58 in file prune.py, change to bias = True.

Why set bias = True in those two lines ?

@BUPTLdy

Edit:
Besides, modifying the code according to your advice does not solve the problem, I have another error came up. Do you have any idea to solve this out-of-memory issue ? I am thinking of reducing batch size or other parameters, but I am not sure where I should modify the code.

[phung@archlinux pytorch-pruning]$ python finetune.py --prune
/usr/lib/python3.7/site-packages/torchvision/transforms/transforms.py:187: UserWarning: The use of the transforms.Scale transform is deprecated, please use transforms.Resize instead.
  warnings.warn("The use of the transforms.Scale transform is deprecated, " +
/usr/lib/python3.7/site-packages/torchvision/transforms/transforms.py:562: UserWarning: The use of the transforms.RandomSizedCrop transform is deprecated, please use transforms.RandomResizedCrop instead.
  warnings.warn("The use of the transforms.RandomSizedCrop transform is deprecated, " +
Accuracy:  0.5848
Number of prunning iterations to reduce 67% filters 5
Ranking filters.. 
Traceback (most recent call last):
  File "finetune.py", line 270, in <module>
    fine_tuner.prune()
  File "finetune.py", line 217, in prune
    prune_targets = self.get_candidates_to_prune(num_filters_to_prune_per_iteration)
  File "finetune.py", line 184, in get_candidates_to_prune
    self.train_epoch(rank_filters = True)
  File "finetune.py", line 179, in train_epoch
    self.train_batch(optimizer, batch.cuda(), label.cuda(), rank_filters)
  File "finetune.py", line 172, in train_batch
    self.criterion(output, Variable(label)).backward()
  File "/usr/lib/python3.7/site-packages/torch/tensor.py", line 96, in backward
    torch.autograd.backward(self, gradient, retain_graph, create_graph)
  File "/usr/lib/python3.7/site-packages/torch/autograd/__init__.py", line 90, in backward
    allow_unreachable=True)  # allow_unreachable flag
RuntimeError: CUDA error: out of memory
[phung@archlinux pytorch-pruning]$ 

from pytorch-pruning.

eeric avatar eeric commented on July 25, 2024

@ProMach
bias = True that bias was needed.

from pytorch-pruning.

Anurag0212 avatar Anurag0212 commented on July 25, 2024

keepdim in torch.sum has a default value of None, I changed it to True and that seems to have solved the issue

I couldn't find the keepdim in torch.sum, Could you please share the line number?

from pytorch-pruning.

buttercutter avatar buttercutter commented on July 25, 2024

@Anurag0212 I have done the modification at https://github.com/promach/pytorch-pruning/ . You could just use the repo. I am still trying to figure out how to test the model_prunned given some classes.

from pytorch-pruning.

Mouatassem1 avatar Mouatassem1 commented on July 25, 2024

RuntimeError Traceback (most recent call last)
in ()
23 # convert output probabilities to predicted class
24 #_, pred = torch.max(output, 1)
---> 25 _, pred = torch.max(output, dim=1)
26 # compare predictions to true label
27 correct_tensor = pred.eq(target.data.view_as(pred))

RuntimeError: Dimension out of range (expected to be in range of [-1, 0], but got 1)

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.