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
Copy file name to clipboardExpand all lines: HISTORY.md
+35Lines changed: 35 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -18,6 +18,41 @@ This release overhauls how VarInfo objects track variables such as the log joint
18
18
-`getlogp` now returns a `NamedTuple` with keys `logprior` and `loglikelihood`. If you want the log joint probability, which is what `getlogp` used to return, use `getlogjoint`.
19
19
- Correspondingly `setlogp!!` and `acclogp!!` should now be called with a `NamedTuple` with keys `logprior` and `loglikelihood`. The `acclogp!!` method with a single scalar value has been deprecated and falls back on `accloglikelihood!!`, and the single scalar version of `setlogp!!` has been removed. Corresponding setter/accumulator functions exist for the log prior as well.
20
20
21
+
### Evaluation contexts
22
+
23
+
Historically, evaluating a DynamicPPL model has required three arguments: a model, some kind of VarInfo, and a context.
24
+
It's less known, though, that since DynamicPPL 0.14.0 the _model_ itself actually contains a context as well.
25
+
This version therefore excises the context argument, and instead uses `model.context` as the evaluation context.
26
+
27
+
The upshot of this is that many functions that previously took a context argument now no longer do.
28
+
There were very few such functions where the context argument was actually used (most of them simply took `DefaultContext()` as the default value).
29
+
30
+
`evaluate!!(model, varinfo, ext_context)` is deprecated, and broadly speaking you should replace calls to that with `new_model = contextualize(model, ext_context); evaluate!!(new_model, varinfo)`.
31
+
If the 'external context' `ext_context` is a parent context, then you should wrap `model.context` appropriately to ensure that its information content is not lost.
32
+
If, on the other hand, `ext_context` is a `DefaultContext`, then you can just drop the argument entirely.
33
+
34
+
To aid with this process, `contextualize` is now exported from DynamicPPL.
35
+
36
+
The main situation where one _did_ want to specify an additional evaluation context was when that context was a `SamplingContext`.
37
+
Doing this would allow you to run the model and sample fresh values, instead of just using the values that existed in the VarInfo object.
38
+
Thus, this release also introduces the unexported function `sample!!`.
39
+
Essentially, `sample!!(rng, model, varinfo, sampler)` is a drop-in replacement for `evaluate!!(model, varinfo, SamplingContext(rng, sampler))`.
40
+
41
+
There are many methods that no longer take a context argument, and listing them all would be too much.
42
+
However, here are the more user-facing ones:
43
+
44
+
-`LogDensityFunction` no longer has a context field (or type parameter)
45
+
-`DynamicPPL.TestUtils.AD.run_ad` no longer uses a context (and the returned `ADResult` object no longer has a context field)
46
+
-`VarInfo(rng, model, sampler)` and other VarInfo constructors / functions that made VarInfos (e.g. `typed_varinfo`) from a model
47
+
-`(::Model)(args...)`: specifically, this now only takes `rng` and `varinfo` arguments (with both being optional)
48
+
- If you are using the `__context__` special variable inside a model, you will now have to use `__model__.context` instead
49
+
50
+
And a couple of more internal changes:
51
+
52
+
-`evaluate!!`, `evaluate_threadsafe!!`, and `evaluate_threadunsafe!!` no longer accept context arguments
53
+
-`evaluate!!` no longer takes rng and sampler (if you used this, you should use `sample!!` instead, or construct your own `SamplingContext`)
54
+
- The model evaluation function, `model.f` for some `model::Model`, no longer takes a context as an argument
0 commit comments