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

in #python5 years ago (edited)

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

Congratulations @octav! You have completed the following achievement on the Steem blockchain and have been rewarded with new badge(s) :

You published more than 50 posts. Your next target is to reach 60 posts.

You can view your badges on your Steem Board and compare to others on the Steem Ranking
If you no longer want to receive notifications, reply to this comment with the word STOP

To support your work, I also upvoted your post!

Vote for @Steemitboard as a witness to get one more award and increased upvotes!

Coin Marketplace

STEEM 0.29
TRX 0.12
JST 0.033
BTC 63071.06
ETH 3121.31
USDT 1.00
SBD 3.84