Solved by ptrblck in post #2 
              
              
                If I execute your code I get a shape mismatch error: 
RuntimeError: mat1 and mat2 shapes cannot be multiplied (1024x1 and 512x32)

since you are not flattening the activation. 
This should work: 
class Resnet18(torch.nn.Module):
    def __init__(self):
        super(Resnet18, self).__init__()
      …