Solved by mailcorahul in post #2 
              
              
                By binary form, do you mean thresholding images(only 0 and 1) rather than using them as grayscale images? 
If that’s the case, I don’t think transforms has a function to threshold an image. You can write a custom dataset class which converts the image to binary form 
class BinaryMNIST(Dataset):
    …