【已解决】RuntimeError: stack expects each tensor to be equal size, but got [3, 256, 341] at entry 0

【报错】如下:

RuntimeError: stack expects each tensor to be equal size, but got [3,256, 341] at entry 0 and [3, 256, 386] at entry 1

【分析】

train_dataset = datasets.ImageFolder(
    traindir,
    transforms.Compose([
        transforms.Resize((224)) ###

【原因】

原因是transforms.Resize() 的参数设置问题,改为如下设置就可以了

【解决】

train_dataset = datasets.ImageFolder(
    traindir,
    transforms.Compose([
        transforms.Resize((224,224)),

搞定!撒花…

你可能感兴趣的:(Resolve,深度学习,pytorch,神经网络,机器学习)