Skip to content

Commit caeef73

Browse files
authored
Update Part 3 - Training Neural Networks (Exercises).ipynb
when torchvision is updated to 0.2.2, need change parameters of transforms.Normalize from (0.5, 0.5, 0.5) to (0.5, ), otherwise will get error below when iterate through trainloader: ~\Anaconda3\lib\site-packages\torchvision\transforms\functional.py in normalize(tensor, mean, std, inplace) 206 mean = torch.tensor(mean, dtype=torch.float32) 207 std = torch.tensor(std, dtype=torch.float32) --> 208 tensor.sub_(mean[:, None, None]).div_(std[:, None, None]) 209 return tensor 210 RuntimeError: output with shape [1, 28, 28] doesn't match the broadcast shape [3, 28, 28]
1 parent 9b6001a commit caeef73

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

intro-to-pytorch/Part 3 - Training Neural Networks (Exercises).ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@
8686
"\n",
8787
"# Define a transform to normalize the data\n",
8888
"transform = transforms.Compose([transforms.ToTensor(),\n",
89-
" transforms.Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5)),\n",
89+
" transforms.Normalize((0.5,), (0.5,)),\n",
9090
" ])\n",
9191
"# Download and load the training data\n",
9292
"trainset = datasets.MNIST('~/.pytorch/MNIST_data/', download=True, train=True, transform=transform)\n",

0 commit comments

Comments
 (0)