thu-ml / zhusuan

A probabilistic programming library for Bayesian deep learning, generative models, based on Tensorflow
http://zhusuan.readthedocs.io
MIT License
2.2k stars 418 forks source link

HMC parameters settings #89

Closed ifangcheng closed 6 years ago

ifangcheng commented 6 years ago

in examples: gaussian.py

Define HMC parameters

kernel_width = 0.1
n_chains = 1000
n_iters = 200

what is the diffetence between n_chains and n_iters?

it seems that both of them affect the final sampling quality?

what is exactly the difference if i change them as follows: n_chains = 100
n_iters = 2000

thjashin commented 6 years ago

n_chains stands for how many MCMC chains you are simulating in parallel. n_iters represents how long you simulate, say, n_chains = 100, n_iters = 2000 means you simulate 100 chains for 2000 iterations.

ifangcheng commented 6 years ago

ok, i see but n_chains = 100 n_iters = 2000 vs n_chains = 1000 n_iters = 200

normally, which one will be better?

thjashin commented 6 years ago

They are independent of each other. In general, n_iters should be sufficiently large so that the chain will mix. It only depends on the problem. For n_chains, you can think of it as n_threads in parallel programming. More is better, which means you can get more samples in the same amount of running time, but for large models, typically you cannot afford a too large n_chains.

ifangcheng commented 6 years ago

it seems like a kind of particle filter many thx!

thjashin commented 6 years ago

You're welcome.