I'm trying to train a model with PyTorch. Is there any simple way to create a loss like weighted_cross_entropy_with_logits
from Tensorflow?
There are pos_weight
argument in weighted_cross_entropy_with_logits
that can help with balancing. But there are only weights for labels in the list of arguments in BCEWithLogitsLoss
.
pos_weight
and the corresponding pull request was merged into PyTorch 0.4.1. See the docs