NeuralNetworkDerivatives<T>

Helpers & Utilities · AiDotNet.PhysicsInformed

Exact first and second derivatives of a network’s outputs with respect to its inputs, for physics-informed losses (gradients, Laplacians, Hessians of the PDE residual).

For Beginners

A physics-informed network is trained so that its output satisfies an equation involving its derivatives (for example the heat equation needs the second derivative in space). This class computes those derivatives of the network itself, exactly.

How It Works

Derivatives come from the AiDotNet.Tensors gradient tape (TensorFunc): the gradient is reverse-mode, and the Hessian is the Jacobian of a differentiable gradient (double backward), as torch.func.hessian computes it. That works for any network whose forward runs through engine ops, not only dense and activation stacks, and is exact rather than a finite-difference estimate.

Methods

Method Summary
PDEDerivatives<T> ComputeDerivatives(NeuralNetworkBase<T> network, T[] inputs, int outputDim) Computes the first derivatives [outputDim, inputDim] and second derivatives [outputDim, inputDim, inputDim] of the network at a single input point.
T[] ComputeHessian(NeuralNetworkBase<T> network, T[] inputs, int outputIndex) Computes the Hessian [inputDim, inputDim] of one network output at a single input point.