Closed lbortolotti closed 10 months ago
Like in the other issue linked, this is caused by the use of tensor methods: which methods are available and what they do depends on the backend framework because your tensors are backend-native tensors.
In order to get a fully standardized API surface, don't use tensor methods and instead us keras.ops
, e.g. ops.add
or ops.cast
.
Do note that using Python operators such as +
or @
will call into the object's methods. It will not call into keras.ops
.
The following code works correctly with the jax backend:
Switching to tensorflow backend:
Throws:
TypeError: Cannot convert 1j to EagerTensor of dtype float
Potentially related, the following runs OK with the jax backend:
While the tensorflow backend:
Throws:
Running enable_numpy_behavior() does resolve the issue, but I don't like the idea of having to modify the default TF behaviour to make it work. I assume that, if the developer goes via the keras_core.ops API, the same code should work with both backends as-is?
Package versions:
Thanks,
Luca