Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question about code? #8

Open
BlossomingL opened this issue Jul 27, 2020 · 18 comments
Open

Question about code? #8

BlossomingL opened this issue Jul 27, 2020 · 18 comments

Comments

@BlossomingL
Copy link

Hi~Thanks for your great work!
In main.py, the code:
if args.arch=='resnet_50':
skip_list=[1,5,8,11,15,18,21,24,28,31,34,37,40,43,47,50,53]
if cov_id+1 not in skip_list:
continue
else:
pruned_checkpoint = torch.load(
args.job_dir + "/pruned_checkpoint/" + args.arch + "_cov" + str(53) + '.pt')
net.load_state_dict(pruned_checkpoint['state_dict'])
Why the model load cov53.pt?

@EthanZhangYC
Copy link
Collaborator

Hi,

the "cov53.pt" in the code was actually for testing, which I mistakenly uploaded it. Really sorry about that. Code has been corrected, please contact us if you have more questions.

Thanks for correcting~

@BlossomingL
Copy link
Author

I have another problem, when I test the accuracy of pretrained resnet-50 on imagenet you provided, but the accuracy is just 0.0899, it's too low?

@lmbxmu
Copy link
Owner

lmbxmu commented Jul 28, 2020

I have another problem, when I test the accuracy of pretrained resnet-50 on imagenet you provided, but the accuracy is just 0.0899, it's too low?

Make sure you are using our data processing code and your imagenet is fine. Everything goes smooth in our testing.

@BlossomingL
Copy link
Author

Thanks for your quick reply!
I run your code just change the pretrained model path and dataset path, my imagenet testset was downloaded from official website named 'ILSVRC2012_img_val.tar'(size: 6.7GB) , is anything wrong?

@lmbxmu
Copy link
Owner

lmbxmu commented Jul 28, 2020

Thanks for your quick reply!
I run your code just change the pretrained model path and dataset path, my imagenet testset was downloaded from official website named 'ILSVRC2012_img_val.tar'(size: 6.7GB) , is anything wrong?

I don't think this is our problem. Many readers adopt our pre-trained model and nothing goes wrong in our communication. You need to check your usage.

@lmbxmu
Copy link
Owner

lmbxmu commented Jul 28, 2020

I have found my mistake: when I untar my validation dataset from official website(6.3GB) , just a single folder, under the folder just many images, it's different from train dataset(there are many subfolders), can you tell me I am right?

老兄啊,你可以直接说中文. 一堆语法错误看不懂你在说什么.

@BlossomingL
Copy link
Author

BlossomingL commented Jul 28, 2020

哈哈^-^
就是说我在官网下载的测试数据集解压过后只有一个文件夹,下面全是图片,代码读取图片是用ImageFolder读的,所以得把测试数据集按照标签分一下类,放到对应的类下面去。。。

@lmbxmu
Copy link
Owner

lmbxmu commented Jul 28, 2020

正常是同一个类别的数据放在一个文件里. 你需要分类下.

@BlossomingL
Copy link
Author

好的,知道了,谢谢

@lmbxmu
Copy link
Owner

lmbxmu commented Jul 28, 2020

好的,知道了,谢谢

不客气,有问题再留言~ 你也可以参考这个代码 https://github.com/lmbxmu/HRankPlus

@BlossomingL
Copy link
Author

我刚刚测试了一下,发现精度还是不对,你能把你的测试集文件目录给我看看嘛?

@lmbxmu
Copy link
Owner

lmbxmu commented Jul 28, 2020

图片无法上传. 请联系你身边的人. 这是常识性问题,不属于我们代码bug范围.

@BlossomingL
Copy link
Author

好的,已经解决了,主要之前没做过分类的实验。。。麻烦你了!

@lmbxmu
Copy link
Owner

lmbxmu commented Jul 28, 2020

好的,已经解决了,主要之前没做过分类的实验。。。麻烦你了!

不客气~ 任何关于我们代码和论文的问题,欢迎随时提问交流

@BlossomingL
Copy link
Author

Hi~
你好,在main.py中第272行的for循环代码中,m.layer_mask将指定层的通道剪枝即w置为0,然后你加载了权重文件
问题一:在此处加载权重是否会覆盖之前已经剪枝为0的参数?
这个问题我后来想通了,m.layer_mask中其实生成了一个self.mask,在后面train的时候才会根据这个mask来进行剪枝。
问题二:在train代码中,为什么把m.grad_mask放在outputs=net(inputs)之后呢?这样在训练第一个batch的时候不就不是基于剪枝的权重(虽然这样不是不可以。。。)

@lmbxmu
Copy link
Owner

lmbxmu commented Jul 29, 2020

Hi~
你好,在main.py中第272行的for循环代码中,m.layer_mask将指定层的通道剪枝即w置为0,然后你加载了权重文件
问题一:在此处加载权重是否会覆盖之前已经剪枝为0的参数?
这个问题我后来想通了,m.layer_mask中其实生成了一个self.mask,在后面train的时候才会根据这个mask来进行剪枝。
问题二:在train代码中,为什么把m.grad_mask放在outputs=net(inputs)之后呢?这样在训练第一个batch的时候不就不是基于剪枝的权重(虽然这样不是不可以。。。)

想通的、可以的。 都没有留言的必要

@BlossomingL
Copy link
Author

你好,我复现了一下ResNet-50在ImageNet上的剪枝实验,但是精度并没有达到文中那么高,大概低了4个点,我每层剪完后训练15个epoch,请问是不是要增加训练的epoch呢?

@lmbxmu
Copy link
Owner

lmbxmu commented Aug 17, 2020

你好,我复现了一下ResNet-50在ImageNet上的剪枝实验,但是精度并没有达到文中那么高,大概低了4个点,我每层剪完后训练15个epoch,请问是不是要增加训练的epoch呢?

大哥,你是怎么跑的能跑成这样. 麻烦移驾 https://github.com/lmbxmu/HRankPlus 看参数配置. 还有我实在不明白为什么微信留言下消失了一下又跑这里来???

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants