-
Notifications
You must be signed in to change notification settings - Fork 615
Add tanhshrink #493
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 tanhshrink #493
Conversation
|
||
@keras_utils.register_keras_custom_object | ||
@tf.function | ||
def tanhshrink(features, name="Tanhshrink"): |
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.
Seems that I missed the name
argument in my previous PRs. @facaiy @seanpmorgan Should we strictly follow this? Like activations in tf.keras.activations.*
, they do not expose name
argument.
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 believe the name argument is important for debugging.
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.
Sorry for the delay, I have no objection, however I prefer to keep consistency with keras module. name
often conflicts with arguments backward compatibility, and it won't hurt to add it in the future. What do you think, @fsx950223 , @WindQAQ Tzu-Wei?
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.
Sorry for the delay, I have no objection, however I prefer to keep consistency with keras module.
name
often conflicts with arguments backward compatibility, and it won't hurt to add it in the future. What do you think, @fsx950223 , @WindQAQ Tzu-Wei?
I opened an issue #505. We can discuss in the issue
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.
@fsx950223 Hello, I drop some comments here. Feel free to ping me if you have further problem.
Keras api is based on tensorflow.nn api. Maybe we should define keras api and custom op api separately. |
We have discussed this previously #426. But you could still open a new issue or re-use the old one for further discussion. |
I agree with the final discussion result. But we should follow tensorflow.nn.* apis' style. |
Hi @fsx950223, as a side note, don't forget to follow the namespace change as per #516. |
a724813
to
df686c3
Compare
0a50383
to
9e09680
Compare
9e09680
to
18f1bb8
Compare
Why? Any other changes? |
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.
The error you mentioned above is probably because you do not use the latest nightly tensorflow. Try to install tf-nightly-gpu-2.0-preview
. Also, I drop some comments below, please check it out. Thanks for the contribution.
|
||
Args: | ||
features: A `Tensor`. Must be one of the following types: | ||
`float16`, `float32`, `float64`, `int32`, `int64`. |
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.
Remove int32
and int64
.
|
||
#undef EIGEN_USE_THREADS | ||
|
||
#endif |
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.
#endif // TENSORFLOW_ADDONS_ACTIVATIONS_KERNELS_TANHSHRINK_OP_H_
// INPUTS: | ||
// g (gradients): backpropagated gradients | ||
// a (inputs): either the inputs that were passed to TanhshrinkOp(), or its | ||
// outputs (using either one yields the same result here). |
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 think in your implementation a (inputs)
should be the inputs that were passed to TanhshrinkOp() instead of its outputs, which will not yield the same result.
+1, please try to upgrade tf |
add33d1
to
969dd10
Compare
Fixed. @WindQAQ |
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.
Want to check the last thing :-) Thanks.
Please review again. |
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!
Related #437