-
Notifications
You must be signed in to change notification settings - Fork 19.5k
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
fix thresholded_relu to support list datatype #16277
Conversation
added support for list datatype
Should I added a test for this too? |
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!
return inputs * tf.cast(tf.greater(inputs, theta), inputs.dtype) | ||
dtype = getattr(inputs, 'dtype', tf.keras.backend.floatx()) | ||
theta = tf.cast(self.theta, dtype) | ||
return inputs * tf.cast(tf.greater(inputs, theta), dtype) |
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 cast here is unnecessary
@@ -59,8 +59,9 @@ def __init__(self, theta=1.0, **kwargs): | |||
self.theta = backend.cast_to_floatx(theta) | |||
|
|||
def call(self, inputs): | |||
theta = tf.cast(self.theta, inputs.dtype) | |||
return inputs * tf.cast(tf.greater(inputs, theta), inputs.dtype) | |||
dtype = getattr(inputs, 'dtype', tf.keras.backend.floatx()) |
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.
Switch to dtype = self.compute_dtype
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
`dtype = self.compute_dtype` from `getattr` and removed cast of `theta`
A tangent to the problem and probably a learning point for some: |
Looks like some comments are still unresolved on the PR. unassigning from Keras team for now. |
The two comments:
has been done. Would you please point out to what else comments are unresolved @LukeWood ? |
added support for list datatype in thresholded_relu similar to relu.
Notebook with the issue and solution.
Auto closes #16273