Comments (18)
so did I
from pytorch-pruning.
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.
0.2.0_1, mine, failed
0.1.12_2, my friend, yet he succeeded.
from pytorch-pruning.
mine is 0.2.0_1 as well...Does it have anything to do with the pytorch version?
from pytorch-pruning.
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.
@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.
@eeric
I have encountered this problem, have you fix it? Thank you
from pytorch-pruning.
@BUPTLdy , Not solved, and I sitll used torch version 0.1.12_2
from pytorch-pruning.
@eeric Thanks for your reply, I solved it by setting bias = True
in file prune.py.
from pytorch-pruning.
ok, but for ResNet model, error setting
from pytorch-pruning.
@BUPTLdy, setting bias = True in file prune.py, in detail?
from pytorch-pruning.
@eeric
In lines 33 and 58 in file prune.py, change to bias = True
.
from pytorch-pruning.
@BUPTLdy, oh, but it occured error for vgg convolution layer inheritance, and What is more, ResNet
from pytorch-pruning.
@eeric
In lines 33 and 58 in file prune.py, change tobias = True
.
Why set bias = True
in those two lines ?
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.
@ProMach
bias = True that bias was needed.
from pytorch-pruning.
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.
@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.
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)
- Python 3.6, pytorch 0.4.1, getting RuntimeError: Dimension out of range (expected to be in range of [-2, 1], but got 3) HOT 4
- torch.load(pruned_model) HOT 7
- vgg16 has 13 conv layers, how can you prune neurons on layer 28? HOT 2
- [CUDA Runtime Error] Assertion `t >= 0 && t < n_classes` failed. HOT 5
- Accuracy drops from 96.46% to 58.67% HOT 1
- train_path
- Time of 1 pruning iteration
- in finetune.py 117 Why "-i"?? HOT 2
- Getting Error in pruning HOT 1
- pruning conv layers with 'groups' > 1
- Batch Nomalization
- I wonder if this pruning approach can be adapted to net like resnet
- layer_index
- how Pruning the last conv layer affects the first linear layer of the classifier
- can u plz tell me how to resolve this issue of not getting training data path
- where is prune_conv_layer?
- Will the pruned weight reactivated after finetuning?
- Running project in google colab
- running project on Anaconda Jupyter Notebook
- Pruning model YOLOX using 'import torch.nn.utils.prune as prune'
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pytorch-pruning.