Skip to content

Commit f2032be

Browse files
committed
Replace Pathfinder example code with a link to Pathfinder docs
1 parent c30e8ac commit f2032be

File tree

2 files changed

+2
-23
lines changed

2 files changed

+2
-23
lines changed

Project.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ Optimization = "7f7a1694-90dd-40f0-9382-eb1efda571ba"
3939
OptimizationNLopt = "4e6fcdb7-1186-4e1f-a706-475e75c168bb"
4040
OptimizationOptimJL = "36348300-93cb-4f02-beb5-3c3902f8871e"
4141
PDMats = "90014a1f-27ba-587c-ab20-58faa44d9150"
42-
Pathfinder = "b1d3bc72-d0e7-4279-b92f-7fa5d6d2d454"
4342
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
4443
RDatasets = "ce6b1742-4840-55fa-b093-852dadbb1d8b"
4544
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"

tutorials/docs-16-using-turing-external-samplers/index.qmd

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -73,30 +73,10 @@ As previously mentioned, the Turing wrappers can often limit the capabilities of
7373
However, the native HMC sampler within Turing only allows the user to specify the type of the mass matrix despite the two options being possible within `AdvancedHMC`.
7474
Thankfully, we can use Turing's support for external samplers to define an HMC sampler with a custom mass matrix in `AdvancedHMC` and then use it to sample our Turing model.
7575

76-
We will use the library `Pathfinder`[^2] ((`Pathfinder`'s GitHub)[https://github.com/mlcolab/Pathfinder.jl]) to construct our estimate of mass matrix.
76+
We can use the library `Pathfinder`[^2] ([`Pathfinder`'s GitHub](https://github.com/mlcolab/Pathfinder.jl)) to construct our estimate of mass matrix.
7777
`Pathfinder` is a variational inference algorithm that first finds the maximum a posteriori (MAP) estimate of a target posterior distribution and then uses the trace of the optimization to construct a sequence of multivariate normal approximations to the target distribution.
7878
In this process, `Pathfinder` computes an estimate of the mass matrix the user can access.
79-
80-
The code below shows this can be done in practice.
81-
82-
```{julia}
83-
using AdvancedHMC, Pathfinder
84-
# Running pathfinder
85-
draws = 1_000
86-
result_multi = multipathfinder(model, draws; nruns=8)
87-
88-
# Estimating the metric
89-
inv_metric = result_multi.pathfinder_results[1].fit_distribution.Σ
90-
metric = DenseEuclideanMetric(Matrix(inv_metric))
91-
92-
# Creating an AdvancedHMC NUTS sampler with the custom metric.
93-
n_adapts = 1000 # Number of adaptation steps
94-
tap = 0.9 # Large target acceptance probability to deal with the funnel structure of the posterior
95-
nuts = AdvancedHMC.NUTS(tap; metric=metric)
96-
97-
# Sample
98-
chain = sample(model, externalsampler(nuts), 10_000; n_adapts=1_000)
99-
```
79+
You can see an example of how to use `Pathfinder` with Turing in [`Pathfinder`'s docs](https://mlcolab.github.io/Pathfinder.jl/stable/examples/turing/).
10080

10181
## Using new inference methods
10282

0 commit comments

Comments
 (0)