I guess transforms.Normalize raises this error, since you are using a single-channel tensor, while Normalize uses 3 values for the mean and stddev.
If you are dealing with grayscale images, you could pass tuples containing a single element to Normalize:
transforms.Normalize((0.5,), (0.5,))