Skip to content

Commit 7cbf7aa

Browse files
committed
add graphviz, rerun
1 parent 69eb993 commit 7cbf7aa

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

examples/mixture_models/dependent_density_regression.ipynb

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
"from IPython.display import HTML\n",
5858
"from matplotlib import animation as ani\n",
5959
"from matplotlib import pyplot as plt\n",
60+
"from theano import shared\n",
6061
"from theano import tensor as tt\n",
6162
"\n",
6263
"print(f\"Running on PyMC3 v{pm.__version__}\")"
@@ -1681,7 +1682,7 @@
16811682
"with pm.Model() as model:\n",
16821683
" alpha = pm.Normal(\"alpha\", 0.0, 5.0, shape=K)\n",
16831684
" beta = pm.Normal(\"beta\", 0.0, 5.0, shape=(1, K))\n",
1684-
" x = pm.Data(\"x\", std_range)\n",
1685+
" x = pm.Data('x', std_range)\n",
16851686
" v = norm_cdf(alpha + pm.math.dot(x, beta))\n",
16861687
" w = pm.Deterministic(\"w\", stick_breaking(v))"
16871688
]
@@ -1699,7 +1700,7 @@
16991700
"tags": []
17001701
},
17011702
"source": [
1702-
"We have defined `x` as a `pm.Data` container variable in order to use `PyMC3`'s posterior prediction capabilities later.\n",
1703+
"We have defined `x_lidar` as a [theano shared](https://theano-pymc.readthedocs.io/en/latest/library/compile/shared.html) variable in order to use `PyMC3`'s posterior prediction capabilities later.\n",
17031704
"\n",
17041705
"While the dependent density regression model theoretically has infinitely many components, we must truncate the model to finitely many components (in this case, twenty) in order to express it using `PyMC3`. After sampling from the model, we will verify that truncation did not unduly influence our results.\n",
17051706
"\n",
@@ -1785,7 +1786,7 @@
17851786
"source": [
17861787
"with model:\n",
17871788
" tau = pm.Gamma(\"tau\", 1.0, 1.0, shape=K)\n",
1788-
" y = pm.Data(\"y\", std_logratio)\n",
1789+
" y = pm.Data('y', std_logratio)\n",
17891790
" obs = pm.NormalMixture(\"obs\", w, mu, tau=tau, observed=y)"
17901791
]
17911792
},
@@ -1941,7 +1942,7 @@
19411942
}
19421943
],
19431944
"source": [
1944-
"trace.posterior[\"w\"].shape # (n_chains, n_samples, N, K)"
1945+
"trace.posterior['w'].shape # (n_chains, n_samples, N, K)"
19451946
]
19461947
},
19471948
{
@@ -1983,7 +1984,7 @@
19831984
"source": [
19841985
"fig, ax = plt.subplots(figsize=(8, 6))\n",
19851986
"\n",
1986-
"w_posterior = trace.posterior[\"w\"].data\n",
1987+
"w_posterior = trace.posterior['w'].data\n",
19871988
"# reshape to (n_chains*n_samples, N, K)\n",
19881989
"w_posterior = w_posterior.reshape(-1, w_posterior.shape[2], w_posterior.shape[3])\n",
19891990
"ax.bar(np.arange(K) + 1, w_posterior.mean(axis=0).max(axis=0))\n",
@@ -2077,7 +2078,7 @@
20772078
"lidar_pp_x = np.linspace(std_range.min() - 0.05, std_range.max() + 0.05, 100)\n",
20782079
"\n",
20792080
"with model:\n",
2080-
" pm.set_data({\"x\": lidar_pp_x[:, np.newaxis]})\n",
2081+
" pm.set_data({'x': lidar_pp_x[:, np.newaxis]})\n",
20812082
" pp_trace = pm.sample_posterior_predictive(trace, PP_SAMPLES, random_seed=SEED)"
20822083
]
20832084
},

0 commit comments

Comments
 (0)