【问题标题】:RuntimeError: invalid argument 0: Sizes of tensors must match except in dimension 0. Got 3 and 1 in dimension 1RuntimeError:无效参数 0:张量的大小必须匹配,但维度 0 除外。得到维度 1 中的 3 和 1
【发布时间】:2019-07-29 22:37:34
【问题描述】:

在通过 pytorch 训练 resnet50 模型时出现此错误:

RuntimeError:无效参数 0:张量的大小必须匹配,除了 在维度 0。在维度 1 中得到 3 和 1 /pytorch/aten/src/TH/generic/THTensorMoreMath.cpp:1333

我正在使用这个:http://github.com/Helias/Car-Model-Recognition/

使用此数据集http://vmmrdb.cecsresearch.org/

【问题讨论】:

    标签: python pytorch torch resnet torchvision


    【解决方案1】:

    我解决了这个,问题是图像颜色通道不同,不是所有图像都是RGB,所以我在dataset.py中进行了转换,我改变了这个:

    im = Image.open(image_path)
    

    进入这个:

    im = Image.open(image_path).convert('RGB')
    

    【讨论】:

      猜你喜欢
      • 2020-05-26
      • 1970-01-01
      • 1970-01-01
      • 2022-12-04
      • 2022-08-08
      • 2021-12-28
      • 1970-01-01
      • 1970-01-01
      • 2021-06-12
      相关资源
      最近更新 更多