Skip to content
Closed
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: 4 additions & 2 deletions pytensor/tensor/math.py
Original file line number Diff line number Diff line change
Expand Up @@ -2753,8 +2753,10 @@ def logsumexp(x, axis=None, keepdims=False):
tensor

"""

return log(sum(exp(x), axis=axis, keepdims=keepdims))
result = log(
sum(exp(x - max(x, axis=axis, keepdims=True)), axis=axis, keepdims=keepdims)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's also a bit more complicated than that to handle cases of all infinities. The graph is pretty messy, that's why we do it later only

)
return result + max(x, axis=axis, keepdims=keepdims)


# Predefine all batched variations of Dot
Expand Down