Version: dev

gradient

Stable function · Replay and adjoint

Tier: stable · Kind: function · Topic: Replay and adjoint

JuliaRust
gradientnot exported

Julia

gradient(run::EarthSciIntegrator.Run)
gradient(run) -> (J, ū₀, p̄)

The discrete adjoint gradient of the run’s functional on the frozen tape (spec/adjoint.md §2.2): ū₀ = λ(t₀) (§6.2) and p̄ over every parameter, with bind_dt-bound parameters set to zero (§5.8). Needs forward! first. Point terms are added on reaching their output times (§2.1).

Source

Example (gradient)

J, ū0, p̄ = gradient(run)
# The functional is u(2), so ū0 is d u(2) / d u(0) = exp(-k t).
@test isapprox(only(ū0), exp(-k * 2); rtol = 1e-4)
@test length(p̄) == length(prob.p)

From docs/api/examples/julia/forward_and_gradient.jl

Rust

Rust does not export this function.