Based on the error message it seems like you are passing an image tensor in channel-last ordering ([batch_size, w, h, c]), while PyTorch expects channel-first inputs as [batch_size, c, h, w].
Could you check, if all your inputs have this shape?