Hello every one. I doing cs231n 's last assignment: Self supervised learning and have a trouble:
Here is the code:
The error is:
return F.normalize(tensor, self.mean, self.std, self.inplace)
File “c:\Users\Admin\Anaconda3\lib\site-packages\torchvision\transforms\functional.py”, line 363, in normalize
RuntimeError: output with shape [1, 32, 32] doesn’t match the broadcast shape [3, 32, 32]
I know this issue relates to the transform: here is the transform (also the required solution of assignment so I dont want to change it)
This function returns a composition of data augmentations to a single training image.
Complete the following lines. Hint: look at available functions in torchvision.transforms
# Transformation that applies color jitter with brightness=0.4, contrast=0.4, saturation=0.4, and hue=0.1
color_jitter = transforms.ColorJitter(0.4, 0.4, 0.4, 0.1)
train_transform = transforms.Compose ([
# Step 1: Randomly resize and crop to 32x32.
# Step 2: Horizontally flip the image with probability 0.5
# Step 3: With a probability of 0.8, apply color jitter (you can use “color_jitter” defined above.
# Step 4: With a probability of 0.2, convert the image to grayscale
transforms.Normalize([0.4914, 0.4822, 0.4465], [0.2023, 0.1994, 0.2010])])
I dont have this issue before. My current version is:
The torch version is 1.11.0
and torchvision version is 0.12.0
Could any one know how to solve this issue?
Thank you very much