7
7
from theano import function , shared
8
8
from theano import tensor as TT
9
9
import theano
10
+ import theano .sandbox .rng_mrg
10
11
11
12
sharedX = (lambda X , name :
12
13
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,
275
276
276
277
"""
277
278
278
- ## POSITION UPDATES # #
279
+ # POSITION UPDATES #
279
280
# broadcast `accept` scalar to tensor with the same dimensions as
280
281
# final_pos.
281
282
accept_matrix = accept .dimshuffle (0 , * (('x' ,) * (final_pos .ndim - 1 )))
282
283
# if accept is True, update to `final_pos` else stay put
283
284
new_positions = TT .switch (accept_matrix , final_pos , positions )
284
285
# end-snippet-5 start-snippet-7
285
- ## STEPSIZE UPDATES # #
286
+ # STEPSIZE UPDATES #
286
287
# if acceptance rate is too low, our sampler is too "noisy" and we reduce
287
288
# the stepsize. If it is too high, our sampler is too conservative, we can
288
289
# 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,
292
293
new_stepsize = TT .clip (_new_stepsize , stepsize_min , stepsize_max )
293
294
294
295
# end-snippet-7 start-snippet-6
295
- ## ACCEPT RATE UPDATES # #
296
+ # ACCEPT RATE UPDATES #
296
297
# perform exponential moving average
297
298
mean_dtype = theano .scalar .upcast (accept .dtype , avg_acceptance_rate .dtype )
298
299
new_acceptance_rate = TT .add (
0 commit comments