1

i have 2 a numpy nd arrays of shape (2000,) where each element is a list containing words as items. Thus each list is a sentence. The other nd array are just the binary labels.
I want to convert this to tensorflow data Dataset where each item is a sentence with a label.
I tried:

 tf.data.Dataset.from_tensor_slices((dataset, labels))

but i get :

ValueError: Failed to convert a NumPy array to a Tensor (Unsupported object type list).

How could this be done?

1 Answer 1

2

This error usually occurs when each list in your array has a different number of elements (words). Try using a ragged representation:

tf.data.Dataset.from_tensor_slices((tf.ragged.constant(dataset), labels))
Sign up to request clarification or add additional context in comments.

1 Comment

This did the trick, Gracias

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.