This issue documents the work plan to allow for sinn to be used for SMC (Sequential Monte Carlo) applications. Altough the project requiring SMC is currently on ice (and thus also the work on these features), we keep this list for future reference. All points below address at least one of the following:
- Build more efficient computational graphs. For SMC on complex models this is likely not just “nice to have”, but necessary.
- Standardize the constructs to reduce time spent writing interfacing code.
- Simplify the constructs to reduce time spent relearning how to instantiate them.
- Standardize conventions before I incur more technical debt.
DynArray updates
Make History inherit from DynArray
History updates
Model updates
This issue documents the work plan to allow for
sinnto be used for SMC (Sequential Monte Carlo) applications. Altough the project requiring SMC is currently on ice (and thus also the work on these features), we keep this list for future reference. All points below address at least one of the following:DynArrayupdatessampling_shape: Number of samples. Might as well allow for multiple sampling dimensions (same effort). Can be used for multiple batches, particle filter. Use empty tuple if there are no sampling dimensions.Make
Historyinherit fromDynArrayHistoryshould no longer define the following functionality, but inherit them fromDynArray:update_function()->compute()DiscreteAxis)observed)[]) and evaluation (())compute()(renamed from_compute_up_to())This method is subclass-specific and takes care of caching.
Different data structures will use cache differently. For example, a
Serieshistory stores the result of every calculation, will aLagSeriesstores only the last few values.HistoryupdatesThese types should fix, or at least greatly alleviate my memory issues. They should also translate into less a convoluted Theano, which is good for a) execution & compilation time and b) putting code on GPU.
LagFreeSeries: Stores only the most recently computed time.LagSeries: Stores only the lastntime steps.Returns
LagFreeSeriesif lag is 0.Sinn.Expired(for now – easier to implement than recomputing and updating cache)VirtualHistory: Does not store anythingProbabilisticHistoryMixin:Noneupdate. Replaces with an optional check whenconfig.debug = True(Set this at instantiation – don't check value at every call toupdate)sampling_dtypemake_sampling_historymethod:sample_sizeorparticlesargument and adds a sampling dimension to the new history.computemethod with a function callingsampleon the result.sampling_dtypeobservedkeyword argument to initializerNotLongerComputed&Expiredreturn types appropriately.[]) may returnSinn.NotComputedif value has not been computedSinn.NoLongerComputed(Sinn.NotComputed)if it must be recomputedSinn.Expiredif it was computed and cannot be recomputed (for example, if it depends on a RNG.)())sinn.Expired.ModelupdatesThis will be used to create the “particle” and “probability” models we will need.
make_sampling_modelwhich creates a new model where some probabilistic histories are replaced by samplers.Args:
sampled_histories: histories it's conditioned on: these probabilistic histories are replaced by samplersOther probabilistic histories are left probabilistic
Passing a non-probabilistic history has no effect
Throw error if a given history is locked
Special value
allmakes all prob. histories into samplersconditioned_on: synonym forsampled_historiessample_sizeorparticles