HMCKernel#
- class liesel.goose.HMCKernel(position_keys, initial_step_size=None, initial_inverse_mass_matrix=None, num_integration_steps=10, da_target_accept=0.8, da_gamma=0.05, da_kappa=0.75, da_t0=10, mm_diag=True, identifier='')[source]#
Bases:
ModelMixin,TransitionMixin[HMCKernelState,HMCTransitionInfo],TuningMixin[HMCKernelState,DefaultTuningInfo],ReprMixinA HMC kernel with dual averaging and an inverse mass matrix tuner, implementing the
Kernelprotocol.- Parameters:
position_keys (
Sequence[str]) – Sequence of position keys (variable names) handled by this kernel.initial_step_size (
float|None, default:None) – Value at which to start step size tuning.initial_inverse_mass_matrix (
Any|None, default:None) – Starting value for the inverse mass matrix (the precision matrix of the momentum). IfNone, an identity matrix will be used here.num_integration_steps (
int, default:10) – Number of integration steps used in the leapfrog algorithm. Corresponds toLin the Stan reference manual [1].da_target_accept (
float, default:0.8) – Target acceptance probability for dual averaging algorithm.da_gamma (
float, default:0.05) – The adaptation regularization scale.da_kappa (
float, default:0.75) – The adaptation relaxation exponent.da_t0 (
int, default:10) – The adaptation iteration offset.mm_diag (
bool, default:True) – Whether to use a diagonal mass matrix for drawing the momentum vector. If True, the inverse mass matrix will be tuned during adaptation usingtune_inv_mm_diag(). If set to False, the mass matrix will be tuned usingtune_inv_mm_full()instead.identifier (
str, default:'') – An string acting as a unique identifier for this kernel.
Notes
For more information on step size tuning via dual averaging, see
da_step()andDAKernelState.Methods
end_epoch(prng_key, kernel_state, ...)Sets the step size as found by the dual averaging algorithm.
end_warmup(prng_key, kernel_state, ...)Currently does nothing.
init_state(prng_key, model_state)Initializes the kernel state with an identity inverse mass matrix and a reasonable step size (unless explicit arguments were provided by the user).
start_epoch(prng_key, kernel_state, ...)Resets the state of the dual averaging algorithm.
Attributes
Dict of error codes and their meaning.
Kernel identifier, set by
EngineBuilderWhether this kernel needs its history for tuning.
Tuple of position keys handled by this kernel.