-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Description
In v3
we (ab)used the Theano .tag.test_value
to evaluate the model (Model.check_test_point
) at a set point as well as provide a starting point for the sampler, this point was stored in the Model
class. In v4
we removed the reliance on testvalue
and instead just have a initial_value
dictionary in Model
that gets updated with a numpy array per RV as the RV gets created. This dict is then referenced by e.g. the sampler. If a user wants to specify their own initval for an RV, they do so during creation of the RV.
After talking to @brandonwillard about several issues related to this mechanism (#4924, #4911) I propose we change this method in the following way:
initval
is not stored in theModel
object anymoreinitval
s can not be specified in RV instantiation anymore (this is rarely done in practice anyway, but sometimes it's necessary)- There is, however, a function like
pm.sample_prior_predictive()
(e.g.pm.sample_mean()
) to draw an initvalue. - This point is stored in a
dict
mapping RV names to numpy arrays. Model.check_test_point
as well as the sampler draw aninitival
using this function when they need it.- What about user-specified values?
pm.sample
takes aninitval
point dict of initvals to override from the default that gets drawn. So whenpm.sample
draws an initval, it conditions the model on the override dict passed by the user. A user could also draw an initval herself, alter it, and pass that in, so that initvals for all RVs are provided in this way. The same can work forModel.check_test_point
.
I think this should cover all the bases. It solves a few of the problems we've been wrestling with:
- Conceptually it makes sense to not create initvals directly during model definition, because when a user changes the dimensionality of a model, we would need to take care of updating the
Model.initval
or the sampler will choke. - Having a somewhat arbitrary point associated with
Model
seems like an odd design choice and it's not clear why that should be the case.