Hi!
I have a external function i need to run in a loop to accumulate some values.
this function i need to loop through has a number of pymc3 variables defined in it.
So it does something like
def func(pymc3-rvs-args):
do some deterministic operations on these variables
As of now i am doing this in a standard python loop, and the theano graph looks like a monster. I was therefore planning to use a theano.scan function instead. I am trying something along the lines of:
with pm.Model() as model:
def fn(x,y,n): # n is a random variable, x a vector of numbers
return x*n
n = pm.Normal('n').get_test_val
s_x = T.ivector()
v_sum = theano.shared(np.int32(0))
s_y, update_sum = theano.scan(
fn,
sequences = [s_x],
outputs_info = [v_sum],
non_sequences=n)
res_ = s_y[-1]
fn = theano.function([s_x,n], res_, updates=update_sum)
I cant seem to make this work.
Am I on the right track here?