I am trying to use pytorch pretrained Alexnet model for feature extraction, which I will pass to the SVM classifier (scikit). I am doing the transfer learning as my dataset is small.
I got the model as
alexnet_model = models.alexnet(pretrained=True)
Then removed the fully connected layer
alexnet_model.classifier = torch.nn.Sequential(*list(alexnet_model.classifier.children())[:-4])
I am unsure about how to pass the training image as input to the model and get the extracted features! Do I have to get the features of each input image sequentially through some loop? Is there a way I can do this all at once?