出现:RuntimeError: The size of tensor a (4) must match the size of tensor b (3) at non-singleton dimension 0的解决办法: 把代码中 Image.open(img_path) 改为 Image.open(img_path).convert('RGB') 即可解决问题。