Solved by ptrblck in post #2 
              
              
                While loading your images, you could use Image.open(path).convert('RGB') on all images. 
If you are using ImageFolder, this functionality should be already there using the default loader. 
Alternatively, you could repeat the values: 
x = torch.randn(28, 28)
x.unsqueeze_(0)
x = x.repeat(3, 1, 1)
x.sh…