lumin.nn.losses package¶
Submodules¶
lumin.nn.losses.basic_weighted module¶
-
class
lumin.nn.losses.basic_weighted.
WeightedMSE
(weight=None)[source]¶ Bases:
torch.nn.modules.loss.MSELoss
Class for computing Mean Squared-Error loss with optional weights per prediction. For compatability with using basic PyTorch losses, weights are passed during initialisation rather than when computing the loss.
- Parameters
weight (
Optional
[Tensor
]) – sample weights as PyTorch Tensor, to be used with data to be passed when computing the loss
- Examples::
>>> loss = WeightedMSE() >>> >>> loss = WeightedMSE(weights)
-
class
lumin.nn.losses.basic_weighted.
WeightedMAE
(weight=None)[source]¶ Bases:
torch.nn.modules.loss.L1Loss
Class for computing Mean Absolute-Error loss with optional weights per prediction. For compatability with using basic PyTorch losses, weights are passed during initialisation rather than when computing the loss.
- Parameters
weight (
Optional
[Tensor
]) – sample weights as PyTorch Tensor, to be used with data to be passed when computing the loss
- Examples::
>>> loss = WeightedMAE() >>> >>> loss = WeightedMAE(weights)
-
class
lumin.nn.losses.basic_weighted.
WeightedCCE
(weight=None)[source]¶ Bases:
torch.nn.modules.loss.NLLLoss
Class for computing Categorical Cross-Entropy loss with optional weights per prediction. For compatability with using basic PyTorch losses, weights are passed during initialisation rather than when computing the loss.
- Parameters
weight (
Optional
[Tensor
]) – sample weights as PyTorch Tensor, to be used with data to be passed when computing the loss
- Examples::
>>> loss = WeightedCCE() >>> >>> loss = WeightedCCE(weights)
lumin.nn.losses.hep_losses module¶
-
class
lumin.nn.losses.hep_losses.
SignificanceLoss
(weight, sig_wgt=<class 'float'>, bkg_wgt=<class 'float'>, func=typing.Callable[[torch.Tensor, torch.Tensor], torch.Tensor])[source]¶ Bases:
torch.nn.modules.module.Module
General class for implementing significance-based loss functions, e.g. Asimov Loss (https://arxiv.org/abs/1806.00322). For compatability with using basic PyTorch losses, event weights are passed during initialisation rather than when computing the loss.
- Parameters
weight (
Tensor
) – sample weights as PyTorch Tensor, to be used with data to be passed when computing the losssig_wgt – total weight of signal events
bkg_wgt – total weight of background events
func – callable which returns a float based on signal and background weights
- Examples::
>>> loss = SignificanceLoss(weight, sig_weight=sig_weight, ... bkg_weight=bkg_weight, func=calc_ams_torch) >>> >>> loss = SignificanceLoss(weight, sig_weight=sig_weight, ... bkg_weight=bkg_weight, ... func=partial(calc_ams_torch, br=10))