Skip to content

WIP: Add tt.nnet.softmax to math (#4226) #4229

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

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions docs/source/api/math.rst
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ expressions rather than NumPy or Python code.
logsumexp
invlogit
logit
softmax

.. automodule:: pymc3.math
:members:
5 changes: 5 additions & 0 deletions pymc3/math.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,11 @@ def invlogit(x, eps=sys.float_info.epsilon):
return (1.0 - 2.0 * eps) / (1.0 + tt.exp(-x)) + eps


def softmax(x):
"""Generalization of the inverse logit function to multiple dimensions."""
return tt.nnet.softmax(x)


def logbern(log_p):
if np.isnan(log_p):
raise FloatingPointError("log_p can't be nan.")
Expand Down