Skip to content

Remove initval from Model class and add function to draw one #4942

@twiecki

Description

@twiecki

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:

  1. initval is not stored in the Model object anymore
  2. initvals can not be specified in RV instantiation anymore (this is rarely done in practice anyway, but sometimes it's necessary)
  3. There is, however, a function like pm.sample_prior_predictive() (e.g. pm.sample_mean()) to draw an initvalue.
  4. This point is stored in a dict mapping RV names to numpy arrays.
  5. Model.check_test_point as well as the sampler draw an initival using this function when they need it.
  6. What about user-specified values? pm.sample takes an initval point dict of initvals to override from the default that gets drawn. So when pm.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 for Model.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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions