'Tensorflow `y` argument is not supported when using dataset as input
When I run this code for generating the dataset and training a GAN,
batch_size = 32
img_height = 128
img_width = 128
train_ds = tf.keras.utils.image_dataset_from_directory(
data_dir,
validation_split=0.2,
subset="training",
seed=123,
image_size=(img_height, img_width),
batch_size=batch_size)
val_ds = tf.keras.utils.image_dataset_from_directory(
data_dir,
validation_split=0.2,
subset="validation",
seed=123,
image_size=(img_height, img_width),
batch_size=batch_size)
autoencoder.fit(train, train,
epochs=10,
shuffle=True,
validation_data=val)
It returns this error
`y` argument is not supported when using dataset as input.
From what I've seen I need to make the input a tuple but I'm not sure of how to do that and I can't find anything that shows me how.
Solution 1:[1]
By default, image_dataset_from_directory auto generate labels for the image based on your directory structure, and returns tuples of (images, labels). That's why fit does not accept y argument as labels should come directly from the dataset.
If you want to manually specify labels for your dataset, pass it as the argument labels when calling image_dataset_from_directory. Note that
Labels should be sorted according to the alphanumeric order of the image file paths (obtained via
os.walk(directory)in Python).
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | bui |
