drugforge.ml.loss.RangeLoss
- class drugforge.ml.loss.RangeLoss(*args: Any, **kwargs: Any)[source]
Bases:
Module- __init__(lower_lim, upper_lim)[source]
Class for calculating a loss to penalize predictions outside of the given range. Current implementation uses a squared difference penalty.
- Parameters:
lower_lim (float) – Bottom limit of acceptable range
upper_lim (float) – Upper limit of acceptable range
Methods
__init__(lower_lim, upper_lim)Class for calculating a loss to penalize predictions outside of the given range.
forward(pred, pose_preds, target, in_range, ...)No loss for predictions within self range, otherwise calculate squared distance to closest bound.
- forward(pred, pose_preds, target, in_range, uncertainty)[source]
No loss for predictions within self range, otherwise calculate squared distance to closest bound.
- Parameters:
pred (torch.Tensor) – Model prediction
target (torch.Tensor) – Prediction target
in_range (torch.Tensor) – target’s presence in the dynamic range of the assay. Give a value of < 0 for target below lower bound, > 0 for target above upper bound, and 0 or None for inside range
uncertainty (torch.Tensor) – Uncertainty in target measurements
- Returns:
Calculated loss
- Return type:
torch.Tensor