Search code examples
pythontensorflowkerasconv-neural-network

Facing error 'DirectoryIterator' object has no attribute 'cache'


I am writing code to Configure the dataset for performance for CNN model. Unfortunately, I have faced an error.

My code:

AUTOTUNE = tf.data.AUTOTUNE

train_data = train_data.cache().shuffle(1000).prefetch(buffer_size=AUTOTUNE)
valid_data = valid_data.cache().prefetch(buffer_size=AUTOTUNE)

Error: 'DirectoryIterator' object has no attribute 'cache'


Solution

  • you can import your dataset with

    tf.data.Dataset.from_generator()