Skip to content

Commit d70f9d3

Browse files
committed
Deploy preview for PR 612
1 parent 5c03598 commit d70f9d3

File tree

3 files changed

+509
-509
lines changed

3 files changed

+509
-509
lines changed

pr-previews/612/search.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@
316316
"href": "tutorials/variational-inference/index.html#basic-usage",
317317
"title": "Variational Inference",
318318
"section": "Basic Usage",
319-
"text": "Basic Usage\nTo run VI, we must first set a variational family. For instance, the most commonly used family is the mean-field Gaussian family. For this, Turing provides functions that automatically construct the initialization corresponding to the model m:\n\nq_init = q_meanfield_gaussian(m);\n\nvi will automatically recognize the variational family through the type of q_init. Here is a detailed documentation for the constructor:\n\n@doc(Variational.q_meanfield_gaussian)\n\nq_meanfield_gaussian(\n [rng::Random.AbstractRNG,]\n model::DynamicPPL.Model;\n location::Union{Nothing,<:AbstractVector} = nothing,\n scale::Union{Nothing,<:Diagonal} = nothing,\n kwargs...\n)\nFind a numerically non-degenerate mean-field Gaussian q for approximating the target model.\nArguments\n\nmodel: The target DynamicPPL.Model.\n\n\nKeyword Arguments\n\nlocation: The location parameter of the initialization. If nothing, a vector of zeros is used.\n\nscale: The scale parameter of the initialization. If nothing, an identity matrix is used.\n\n\nThe remaining keyword arguments are passed to q_locationscale.\nReturns\n\nq::Bijectors.TransformedDistribution: A AdvancedVI.LocationScale distribution matching the support of model.\n\n\n\n\n\n\n\nAs we can see, the precise initialization can be customized through the keyword arguments.\nLet’s run VI with the default setting:\n\nn_iters = 1000\nq_avg, q_last, info, state = vi(m, q_init, n_iters; show_progress=false);\n\nThe default setting uses the AdvancedVI.RepGardELBO objective, which corresponds to a variant of what is known as automatic differentiation VI7 or stochastic gradient VI8 or black-box VI9 with the reparameterization gradient101112. The default optimizer we use is AdvancedVI.DoWG13 combined with a proximal operator. (The use of proximal operators with VI on a location-scale family is discussed in detail by J. Domke1415 and others16.) We will take a deeper look into the returned values and the keyword arguments in the following subsections. First, here is the full documentation for vi:\n\n@doc(Variational.vi)\n\nvi(\n [rng::Random.AbstractRNG,]\n model::DynamicPPL.Model;\n q,\n n_iterations::Int;\n objective::AdvancedVI.AbstractVariationalObjective = AdvancedVI.RepGradELBO(\n 10; entropy = AdvancedVI.ClosedFormEntropyZeroGradient()\n ),\n show_progress::Bool = Turing.PROGRESS[],\n optimizer::Optimisers.AbstractRule = AdvancedVI.DoWG(),\n averager::AdvancedVI.AbstractAverager = AdvancedVI.PolynomialAveraging(),\n operator::AdvancedVI.AbstractOperator = AdvancedVI.ProximalLocationScaleEntropy(),\n adtype::ADTypes.AbstractADType = Turing.DEFAULT_ADTYPE,\n kwargs...\n)\nApproximating the target model via variational inference by optimizing objective with the initialization q. This is a thin wrapper around AdvancedVI.optimize.\nArguments\n\nmodel: The target DynamicPPL.Model.\n\nq: The initial variational approximation.\n\nn_iterations: Number of optimization steps.\n\n\nKeyword Arguments\n\nobjective: Variational objective to be optimized.\n\nshow_progress: Whether to show the progress bar.\n\noptimizer: Optimization algorithm.\n\naverager: Parameter averaging strategy.\n\noperator: Operator applied after each optimization step.\n\nadtype: Automatic differentiation backend.\n\n\nSee the docs of AdvancedVI.optimize for additional keyword arguments.\nReturns\n\nq: Variational distribution formed by the last iterate of the optimization run.\n\nq_avg: Variational distribution formed by the averaged iterates according to averager.\n\nstate: Collection of states used for optimization. This can be used to resume from a past call to vi.\n\ninfo: Information generated during the optimization run.",
319+
"text": "Basic Usage\nTo run VI, we must first set a variational family. For instance, the most commonly used family is the mean-field Gaussian family. For this, Turing provides functions that automatically construct the initialization corresponding to the model m:\n\nq_init = q_meanfield_gaussian(m);\n\nvi will automatically recognize the variational family through the type of q_init. Here is a detailed documentation for the constructor:\n\n@doc(Variational.q_meanfield_gaussian)\n\nq_meanfield_gaussian(\n [rng::Random.AbstractRNG,]\n model::DynamicPPL.Model;\n location::Union{Nothing,<:AbstractVector} = nothing,\n scale::Union{Nothing,<:Diagonal} = nothing,\n kwargs...\n)\nFind a numerically non-degenerate mean-field Gaussian q for approximating the target model.\nArguments\n\nmodel: The target DynamicPPL.Model.\n\n\nKeyword Arguments\n\nlocation: The location parameter of the initialization. If nothing, a vector of zeros is used.\n\nscale: The scale parameter of the initialization. If nothing, an identity matrix is used.\n\n\nThe remaining keyword arguments are passed to q_locationscale.\nReturns\n\nq::Bijectors.TransformedDistribution: A AdvancedVI.LocationScale distribution matching the support of model.\n\n\n\n\n\n\n\nAs we can see, the precise initialization can be customized through the keyword arguments.\nLet’s run VI with the default setting:\n\nn_iters = 1000\nq_avg, q_last, info, state = vi(m, q_init, n_iters; show_progress=false);\n\nThe default setting uses the AdvancedVI.RepGradELBO objective, which corresponds to a variant of what is known as automatic differentiation VI7 or stochastic gradient VI8 or black-box VI9 with the reparameterization gradient101112. The default optimizer we use is AdvancedVI.DoWG13 combined with a proximal operator. (The use of proximal operators with VI on a location-scale family is discussed in detail by J. Domke1415 and others16.) We will take a deeper look into the returned values and the keyword arguments in the following subsections. First, here is the full documentation for vi:\n\n@doc(Variational.vi)\n\nvi(\n [rng::Random.AbstractRNG,]\n model::DynamicPPL.Model;\n q,\n n_iterations::Int;\n objective::AdvancedVI.AbstractVariationalObjective = AdvancedVI.RepGradELBO(\n 10; entropy = AdvancedVI.ClosedFormEntropyZeroGradient()\n ),\n show_progress::Bool = Turing.PROGRESS[],\n optimizer::Optimisers.AbstractRule = AdvancedVI.DoWG(),\n averager::AdvancedVI.AbstractAverager = AdvancedVI.PolynomialAveraging(),\n operator::AdvancedVI.AbstractOperator = AdvancedVI.ProximalLocationScaleEntropy(),\n adtype::ADTypes.AbstractADType = Turing.DEFAULT_ADTYPE,\n kwargs...\n)\nApproximating the target model via variational inference by optimizing objective with the initialization q. This is a thin wrapper around AdvancedVI.optimize.\nArguments\n\nmodel: The target DynamicPPL.Model.\n\nq: The initial variational approximation.\n\nn_iterations: Number of optimization steps.\n\n\nKeyword Arguments\n\nobjective: Variational objective to be optimized.\n\nshow_progress: Whether to show the progress bar.\n\noptimizer: Optimization algorithm.\n\naverager: Parameter averaging strategy.\n\noperator: Operator applied after each optimization step.\n\nadtype: Automatic differentiation backend.\n\n\nSee the docs of AdvancedVI.optimize for additional keyword arguments.\nReturns\n\nq: Variational distribution formed by the last iterate of the optimization run.\n\nq_avg: Variational distribution formed by the averaged iterates according to averager.\n\nstate: Collection of states used for optimization. This can be used to resume from a past call to vi.\n\ninfo: Information generated during the optimization run.",
320320
"crumbs": [
321321
"Get Started",
322322
"Tutorials",
@@ -352,7 +352,7 @@
352352
"href": "tutorials/variational-inference/index.html#using-different-optimisers",
353353
"title": "Variational Inference",
354354
"section": "Using Different Optimisers",
355-
"text": "Using Different Optimisers\nThe default optimiser we use is a proximal variant of DoWG18. For Gaussian variational families, this works well as a default option. Sometimes, the step size of AdvancedVI.DoWG could be too large, resulting in unstable behavior. (In this case, we recommend trying AdvancedVI.DoG19) Or, for whatever reason, it might be desirable to use a different optimiser. Our implementation supports any optimiser that implements the Optimisers.jl interface.\nFor instance, let’s try using Optimiers.Adam20, which is a popular choice. Since AdvancedVI does not implement a proximal operator for Optimisers.Adam, we must use the AdvancedVI.ClipScale() projection operator, which ensures that the scale matrix of the variational approximation is positive definite. (See the paper by J. Domke 202021 for more detail about the use of a projection operator.)\n\nusing Optimisers\n\n_, _, info_adam, _ = vi(m, q_init, n_iters; show_progress=false, callback=callback, optimizer=Optimisers.Adam(3e-3), operator=ClipScale());\n\n\niters = 1:10:length(info_mf)\nelbo_adam = [i.elbo_avg for i in info_adam[iters]]\nPlots.plot(iters, elbo_mf, xlabel=\"Iterations\", ylabel=\"ELBO\", label=\"DoWG\")\nPlots.plot!(iters, elbo_adam, xlabel=\"Iterations\", ylabel=\"ELBO\", label=\"Adam\")\n\n\n\n\n \n \n \n\n\n\n \n \n \n\n\n\n \n \n \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nCompared to the default option AdvancedVI.DoWG(), we can see that Optimisers.Adam(3e-3) is converging more slowly. With more step size tuning, it is possible that Optimisers.Adam could perform better or equal. That is, most common optimisers require some degree of tuning to perform better or comparably to AdvancedVI.DoWG() or AdvancedVI.DoG(), which do not require much tuning at all. Due to this fact, they are referred to as parameter-free optimizers.",
355+
"text": "Using Different Optimisers\nThe default optimiser we use is a proximal variant of DoWG18. For Gaussian variational families, this works well as a default option. Sometimes, the step size of AdvancedVI.DoWG could be too large, resulting in unstable behavior. (In this case, we recommend trying AdvancedVI.DoG19) Or, for whatever reason, it might be desirable to use a different optimiser. Our implementation supports any optimiser that implements the Optimisers.jl interface.\nFor instance, let’s try using Optimisers.Adam20, which is a popular choice. Since AdvancedVI does not implement a proximal operator for Optimisers.Adam, we must use the AdvancedVI.ClipScale() projection operator, which ensures that the scale matrix of the variational approximation is positive definite. (See the paper by J. Domke 202021 for more detail about the use of a projection operator.)\n\nusing Optimisers\n\n_, _, info_adam, _ = vi(m, q_init, n_iters; show_progress=false, callback=callback, optimizer=Optimisers.Adam(3e-3), operator=ClipScale());\n\n\niters = 1:10:length(info_mf)\nelbo_adam = [i.elbo_avg for i in info_adam[iters]]\nPlots.plot(iters, elbo_mf, xlabel=\"Iterations\", ylabel=\"ELBO\", label=\"DoWG\")\nPlots.plot!(iters, elbo_adam, xlabel=\"Iterations\", ylabel=\"ELBO\", label=\"Adam\")\n\n\n\n\n \n \n \n\n\n\n \n \n \n\n\n\n \n \n \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nCompared to the default option AdvancedVI.DoWG(), we can see that Optimisers.Adam(3e-3) is converging more slowly. With more step size tuning, it is possible that Optimisers.Adam could perform better or equal. That is, most common optimisers require some degree of tuning to perform better or comparably to AdvancedVI.DoWG() or AdvancedVI.DoG(), which do not require much tuning at all. Due to this fact, they are referred to as parameter-free optimizers.",
356356
"crumbs": [
357357
"Get Started",
358358
"Tutorials",

pr-previews/612/sitemap.xml

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -2,166 +2,166 @@
22
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
33
<url>
44
<loc>https://turinglang.org/docs/tutorials/gaussian-process-latent-variable-models/index.html</loc>
5-
<lastmod>2025-06-23T16:17:22.541Z</lastmod>
5+
<lastmod>2025-06-23T16:24:28.668Z</lastmod>
66
</url>
77
<url>
88
<loc>https://turinglang.org/docs/tutorials/probabilistic-pca/index.html</loc>
9-
<lastmod>2025-06-23T16:17:22.542Z</lastmod>
9+
<lastmod>2025-06-23T16:24:28.669Z</lastmod>
1010
</url>
1111
<url>
1212
<loc>https://turinglang.org/docs/tutorials/bayesian-poisson-regression/index.html</loc>
13-
<lastmod>2025-06-23T16:17:22.541Z</lastmod>
13+
<lastmod>2025-06-23T16:24:28.668Z</lastmod>
1414
</url>
1515
<url>
1616
<loc>https://turinglang.org/docs/tutorials/bayesian-neural-networks/index.html</loc>
17-
<lastmod>2025-06-23T16:17:22.541Z</lastmod>
17+
<lastmod>2025-06-23T16:24:28.668Z</lastmod>
1818
</url>
1919
<url>
2020
<loc>https://turinglang.org/docs/tutorials/gaussian-mixture-models/index.html</loc>
21-
<lastmod>2025-06-23T16:17:22.541Z</lastmod>
21+
<lastmod>2025-06-23T16:24:28.668Z</lastmod>
2222
</url>
2323
<url>
2424
<loc>https://turinglang.org/docs/tutorials/bayesian-time-series-analysis/index.html</loc>
25-
<lastmod>2025-06-23T16:17:22.541Z</lastmod>
25+
<lastmod>2025-06-23T16:24:28.668Z</lastmod>
2626
</url>
2727
<url>
2828
<loc>https://turinglang.org/docs/tutorials/bayesian-differential-equations/index.html</loc>
29-
<lastmod>2025-06-23T16:17:22.541Z</lastmod>
29+
<lastmod>2025-06-23T16:24:28.667Z</lastmod>
3030
</url>
3131
<url>
3232
<loc>https://turinglang.org/docs/tutorials/variational-inference/index.html</loc>
33-
<lastmod>2025-06-23T16:17:22.542Z</lastmod>
33+
<lastmod>2025-06-23T16:24:28.669Z</lastmod>
3434
</url>
3535
<url>
3636
<loc>https://turinglang.org/docs/developers/compiler/minituring-contexts/index.html</loc>
37-
<lastmod>2025-06-23T16:17:22.537Z</lastmod>
37+
<lastmod>2025-06-23T16:24:28.663Z</lastmod>
3838
</url>
3939
<url>
4040
<loc>https://turinglang.org/docs/developers/compiler/design-overview/index.html</loc>
41-
<lastmod>2025-06-23T16:17:22.536Z</lastmod>
41+
<lastmod>2025-06-23T16:24:28.663Z</lastmod>
4242
</url>
4343
<url>
4444
<loc>https://turinglang.org/docs/developers/inference/implementing-samplers/index.html</loc>
45-
<lastmod>2025-06-23T16:17:22.537Z</lastmod>
45+
<lastmod>2025-06-23T16:24:28.664Z</lastmod>
4646
</url>
4747
<url>
4848
<loc>https://turinglang.org/docs/developers/inference/abstractmcmc-interface/index.html</loc>
49-
<lastmod>2025-06-23T16:17:22.537Z</lastmod>
49+
<lastmod>2025-06-23T16:24:28.664Z</lastmod>
5050
</url>
5151
<url>
5252
<loc>https://turinglang.org/docs/developers/contributing/index.html</loc>
53-
<lastmod>2025-06-23T16:17:22.537Z</lastmod>
53+
<lastmod>2025-06-23T16:24:28.664Z</lastmod>
5454
</url>
5555
<url>
5656
<loc>https://turinglang.org/docs/developers/transforms/bijectors/index.html</loc>
57-
<lastmod>2025-06-23T16:17:22.538Z</lastmod>
57+
<lastmod>2025-06-23T16:24:28.664Z</lastmod>
5858
</url>
5959
<url>
6060
<loc>https://turinglang.org/docs/getting-started/index.html</loc>
61-
<lastmod>2025-06-23T16:17:22.540Z</lastmod>
61+
<lastmod>2025-06-23T16:24:28.667Z</lastmod>
6262
</url>
6363
<url>
6464
<loc>https://turinglang.org/docs/usage/dynamichmc/index.html</loc>
65-
<lastmod>2025-06-23T16:17:22.542Z</lastmod>
65+
<lastmod>2025-06-23T16:24:28.669Z</lastmod>
6666
</url>
6767
<url>
6868
<loc>https://turinglang.org/docs/usage/sampler-visualisation/index.html</loc>
69-
<lastmod>2025-06-23T16:17:22.543Z</lastmod>
69+
<lastmod>2025-06-23T16:24:28.670Z</lastmod>
7070
</url>
7171
<url>
7272
<loc>https://turinglang.org/docs/usage/modifying-logprob/index.html</loc>
73-
<lastmod>2025-06-23T16:17:22.543Z</lastmod>
73+
<lastmod>2025-06-23T16:24:28.669Z</lastmod>
7474
</url>
7575
<url>
7676
<loc>https://turinglang.org/docs/usage/automatic-differentiation/index.html</loc>
77-
<lastmod>2025-06-23T16:17:22.542Z</lastmod>
77+
<lastmod>2025-06-23T16:24:28.669Z</lastmod>
7878
</url>
7979
<url>
8080
<loc>https://turinglang.org/docs/usage/mode-estimation/index.html</loc>
81-
<lastmod>2025-06-23T16:17:22.543Z</lastmod>
81+
<lastmod>2025-06-23T16:24:28.669Z</lastmod>
8282
</url>
8383
<url>
8484
<loc>https://turinglang.org/docs/usage/troubleshooting/index.html</loc>
85-
<lastmod>2025-06-23T16:17:22.543Z</lastmod>
85+
<lastmod>2025-06-23T16:24:28.670Z</lastmod>
8686
</url>
8787
<url>
8888
<loc>https://turinglang.org/docs/usage/external-samplers/index.html</loc>
89-
<lastmod>2025-06-23T16:17:22.543Z</lastmod>
89+
<lastmod>2025-06-23T16:24:28.669Z</lastmod>
9090
</url>
9191
<url>
9292
<loc>https://turinglang.org/docs/usage/probability-interface/index.html</loc>
93-
<lastmod>2025-06-23T16:17:22.543Z</lastmod>
93+
<lastmod>2025-06-23T16:24:28.670Z</lastmod>
9494
</url>
9595
<url>
9696
<loc>https://turinglang.org/docs/usage/custom-distribution/index.html</loc>
97-
<lastmod>2025-06-23T16:17:22.542Z</lastmod>
97+
<lastmod>2025-06-23T16:24:28.669Z</lastmod>
9898
</url>
9999
<url>
100100
<loc>https://turinglang.org/docs/usage/tracking-extra-quantities/index.html</loc>
101-
<lastmod>2025-06-23T16:17:22.543Z</lastmod>
101+
<lastmod>2025-06-23T16:24:28.670Z</lastmod>
102102
</url>
103103
<url>
104104
<loc>https://turinglang.org/docs/usage/performance-tips/index.html</loc>
105-
<lastmod>2025-06-23T16:17:22.543Z</lastmod>
105+
<lastmod>2025-06-23T16:24:28.670Z</lastmod>
106106
</url>
107107
<url>
108108
<loc>https://turinglang.org/docs/core-functionality/index.html</loc>
109-
<lastmod>2025-06-23T16:17:22.536Z</lastmod>
109+
<lastmod>2025-06-23T16:24:28.663Z</lastmod>
110110
</url>
111111
<url>
112112
<loc>https://turinglang.org/docs/developers/transforms/distributions/index.html</loc>
113-
<lastmod>2025-06-23T16:17:22.538Z</lastmod>
113+
<lastmod>2025-06-23T16:24:28.665Z</lastmod>
114114
</url>
115115
<url>
116116
<loc>https://turinglang.org/docs/developers/transforms/dynamicppl/index.html</loc>
117-
<lastmod>2025-06-23T16:17:22.540Z</lastmod>
117+
<lastmod>2025-06-23T16:24:28.667Z</lastmod>
118118
</url>
119119
<url>
120120
<loc>https://turinglang.org/docs/developers/inference/variational-inference/index.html</loc>
121-
<lastmod>2025-06-23T16:17:22.538Z</lastmod>
121+
<lastmod>2025-06-23T16:24:28.664Z</lastmod>
122122
</url>
123123
<url>
124124
<loc>https://turinglang.org/docs/developers/inference/abstractmcmc-turing/index.html</loc>
125-
<lastmod>2025-06-23T16:17:22.537Z</lastmod>
125+
<lastmod>2025-06-23T16:24:28.664Z</lastmod>
126126
</url>
127127
<url>
128128
<loc>https://turinglang.org/docs/developers/compiler/model-manual/index.html</loc>
129-
<lastmod>2025-06-23T16:17:22.537Z</lastmod>
129+
<lastmod>2025-06-23T16:24:28.663Z</lastmod>
130130
</url>
131131
<url>
132132
<loc>https://turinglang.org/docs/developers/compiler/minituring-compiler/index.html</loc>
133-
<lastmod>2025-06-23T16:17:22.537Z</lastmod>
133+
<lastmod>2025-06-23T16:24:28.663Z</lastmod>
134134
</url>
135135
<url>
136136
<loc>https://turinglang.org/docs/developers/contexts/submodel-condition/index.html</loc>
137-
<lastmod>2025-06-23T16:17:22.537Z</lastmod>
137+
<lastmod>2025-06-23T16:24:28.664Z</lastmod>
138138
</url>
139139
<url>
140140
<loc>https://turinglang.org/docs/tutorials/bayesian-logistic-regression/index.html</loc>
141-
<lastmod>2025-06-23T16:17:22.541Z</lastmod>
141+
<lastmod>2025-06-23T16:24:28.668Z</lastmod>
142142
</url>
143143
<url>
144144
<loc>https://turinglang.org/docs/tutorials/bayesian-linear-regression/index.html</loc>
145-
<lastmod>2025-06-23T16:17:22.541Z</lastmod>
145+
<lastmod>2025-06-23T16:24:28.667Z</lastmod>
146146
</url>
147147
<url>
148148
<loc>https://turinglang.org/docs/tutorials/coin-flipping/index.html</loc>
149-
<lastmod>2025-06-23T16:17:22.541Z</lastmod>
149+
<lastmod>2025-06-23T16:24:28.668Z</lastmod>
150150
</url>
151151
<url>
152152
<loc>https://turinglang.org/docs/tutorials/hidden-markov-models/index.html</loc>
153-
<lastmod>2025-06-23T16:17:22.542Z</lastmod>
153+
<lastmod>2025-06-23T16:24:28.668Z</lastmod>
154154
</url>
155155
<url>
156156
<loc>https://turinglang.org/docs/tutorials/multinomial-logistic-regression/index.html</loc>
157-
<lastmod>2025-06-23T16:17:22.542Z</lastmod>
157+
<lastmod>2025-06-23T16:24:28.669Z</lastmod>
158158
</url>
159159
<url>
160160
<loc>https://turinglang.org/docs/tutorials/gaussian-processes-introduction/index.html</loc>
161-
<lastmod>2025-06-23T16:17:22.542Z</lastmod>
161+
<lastmod>2025-06-23T16:24:28.668Z</lastmod>
162162
</url>
163163
<url>
164164
<loc>https://turinglang.org/docs/tutorials/infinite-mixture-models/index.html</loc>
165-
<lastmod>2025-06-23T16:17:22.542Z</lastmod>
165+
<lastmod>2025-06-23T16:24:28.669Z</lastmod>
166166
</url>
167167
</urlset>

0 commit comments

Comments
 (0)