Solved by vfdev-5 in post #8 
              
              
                But for 2D tensors, the transforms.ToPILImage() and transforms.ToTensor() are needed. 

Yes, I see you point here. Yes, images as tensors should be 3D tensors. In case of 2D tensors, I’d recommend to update the way to construct the input as 3D tensor, instead of 2D tensor. And in this case, I would…