1

I have a beginner high level question about pytorch optimizer, namely is there a non-custom way to optimize for true positives? Let's say that i have a list of labels:

labels=[0,0,0,0,0,0,0,0,0,1]

And I would like a model to fit to those labels in a way that would favor a true positive - aka i really would like it to return '1' as last item, and i am not that concerned about false positive '1's for other items in a list.

I presume i can workaround this problem by defining a custom loss function which would give me weights for true positives / false positives, but i was wondering if there is an out of the box solution for that.

Kind regards.

Poe Dator
  • 4,535
  • 2
  • 14
  • 35
pawelek69420
  • 134
  • 1
  • 5

1 Answers1

1

you should pass classes weights as parameters to the loss function. For example, look at CrossEntropyLoss doc here to see how it is done. Also see similar answer here: https://stackoverflow.com/a/67836741/10396469

Poe Dator
  • 4,535
  • 2
  • 14
  • 35