SGHMC¶

class
pysgmcmc.samplers.sghmc.
SGHMCSampler
(params, cost_fun, batch_generator=None, stepsize_schedule=<pysgmcmc.stepsize_schedules.ConstantStepsizeSchedule object>, burn_in_steps=3000, mdecay=0.05, scale_grad=1.0, session=None, dtype=tf.float64, seed=None)[source]¶ Stochastic Gradient Hamiltonian MonteCarlo Sampler that uses a burnin procedure to adapt its own hyperparameters during the initial stages of sampling.
See [1] for more details on this burnin procedure.
See [2] for more details on Stochastic Gradient Hamiltonian MonteCarlo.
 [1] J. T. Springenberg, A. Klein, S. Falkner, F. Hutter
In Advances in Neural Information Processing Systems 29 (2016).
 [2] T. Chen, E. B. Fox, C. Guestrin
In Proceedings of Machine Learning Research 32 (2014).

__init__
(params, cost_fun, batch_generator=None, stepsize_schedule=<pysgmcmc.stepsize_schedules.ConstantStepsizeSchedule object>, burn_in_steps=3000, mdecay=0.05, 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 1d tensorflow.Tensor that contains the costvalue. Frequently denoted with U in literature.
 batch_generator (iterable, 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 burnin steps to perform. In each burnin 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.
 mdecay (float, optional) –
(Constant) momentum decay per timestep. Defaults to 0.05.
For reference see: Bayesian Optimization with Robust Bayesian Neural Networks.
 scale_grad (float, optional) – Value that is used to scale the magnitude of the noise used during sampling. In a typical batchesofdata setting this usually corresponds to the number of examples in the entire dataset. Defaults to 1.0 which corresponds to no scaling.
 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 (burnin/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.
See also
pysgmcmc.sampling.BurnInMCMCSampler()
 Base class for SGHMCSampler that specifies how actual sampling is performed (using iterator protocol, e.g. next(sampler)).