neuralop.losses
.LpLoss
- class neuralop.losses.LpLoss(d=1, p=2, L=6.283185307179586, reduce_dims=0, reductions='sum')[source]
LpLoss provides the L-p norm between two discretized d-dimensional functions
- Attributes:
- name
Methods
__call__
(y_pred, y, **kwargs)Call self as a function.
abs
(x, y[, h])absolute Lp-norm
reduce_all
(x)reduce x across all dimensions in self.reduce_dims according to self.reductions
rel
(x, y)rel: relative LpLoss computes ||x-y||/||y||
uniform_h
(x)uniform_h creates default normalization constants if none already exist.
- uniform_h(x)[source]
uniform_h creates default normalization constants if none already exist.
- Parameters:
- xtorch.Tensor
input data
- Returns:
- hlist
list of normalization constants per-dim
- reduce_all(x)[source]
reduce x across all dimensions in self.reduce_dims according to self.reductions
- abs(x, y, h=None)[source]
absolute Lp-norm
- Parameters:
- xtorch.Tensor
inputs
- ytorch.Tensor
targets
- hfloat or list, optional
normalization constants for reduction either single scalar or one per dimension
- rel(x, y)[source]
rel: relative LpLoss computes ||x-y||/||y||
- Parameters:
- xtorch.Tensor
inputs
- ytorch.Tensor
targets