cvar_ce_loss¶
- probly.losses.torch.cvar_ce_loss(output: Tensor, targets: Tensor, delta: float) Tensor[source]¶
CVaR cross-entropy loss from [WFC+26].
The batch-wise CVaR approximation of Eq. 7 averages cross-entropy over the top
floor(delta * B)highest-loss samples: only the worstdeltafraction of the batch receives gradient.delta=1recovers the batch mean (ERM).- Parameters:
output – Logits of shape
(B, num_classes).targets – Ground-truth class indices of shape
(B,).delta – Fraction of highest-loss samples to keep, in (0, 1].
- Returns:
Scalar cross-entropy loss averaged over the selected samples.
- Raises:
ValueError – If delta is outside (0, 1].