xnn.common.train.losses.UncertaintyWeights#
- class xnn.common.train.losses.UncertaintyWeights(names)[source]#
Bases:
ModuleLearned weights of the loss terms, after Kendall, Gal and Cipolla (CVPR 2018).
Every term
L_k(already times its config weight) enters the training objective asL_k / (2 sigma_k^2) + log sigma_kwith a trainablelog sigma_k, which starts at zero. The weights settle where each term is balanced by its own noise level, so they need no hand tuning.- Parameters:
names (sequence of str) – The log keys of the weighted terms (
"energy_mse","charge_mse", …).- Variables:
log_sigma (torch.nn.ParameterDict) –
log sigma_kper term.
- forward(parts)[source]#
The objective of the terms in
parts(a term without a weight adds as it is).- Parameters:
parts (dict of str to Tensor) – The weighted terms of
weighted_loss()(itsparts).- Returns:
The scalar objective.
- Return type:
Tensor