Solved by ptrblck in post #2 
              
              
                It seems you’ve wrapped all modules into an nn.Sequential block. 
If that’s the case, you are removing the flattening, which is used here directly in the forward method. 
You could keep the original architecture and change both layers by reassigning the new layers: 
model = models.resnet18()
model.c…