@@ -17,13 +17,13 @@ Theory
1717++++++
1818
1919Maximum likelihood learning of energy-based models requires a robust algorithm
20- to sample negative phase particles (see Eq. :ref:`free_energy_grad` of the
21- :doc:`rbm` tutorial). When training RBMs with CD or PCD, this is typically
22- done with block Gibbs sampling, where the conditional distributions
23- :math:`p(h|v)` and :math:`p(v |h)` are used as the transition operators of the
24- Markov chain. While Gibbs sampling may be computationally efficient, it
25- nevertheless operates via a random walk which might not be statistically
26- efficient for some distributions.
20+ to sample negative phase particles (see Eq.(4) of the :doc:`rbm` tutorial).
21+ When training RBMs with CD or PCD, this is typically done with block Gibbs
22+ sampling, where the conditional distributions :math:`p(h|v)` and
23+ :math:`p(v |h)` are used as the transition operators of the Markov chain. While
24+ Gibbs sampling may be computationally efficient, it nevertheless operates via
25+ a random walk which might not be statistically efficient for some
26+ distributions.
2727
2828Hybrid Monte Carlo (HMC) [Duane87]_ avoids random walk behavior by simulating
2929a physical system governed by Hamiltonian dynamics. Model samples are obtained
@@ -252,6 +252,12 @@ and full-step of :math:`s`, and then scan over the `leapfrog` method
252252 non_sequences=[stepsize],
253253 n_steps=n_steps-1)
254254
255+ # NOTE: Scan always returns an updates dictionary, in case the scanned function draws
256+ # samples from a RandomStream. These updates must then be used when compiling the Theano
257+ # function, to avoid drawing the same random numbers each time the function is called. In
258+ # this case however, we consciously ignore "scan_updates" because we know it is empty.
259+ assert not scan_updates
260+
255261 # The last velocity returned by scan is vel(t + (n_steps-1/2)*stepsize)
256262 # We therefore perform one more half-step to return vel(t + n_steps*stepsize)
257263 energy = energy_fn(final_pos)
@@ -648,7 +654,7 @@ The above code can be run using the command: `nosetests -s code/mcrbm/test_hmc.p
648654
649655.. code-block:: bash
650656
651- [desjagui@atchoum mcRBM ]$ python test_hmc.py
657+ [desjagui@atchoum mcrbm ]$ python test_hmc.py
652658
653659 ****** TARGET VALUES ******
654660 target mean: [ 6.96469186 2.86139335 2.26851454 5.51314769 7.1946897 ]
0 commit comments