blackjax.adaptation.pathfinder_adaptation#

Implementation of the Pathinder warmup for the HMC family of sampling algorithms.

Module Contents#

Classes#

PathfinderAdaptationState

Typed version of namedtuple.

Functions#

base([target_acceptance_rate])

Warmup scheme for sampling procedures based on euclidean manifold HMC.

pathfinder_adaptation(→ blackjax.base.AdaptationAlgorithm)

Adapt the value of the inverse mass matrix and step size parameters of

class PathfinderAdaptationState[source]#

Typed version of namedtuple.

Usage in Python versions >= 3.6:

class Employee(NamedTuple):
    name: str
    id: int

This is equivalent to:

Employee = collections.namedtuple('Employee', ['name', 'id'])

The resulting class has an extra __annotations__ attribute, giving a dict that maps field names to types. (The field names are also in the _fields attribute, which is part of the namedtuple API.) Alternative equivalent keyword syntax is also accepted:

Employee = NamedTuple('Employee', name=str, id=int)

In Python versions <= 3.5 use:

Employee = NamedTuple('Employee', [('name', str), ('id', int)])
ss_state: blackjax.adaptation.step_size.DualAveragingAdaptationState[source]#
step_size: float[source]#
inverse_mass_matrix: blackjax.types.Array[source]#
base(target_acceptance_rate: float = 0.8)[source]#

Warmup scheme for sampling procedures based on euclidean manifold HMC.

This adaptation runs in two steps:

1. The Pathfinder algorithm is ran and we subsequently compute an estimate for the value of the inverse mass matrix, as well as a new initialization point for the markov chain that is supposedly closer to the typical set. 2. We then start sampling with the MCMC algorithm and use the samples to adapt the value of the step size using an optimization algorithm so that the mcmc algorithm reaches a given target acceptance rate.

Parameters:

target_acceptance_rate – The target acceptance rate for the step size adaptation.

Returns:

  • init – Function that initializes the warmup.

  • update – Function that moves the warmup one step.

  • final – Function that returns the step size and mass matrix given a warmup state.

pathfinder_adaptation(algorithm: Union[blackjax.mcmc.hmc.hmc, blackjax.mcmc.nuts.nuts], logdensity_fn: Callable, initial_step_size: float = 1.0, target_acceptance_rate: float = 0.8, **extra_parameters) blackjax.base.AdaptationAlgorithm[source]#

Adapt the value of the inverse mass matrix and step size parameters of algorithms in the HMC fmaily.

Parameters:
  • algorithm – The algorithm whose parameters are being tuned.

  • logdensity_fn – The log density probability density function from which we wish to sample.

  • initial_step_size – The initial step size used in the algorithm.

  • target_acceptance_rate – The acceptance rate that we target during step size adaptation.

  • **extra_parameters – The extra parameters to pass to the algorithm, e.g. the number of integration steps for HMC.

Returns:

  • A function that returns the last chain state and a sampling kernel with the

  • tuned parameter values from an initial state.