Skip to content

How to use ClassifierOutputTarget() for a model based on binary classification #297

Answered by jacobgil
ahxmeds asked this question in Q&A
Discussion options

You must be logged in to vote

Hi,
The issue is that we need a target that supports the binary output case.
When we have a binary output, it's already the score of category 1.
So we can create a custom target that multiplies by 1 if we want the second category, and by -1 if we want to first category.
I added a custom target here:
https://github.com/jacobgil/pytorch-grad-cam/blob/master/pytorch_grad_cam/utils/model_targets.py#L21

So you can now just use BinaryClassifierOutputTarget.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by ahxmeds
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants