You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
sampling_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 History inherit from DynArray
History should no longer define the following functionality, but inherit them from DynArray:
update_function() -> compute()
Indexing functions (and have them use to DiscreteAxis)
locking function and attributes (incl. observed)
access ([]) 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 Series history stores the result of every calculation, will a LagSeries stores only the last few values.
History updates
Implement new types
These 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.
Test: Caching works with single times, slices and arrays of times.
LagSeries: Stores only the last n time steps.
Returns LagFreeSeries if lag is 0.
Test: Evaluating in past within lag does not change cache.
Test: Evaluating in past beyond lag returns Sinn.Expired (for now – easier to implement than recomputing and updating cache)
Test: Evaluating at future $t_i$ moves cache ahead so that values from $t_i - \text{lag}$ to $t_i$ are available.
VirtualHistory: Does not store anything
Basically just a wrapper around a function
Can be safely shared between samples/threads since nothing is cached.
ProbabilisticHistoryMixin:
Identifies history as probabilistic (i.e. PyMC3 distribution)
Sets history type to None
Disables cast to history's dtype in update. Replaces with an optional check when config.debug = True (Set this at instantiation – don't check value at every call to update)
stores original dtype as sampling_dtype
Adds make_sampling_history method:
Takes a sample_size or particles argument and adds a sampling dimension to the new history.
Wraps the compute method with a function calling sample on the result.
Sets history type to sampling_dtype
Add observed keyword argument to initializer
Sets the data
Locks the data
Use the NotLongerComputed & Expired return types appropriately.
Access ([]) may return
cached value
Sinn.NotComputed if value has not been computed
Sinn.NoLongerComputed(Sinn.NotComputed) if it must be recomputed
Sinn.Expired if it was computed and cannot be recomputed (for example, if it depends on a RNG.)
Allow any history in a model to be passed as a parameter, or created with a default type
This will be used to create the “particle” and “probability” models we will need.
Create HistorySpec to define at class level the history names, shapes, and allowed/default types.
Default created histories use model's time axis.
Add make_sampling_model which 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 samplers
Other probabilistic histories are left probabilistic
Passing a non-probabilistic history has no effect
Throw error if a given history is locked
Special value all makes all prob. histories into samplers
conditioned_on: synonym for sampled_histories
sample_size or particles
Locked / observed histories are shared between models
VirtualHistory's are shared between models
Other histories are recreated
The text was updated successfully, but these errors were encountered:
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:DynArray
updatessampling_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
History
inherit fromDynArray
History
should 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
Series
history stores the result of every calculation, will aLagSeries
stores only the last few values.History
updatesThese 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 lastn
time steps.Returns
LagFreeSeries
if lag is 0.Sinn.Expired
(for now – easier to implement than recomputing and updating cache)VirtualHistory
: Does not store anythingProbabilisticHistoryMixin
:None
update
. Replaces with an optional check whenconfig.debug = True
(Set this at instantiation – don't check value at every call toupdate
)sampling_dtype
make_sampling_history
method:sample_size
orparticles
argument and adds a sampling dimension to the new history.compute
method with a function callingsample
on the result.sampling_dtype
observed
keyword argument to initializerNotLongerComputed
&Expired
return types appropriately.[]
) may returnSinn.NotComputed
if value has not been computedSinn.NoLongerComputed(Sinn.NotComputed)
if it must be recomputedSinn.Expired
if it was computed and cannot be recomputed (for example, if it depends on a RNG.)()
)sinn.Expired
.Model
updatesThis will be used to create the “particle” and “probability” models we will need.
make_sampling_model
which 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
all
makes all prob. histories into samplersconditioned_on
: synonym forsampled_histories
sample_size
orparticles
The text was updated successfully, but these errors were encountered: