How to input pymc3.Deterministic variables into theano.scan method?

Here is my code:

from pymc3.distributions.timeseries import scan`
from pymc3 import Deterministic

V = Deterministic(‘V’, tt.concatenate([V0, Q[:-1]]))
G0 = Deterministic(‘G0’, beta0[None, :, None] * V + log_c.T[None, :, :])
(G, _) = scan(g_model,sequences=[inp, V, G0],non_sequences=[beta1, log_c, range(n_subs)], name=‘g’)

where inp is a numpy.array with size of d1*d2*d3, g_model is a function.
The error shows at following:

TypeError: slice indices must be integers or None or have an _index_ method

I guess the problem fixed on the Deterministic datatype. I don’t know how to make Deterministic be looped like theano variables or numpy.array. So how to make it possible?

The problem is probably indexing inp,using a theano tensor. try inp = theano.shared(inp)

1 Like

Thank you! It works. I’m confused why it didn’t show any errors when I just input “inp” into scan in the previous version. Could you explain it?

I am a bit surprise as well - we are making some improvement of indexing in theano-pymc fork so hopefully these kind of surprise will be a bit less moving forward.

Thank you!