 ValueError: Invalid dtype: str768
@maxlelyonais Please make sure the string data uses the same encoding as the rest of your code?
 Could you provide the access to the colab gist you have provided?
Thank you! Sorry for the delay, yes here is the colab gist: https://colab.research.google.com/gist/maxlelyonais/28bd9f80a71a55ec9513950c057cf5c6/clasificacion_de_spam.ipynb I had a similar issue when I upgraded to Tensorflow 2.16.1, Python 3.12.2. In my case, I triggered the error `"ValueError: Invalid dtype: str39968"` when trying to run the 'fit' function for a very similar RNN with string data (dtype <U1249). For a quick workaround, the fit function works when setting the dtype to a generic 'object' (i.e. `x_train = x_train.astype(object)`.  In Tensorflow 2.15.0 , Python 3.9.16, I didn't have the same issue. @maxlelyonais Could you please have a look at the workaround provided by @nlbrown62 and let us know?
Thank you! It works perfectly, May I know why using 'object' works? @maxlelyonais object dtype in TensorFlow acts as a catch-all for various data types, including strings of any length.
Thank you!
### Issue type

Feature Request

### Have you reproduced the bug with TensorFlow Nightly?

No

### Source

source

### TensorFlow version

2.17.0-dev20240407

### Custom code

No

### OS platform and distribution

Google Colab

### Mobile device

_No response_

### Python version

Python 3.10.12

### Bazel version

None

### GCC/compiler version

None

### CUDA/cuDNN version

_No response_

### GPU model and memory

None

### Current behavior?

Tensorflow doesn't support arrays where the dtype is numpy.str_.

pred_text = "how are you doing today?"
pred_text = np.array([[pred_text]])

It returns ValueError: Invalid dtype: str768 when I use it to train/predict with my model:
model = tf.keras.Sequential([
    encoder,
    tf.keras.layers.Embedding(
        input_dim=len(encoder.get_vocabulary())+1,
        output_dim=64,
        mask_zero=True),
    tf.keras.layers.Bidirectional(tf.keras.layers.LSTM(64)),
    tf.keras.layers.Dense(64, activation='relu'),
    tf.keras.layers.Dense(1, activation='sigmoid')
])


model.compile(loss=tf.keras.losses.BinaryCrossentropy(),
              optimizer=tf.keras.optimizers.Adam(1e-4),
              metrics=['accuracy'])

The problem is that the data is stored in a 2D array numpy.array([[]]), so converting each data to str or int slows down the process.

### Standalone code to reproduce the issue

```shell
https://colab.research.google.com/drive/1ymbplqo6wK1ZUVn-vP8jnBMsh6dccgZP#scrollTo=DhMNlE-AOzH9
```


### Relevant log output

_No response_