issues
search
Xzzit
/
pytorch-tutorial
Introduction to PyTorch: A comprehensive Chinese course available at the provided link.
https://space.bilibili.com/12580263/channel/series
GNU General Public License v3.0
11
stars
4
forks
source link
cnn+ImageNet代码(报错版)
#2
Closed
minqi-source
closed
1 year ago
minqi-source
commented
1 year ago
将mnist数据集换成ImageNet数据集后会报错,麻烦帮我看下,谢谢!!
Xzzit
commented
1 year ago
报错原因:该代码中,train_data、train_data_loader中的图片形状不一样。
具体原因:在代码第16行定义的transform中,用到了transforms.Resize(24)函数,但是该函数只能将图像中边长最短的一边resize为24,另一边按比例缩放,而ImageNet里的图像很多是长宽不同的图像,该函数会导致resize后的图像仅有最短的一边等于24,而另一条边不确定。关于该函数的详情,参考
官方文档
解决方法:在18行中的transforms.Resize(24)下新增一行,transforms.CenterCrop(24)即可。
将mnist数据集换成ImageNet数据集后会报错,麻烦帮我看下,谢谢!!