Skip to content

dew.objectives.residuals

Objectives whose loss is a mean square of residuals, stepped by the gradient or by Gauss-Newton.

A physics-informed network’s loss is its equation’s residuals at its collocation points, and a least-squares fit’s is its errors: Residuals takes each batch row’s residuals from its subclass and trains on their mean square. A run whose optimizer is Gauss-Newton’s (dew.gauss_newton.gauss_newton, damped as Levenberg-Marquardt’s) asks it for its residuals’ system (Step.equations): each microbatch states its part of the update’s as statistics that pool by adding, which the trainer sums as it sums any statistic and hands the optimizer whole, J_i^T J_i and J_i^T r_i where the update’s residuals are at least its parameters (NormalEquations), its rows of J and r placed at its examples’ places among the update’s where they are fewer (RowEquations). Which form an update takes is its geometry, the update’s examples (Step.example_count) against the parameters, which the trainer gives the loss as it plans the step’s shapes. The loss is the mean square still, its gradient its own; the optimizer steps by the solve.

NameSummary
ResidualsAn objective whose loss is the mean over its batch’s rows of the sum of each row’s squared residuals (residuals), which states its residuals’ Gauss-Newton system where its step asks for it (Step.equations, the module’s docstring).

class source

class Residuals(Objective[Ratio | NormalEquations | RowEquations])

An objective whose loss is the mean over its batch’s rows of the sum of each row’s squared residuals (residuals), which states its residuals’ Gauss-Newton system where its step asks for it (Step.equations, the module’s docstring).

def residuals(variables: Variables, batch: Batch, step: Step) -> jax.Array

Each row’s residuals, [B, …], every entry of a row a residual its loss squares.

def loss(
variables: Variables,
batch: Batch,
step: Step,
) -> Ratio | NormalEquations | RowEquations
def reduce_loss(
stats: Ratio | NormalEquations | RowEquations,
) -> tuple[jax.Array, jax.Array]

The mean squared residual, whatever system the statistics state beside it.