Skip to content

Loss Functions

EikonalLoss()

The Eikonal loss regularizes the gradient of a neural implicit to have unit norm everywhere:

\[\mathcal{L}_{\text{eik}}(x) = (||\nabla f_\theta(x)|| -1)^2\]

The gradient is computed from the input \(X\) and the output \(Y\) of the neural model.

__call__(X, Y)

Parameters:

Name Type Description Default
X Tensor

input batch of the model

required
Y Tensor

output of the model.

required

Returns:

Type Description

torch.Tensor: Eikonal loss

HKRLoss(margin=0.01, lmbd=10.0)

Hinge Kantorovitch-Rubinstein loss

\[\text{hKR}(x) = \max(0, m-x) - \frac{x}{\lambda}\]

Parameters:

Name Type Description Default
margin float

hinge margin. Must be small but not too small. Defaults to 1e-2.

0.01
lmbd float

weight balance between the two terms.. Defaults to 10.

10.0
References
  • Achieving robustness in classification using optimal transport with hinge regularization, Serrurier et al., 2021
  • 1-Lipschitz neural distance fields, Coiffier and Béthune, 2024

__call__(y)

Parameters:

Name Type Description Default
y Tensor

vector of predicted values

required

HotspotLoss(lmbd)

\[\mathcal{L}_{\text{heat}}(f) = \mathbb{E}_x \left[ e^{-2 \lambda |f(x)|} \left( || \nabla f||^2 + 1 \right) \right].\]
References
  • HotSpot: Signed Distance Function Optimization with an Asymptotically Sufficient Condition, Wang et al., 2025

SALDLoss()

Sign agnostic learning loss with derivatives

References

SALD: Sign Agnostic Learning with Derivatives, Atzmon and Lipman, 2020

__call__(y_pred, y_target)

Parameters:

Name Type Description Default
y_pred Tensor

predicted values by the model

required
y_target Tensor

target values

required

SALLoss(l=1.0, metric='l2')

Signed agnostic learning loss.

Parameters:

Name Type Description Default
l float

Power value for the distance. Defaults to 1.

1.0
metric str

which metric to use. Choices are "l2" and "l0". Defaults to "l2".

'l2'
References

SAL: Sign Agnostic Learning of Shapes From Raw Data, Atzmon and Lipman, 2020

__call__(y_pred, y_target)

Parameters:

Name Type Description Default
y_pred Tensor

predicted values by the model

required
y_target Tensor

target values

required

SingularHessianLoss

TODO

VectorAlignmentLoss()

Cosine similarity loss between two vectors.

__call__(y, target)

Parameters:

Name Type Description Default
y Tensor

input tensor

required
target Tensor

target tensor

required

Returns:

Type Description

torch.Tensor: Cosine similarity