Loss¶
- class mlip.models.loss.Loss¶
Very simple loss base class that defines the signature of the call function.
- abstract __call__(prediction: Prediction, ref_graph: GraphsTuple, epoch: int, eval_metrics: bool = False) tuple[float, dict[str, float]] ¶
The call function that outputs the loss and metrics (auxiliary data).
- Parameters:
prediction – The force field predictor’s outputs.
ref_graph – The reference graph holding the ground truth data.
epoch – The epoch number.
eval_metrics – Switch deciding whether to include additional evaluation metrics to the returned dictionary. Default is
False
.
- Returns:
The loss and the auxiliary metrics dictionary.
- class mlip.models.loss.WeightedEFSLoss(energy_weight_schedule: ~typing.Callable[[int], float] = <function WeightedEFSLoss.<lambda>>, forces_weight_schedule: ~typing.Callable[[int], float] = <function WeightedEFSLoss.<lambda>>, stress_weight_schedule: ~typing.Callable[[int], float] = <function WeightedEFSLoss.<lambda>>, extended_metrics: bool = False)¶
Loss base class for scheduled average of energy, forces and stress errors.
- __init__(energy_weight_schedule: ~typing.Callable[[int], float] = <function WeightedEFSLoss.<lambda>>, forces_weight_schedule: ~typing.Callable[[int], float] = <function WeightedEFSLoss.<lambda>>, stress_weight_schedule: ~typing.Callable[[int], float] = <function WeightedEFSLoss.<lambda>>, extended_metrics: bool = False) None ¶
Loss averaging energy, forces and stress errors with epoch-dependent weights.
- Parameters:
energy_weight_schedule – The schedule function for the energy weight. Default is a constant weight of 1.
forces_weight_schedule – The schedule function for the energy weight. Default is a constant weight of 25.
stress_weight_schedule – The schedule function for the energy weight. Default is a constant weight of 0.
extended_metrics – Whether to include an extended list of metrics. Defaults to
False
.
- __call__(prediction: Prediction, ref_graph: GraphsTuple, epoch: int, eval_metrics: bool = False) tuple[float, dict[str, float]] ¶
The call function that outputs the loss and metrics (auxiliary data).
- Parameters:
prediction – The force field predictor’s outputs.
ref_graph – The reference graph holding the ground truth data.
epoch – The epoch number.
eval_metrics – Switch deciding whether to include additional evaluation metrics to the returned dictionary. Default is
False
.
- Returns:
The loss and the auxiliary metrics dictionary.
- class mlip.models.loss.MSELoss(energy_weight_schedule: ~typing.Callable[[int], float] = <function WeightedEFSLoss.<lambda>>, forces_weight_schedule: ~typing.Callable[[int], float] = <function WeightedEFSLoss.<lambda>>, stress_weight_schedule: ~typing.Callable[[int], float] = <function WeightedEFSLoss.<lambda>>, extended_metrics: bool = False)¶
Mean squared-error loss for scheduled average of energy, forces and stress errors.
- __init__(energy_weight_schedule: ~typing.Callable[[int], float] = <function WeightedEFSLoss.<lambda>>, forces_weight_schedule: ~typing.Callable[[int], float] = <function WeightedEFSLoss.<lambda>>, stress_weight_schedule: ~typing.Callable[[int], float] = <function WeightedEFSLoss.<lambda>>, extended_metrics: bool = False) None ¶
Loss averaging energy, forces and stress errors with epoch-dependent weights.
- Parameters:
energy_weight_schedule – The schedule function for the energy weight. Default is a constant weight of 1.
forces_weight_schedule – The schedule function for the energy weight. Default is a constant weight of 25.
stress_weight_schedule – The schedule function for the energy weight. Default is a constant weight of 0.
extended_metrics – Whether to include an extended list of metrics. Defaults to
False
.
- __call__(prediction: Prediction, ref_graph: GraphsTuple, epoch: int, eval_metrics: bool = False) tuple[float, dict[str, float]] ¶
The call function that outputs the loss and metrics (auxiliary data).
- Parameters:
prediction – The force field predictor’s outputs.
ref_graph – The reference graph holding the ground truth data.
epoch – The epoch number.
eval_metrics – Switch deciding whether to include additional evaluation metrics to the returned dictionary. Default is
False
.
- Returns:
The loss and the auxiliary metrics dictionary.
- class mlip.models.loss.HuberLoss(energy_weight_schedule: ~typing.Callable[[int], float] = <function WeightedEFSLoss.<lambda>>, forces_weight_schedule: ~typing.Callable[[int], float] = <function WeightedEFSLoss.<lambda>>, stress_weight_schedule: ~typing.Callable[[int], float] = <function WeightedEFSLoss.<lambda>>, extended_metrics: bool = False)¶
Huber loss for scheduled average of energy, forces and stress errors.
- __init__(energy_weight_schedule: ~typing.Callable[[int], float] = <function WeightedEFSLoss.<lambda>>, forces_weight_schedule: ~typing.Callable[[int], float] = <function WeightedEFSLoss.<lambda>>, stress_weight_schedule: ~typing.Callable[[int], float] = <function WeightedEFSLoss.<lambda>>, extended_metrics: bool = False) None ¶
Loss averaging energy, forces and stress errors with epoch-dependent weights.
- Parameters:
energy_weight_schedule – The schedule function for the energy weight. Default is a constant weight of 1.
forces_weight_schedule – The schedule function for the energy weight. Default is a constant weight of 25.
stress_weight_schedule – The schedule function for the energy weight. Default is a constant weight of 0.
extended_metrics – Whether to include an extended list of metrics. Defaults to
False
.
- __call__(prediction: Prediction, ref_graph: GraphsTuple, epoch: int, eval_metrics: bool = False) tuple[float, dict[str, float]] ¶
The call function that outputs the loss and metrics (auxiliary data).
- Parameters:
prediction – The force field predictor’s outputs.
ref_graph – The reference graph holding the ground truth data.
epoch – The epoch number.
eval_metrics – Switch deciding whether to include additional evaluation metrics to the returned dictionary. Default is
False
.
- Returns:
The loss and the auxiliary metrics dictionary.