callcut.training.BCEWithLogitsLoss🔗
- class callcut.training.BCEWithLogitsLoss(pos_weight=None)[source]🔗
Binary cross-entropy loss with logits.
Wraps
torch.nn.BCEWithLogitsLosswith the BaseLoss interface.- Parameters:
- pos_weight
float|None Weight for the positive class. If
> 1, increases recall; if< 1, increases precision. Can be computed usingcompute_pos_weight().
- pos_weight
Attributes
Positive class weight.
Methods
forward(logits, targets)Compute binary cross-entropy loss.
Examples
>>> loss_fn = BCEWithLogitsLoss(pos_weight=2.0) >>> loss = loss_fn(logits, targets)