When trying to load my image dataset for an unsupervised problem, without labels, the image_dataset_from_directory function from Keras assumes they belong to a class. The resulting dataset has shape:
(batch_size, None, image_height, image_width, n_channels)
The code:
data_dir = pathlib.Path(path_to_image)
train_dataset = (keras.utils.image_dataset_from_directory
(
data_dir,
labels=None,
validation_split=validation_split,
subset="training",
shuffle=False,
image_size=(image_size, image_size)
)
.map(preprocess_image, num_parallel_calls=tf.data.AUTOTUNE)
.cache()
.batch(batch_size, drop_remainder=True)
.prefetch(buffer_size=tf.data.AUTOTUNE))
I believe the dimension with None should be 2 in the case of a dataset with both inputs and target pairs. However, I only wish to load my images from a folder, without labels.