Skip to content
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

[DOC] Incorrect interval in jax.nn.log_softmax #23992

Open
Qazalbash opened this issue Sep 28, 2024 · 1 comment
Open

[DOC] Incorrect interval in jax.nn.log_softmax #23992

Qazalbash opened this issue Sep 28, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@Qazalbash
Copy link

Qazalbash commented Sep 28, 2024

Note that the mathematically correct interval should be

:math:`(-\infty,0)`

elements to the range :math:`[-\infty, 0)`.

elements to the range :math:`[-\infty, 0)`.

@Qazalbash Qazalbash added the enhancement New feature or request label Sep 28, 2024
@justinjfu
Copy link
Collaborator

I think the documentation should follow the code and not necessarily the mathematically correct definition, but either way the docs are wrong: This function does potentially output the floating point representation of -inf, but it can also output 0 due to rounding. So the interval should either be [-inf, 0] following code or (-inf, 0) following math.

>>> jax.nn.log_softmax(jnp.array([-jnp.inf, 0, 1])) # outputs -inf
Array([       -inf, -1.3132616 , -0.31326163], dtype=float32)

>>> jax.nn.log_softmax(jnp.array([-jnp.inf, -1000, 1])) # outputs 0
Array([  -inf, -1001.,     0.], dtype=float32)

@jakevdp or @mattjj thoughts? I can submit a quick PR to update this if it's a good idea.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants