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
PERF Don't return anything from neural net activation functions #17633
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks @alexhenrie !
Have you tried visualizing profiling results e.g. with snakeviz or py-spy? That could give you more ideas what to optimize..
Thanks Roman. I haven't tried snakeviz or py-spy yet. I do know that I could make the neural nets a lot faster by porting the code to Cython and using C functions instead of numpy functions, but I'm not sure if that's a project I want to take on. |
I wouldn't be so sure about it. After skimming though the implementation I couldn't see places were rewriting in Cython would be massively different (after a superficial look). Profiling would probably be a good start though. |
Also it could be worth trying to storing / computing weights and activation in 32bit optionally, even if LBFGS would then need to cast back and forth to 64bit. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add an entry to the change log at doc/whats_new/v0.24.rst
. Like the other entries there, please reference this pull request with :pr:
and credit yourself (and other contributors if applicable) with :user:
I've made a few nice improvements to the neural net performance, but I don't think they deserve a change log entry because they're all pretty small. |
It's worth having an entry for all together listing the relevant pull requests. If nothing else, this can be helpful if one of your changes accidentally creates a bug. |
This pull request is similar to pull request #17604: Returning a reference to X from the activation functions is unnecessary and creates the false impression that they make copies. The activiation functions should have the same interface as the derivative functions, which were already returning nothing. Furthermore, dropping the return values improves the performance of neural net training by about 3%.
Test program:
Before:
After: