0

I am trying to concatenate two datasets that were created using the keras.preprocessing.image_dataset_from_directory() with the paths as follows:

>>> val_ds = tf.keras.preprocessing.image_dataset_from_directory(
    Val_data_dir,
    image_size=(127, 127),
    batch_size=32)
Found 16 files belonging to 2 classes.

>>> train_ds = tf.keras.preprocessing.image_dataset_from_directory(
    Train_data_dir,
    image_size=(127, 127),
    batch_size=32)
Found 5216 files belonging to 2 classes.

>>> print(len(list(train_ds)))
131

When I print the length of the list in train_ds, it's showing 131 when I'm expecting 5216 that it found when it loaded it from the directory. Can someone explain why? What other function should I use to get the number of files loaded in the dataset?

0

1 Answer 1

1

In order to get the count of all files, you can use .file_paths attributes as follows:

train_ds = tf.keras.preprocessing.image_dataset_from_directory(
    Train_data_dir,
    image_size=(32, 32),
    batch_size=32)

len(train_ds.file_paths)
Sign up to request clarification or add additional context in comments.

Comments

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.