# SGLD¶

class pysgmcmc.samplers.sgld.SGLDSampler(params, cost_fun, batch_generator=None, stepsize_schedule=<pysgmcmc.stepsize_schedules.ConstantStepsizeSchedule object>, burn_in_steps=3000, A=1.0, scale_grad=1.0, session=None, dtype=tf.float64, seed=None)[source]

Stochastic Gradient Langevin Dynamics 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 Langevin Dynamics.

[1] J. T. Springenberg, A. Klein, S. Falkner, F. Hutter

In Advances in Neural Information Processing Systems 29 (2016).

Bayesian Optimization with Robust Bayesian Neural Networks.

[2] M.Welling, Y. W. Teh

In International Conference on Machine Learning (ICML) 28 (2011).

Bayesian Learning via Stochastic Gradient Langevin Dynamics.

__init__(params, cost_fun, batch_generator=None, stepsize_schedule=<pysgmcmc.stepsize_schedules.ConstantStepsizeSchedule object>, burn_in_steps=3000, A=1.0, scale_grad=1.0, session=None, dtype=tf.float64, seed=None)[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. 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. stepsize_schedule (pysgmcmc.stepsize_schedules.StepsizeSchedule) – Iterator class that produces a stream of stepsize values that we can use in our samplers. See also: pysgmcmc.stepsize_schedules 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. Defaults to 3000. For reference see: Bayesian Optimization with Robust Bayesian Neural Networks. A (float, optional) – TODO Doku Defaults to 1.0. 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. 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. dtype (tensorflow.DType, optional) – Type of elements of tensorflow.Tensor objects used in this sampler. Defaults to tensorflow.float64. seed (int, optional) – Random seed to use. Defaults to None.

tensorflow_mcmc.sampling.mcmc_base_classes.BurnInMCMCSampler()