I am trying to implement MCMC using PyMC4(pymc). The issue that I have is that I have to feed the pymc distributions a, b, c, d, e, f
into a machine learning model (in TensorFlow). the TensorFlow model recognize the distributions. But the distributions is same. (not inference). Is there a way to make the TensorFlow model compatible with PYMC4?
with Model() as model:
# define Priors
a = Uniform('a', lower = 0, upper = 1 )
b = Uniform('b', lower = 0, upper = 1 )
c = Uniform('c', lower = 0, upper = 1 )
d = Uniform('d', lower = 0, upper = 1 )
e = Uniform('e', lower = 0, upper = 1 )
f = Uniform('f', lower = 0, upper = 1 )
sd = Uniform("sd", lower = 0, upper = 1 )
params = Deterministic("params", math.stack([a,b,c,d,e,f], axis=0) )
params = params.eval().reshape(1,-1)
aesara.dprint(params)
# Expected
yhat_1 = m1.predict(params)
yhat_2 = m2.predict(params)
yhat_3 = m3.predict(params)
yhat_4 = m4.predict(params)
yhat_5 = m5.predict(params)
yhat_6 = m6.predict(params)
yhat_7 = m7.predict(params)
yhat_8 = m8.predict(params)
yhat_9 = m9.predict(params)
yhat_10 = m10.predict(params)
yhat_11 = m11.predict(params)
yhat_12 = m12.predict(params)
yhatArr = np.append(yhatArr, np.array([yhat_1, yhat_2, yhat_3, yhat_4, yhat_5, yhat_6, yhat_7, yhat_8, yhat_9, yhat_10, yhat_11, yhat_12]))
pred = Deterministic("pred", math.stack(yhatArr).flatten())
print("pred ################################ START")
print(pred.eval())
print("pred ################################ END")
likelihood = Normal("likelihood", mu = pred, sigma = sd, observed = merge.iloc[3,2:]) # merge => 1*12
start = find_MAP()
print("trace ################################################## START")
trace = sample(3000, tune=3000, chains=1, start = start, progressbar=True)
print("trace ################################################## END")