|
11 | 11 | "cell_type": "markdown",
|
12 | 12 | "metadata": {},
|
13 | 13 | "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" |
22 | 22 | ]
|
23 | 23 | },
|
24 | 24 | {
|
25 | 25 | "cell_type": "markdown",
|
26 | 26 | "metadata": {},
|
27 | 27 | "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" |
29 | 39 | ]
|
30 | 40 | },
|
31 | 41 | {
|
|
47 | 57 | "outputs": [],
|
48 | 58 | "source": [
|
49 | 59 | "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\")" |
51 | 61 | ]
|
52 | 62 | },
|
53 | 63 | {
|
|
92 | 102 | "from sbi.neural_nets import posterior_nn\n",
|
93 | 103 | "\n",
|
94 | 104 | "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", |
96 | 106 | ")\n",
|
97 | 107 | "inference = NPE(prior=prior, density_estimator=density_estimator_build_fun)"
|
98 | 108 | ]
|
|
0 commit comments