Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated docs and fixed spelling #3254

Merged
merged 1 commit into from
Aug 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions pyro/infer/autoguide/guides.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ def median(self, *args, **kwargs):

class AutoGuideList(AutoGuide, nn.ModuleList):
"""
Container class to combine multiple automatic guides.
Container class to combine multiple automatic or custom guides.

Example usage::

Expand All @@ -203,7 +203,7 @@ def _check_prototype(self, part_trace):

def append(self, part):
"""
Add an automatic guide for part of the model. The guide should
Add an automatic or custom guide for part of the model. The guide should
have been created by blocking the model to restrict to a subset of
sample sites. No two parts should operate on any one sample site.

Expand Down Expand Up @@ -286,15 +286,15 @@ def my_local_guide(*args, **kwargs):
...

guide = AutoGuideList(model)
guide.add(AutoDelta(poutine.block(model, expose=['my_global_param']))
guide.add(my_local_guide) # automatically wrapped in an AutoCallable
guide.append(AutoDelta(poutine.block(model, expose=['my_global_param']))
guide.append(my_local_guide) # automatically wrapped in an AutoCallable

To specify a median callable, you can instead::

def my_local_median(*args, **kwargs)
...

guide.add(AutoCallable(model, my_local_guide, my_local_median))
guide.append(AutoCallable(model, my_local_guide, my_local_median))

For more complex guides that need e.g. access to plates, users should
instead subclass ``AutoGuide``.
Expand Down
21 changes: 19 additions & 2 deletions tutorial/source/svi_part_iv.ipynb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"cells": [
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand All @@ -24,6 +25,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand All @@ -43,6 +45,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand All @@ -65,6 +68,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand All @@ -84,6 +88,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand Down Expand Up @@ -112,6 +117,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand All @@ -135,6 +141,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand All @@ -146,7 +153,7 @@
"\n",
"Sometimes the problem is actually in your model even though you think it's in the guide. \n",
"Conversely, sometimes the problem is in your guide even though you think it's in the model or somewhere else. \n",
"For these reasons it can be helpful to reduce the number of moving parts while you try to identify the underyling issue.\n",
"For these reasons it can be helpful to reduce the number of moving parts while you try to identify the underlying issue.\n",
"One convenient way to do this is to replace your custom guide with a [pyro.infer.AutoGuide](http://docs.pyro.ai/en/stable/infer.autoguide.html#module-pyro.infer.autoguide). \n",
"\n",
"For example, if all the latent variables in your model are continuous, you can try a [pyro.infer.AutoNormal](http://docs.pyro.ai/en/stable/infer.autoguide.html#autonormal) guide.\n",
Expand All @@ -164,6 +171,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand Down Expand Up @@ -196,6 +204,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand All @@ -216,16 +225,18 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"### 9. Use `TraceMeanField_ELBO` if applicable\n",
"\n",
"The basic `ELBO` implementation in Pyro, [Trace_ELBO](http://docs.pyro.ai/en/stable/inference_algos.html?highlight=tracemeanfield#pyro.infer.trace_elbo.Trace_ELBO), uses stochastic samples to estimate the KL divergence term. \n",
"When analytic KL diverences are available, you may be able to lower ELBO variance by using analytic KL divergences instead. This functionality is provided by [TraceMeanField_ELBO](http://docs.pyro.ai/en/stable/inference_algos.html?highlight=tracemeanfield#pyro.infer.trace_elbo.Trace_ELBO)."
"When analytic KL divergences are available, you may be able to lower ELBO variance by using analytic KL divergences instead. This functionality is provided by [TraceMeanField_ELBO](https://docs.pyro.ai/en/stable/inference_algos.html?highlight=tracemeanfield#pyro.infer.trace_mean_field_elbo.TraceMeanField_ELBO)."
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand All @@ -243,6 +254,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand Down Expand Up @@ -279,6 +291,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand All @@ -297,6 +310,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand All @@ -306,6 +320,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand All @@ -316,6 +331,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand All @@ -330,6 +346,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand Down
Loading