Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Add support for GELU and approximate activation functions #8224
Add support for GELU and approximate activation functions #8224
Changes from 5 commits
f4ad2b1
d90d735
f27de34
6352f8b
890182d
679a162
7181b07
f78d5d9
742e19d
376ba19
ed02f32
bfaee9e
7b38dbc
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
this test is failing on webgl
https://btx.cloud.google.com/invocations/e17bf0ae-be69-4c2c-ae42-898362837087/targets/%2F%2Ftfjs-layers:bs_chrome_mac_tfjs-layers_webgl2_test;config=558edca9061547b5089f0232d6a9290fa00acb52e12d7215b154805a33d24105/log
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.
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.
I can't see the error, so I don't know what's failing. I can't imagine why webgl would fail while other backends would succeed, but maybe it's a difference in floating point precision between environments?
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.
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.
I'm not sure how I screwed up so badly, but every single test value was wrong. I just went through and updated every one of them by-hand; tests should be fixed now. Sorry about that!
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.
no worries, thanks for fixing the test.
can you run following in the tfjs directory:
tslint -p tsconfig_tslint.json
and fix the lint errors.
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.
Done! I'll remember to check the linting in future commits.
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.
Thanks for the PR! I'm back in office now, so I've taken a look.
I think this implementation of
gelu_new
might be computing justΦ(x)
instead ofx Φ(x)
According to
help(keras.activations.gelu)
in python,0.5 * x * (1 + tanh(sqrt(2 / pi) * (x + 0.044715 * x^3)))
is the approximate form thatgelu_new
is computing, but I think the implementation is missing the* x
. That's why all the values were wrong.I tried adding a
* x
to the implementation and the values look closer: