This is a problem I’ve been observing with sampling in pymc3. I have a deterministic function (nonlinear ODE) that I can evaluate and the response seems to be correct.
When I tell pymc3 to sample the function, it does but it does not seem to realize that it is sampling. Instead it continues to sample the same function without any update. My definition of the model is as follows:
tstt = tt.tensor.as_tensor_variable(ts)
straintt = tt.tensor.as_tensor_variable(strains)
one = tt.tensor.as_tensor_variable(1)
onehundred = tt.tensor.as_tensor_variable(100)
plt.plot(stress_noise[0,:])
with pm.Model() as model:
lamda = pm.Uniform("lambda", lower=10, upper=100)
mu = pm.Uniform("mu", lower=10, upper=100)
sigy_K = pm.Uniform("sigy_K", lower=100, upper=400)
mod_K = pm.Uniform("mod_K", lower=0., upper=100)
sigy_H = pm.Uniform("sigy_H", lower=100, upper=400)
mod_H = pm.Uniform("mod_H", lower=0., upper=100)
y = evaluate(tstt,straintt,lamda,mu,tt.tensor.stack([one, sigy_K, mod_K]),\
tt.tensor.stack([one, sigy_H, mod_H]),onehundred)
sigma = pm.HalfNormal("sigma",sd=1.0)
r = pm.Normal("r",mu=y,sd=sigma,observed=stress_noise)
trace = pm.sample(1,njobs=1,chains=1,n_init=1,random_seed=123,progressbar=True)
And my deterministic model is initialized as follows:
@tt.compile.ops.as_op(itypes=[tt.tensor.dvector, tt.tensor.dmatrix, tt.tensor.dscalar, tt.tensor.dscalar, tt.tensor.dvector, tt.tensor.dvector, tt.tensor.bscalar],otypes=[tt.tensor.dmatrix])
def evaluate(ts,strains,lambda_in,mu_in,pmod1,pmod2,pts_per_segment)
evaluate returns a 6x300 matrix and stress_noise is also a 6x300 matrix. Is anything obviously wrong here?