Skip to content

Commit 18f92b1

Browse files
authored
docs: add details about zuko density estimators' (#1387)
1 parent 6d527f7 commit 18f92b1

File tree

1 file changed

+21
-11
lines changed

1 file changed

+21
-11
lines changed

tutorials/03_density_estimators.ipynb

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,31 @@
1111
"cell_type": "markdown",
1212
"metadata": {},
1313
"source": [
14-
"`sbi` allows to specify a custom density estimator for each of the implemented methods. For all options, check the API reference [here](https://sbi-dev.github.io/sbi/reference/models/).\n"
15-
]
16-
},
17-
{
18-
"cell_type": "markdown",
19-
"metadata": {},
20-
"source": [
21-
"## Changing the type of density estimator\n"
14+
"`sbi` allows to specify a specific density estimator for each of the implemented methods.\n",
15+
"We support a variety of density estimators, e.g., mixtures of Gaussians, normalizing\n",
16+
"flows, and diffusion models. Some of the density estimators are implemented as part of\n",
17+
"`sbi`, for others we rely on other packages like\n",
18+
"[`nflows`](https://github.com/bayesiains/nflows/) (via `pyknos`) or [`zuko`](https://github.com/probabilists/zuko). \n",
19+
"\n",
20+
"For all options, check the API reference\n",
21+
"[here](https://sbi-dev.github.io/sbi/reference/models/).\n"
2222
]
2323
},
2424
{
2525
"cell_type": "markdown",
2626
"metadata": {},
2727
"source": [
28-
"One option is using one of the preconfigured density estimators by passing a string in the `density_estimator` keyword argument to the inference object (`NPE` or `NLE`), e.g., \"maf\" for a Masked Autoregressive Flow, of \"nsf\" for a Neural Spline Flow with default hyperparameters.\n"
28+
"## Changing the type of density estimator\n",
29+
"\n",
30+
"One option is using one of the preconfigured density estimators by passing a string in\n",
31+
"the `density_estimator` keyword argument to the inference object (`NPE` or `NLE`), e.g.,\n",
32+
"\"maf\" for a Masked Autoregressive Flow, of \"nsf\" for a Neural Spline Flow with default\n",
33+
"hyperparameters.\n",
34+
"\n",
35+
"**New with sbi 0.23:** Note that `\"maf\"` or `\"nsf\"` correspond to `nflows` density\n",
36+
"estimators. Those have proven to work well, but the `nflows` package is not maintained\n",
37+
"anymore. To use more recent and actively maintained density estimators, we tentatively\n",
38+
"recommend using `zuko`, e.g., by passing `zuko_maf` or `zuko_nsf`. \n"
2939
]
3040
},
3141
{
@@ -47,7 +57,7 @@
4757
"outputs": [],
4858
"source": [
4959
"prior = BoxUniform(torch.zeros(2), torch.ones(2))\n",
50-
"inference = NPE(prior=prior, density_estimator=\"maf\")"
60+
"inference = NPE(prior=prior, density_estimator=\"zuko_maf\")"
5161
]
5262
},
5363
{
@@ -92,7 +102,7 @@
92102
"from sbi.neural_nets import posterior_nn\n",
93103
"\n",
94104
"density_estimator_build_fun = posterior_nn(\n",
95-
" model=\"nsf\", hidden_features=60, num_transforms=3\n",
105+
" model=\"zuko_nsf\", hidden_features=60, num_transforms=3\n",
96106
")\n",
97107
"inference = NPE(prior=prior, density_estimator=density_estimator_build_fun)"
98108
]

0 commit comments

Comments
 (0)