RuntimeError: Given groups=1, weight of size [64, 3, 7, 7], expected input[3, 1, 224, 224] to have 3 channels, but got 1 channels instead

Thanks for your response. I am facing this issue in a different context. If I don’t want to change my original images and also don’t have the option to change the architecture (since I am using resnet18 from models), how can I do slicing? Is there an example to guide?

The new error setting is as such:

RuntimeError: Given groups=1, weight of size [64, 1, 7, 7], expected input[51, 3, 224, 224] to have 1 channels, but got 3 channels instead

Here is a test image above. I am wondering if I don’t want to convert my images to black and white or grey-scale, and want to use all three RGB channel, how could I still do so for PyTorch training given I cannot change the loaded ResNet18?