spaCy icon indicating copy to clipboard operation
spaCy copied to clipboard

training with custom loss function, or assigning weights to classes

Open fhamborg opened this issue 4 years ago • 1 comments

Hi!

Is it possible to define a custom loss function when training spacy's transformers? Specifically, I'm asking because the classes in my dataset are imbalanced, and I'd like to weight each class differently. In pytorch, you could define a weight for each class in various loss functions, such as nn.CrossEntropyLoss(weight=...)

How would that work in spacy-transformers?

Thanks in advance for your answer! :-)

Cheers, Felix

fhamborg avatar Oct 05 '19 08:10 fhamborg

Also want to know this for explosion/spacy-transformers#77

pbakhtin avatar Oct 11 '19 17:10 pbakhtin