nvalchemi.training.StressHuberLoss#

class nvalchemi.training.StressHuberLoss(*, target_key='stress', prediction_key='predicted_stress', delta=0.01, ignore_nonfinite=True, dtype_policy='strict')[source]#

Huber loss on per-graph stress tensors.

Applies the Huber function \(H_\delta\) to each stress-component residual, then reuses the per-graph averaging of StressMSELoss:

\[L = \frac{1}{B} \sum_{i=1}^{B} \frac{1}{9} \sum_{p=1}^{3} \sum_{q=1}^{3} H_\delta\!\left(\hat{\sigma}_{ipq} - \sigma_{ipq}\right).\]
Parameters:
  • target_key (str, default "stress") – Target container key for the target tensor.

  • prediction_key (str, default "predicted_stress") – Prediction container key for the model output.

  • delta (float, default 0.01) – Positive transition point between quadratic and linear Huber regimes.

  • ignore_nonfinite (bool, default True) – When True, target stress components that are NaN or infinite are excluded from both loss value and gradient using torch.isfinite().

  • dtype_policy ({"strict", "prediction_to_target", "target_to_prediction"}, default "strict") – How to handle prediction/target dtype mismatches before validation. "strict" raises; the other policies cast one tensor to match the other.

compute_residual(pred, target, valid)[source]#

Return componentwise Huber stress losses, zeroing invalid entries.

Parameters:
Return type:

Tensor

extra_repr()[source]#

Human-readable hyperparameter summary for nn.Module’s repr.

Return type:

str