neuralop.losses.equation_losses
.PoissonInteriorLoss
- class neuralop.losses.equation_losses.PoissonInteriorLoss(method='autograd', loss=<function mse_loss>)[source]
PoissonInteriorLoss computes the loss on the interior points of model outputs according to Poisson’s equation in 2d: ∇·((1 + 0.1u^2)∇u(x)) = f(x)
- Parameters:
- methodLiteral[‘autograd’] only (for now)
How to compute derivatives for equation loss.
If ‘autograd’, differentiates using torch.autograd.grad. This can be used with outputs with any irregular
point cloud structure.
- loss: Callable, optional
Base loss class to compute distances between expected and true values, by default torch.nn.functional.mse_loss
Methods
__call__
(y_pred, **kwargs)Call self as a function.
autograd
(u, output_queries, ...)Compute loss between the left-hand side and right-hand side of nonlinear Poisson's equation: ∇·((1 + 0.1u^2)∇u(x)) = f(x)
- autograd(u, output_queries, output_source_terms_domain, num_boundary, **kwargs)[source]
Compute loss between the left-hand side and right-hand side of nonlinear Poisson’s equation: ∇·((1 + 0.1u^2)∇u(x)) = f(x)
- u: torch.Tensor | dict
output of the model.
If output_queries is passed to the model as a dict, this will be a
dict of outputs provided over the points at each value in output_queries. Each tensor will be shape (batch, n_points, 2).
If a tensor, u will be of shape (batch, num_boundary + num_interior, 2), where
u[:, 0:num_boundary, :] are boundary points and u[:, num_boundary:, :] are interior points.
- output_queries: torch.Tensor | dict
output queries provided to the model. If provided as a dict of tensors, u will also be returned as a dict keyed the same way. If provided as a tensor, u will be a tensor of the same shape except for number of channels. If a tensor, output_queries[:, 0:num_boundary, :] are boundary points and output_queries[:, num_boundary:, :] are interior points.
- output_source_terms_domain: torch.Tensor
source terms f(x) defined for this specific instance of Poisson’s equation.