TransWikia.com

how to get length of files loaded with keras to dataset

Data Science Asked by ptn77 on July 2, 2021

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)))

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?

One Answer

I figured this out. It was related to the batch size. Only counted first batch.

Answered by ptn77 on July 2, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP