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
+26-6Lines changed: 26 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -32,20 +32,40 @@ Their semantics are the same as in Julia's `isapprox`; two values are equal if t
32
32
You now need to explicitly pass a `VarInfo` argument to `check_model` and `check_model_and_trace`.
33
33
Previously, these functions would generate a new VarInfo for you (using an optionally provided `rng`).
34
34
35
-
### Removal of `PriorContext` and `LikelihoodContext`
36
-
37
-
A number of DynamicPPL's contexts have been removed, most notably `PriorContext` and `LikelihoodContext`.
38
-
Although these are not the only _exported_ contexts, we consider unlikely that anyone was using _other_ contexts manually: if you have a question about contexts _other_ than these, please continue reading the 'Internals' section below.
35
+
### Evaluating model log-probabilities in more detail
39
36
40
37
Previously, during evaluation of a model, DynamicPPL only had the capability to store a _single_ log probability (`logp`) field.
41
38
`DefaultContext`, `PriorContext`, and `LikelihoodContext` were used to control what this field represented: they would accumulate the log joint, log prior, or log likelihood, respectively.
42
39
43
-
Now, we have reworked DynamicPPL's `VarInfo` object such that it can track multiple log probabilities at once (see the 'Accumulators' section below).
40
+
In this version, we have overhauled this quite substantially.
41
+
The technical details of exactly _how_ this is done is covered in the 'Accumulators' section below, but the upshot is that the log prior, log likelihood, and log Jacobian terms (for any linked variables) are separately tracked.
42
+
43
+
Specifically, you will want to use the following functions to access these log probabilities:
44
+
45
+
-`getlogprior(varinfo)` to get the log prior. **Note:** This version introduces new, more consistent behaviour for this function, in that it always returns the log-prior of the values in the original, untransformed space, even if the `varinfo` has been linked.
46
+
-`getloglikelihood(varinfo)` to get the log likelihood.
47
+
-`getlogjoint(varinfo)` to get the log joint probability. **Note:** Similar to `getlogprior`, this function now always returns the log joint of the values in the original, untransformed space, even if the `varinfo` has been linked.
48
+
49
+
If you are using linked VarInfos (e.g. if you are writing a sampler), you may find that you need to obtain the log probability of the variables in the transformed space.
50
+
To this end, you can use:
51
+
52
+
-`getlogjac(varinfo)` to get the log Jacobian of the link transforms for any linked variables.
53
+
-`getlogprior_internal(varinfo)` to get the log prior of the variables in the transformed space.
54
+
-`getlogjoint_internal(varinfo)` to get the log joint probability of the variables in the transformed space.
55
+
56
+
Since transformations only apply to random variables, the likelihood is unaffected by linking.
57
+
58
+
### Removal of `PriorContext` and `LikelihoodContext`
59
+
60
+
Following on from the above, a number of DynamicPPL's contexts have been removed, most notably `PriorContext` and `LikelihoodContext`.
61
+
Although these are not the only _exported_ contexts, we consider unlikely that anyone was using _other_ contexts manually: if you have a question about contexts _other_ than these, please continue reading the 'Internals' section below.
62
+
44
63
If you were evaluating a model with `PriorContext`, you can now just evaluate it with `DefaultContext`, and instead of calling `getlogp(varinfo)`, you can call `getlogprior(varinfo)` (and similarly for the likelihood).
45
64
46
65
If you were constructing a `LogDensityFunction` with `PriorContext`, you can now stick to `DefaultContext`.
47
66
`LogDensityFunction` now has an extra field, called `getlogdensity`, which represents a function that takes a `VarInfo` and returns the log density you want.
48
-
Thus, if you pass `getlogprior` as the value of this parameter, you will get the same behaviour as with `PriorContext`.
67
+
Thus, if you pass `getlogprior_internal` as the value of this parameter, you will get the same behaviour as with `PriorContext`.
68
+
(You should consider whether your use case needs the log prior in the transformed space, or the original space, and use (respectively) `getlogprior_internal` or `getlogprior` as needed.)
49
69
50
70
The other case where one might use `PriorContext` was to use `@addlogprob!` to add to the log prior.
51
71
Previously, this was accomplished by manually checking `__context__ isa DynamicPPL.PriorContext`.
0 commit comments