Problem with ragged_batch

Hi everyone,

I am trying to create a tf.data.Dataset from images that have different shapes without resizing and cropping while creating the dataset in order to keep that to be handled in the data augmentation part.

I tried to create the dataset a little similar to what the Keras example Classification with KerasCV does in its last section however, unlike the Keras example that works, my example fails when I try to ragged_batch the dataset with error “Cannot add tensor to the batch: number of elements does not match.”

I cannot figure out what the actual difference between the 2 examples since the tensors types in those examples prior to batching the datasets are the same.

Any help?

Here’s the Colab I show both dataset creation:

Thanks!
Fadi Badine

Hi @Fadi_Badine, I don’t have access to the colab you have shared to look into the code. Could please provide the access to the colab. Thank You.

ohhh I’m sorry :frowning:
I have updated it. You should be able now

Hi @Fadi_Badine, While trying to execute the mentioned code in colab i am facing NameError: name 'package_inputs' is not defined. so could you please let me know what the package_input variable is defined for. Thank You.