Skip to content

Commit 7060896

Browse files
committed
Update changelog
1 parent d343827 commit 7060896

File tree

1 file changed

+39
-3
lines changed

1 file changed

+39
-3
lines changed

HISTORY.md

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## 0.35.0
44

5-
**Breaking**
5+
**Breaking changes**
66

77
### Remove indexing by samplers
88

@@ -49,14 +49,50 @@ This release removes the feature of `VarInfo` where it kept track of which varia
4949
5050
This change also affects sampling in Turing.jl.
5151
52+
### `LogDensityFunction` argument order
53+
54+
- The method `LogDensityFunction(varinfo, model, context)` has been removed.
55+
The only accepted order is `LogDensityFunction(model, varinfo, context; adtype)`.
56+
(For an explanation of `adtype`, see below.)
57+
The varinfo and context arguments are both still optional.
58+
5259
**Other changes**
5360
61+
### `LogDensityProblems` interface
62+
5463
LogDensityProblemsAD is now removed as a dependency.
5564
Instead of constructing a `LogDensityProblemAD.ADgradient` object, we now directly use `DifferentiationInterface` to calculate the gradient of the log density with respect to model parameters.
5665
57-
In practice, this means that if you want to calculate the gradient for a model, you can do:
66+
Note that if you wish, you can still construct an `ADgradient` out of a `LogDensityFunction` object (there is nothing preventing this).
67+
68+
However, in this version, `LogDensityFunction` now takes an extra AD type argument.
69+
If this argument is not provided, the behaviour is exactly the same as before, i.e. you can calculate `logdensity` but not its gradient.
70+
However, if you do pass an AD type, that will allow you to calculate the gradient as well.
71+
You may thus find that it is easier to instead do this:
72+
73+
```julia
74+
@model f() = ...
75+
76+
ldf = LogDensityFunction(f(); adtype=AutoForwardDiff())
77+
```
78+
79+
This will return an object which satisfies the `LogDensityProblems` interface to first-order, i.e. you can now directly call both
80+
81+
```
82+
LogDensityProblems.logdensity(ldf, params)
83+
LogDensityProblems.logdensity_and_gradient(ldf, params)
84+
```
85+
86+
without having to construct a separate `ADgradient` object.
87+
88+
If you prefer, you can also use `setadtype` to tack on the AD type afterwards:
89+
90+
```julia
91+
@model f() = ...
5892
59-
TODO(penelopeysm): Finish this
93+
ldf = LogDensityFunction(f()) # by default, no adtype set
94+
ldf_with_ad = setadtype(ldf, AutoForwardDiff())
95+
```
6096
6197
## 0.34.2
6298

0 commit comments

Comments
 (0)