Environment:
- Keras version: 3.14.0
- Backend: JAX
- Python: 3.12
When using TextVectorization with a custom standardize callable and a non-TensorFlow backend (e.g. JAX), calling .adapt() raises an AttributeError because the callable receives a tf.EagerTensor instead of a plain Python string.
import os
os.environ["KERAS_BACKEND"] = "jax"
import re
import string
import keras
strip_chars = string.punctuation
def my_standardize(input_string):
input_string = input_string.lower() # AttributeError here
return re.sub(f"[{re.escape(strip_chars)}]", "", input_string)
layer = keras.layers.TextVectorization(standardize=my_standardize)
layer.adapt(["Hello, world."])
AttributeError: 'tensorflow.python.framework.ops.EagerTensor' object has no attribute 'lower'
TextVectorization should be independent of TensorFlow.
Environment:
When using TextVectorization with a custom standardize callable and a non-TensorFlow backend (e.g. JAX), calling .adapt() raises an AttributeError because the callable receives a tf.EagerTensor instead of a plain Python string.
AttributeError: 'tensorflow.python.framework.ops.EagerTensor' object has no attribute 'lower'TextVectorization should be independent of TensorFlow.