Skip to content

Instantly share code, notes, and snippets.

@justheuristic
Created June 1, 2016 14:00
Show Gist options
  • Select an option

  • Save justheuristic/a3ae56a198a51d49cb0590036deed4ab to your computer and use it in GitHub Desktop.

Select an option

Save justheuristic/a3ae56a198a51d49cb0590036deed4ab to your computer and use it in GitHub Desktop.
import theano
from theano import tensor as T
trng = T.shared_randomstreams.RandomStreams(1234)
inner_upd = None
def OneStep(vsample) :
def inner(vsample):
return vsample + trng.normal(size=vsample.shape)
global inner_upd
vsample,inner_upd = theano.scan(inner,outputs_info=vsample,n_steps=5)
return vsample + trng.normal(size=vsample.shape)
sample = theano.tensor.vector()
values, updates = theano.scan(OneStep, outputs_info=sample, n_steps=10)
fun = theano.function([sample], values[-1],
#no_default_updates=True #wontwork
#updates = updates+inner_upd #wontwork
#updates = updates #wontwork
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment