import keras
import tensorflow as tf
x = tf.ones((3, 4, 5))
print(keras.ops.flip(x, axis=[0, 1]))
The tensor should be flipped along axes 0 and 1, returning a tensor of the same shape.
Traceback (most recent call last):
File "/mnt/data2/Users/sunshuo/2026/dltest_3.3/src/test.py", line 5, in <module>
print(keras.ops.flip(x, axis=[1]))
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/mnt/data2/Users/sunshuo/anaconda3/envs/dltest_to_raise_issue/lib/python3.12/site-packages/keras/src/ops/numpy.py", line 3338, in flip
return backend.numpy.flip(x, axis=axis)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/mnt/data2/Users/sunshuo/anaconda3/envs/dltest_to_raise_issue/lib/python3.12/site-packages/keras/src/backend/tensorflow/numpy.py", line 1552, in flip
return tf.reverse(x, [axis])
^^^^^^^^^^^^^^^^^^^^^
File "/mnt/data2/Users/sunshuo/anaconda3/envs/dltest_to_raise_issue/lib/python3.12/site-packages/tensorflow/python/ops/gen_array_ops.py", line 9263, in reverse_v2
return reverse_v2_eager_fallback(
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/mnt/data2/Users/sunshuo/anaconda3/envs/dltest_to_raise_issue/lib/python3.12/site-packages/tensorflow/python/ops/gen_array_ops.py", line 9309, in reverse_v2_eager_fallback
_result = _execute.execute(b"ReverseV2", 1, inputs=_inputs_flat,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/mnt/data2/Users/sunshuo/anaconda3/envs/dltest_to_raise_issue/lib/python3.12/site-packages/tensorflow/python/eager/execute.py", line 53, in quick_execute
tensors = pywrap_tfe.TFE_Py_Execute(ctx._handle, device_name, op_name,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
tensorflow.python.framework.errors_impl.InvalidArgumentError: {{function_node __wrapped__ReverseV2_device_/job:localhost/replica:0/task:0/device:CPU:0}} 'dims' must be 1-dimension, not 2 [Op:ReverseV2]```
keras.ops.flip()raises a TensorFlowReverseV2error when used with an eager tensor andaxisprovided as a list of axes, even though the API docs sayaxismay be an axis or axes.Reproduction
Expected behavior
The tensor should be flipped along axes 0 and 1, returning a tensor of the same shape.
Actual behavior