Skip to content

Commit ecfcec5

Browse files
Clarify last round behavior of SNPE-A
1 parent 4b3d409 commit ecfcec5

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

tutorials/16_implemented_methods.ipynb

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,13 @@
6666
"\n",
6767
"inference = NPE_A(prior)\n",
6868
"proposal = prior\n",
69-
"for _ in range(num_rounds):\n",
69+
"for r in range(num_rounds):\n",
7070
" theta = proposal.sample((num_sims,))\n",
7171
" x = simulator(theta)\n",
72-
" _ = inference.append_simulations(theta, x, proposal=proposal).train()\n",
72+
" # NPE-A trains a Gaussian density estimator in all but the last round. In the last round,\n",
73+
" # it trains a mixture of Gaussians, which is why we have to pass the `final_round` flag.\n",
74+
" final_round = True if r == num_rounds - 1 else False\n",
75+
" _ = inference.append_simulations(theta, x, proposal=proposal).train(final_round=final_round)\n",
7376
" posterior = inference.build_posterior().set_default_x(x_o)\n",
7477
" proposal = posterior"
7578
]
@@ -598,7 +601,7 @@
598601
"name": "python",
599602
"nbconvert_exporter": "python",
600603
"pygments_lexer": "ipython3",
601-
"version": "3.10.14"
604+
"version": "3.12.4"
602605
},
603606
"toc": {
604607
"base_numbering": 1,

0 commit comments

Comments
 (0)