Hi everyone,
I am trying to work for higher dimensional inputs in Thomas Wiecki’s example . After taking the log of the ‘adjwt’ column,here is the new model:
county_idx = data['county_code'].values
data_set = np.hstack((np.ones((len(data),1)), data[['floor','log_adjwt']].values))
#data_set.shape = (919,3)
x,y = T.dmatrices('x', 'y')
out = x * y
f = theano.function([x,y], out)
with pm.Model() as hierarchical_model:
mu_b = pm.Normal('mu_beta', mu=0., sd=100**2)
sigma_b = pm.HalfCauchy('sigma_beta', beta=1)
b = pm.Normal('beta', mu=mu_b, sd=sigma_b, shape=(n_counties,3) )
eps = pm.HalfNormal('eps', sd=100)
radon_est = f( b[county_idx] , data_set ).sum(axis=1)
radon_like = pm.Normal('radon_like', mu=radon_est, sd=eps, observed=target_var)
I get this theano error:
Expected an array-like object, but found a Variable: maybe you are trying to call a function on a (possibly shared) variable instead of a numeric array?
f works fine on this regular matrix:
z=np.ones((n_counties,3))*np.arange(1,86).reshape(-1,1)
z = z[county_idx]
f(z,data_set) = good output
So, I am guessing it has something to do with the pymc3 object (b in this case). Is there something I need to do to make a pymc3 object work in a theano function? Or am I way off base in what I think is the problem?
Thanks in advance!
- Charles