Package jdistlib.inference.autodiff
Class ReverseModeLogDensity
java.lang.Object
jdistlib.inference.autodiff.ReverseModeLogDensity
- All Implemented Interfaces:
DifferentiableLogDensity,GradientProvider,LogDensity
public final class ReverseModeLogDensity
extends Object
implements DifferentiableLogDensity, GradientProvider
Reusable reverse-mode log density suitable for HMC and NUTS.
The primitive tape arena is reset, not reallocated, between evaluations. Instances are deliberately not thread-safe; create one per sampler chain.
-
Constructor Summary
ConstructorsConstructorDescriptionReverseModeLogDensity(int dimension, ReverseDifferentiableFunction function) ReverseModeLogDensity(int dimension, ReverseDifferentiableFunction function, int initialTapeCapacity) -
Method Summary
Modifier and TypeMethodDescriptionintbooleandoublelogDensityAndGradient(double[] state, double[] gradient) Evaluates the log density and replacesgradientwith its gradient.tape()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface jdistlib.inference.DifferentiableLogDensity
logDensity
-
Constructor Details
-
ReverseModeLogDensity
-
ReverseModeLogDensity
public ReverseModeLogDensity(int dimension, ReverseDifferentiableFunction function, int initialTapeCapacity)
-
-
Method Details
-
dimension
public int dimension() -
tape
-
logDensityAndGradient
public double logDensityAndGradient(double[] state, double[] gradient) Description copied from interface:DifferentiableLogDensityEvaluates the log density and replacesgradientwith its gradient.- Specified by:
logDensityAndGradientin interfaceDifferentiableLogDensity
-
hasAnalyticGradient
public boolean hasAnalyticGradient()- Specified by:
hasAnalyticGradientin interfaceGradientProvider
-