Stochastic Gradient Hamiltonian Monte Carlo (SGHMC)

class sghmc.SGHMCSampler(params, cost_fun, seed=None, batch_generator=None, epsilon=0.01, session=<Mock name='tensorflow.get_default_session()' id='139670266625552'>, burn_in_steps=3000, scale_grad=1.0, dtype=<Mock name='tensorflow.float64' id='139670266623648'>, mdecay=0.05)[source]

Bases: tensorflow_mcmc.sampling.mcmc_base_classes.BurnInMCMCSampler

Stochastic Gradient Hamiltonian Monte-Carlo Sampler that uses a burn-in procedure to adapt its own hyperparameters during the initial stages of sampling.

See [1] for more details on this burn-in procedure. See [2] for more details on Stochastic Gradient Hamiltonian Monte-Carlo.

[1] J. T. Springenberg, A. Klein, S. Falkner, F. Hutter
Bayesian Optimization with Robust Bayesian Neural Networks. In Advances in Neural Information Processing Systems 29 (2016).
[2] T. Chen, E. B. Fox, C. Guestrin
Stochastic Gradient Hamiltonian Monte Carlo In Proceedings of Machine Learning Research 32 (2014).
__init__(params, cost_fun, seed=None, batch_generator=None, epsilon=0.01, session=<Mock name='tensorflow.get_default_session()' id='139670266625552'>, burn_in_steps=3000, scale_grad=1.0, dtype=<Mock name='tensorflow.float64' id='139670266623648'>, mdecay=0.05)[source]
Initialize the sampler parameters and set up a tensorflow.Graph
for later queries.
Parameters:

params : list of tensorflow.Variable objects

Target parameters for which we want to sample new values.

cost_fun : callable

Function that takes params as input and returns a 1-d tensorflow.Tensor that contains the cost-value. Frequently denoted with U in literature.

seed : int, optional

Random seed to use. Defaults to None.

batch_generator : BatchGenerator, optional

Iterable which returns dictionaries to feed into tensorflow.Session.run() calls to evaluate the cost function. Defaults to None which indicates that no batches shall be fed.

epsilon : float, optional

Value that is used as learning rate parameter for the sampler, also denoted as discretization parameter in literature. Defaults to 0.01.

session : tensorflow.Session, optional

Session object which knows about the external part of the graph (which defines Cost, and possibly batches). Used internally to evaluate (burn-in/sample) the sampler.

burn_in_steps: int, optional

Number of burn-in steps to perform. In each burn-in step, this sampler will adapt its own internal parameters to decrease its error. For reference see: TODO ADD PAPER REFERENCE HERE

scale_grad : float, optional

Value that is used to scale the magnitude of the noise used during sampling. In a typical batches-of-data setting this usually corresponds to the number of examples in the entire dataset. Defaults to 1.0 which corresponds to no scaling.

dtype : tensorflow.DType, optional

Type of elements of tensorflow.Tensor objects used in this sampler. Defaults to tensorflow.float64.

mdecay : float, optional

(Constant) momentum decay per time-step. Defaults to 0.05.

See also

tensorflow_mcmc.sampling.mcmc_base_classes.BurnInMCMCSampler
Base class for SGHMCSampler that specifies how actual sampling is performed (using iterator protocol, e.g. next(sampler)).

Examples

Simple, plain example: TODO: Add 2D Gaussian Case here

Simple example that uses batches: TODO: Add simplified batch example here