Octav avatar

Tensorflow ImageDataGenerator 'DirectoryIterator' object has no attribute 'shape'

octav

Published: 18 Aug 2019 › Updated: 18 Aug 2019

Tensorflow ImageDataGenerator 'DirectoryIterator' object has no attribute 'shape'

If you are using Tensorflow 1.14.0 and ImageDataGenerator, then when fitting the generator to the model, this error appears:

AttributeError: 'DirectoryIterator' object has no attribute 'shape'

FIX

Enter

nano ~/.local/lib/python3.6/site-packages/tensorflow/python/keras/engine/training_generator.py

into the terminal and edit the problem line.

From:

# Convert to a format that supports `next(generator)`.
generator, steps_per_epoch = convert_to_generator_like(
     data,
     steps_per_epoch=steps_per_epoch,
     batch_size=batch_size,
     epochs=epochs - initial_epoch,
     shuffle=shuffle)

To:

generator = data
# Convert to a format that supports `next(generator)`.
# generator, steps_per_epoch = convert_to_generator_like(
#      data,
#      steps_per_epoch=steps_per_epoch,
#      batch_size=batch_size,
#      epochs=epochs - initial_epoch,
#      shuffle=shuffle)

Leave Tensorflow ImageDataGenerator 'DirectoryIterator' object has no attribute 'shape' to:

Written by

- programmer

Read more #python posts


Best Posts From Octav

We have not curated any of octav's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.

More Posts From Octav