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

Update softmax with parameterization #16

Merged
merged 12 commits into from
Apr 21, 2021
Merged

Conversation

bdeonovic
Copy link
Contributor

parameterize softmax to be usable with AD.

parameterize softmax to be usable with AD.
src/basicfuns.jl Outdated Show resolved Hide resolved
@devmotion
Copy link
Member

Depending on your use case, you might need to improve the implementation of softmax! as well (e.g., I guess <:AbstractFloat is quite restrictive and s = 0. should probably not be hardcoded as Float64).

incorporate suggestions from @devmotion

Co-authored-by: David Widmann <devmotion@users.noreply.github.com>
@bdeonovic
Copy link
Contributor Author

Do you have any comments on why softmax! was written the way it was? Is there a point to using inv rather than just dividing by the sum s?

@devmotion
Copy link
Member

Do you have any comments on why softmax! was written the way it was? Is there a point to using inv rather than just dividing by the sum s?

No, I don't know why it was written in this way. I assume that it uses inv for performance reasons: usually multiplication is faster than division.

src/basicfuns.jl Outdated Show resolved Hide resolved
src/basicfuns.jl Outdated Show resolved Hide resolved
src/basicfuns.jl Show resolved Hide resolved
test/basicfuns.jl Show resolved Hide resolved
bdeonovic and others added 3 commits April 21, 2021 08:04
Co-authored-by: David Widmann <devmotion@users.noreply.github.com>
Co-authored-by: David Widmann <devmotion@users.noreply.github.com>
Copy link
Member

@devmotion devmotion left a comment

Choose a reason for hiding this comment

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

OK, looks good! If you revert back to using invs = inv(s), then it should be good to go and I'll merge and make a new release.

src/basicfuns.jl Outdated Show resolved Hide resolved
@bdeonovic
Copy link
Contributor Author

thanks for your patience

Copy link
Member

@devmotion devmotion left a comment

Choose a reason for hiding this comment

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

Thanks a lot for the PR!

@devmotion devmotion merged commit 3289f12 into JuliaStats:master Apr 21, 2021
@devmotion
Copy link
Member

A new release with the fix should be available soon: JuliaRegistries/General#34861

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

Successfully merging this pull request may close these issues.

2 participants