nvalchemi.training.losses.reductions.frobenius_mse#

nvalchemi.training.losses.reductions.frobenius_mse(pred, target)[source]#

Per-graph Frobenius MSE over the trailing two matrix dims.

Returns ((pred - target) ** 2).mean(dim=(-2, -1)) — the squared Frobenius norm of the residual matrix, averaged over its entries. Canonical use is on stress tensors of shape (B, 3, 3).

Parameters:
  • pred (Float[torch.Tensor, 'B 3 3']) – Same-shape per-graph matrix tensors.

  • target (Float[torch.Tensor, 'B 3 3']) – Same-shape per-graph matrix tensors.

Returns:

Per-graph Frobenius MSE.

Return type:

Float[torch.Tensor, “B”]

Raises:

ValueError – If shapes differ or input is not at least a batched matrix tensor (ndim >= 3).