A question and Ambiguity about torchvision.transforms.ToTensor

Hello, Everyone. I’m new to the Pytorch and I want to train a CNN Model for classifying MNIST Dataset From a Directory Root in My Computer.
For this purpose, I used this Commands:

Transform = torchvision.transforms.Compose([torchvision.transforms.ToTensor()])
Data = torchvision.datasets.ImageFolder(‘my_root’,transform=Transform)

The Images of Dataset are Gray_Scale but the output of Transform Command is 3 channel Tensor that incompatible with input of the network
How Can I Modify this code in order to Converting Images to 1 channel Tensor ?

You could take the mean of the channels, keeping the dimension.

Best regards