'Model' object has no attribute 'logpt'
staeff777 opened this issue · comments
I'm very new to PYMC and I wanted to test an compute intensive approach (not even sure if it is a good approach) with nutpie.
def get_px_deterministic(data):
px = []
for i in range(len(data)):
beta = pm.Normal(f"beta_{data[i].name}", mu=0, tau=0.001, initval=0)
alpha = pm.Normal(f"alpha_{data[i].name}", mu=0, tau=0.001, initval=0)
px.append(pm.Deterministic(f"p_{data[i].name}", 1.0/(1.0 + at.exp(beta*data[i].data + alpha))))
return px
def get_p_deterministic(px):
p=1
for prop in px:
p*=prop
return pm.Deterministic("p", at.pow(p, 1/len(px)))
with pm.Model() as model:
px = get_px_deterministic(full_training_data)
p = get_p_deterministic(px)
observed = pm.Bernoulli("bernoulli_obs",p,observed=D)
In the essence I'm taking the geometric mean of some sigmoid generated probabilities, and try to sample it for a binary decision (the description is probably incorrectly expressed ).
The error I receive during the compilation is that logpt is not yet implemented (?)
File ".../model.py", line 155, in <module>
compiled_model = nutpie.compile_pymc_model(model)
File ".../lib/python3.8/site-packages/nutpie/compile_pymc.py", line 38, in compile_pymc_model
n_dim, logp_func, expanding_function, shape_info = _make_functions(model)
File ".../lib/python3.8/site-packages/nutpie/compile_pymc.py", line 96, in _make_functions
logp = model.logpt()
AttributeError: 'Model' object has no attribute 'logpt'
Could it be implemented?
Thank you for reporting this, seems this was broken a few days ago by this PR: pymc-devs/pymc#5320. nutpie was still using an old API that was removed in this PR.
Should be easy enough to fix on our end.
Somewhat off topic: you can use the shape
(or dims
) argument to pm.Normal
etc to get a vector of number at the same time, so you can avoid the loops.
Just tried to fix it and noticed that apparently I already did, some time ago... :-)
Can you try updating nutpie to see if that fixes it?