-
Notifications
You must be signed in to change notification settings - Fork 19.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RaggedTensor #19646
Comments
Keras 3 does not support Ragged tensors at this time. You should drop the |
It is not an option that I need. Does not exist the path to I can solve it? I would like to have a different sentence length. Without padding it is consuming the memory unnecessarily. Thanks. |
You can bucket your inputs by sequence length and reduce your batch size in order to minimize padding requirements. With small batch sizes and sufficient bucketing padding becomes pretty much unnecessary. |
@fchollet sample = [
'A B',
'A B C',
'A B C D',
'A B C D E',
'A B C D E F',
'A B C D E F G',
'A B C D E F G H',
'A B C D E F G H I',
'A B C D E F G H I J',
'A B C D E F G H I J K',
'A B C D E F G H I J K L',
]
ds = tf.data.Dataset.from_tensor_slices(sample)
ds = ds.map(lambda x: tf.strings.split(x)).repeat().bucket_by_sequence_length(
element_length_func=lambda x: tf.shape(x)[0],
bucket_boundaries=[2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],
bucket_batch_sizes=[4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4],
)
for x in ds.take(10):
print(x) Result
The repeat() is only for illustration purposes. |
@markub3327 , Could you please mark the issue as closed if you don't have any additional questions, for support on RaggedTensors, you can track it here #18414 |
Ok. Thank you. |
Hi @fchollet,
I try to implement Embedding layer with RaggedTensor in TF 2.16.1:
where is vectorize_layer = tf.keras.layers.TextVectorization(..., ragged=True). I need a different size of sentences as input to the model. For more info here is docs: https://www.tensorflow.org/guide/ragged_tensor#tensorflow_apis
The issue is:
Thanks for your reply.
The text was updated successfully, but these errors were encountered: