Prediction on New Data Fails with Deterministic Variable #3346
Closed
Description
I am not sure if this behavior is due to some theoretical limitation or not.....but the prediction of new data with sample_posterior_predictive() fails to recognize new new shared variables when the model was run with a Deterministic() parameter in the model. See example below from the quick start.
import theano
x = np.random.randn(100)
y = x > 0
x_shared = theano.shared(x)
y_shared = theano.shared(y)
with pm.Model() as model:
coeff = pm.Normal('x', mu=0, sd=1)
# Uncomment this and comment next line to see the issue
#logistic = pm.Deterministic('p',pm.math.sigmoid(coeff * x_shared))
logistic = pm.math.sigmoid(coeff * x_shared)
pm.Bernoulli('obs', p=logistic, observed=y_shared)
trace = pm.sample()
x_shared.set_value([-1, 0, 1.])
y_shared.set_value([0, 0, 0]) # dummy values
with model:
post_pred = pm.sample_posterior_predictive(trace, samples=500)
post_pred['obs'].shape
Metadata
Assignees
Labels
No labels