Thank you a lot, yeah I am using Python 2.
I solved it by taking the classifier as a list and appending nn.Linear(4096,num_class)
and than again appending nn.Sigmoid().
Another last question:
Does Alexnet need images of exactly 224x224. When I was trying to run it with 256x256 it was not working and I got this strange error message:
pytorch RuntimeError: size mismatch at /opt/conda/conda-bld/pytorch_1503966894950/work/torch/lib/THC/generic/THCTensorMathBlas.cu:243

On the other hand I got Resnet18 working with images of size 256x256. Could you explain why this is the case?
Thanks!