Skip to content

Updating softmax in rethinking_2 chapter 11 #240

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions Rethinking_2/Chp_11.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
"outputs": [],
"source": [
"import warnings\n",
"\n",
"import aesara.tensor as at\n",
"import arviz as az\n",
"import matplotlib.pyplot as plt\n",
"import numpy as np\n",
Expand Down Expand Up @@ -4719,7 +4717,7 @@
" s2 = 0.0 + b * income[2] # pivoting the intercept for the third category\n",
" s = pm.math.stack([s0, s1, s2])\n",
"\n",
" p_ = at.nnet.softmax(s)\n",
" p_ = pm.math.softmax(s, axis=1)\n",
" career_obs = pm.Categorical(\"career\", p=p_, observed=career)\n",
"\n",
" trace_11_13 = pm.sample(tune=2000, target_accept=0.99, random_seed=RANDOM_SEED)\n",
Expand Down Expand Up @@ -5061,7 +5059,7 @@
" s2 = np.zeros(N) # pivot\n",
" s = pm.math.stack([s0, s1, s2]).T\n",
"\n",
" p_ = at.nnet.softmax(s)\n",
" p_ = pm.math.softmax(s, axis=1)\n",
" career_obs = pm.Categorical(\"career\", p=p_, observed=career)\n",
"\n",
" trace_11_14 = pm.sample(1000, tune=2000, target_accept=0.9, random_seed=RANDOM_SEED)\n",
Expand Down