Open ricardoV94 opened 2 years ago
Even before that we need a backend to support this. The NDarray for example does not.
I'm not sure it's worth it. What type of models require this? Can they even be efficiently sampled?
For example in tomographic imaging you need that, to decide whether data allows to resolve if a cell in the image can be discretized finer and thus giving you more information.
+1 for this feature. A specific use case is models whose structure is (partially) inferred. For example, a change-point detection model where the number of change points is inferred. Another would be a Gaussian mixture model where the number of mixtures is to be inferred. That is, assuming my understanding of this issue is correct :)
One step in this direction will be to swap the trace backend to mcbackend
such that we can store the dynamically sized draws.
DictToArrayBijection
and RaveledVars
were not desined to work with dynamic sizes, and refactoring them might be quite difficult. So a step method that can act on dynamic size RVs would probably inherit from BlockedStep
directly.
https://github.com/pymc-devs/pymc/issues/4463 raises several points related to this.
Our step methods are built around the assumption that model variables dimensions are fixed during sampling, which we might want to relax. Such refactoring would probably be quite painful, so perhaps we could explore adding some variants of the step methods that allow for this, incrementally. Users would have to manually assign variables they know don't have a fixed shape to them, or we would need some extra logic in the step assignment to check if a variable has non-fixed size.
Some aspects of this might prove trickier. @brandonwillard noted: