explosion / explosion/spaCy

training with custom loss function, or assigning weights to classes

Open
#6,873 1 comment 3 reactions 0 assignees View on GitHub
enhancement feat / transformer
Dominant language
Python
Stars
33.9k
Forks
4.7k
Avg merge
3m
Merged PRs (30d)
1

Description

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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.