and got the subset of Imagenet Classes which are most similar to my dataset. Now I want to use the pretrained features only from these most similar classes.

Earlier, I was using the pretrained model as follows:

May I know how can i get the pretrained features from the selective classes of Imagenet.
I don’t have any clue to pursue this further.
Looking for help.

Perhaps you can take the output (which is a list of probabilities) of resnet34, set the probabilities corresponding to the non-selected classes to zeroes, and normalize the remaining probabilities (scale them up by a uniform factor so that they again add up to 1)?

This seems to be the simplest interpretation of “drop some classes from resnet34”. Perhaps this will work for your purpose?

Actually, output of this resnet model is 20 classes from my data set. I want to drop few classes from 1000 classes of ImageNet.
Do you think if that is possible.

My data is highly imbalanced, and I am using pretrained ResNet model to get the logits.
In hope of getting better accuracy, i want to use only those classes of ImageNet which are similar to the classes of my dataset.
There is a paper on this approach : ‘Large Scale Fine-Grained Categorization and Domain-Specific Transfer Learning’.
But unfortunately code is not complete

Thanks for the reply.
Sorry, i am not sure if i understood that correctly. Isn’t that the ‘output (which is a list of probabilities) of resnet34’ will be 20 as the number of my dataset classes are 20, while Imagenet classes are 1000.

I see. Your problem is much more basic than I thought. I suggest that you first do a course in Python to get a basic understanding of the language, before using it to play with neural networks.