-
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
Add keras.ops.rot90
for tf.image.rot90
#20723
Comments
keras.ops.rot90*
for tf.image.rot90
keras.ops.rot90
for tf.image.rot90
It is a numpy op: https://numpy.org/doc/stable/reference/generated/numpy.rot90.html Any op that is in numpy is in-scope for inclusion in Keras. Since there are already built-in functions for it in all backends, adding it should be easy. Are you able to open a PR? |
I'm working on a related topic and can submit a PR if that helps. |
Please do. |
This is my first time contributing to this repo, and I’ve just raised a pull request for the issue. Let me know if there’s anything I need to fix or improve, I’d be happy to make changes! |
* feat(ops): Add keras.ops.image.rot90 operation Adds a new operation to rotate tensors by 90 degrees in the specified plane: - Implements rot90 operation in keras.ops.image module - Adds support for multiple rotations (k parameter) and custom axes - Matches numpy.rot90 behavior and API for consistency - Adds comprehensive test coverage including batch images support - Handles input validation for tensor dimensions and axes - Supports symbolic tensor execution The operation follows the same interface as numpy.rot90 and tf.image.rot90: rot90(array, k=1, axes=(0, 1)) * feat: add JAX, NumPy and PyTorch backends for rot90 Add implementations of rot90() for multiple backend frameworks: - JAX backend implementation - NumPy backend implementation - PyTorch backend implementation * Move rot90 from image to numpy ops Move rot90 operation to numpy.py files in backend implementations since it's a numpy op (https://numpy.org/doc/stable/reference/generated/numpy.rot90.html). Now exported as both keras.ops.rot90 and keras.ops.numpy.rot90. * Fix dtype conflict in PyTorch backend's rot90 function Resolved the 'Invalid dtype: object' error by explicitly using to avoid naming conflicts with the custom function. * Replace experimental NumPy rot90 with core TF ops Replace tf.experimental.numpy.rot90 with core TF ops for XLA compatibility. Use convert_to_tensor for input handling.
tf api: https://www.tensorflow.org/api_docs/python/tf/image/rot90
torch api: https://pytorch.org/docs/stable/generated/torch.rot90.html
jax api: https://jax.readthedocs.io/en/latest/_autosummary/jax.numpy.rot90.html
In keras, it provides RandomRotation and probably not replacable with tf.image.90.
The text was updated successfully, but these errors were encountered: