Skip to content

Commit e6513a0

Browse files
committed
Update changelog
1 parent 8d10fc1 commit e6513a0

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
### `.~` right hand side must be a univariate distribution
88

@@ -119,14 +119,50 @@ This release removes the feature of `VarInfo` where it kept track of which varia
119119
120120
This change also affects sampling in Turing.jl.
121121
122+
### `LogDensityFunction` argument order
123+
124+
- The method `LogDensityFunction(varinfo, model, context)` has been removed.
125+
The only accepted order is `LogDensityFunction(model, varinfo, context; adtype)`.
126+
(For an explanation of `adtype`, see below.)
127+
The varinfo and context arguments are both still optional.
128+
122129
**Other changes**
123130
131+
### `LogDensityProblems` interface
132+
124133
LogDensityProblemsAD is now removed as a dependency.
125134
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.
126135
127-
In practice, this means that if you want to calculate the gradient for a model, you can do:
136+
Note that if you wish, you can still construct an `ADgradient` out of a `LogDensityFunction` object (there is nothing preventing this).
137+
138+
However, in this version, `LogDensityFunction` now takes an extra AD type argument.
139+
If this argument is not provided, the behaviour is exactly the same as before, i.e. you can calculate `logdensity` but not its gradient.
140+
However, if you do pass an AD type, that will allow you to calculate the gradient as well.
141+
You may thus find that it is easier to instead do this:
142+
143+
```julia
144+
@model f() = ...
145+
146+
ldf = LogDensityFunction(f(); adtype=AutoForwardDiff())
147+
```
148+
149+
This will return an object which satisfies the `LogDensityProblems` interface to first-order, i.e. you can now directly call both
150+
151+
```
152+
LogDensityProblems.logdensity(ldf, params)
153+
LogDensityProblems.logdensity_and_gradient(ldf, params)
154+
```
155+
156+
without having to construct a separate `ADgradient` object.
128157
129-
TODO(penelopeysm): Finish this
158+
If you prefer, you can also use `setadtype` to tack on the AD type afterwards:
159+
160+
```julia
161+
@model f() = ...
162+
163+
ldf = LogDensityFunction(f()) # by default, no adtype set
164+
ldf_with_ad = setadtype(ldf, AutoForwardDiff())
165+
```
130166
131167
## 0.34.2
132168

0 commit comments

Comments
 (0)