My basic understanding of HMC comes from here.

Reference: https://www.tensorflow.org/api_docs/python/tf/contrib/bayesflow/hmc/chain

```
# Sampling from a standard normal (note `log_joint()` is unnormalized):
from tensorflow.contrib.bayesflow import hmc
class HMCChainSampling():
def __init__(self):
self.chain, self.acceptance_probs = hmc.chain(1000, 0.5, 2, tf.zeros(10), log_joint,
event_dims=[0])
# Discard first half of chain as warmup/burn-in
self.warmed_up = self.chain[500:]
self.mean_est = tf.reduce_mean(self.warmed_up, 0)
self.var_est = tf.reduce_mean(tf.square(self.warmed_up), 0) - tf.square(self.mean_est)
self.init = tf.global_variables_initializer()
def log_joint(x):
return tf.reduce_sum(-0.5 * tf.square(x))
def sampling(self):
sess = tf.Session()
with sess.as_default():
self.init.run()
mean_est, var_est = self.mean_est.eval(), self.var_est.eval()
sess.close()
return mean_est, var_est
hmc = HMCChainSampling()
mean_est, var_est = hmc.sampling()
print("var_est: ", var_est, " mean_est: ", mean_est)
```

@junpenglao Am I on the right track?