Skip to content

Commit

Permalink
Clarify last round behavior of SNPE-A
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeldeistler committed Dec 9, 2024
1 parent 4b3d409 commit ecfcec5
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions tutorials/16_implemented_methods.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,13 @@
"\n",
"inference = NPE_A(prior)\n",
"proposal = prior\n",
"for _ in range(num_rounds):\n",
"for r in range(num_rounds):\n",
" theta = proposal.sample((num_sims,))\n",
" x = simulator(theta)\n",
" _ = inference.append_simulations(theta, x, proposal=proposal).train()\n",
" # NPE-A trains a Gaussian density estimator in all but the last round. In the last round,\n",
" # it trains a mixture of Gaussians, which is why we have to pass the `final_round` flag.\n",
" final_round = True if r == num_rounds - 1 else False\n",
" _ = inference.append_simulations(theta, x, proposal=proposal).train(final_round=final_round)\n",
" posterior = inference.build_posterior().set_default_x(x_o)\n",
" proposal = posterior"
]
Expand Down Expand Up @@ -598,7 +601,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.14"
"version": "3.12.4"
},
"toc": {
"base_numbering": 1,
Expand Down

0 comments on commit ecfcec5

Please sign in to comment.