How to add a varying filter to a CNN

I have trained a Classifier having num_classes = 20, say 20 different animals. But during inference, I need to predict from only 4 known animals. So how can I add an additional filter to my inference code such that it will increase the probability of the outcome of these 4 animals than the other 16 animals? Now the catch here is the 4 classes of animals vary each time so I cannot add an additional layer to train.py and I have to implement this on predict.py.

So how can I add an additional filter to my inference code such that it will increase the probability of the outcome of these 4 animals than the other 16 animals?

I’m not sure you can increase the probability of certain classes without training the model.
You could index these four classes and just use the argmax on these logits to avoid getting invalid classes.

1 Like

Thanks for the reply @ptrblck even I was in a doubt wether its possible or not. So I thougth I might post and check wether there is a possibility

Yeah sure, let’s wait for some other answers.
Maybe someone has a good idea!