The error message is a bit hard to interpret without the code.
It seems you are trying to load images using a DataLoader.
Some of these images seem to have 3 channels (color images), while others might have a single channel (BW images).
Since the dimension differ in dim1, they cannot be concatenated into a batch.
You could try to add img = img.convert('RGB') into your __getitem__ in your Dataset.