77from theano import function , shared
88from theano import tensor as TT
99import theano
10+ import theano .sandbox .rng_mrg
1011
1112sharedX = (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 (
@@ -358,7 +359,7 @@ def new_from_shared_positions(
358359 stepsize = sharedX (initial_stepsize , 'hmc_stepsize' )
359360 avg_acceptance_rate = sharedX (target_acceptance_rate ,
360361 'avg_acceptance_rate' )
361- s_rng = TT . shared_randomstreams . RandomStreams (seed )
362+ s_rng = theano . sandbox . rng_mrg . MRG_RandomStreams (seed )
362363
363364 # define graph for an `n_steps` HMC simulation
364365 accept , final_pos = hmc_move (
0 commit comments