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

I faced the same problem and alex has explained it properly.

Use this, to convert a [H,W,C] into [C,H,W]
For including batch_size(N) use DataLoader, it will automatically include
image = image.transpose((2, 0, 1))

3 Likes