1.resnet需要加载预训练模型,但是最后一层fc层的输出数不是1000。
解决方案:先加载预训练模型,然后取除了最后一层的所有层,再加一层自己需要的在后面。
修改pytorch提供的resnet接口实现Kaggle猫狗识别_ZJE-优快云博客
2.model.children()和model.modules()的区别。
model.modules()和model.children()均为迭代器,model.modules()会遍历model中所有的子层,而model.children()仅会遍历当前层。
pytorch中model.modules()和model.children()的区别_灰灰灰灰灰发的博客-优快云博客
3.pytorch中自定义module