Hi Pymc3 Comunity,
Im trying to use a model for prediction. However, after training a model, and updating the shared variables (via set_value), the old values remain. See this toy example below:
a_predicted_value = np.random.normal(loc=10, size=(1000,))
a_predictor_value = shared(np.random.normal(loc=0, size=(1000,)))
with pm.Model() as model:
a_parameter = pm.Normal('mu',0,sd=1)
a_predictor_value_det = pm.Deterministic('a_predictor_value', a_predictor_value)
sd = pm.HalfNormal('sd', sd=1)
a_predicted_value_obs = pm.Normal('a_predicted_value', mu=a_parameter+a_predictor_value_det, sd=sd, observed=a_predicted_value)
trace = pm.sample()
pred_values_before_setting = pm.sample_posterior_predictive(trace=trace, model=model,
vars=[a_predictor_value_det, a_predicted_value_obs])
a_predictor_value.set_value(np.random.normal(loc=10, size=(1000,)))
pred_values_after_setting = pm.sample_posterior_predictive(trace=trace, model=model,
vars=[a_predictor_value_det, a_predicted_value_obs])
fig, ax = plt.subplots()
plt.hist(pred_values_before_setting['a_predictor_value'].flatten(), hist=False, ax=ax)
plt.hist(pred_values_after_setting['a_predictor_value'].flatten(), hist=False, ax=ax)
plt.show()
Here you can see the values before and after are the same!? This is true for a_predicted_variable
too.