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 hardshrink kernel #500
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.
Looks very good thanks as always Tzu-Wei. One request if you think it's appropriate.
|
||
#define REGISTER_HARDSHRINK_KERNELS(type) \ | ||
REGISTER_KERNEL_BUILDER( \ | ||
Name("Hardshrink").Device(DEVICE_CPU).TypeConstraint<type>("T"), \ |
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.
Think we could change this to Addons>Hardshrink
per tensorflow/community#126 ? It should work on the nightly and RC I believe.
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 wonder how to do this... I have tried to modify cc/kernels/hardshrink_op.cc
and cc/ops/hardshrink_op.cc
, but none of them gives the answer. I think I could just follow @tomerk's PR though.
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.
Works for me.
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 again!
* add hardshrink kernel * make linter happy
* Namespaced all of the custom ops * Updated C++ namespaces to not conflict w/ TF contrib ones * Ran code reformatting tool * Port bug fix in TF contrib to addons. (#497) * Port bug fix in TF contrib to addons. Original change at tensorflow/tensorflow@a913689. * Fix lint warning. * check pass through and do the expand_dims() only if needed (#464) * check pass through and do the expand_dims() only if needed * add indent to the fixed line * merge return condition to if state * add hardshrink kernel (#500) * add hardshrink kernel * make linter happy * Fixing SequenceLoss Keras incompatibility (#503) * Fix SequenceLoss incompatibility with Keras built-in loops * Remove debugging prints * Change the attribute existence checking to use more pythonic way * Replace some compat.v1 APIs by their v2 equivalent (#507) * Replace some compat.v1 APIs by their v2 equivalent * Fix lint error * Add documentation for LazyAdam (#515) * Updated hardshrink custom ops & made #ifdef names more consistent. * Fix to undef
Add hardshrink kernel:
x if x < lower or x > upper else 0
.