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

麻烦写一下kaggle cat dog的注释以及代码的运行顺序,谢谢了 #11

Open
gittigxuy opened this issue Mar 6, 2018 · 7 comments

Comments

@gittigxuy
Copy link

No description provided.

@L1aoXingyu
Copy link
Owner

好的,我会加到这一版的书中,这两天会写一个新的repo出来

@gittigxuy
Copy link
Author

这段是猫狗大战当中的net.py文件当中的代码片段
if model == 'vgg':
vgg = models.vgg19(pretrained=True)
self.feature = nn.Sequential(*list(vgg.children())[:-1])
self.feature.add_module('global average', nn.AvgPool2d(9))
elif model == 'inceptionv3':
inception = models.inception_v3(pretrained=True)
self.feature = nn.Sequential(*list(inception.children())[:-1])
self.feature._modules.pop('13')
self.feature.add_module('global average', nn.AvgPool2d(35))
elif model == 'resnet152':
resnet = models.resnet152(pretrained=True)
self.feature = nn.Sequential(*list(resnet.children())[:-1])

有如下2个问题:
1)nn.Sequential(list(vgg.children())[:-1]),list前面的代表什么意思呢?
2)为什么vgg当中最后面加入了平均池化,而inceptionv3前面还要加上self.feature._modules.pop('13')
这个pop('13')是什么意思呢?resnet152为什么不加上池化了呢?
谢谢作者

@L1aoXingyu
Copy link
Owner

我会把预训练的模型放到百度云上

@L1aoXingyu
Copy link
Owner

https://pan.baidu.com/s/1xBK8gFWfHcFrHu0LIcZP8Q
这是 resnet18 的模型下载百度云地址

@L1aoXingyu
Copy link
Owner

下载完成之后放在 .torch/models 里面

@fengshi-cherish
Copy link

同样的问题:
为什么vgg当中最后面加入了平均池化,而inceptionv3前面还要加上self.feature._modules.pop('13')
这个pop('13')是什么意思呢?resnet152为什么不加上池化了呢?

@L1aoXingyu
Copy link
Owner

@fengshi-cherish inceptionv3 里面有一个额外的中间分类loss
image
这个loss对应于下面
image
所以要删掉13个模块,vgg是因为没有平均池化,所以加入,resnet有了平均池化,所以不需要加入

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