foolwood / pytorch-slimming Goto Github PK
View Code? Open in Web Editor NEWLearning Efficient Convolutional Networks through Network Slimming, In ICCV 2017.
License: MIT License
Learning Efficient Convolutional Networks through Network Slimming, In ICCV 2017.
License: MIT License
Question about loss, I have a question about the loss function, in this repo, loss function is only a cross_entropy but in the paper this cross_entropy and Xγ∈Γ g(γ) , how to understand the different between implementation and the paper ?
Lines 97 to 101 in 7d13c09
is it right?
Traceback (most recent call last):
File "main.py", line 152, in
train(epoch)
File "main.py", line 120, in train
100. * batch_idx / len(train_loader), loss.data[0]))
IndexError: invalid index of a 0-dim tensor. Use tensor.item()
in Python or tensor.item<T>()
in C++ to convert a 0-dim tensor to a number
I noticed model size after finetuning is the same as the original model size.
Shouldn't the size be the same as the pruned model?
Thanks,
python main.py -sr --s 0.0001
进行稀疏训练的时候,应该是在训练的模型之后,额外再进行训练吧?不是从头进行训练吧这个地方可以解释一下吗?有点困惑
我的是'1.5.0+cu92',一直报错。
RuntimeError:
An attempt has been made to start a new process before the
current process has finished its bootstrapping phase.
This probably means that you are not using fork to start your
child processes and you have forgotten to use the proper idiom
in the main module:
if __name__ == '__main__':
freeze_support()
...
The "freeze_support()" line can be omitted if the program
is not going to be frozen to produce an executable.
没有过torch,这个代码有人跑通了吗?效果如何?
大神您好,我在进行prune模型时,出现[59, 64, 'M', 128, 128, 'M', 256, 256, 256, 256, 'M', 470, 239, 59, 40, 'M', 0, 3, 54, 483],有一层卷积数量是0,然后就报错了,怎么解决呢?
[59, 64, 'M', 128, 128, 'M', 256, 256, 256, 256, 'M', 470, 239, 59, 40, 'M', 0, 3, 54, 483]
Traceback (most recent call last):
File "prune.py", line 111, in
newmodel = vgg(cfg=cfg)
File "/home/wxl/temp/pytorch-slimming/vgg.py", line 13, in init
self.feature = self.make_layers(cfg, True)
File "/home/wxl/temp/pytorch-slimming/vgg.py", line 30, in make_layers
conv2d = nn.Conv2d(in_channels, v, kernel_size=3, padding=1, bias=False)
File "/home/wxl/project/py36/lib/python3.6/site-packages/torch/nn/modules/conv.py", line 330, in init
False, pair(0), groups, bias, padding_mode)
File "/home/wxl/project/py36/lib/python3.6/site-packages/torch/nn/modules/conv.py", line 46, in init
self.reset_parameters()
File "/home/wxl/project/py36/lib/python3.6/site-packages/torch/nn/modules/conv.py", line 49, in reset_parameters
init.kaiming_uniform(self.weight, a=math.sqrt(5))
File "/home/wxl/project/py36/lib/python3.6/site-packages/torch/nn/init.py", line 314, in kaiming_uniform_
fan = _calculate_correct_fan(tensor, mode)
File "/home/wxl/project/py36/lib/python3.6/site-packages/torch/nn/init.py", line 283, in _calculate_correct_fan
fan_in, fan_out = _calculate_fan_in_and_fan_out(tensor)
File "/home/wxl/project/py36/lib/python3.6/site-packages/torch/nn/init.py", line 215, in _calculate_fan_in_and_fan_out
receptive_field_size = tensor[0][0].numel()
IndexError: index 0 is out of bounds for dimension 0 with size 0
@ @ @foolwood
Hey, thx for the code released.
I follow the steps in the READEME file, as python main.py
in the first, and then, intend to run python prune.py --model model_best.pth.tar --save pruned.pth.tar --percent 0.7
but I encounter the error as below
Traceback (most recent call last):
File "prune.py", line 110, in
newmodel = vgg(cfg=cfg)
File "/home/amax/users/liuwenzhe/pruning/pytorch-slimming/vgg.py", line 13, in init
self.feature = self.make_layers(cfg, True)
File "/home/amax/users/liuwenzhe/pruning/pytorch-slimming/vgg.py", line 31, in make_layers
conv2d = nn.Conv2d(in_channels, v, kernel_size=3, padding=1, bias=False)
File "/home/amax/anaconda3/envs/lwz36/lib/python3.6/site-packages/torch/nn/modules/conv.py", line 332, in init
False, pair(0), groups, bias, padding_mode)
File "/home/amax/anaconda3/envs/lwz36/lib/python3.6/site-packages/torch/nn/modules/conv.py", line 46, in init
self.reset_parameters()
File "/home/amax/anaconda3/envs/lwz36/lib/python3.6/site-packages/torch/nn/modules/conv.py", line 49, in reset_parameters
init.kaiming_uniform(self.weight, a=math.sqrt(5))
File "/home/amax/anaconda3/envs/lwz36/lib/python3.6/site-packages/torch/nn/init.py", line 310, in kaiming_uniform_
fan = _calculate_correct_fan(tensor, mode)
File "/home/amax/anaconda3/envs/lwz36/lib/python3.6/site-packages/torch/nn/init.py", line 279, in _calculate_correct_fan
fan_in, fan_out = _calculate_fan_in_and_fan_out(tensor)
File "/home/amax/anaconda3/envs/lwz36/lib/python3.6/site-packages/torch/nn/init.py", line 211, in _calculate_fan_in_and_fan_out
receptive_field_size = tensor[0][0].numel()
IndexError: index 0 is out of bounds for dimension 0 with size 0
I checked the cfg in newmodel = vgg(cfg=cfg)
, and it printed as
[53, 64, 'M', 128, 128, 'M', 256, 256, 254, 212, 'M', 34, 1, 1, 0, 'M', 0, 0, 1, 263]
I guess the error may lie in 0, and confuses the nn.Conv2d().
What can I do to fix it? Is it necessary to train it again?
Thx in advance.
main.py文件当中,L1正则化应该是torch.abs而不是torch.sign吧
m.weight.grad.data.add_(args.s*torch.sign(m.weight.data)) # L1
Thank you for sharing, I encountered the following error in the implementation of the following code,
python prune.py --model model_best.pth.tar --save pruned.pth.tar --percent 0.7
error:
Traceback (most recent call last):
File "prune.py", line 120, in
m1.weight.data = m0.weight.data[idx1].clone()
TypeError: indexing a tensor with an object of type numpy.ndarray. The only supported types are integers, slices, numpy scalars and torch.cuda.LongTensor or torch.cuda.ByteTensor as the only argument.
I am not very familiar with Pytorch, do not know how to solve, can you help me fix this bug? Thanks for your help, I use Python 2.7.14, Pytorch 0.20
你好,我用这个代码的思路剪了一个检测的模型,但剪完之后的模型就无法正常检测出框了,请问可能是哪里出了问题
为什么我稀疏化训练的时候,BN层的gamma系数随着训练的进行,从1到-1震荡,然后又从-1到1震荡,而且所有的gamma系数都同步的震荡变化,根本不会出现离散稀疏的情况。不知道是否有人出现过这种情况?
python main.py --refine pruned.pth.tar --epochs 40里面那个命令写错了,超参前是两个杠杠
Traceback (most recent call last):
File "vggprune.py", line 73, in
mask = weight_copy.gt(thre).float().cuda()
RuntimeError: Expected object of type torch.cuda.FloatTensor but found type torch.FloatTensor for argument #2 'other'
我用的环境是python3.6 torch0.4.1
when i reload the model_best.pth.tar, i got this error:
=> loading checkpoint './model_best.pth.tar'
Traceback (most recent call last):
File "prune.py", line 37, in
model.load_state_dict(checkpoint['state_dict'])
File "/usr/local/lib/python3.5/dist-packages/torch/nn/modules/module.py", line 522, in load_state_dict
.format(name))
KeyError: 'unexpected key "module.feature.0.weight" in state_dict'
how can i solve this problem???
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.