From 04490724772e97fbf7f48f98e04347ba63c03b27 Mon Sep 17 00:00:00 2001 From: kees ter brugge Date: Sun, 10 Jul 2022 14:49:38 +0200 Subject: [PATCH 1/2] update function argument `res = pm.find_MAP(vars=[z], fmin=optimize.fmin_l_bfgs_b)` gave me the error ```python /usr/local/lib/python3.7/dist-packages/fastprogress/fastprogress.py:74: UserWarning: Your generator is empty. warn("Your generator is empty.") --------------------------------------------------------------------------- TypeError Traceback (most recent call last) in () 1 smoothing = 0.5 ----> 2 z_val = infer_z(smoothing) 3 4 plot(x, y) 5 plot(x, z_val) 1 frames /usr/local/lib/python3.7/dist-packages/pymc3/tuning/starting.py in find_MAP(start, vars, method, return_raw, include_transformed, progressbar, maxeval, model, *args, **kwargs) 133 134 try: --> 135 opt_result = minimize(cost_func, x0, method=method, jac=compute_gradient, *args, **kwargs) 136 mx0 = opt_result["x"] # r -> opt_result 137 except (KeyboardInterrupt, StopIteration) as e: TypeError: minimize() got an unexpected keyword argument 'fmin' ``` whereas `res = pm.find_MAP(vars=[z], method="L-BFGS-B")` did work for me --- examples/gaussian_processes/GP-smoothing.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/gaussian_processes/GP-smoothing.ipynb b/examples/gaussian_processes/GP-smoothing.ipynb index de2aad56f..ade43eeb6 100644 --- a/examples/gaussian_processes/GP-smoothing.ipynb +++ b/examples/gaussian_processes/GP-smoothing.ipynb @@ -207,7 +207,7 @@ "def infer_z(smoothing):\n", " with model:\n", " smoothing_param.set_value(smoothing)\n", - " res = pm.find_MAP(vars=[z], fmin=optimize.fmin_l_bfgs_b)\n", + " res = pm.find_MAP(vars=[z], method=\"L-BFGS-B\")\n", " return res[\"z\"]" ] }, From f6b75723360b48727c73407b93366a03befbebe7 Mon Sep 17 00:00:00 2001 From: "Oriol (ZBook)" Date: Sat, 5 Nov 2022 21:36:28 +0100 Subject: [PATCH 2/2] add myst counterpart --- myst_nbs/gaussian_processes/GP-smoothing.myst.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/myst_nbs/gaussian_processes/GP-smoothing.myst.md b/myst_nbs/gaussian_processes/GP-smoothing.myst.md index 15f6e80d0..e277d43f1 100644 --- a/myst_nbs/gaussian_processes/GP-smoothing.myst.md +++ b/myst_nbs/gaussian_processes/GP-smoothing.myst.md @@ -121,7 +121,7 @@ Let's also make a helper function for inferring the most likely values of $z$: def infer_z(smoothing): with model: smoothing_param.set_value(smoothing) - res = pm.find_MAP(vars=[z], fmin=optimize.fmin_l_bfgs_b) + res = pm.find_MAP(vars=[z], method="L-BFGS-B") return res["z"] ``` @@ -155,7 +155,7 @@ title(f"Smoothing={smoothing}"); ### Smoothing "to the limits" -By increasing the smoothing parameter, we can gradually make the inferred values of the hidden Brownian motion approach the average value of the data. This is because as we increase the smoothing parameter, we allow less and less of the variance to be allocated to the Brownian motion, so eventually it approaches the process which almost doesn't change over the domain of $x$: +By increasing the smoothing parameter, we can gradually make the inferred values of the hidden Brownian motion approach the average value of the data. This is because as we increase the smoothing parameter, we allow less and less of the variance to be allocated to the Brownian motion, so eventually it approaches the process which almost doesn't change over the domain of $x$: ```{code-cell} ipython3 fig, axes = subplots(2, 2)