It seems you are passing the input tensor in a channels-last memory format, while PyTorch expects channels-first by default, so you would have to permute the dimensions into [batch_size, channels, height, width]. In case you are changing the memory format via tensor.to(memory_format=torch.channels_last) note that you should not change the dimensions manually, but let PyTorch do it internally.
Once you’ve permuted the input tensor you would run into the next error of a wrong number of in_channels in the first conv layer.
While it seems that your input tensor uses 3 channels, the first conv layer uses 1 input channel, so you would have to change this next.