Skip to content

Commit 5a13d98

Browse files
committed
Fix import of sandbox.
1 parent d403591 commit 5a13d98

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

code/hmc/hmc.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from theano import function, shared
88
from theano import tensor as TT
99
import theano
10+
import theano.sandbox.rng_mrg
1011

1112
sharedX = (lambda X, name:
1213
shared(numpy.asarray(X, dtype=theano.config.floatX), name=name))
@@ -275,14 +276,14 @@ def hmc_updates(positions, stepsize, avg_acceptance_rate, final_pos, accept,
275276
276277
"""
277278

278-
## POSITION UPDATES ##
279+
# POSITION UPDATES #
279280
# broadcast `accept` scalar to tensor with the same dimensions as
280281
# final_pos.
281282
accept_matrix = accept.dimshuffle(0, *(('x',) * (final_pos.ndim - 1)))
282283
# if accept is True, update to `final_pos` else stay put
283284
new_positions = TT.switch(accept_matrix, final_pos, positions)
284285
# end-snippet-5 start-snippet-7
285-
## STEPSIZE UPDATES ##
286+
# STEPSIZE UPDATES #
286287
# if acceptance rate is too low, our sampler is too "noisy" and we reduce
287288
# the stepsize. If it is too high, our sampler is too conservative, we can
288289
# get away with a larger stepsize (resulting in better mixing).
@@ -292,7 +293,7 @@ def hmc_updates(positions, stepsize, avg_acceptance_rate, final_pos, accept,
292293
new_stepsize = TT.clip(_new_stepsize, stepsize_min, stepsize_max)
293294

294295
# end-snippet-7 start-snippet-6
295-
## ACCEPT RATE UPDATES ##
296+
# ACCEPT RATE UPDATES #
296297
# perform exponential moving average
297298
mean_dtype = theano.scalar.upcast(accept.dtype, avg_acceptance_rate.dtype)
298299
new_acceptance_rate = TT.add(

0 commit comments

Comments
 (0)