Skip to content

Add additional signatures to softmax and log_softmax #3166

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
jachymb opened this issue Mar 19, 2025 · 0 comments
Open

Add additional signatures to softmax and log_softmax #3166

jachymb opened this issue Mar 19, 2025 · 0 comments

Comments

@jachymb
Copy link

jachymb commented Mar 19, 2025

Currently the only signature available is (vector) => vector

But it's somewhat annoying when I want to do this row-wise over a matrix. (To hand-code a similar effect as stochastic_row_matrix constraint has)

I suggest adding the following signatures:

Softmax for row_vectors:

(row_vector) => row_vector

And a 'vectorized' variant:

(array[] vector) => array[] vector
(array[] row_vector) => array[] row_vector

The signature (matrix) => matrix is perhaps not a good idea because it's not immediately clear which dimension it should work over, but maybe there could be pairs of functions softmax_rowwise, softmax_columnwise (which would essentially return stochastic_row_matrix and stochastic_col_matrix respectively) as well as the log variants log_softmax_rowwise, log_softmax_colwise.

Possibly related: stan-dev/stan#3331

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

No branches or pull requests

1 participant