---------------------------------------------------------------------------
Input has shape: torch.Size([10, 3, 64, 64])
x after self.features: tensor([[[[0.0486]],

         [[0.0576]],

         [[0.0202]],

         ...,

         [[0.0301]],

         [[0.0128]],

         [[0.0528]]],


        [[[0.0439]],

         [[0.0621]],

         [[0.0302]],

         ...,

         [[0.0398]],

         [[0.0171]],

         [[0.0494]]],


        [[[0.0156]],

         [[0.0240]],

         [[0.0101]],

         ...,

         [[0.0218]],

         [[0.0055]],

         [[0.0158]]],


        ...,


        [[[0.0359]],

         [[0.0443]],

         [[0.0132]],

         ...,

         [[0.0209]],

         [[0.0095]],

         [[0.0220]]],


        [[[0.0192]],

         [[0.0251]],

         [[0.0114]],

         ...,

         [[0.0180]],

         [[0.0051]],

         [[0.0143]]],


        [[[0.0409]],

         [[0.0476]],

         [[0.0173]],

         ...,

         [[0.0355]],

         [[0.0091]],

         [[0.0355]]]], grad_fn=<MaxPool2DWithIndicesBackward>)
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
<ipython-input-4-702d467d5d33> in <module>()
     67 
     68     # train for one epoch
---> 69     train(train_loader, model, criterion, optimizer, epoch)
     70 
     71     # evaluate on validation set

<ipython-input-3-d58a1c9f986c> in train(train_loader, model, criterion, optimizer, epoch)
     20         target = target.to(device)
     21 
---> 22         output = model(data)
     23         loss = F.nll_loss(output, target)
     24 

~/anaconda3/lib/python3.7/site-packages/torch/nn/modules/module.py in __call__(self, *input, **kwargs)
    487             result = self._slow_forward(*input, **kwargs)
    488         else:
--> 489             result = self.forward(*input, **kwargs)
    490         for hook in self._forward_hooks.values():
    491             hook_result = hook(self, input, result)

~/Desktop/pytorch-alexnet-gtsrb/model.py in forward(self, x)
     45         x = self.features(x)
     46         print("x after self.features: " + str(x))
---> 47         x = x.view(x.size(0), 256 * 6 * 6)
     48         x = self.classifier(x)
     49         return x

RuntimeError: shape '[10, 9216]' is invalid for input of size 2560
---------------------------------------------------------------------------

Interestingly after closing and reopening the jupyter notebook now the runtime error has changed from “RuntimeError: shape ‘[64, 2304]’ is invalid for input of size 16384” to “RuntimeError: shape ‘[10, 9216]’ is invalid for input of size 2560”.