RuntimeError: invalid argument 0: Sizes of tensors must match except in dimension 0. Got 3 and 1 in dimension 1
While training the resnet50 model through pytorch I got this error:


  RuntimeError: invalid argument 0: Sizes of tensors must match except
  in dimension 0. Got 3 and 1 in dimension 1 at
  /pytorch/aten/src/TH/generic/THTensorMoreMath.cpp:1333


I'm using this: http://github.com/Helias/Car-Model-Recognition/

with this dataset http://vmmrdb.cecsresearch.org/

I solved this, the problem was the different images color channels, not all the images were RGB, so I made a conversion in dataset.py, I changed this:

im = Image.open(image_path)


into this:

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

