【Bug】RuntimeError: The size of tensor a (4) must match the size of tensor b (3) at non-singleton dim

错误信息:

tensor.sub_(mean[:, None, None]).div_(std[:, None, None])
RuntimeError: The size of tensor a (4) must match the size of tensor b (3) at non-singleton dimension 0

报错原因:

维度信息不匹配

修改之前:

image = Image.open(image_path)

修改之后:

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

参考:
https://blog.csdn.net/qq_32445941/article/details/114868786

你可能感兴趣的:(Bug修复&解决方案,bug)