create account

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

View this thread on: hive.blogpeakd.comecency.com
· @octav · (edited)
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:
```python
AttributeError: 'DirectoryIterator' object has no attribute 'shape'

```

# FIX

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

```
into the terminal and edit the problem line.

From:

```python
# 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:

```python
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)
```
👍  ,
properties (23)
authoroctav
permlinktensorflow-imagedatagenerator-directoryiterator-object-has-no-attribute-shape
categorypython
json_metadata{"tags":["python","tensorflow","ai","machinelearning","howtofix"],"app":"steemit/0.1","format":"markdown"}
created2019-08-18 10:16:45
last_update2019-08-18 10:20:57
depth0
children1
last_payout2019-08-25 10:16:45
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length937
author_reputation647,853,339,261
root_title"Tensorflow ImageDataGenerator 'DirectoryIterator' object has no attribute 'shape'"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id89,660,515
net_rshares20,169,986,179
author_curate_reward""
vote details (2)
@steemitboard ·
Congratulations @octav! You have completed the following achievement on the Steem blockchain and have been rewarded with new badge(s) :

<table><tr><td><img src="https://steemitimages.com/60x70/http://steemitboard.com/@octav/posts.png?201908181223"></td><td>You published more than 50 posts. Your next target is to reach 60 posts.</td></tr>
</table>

<sub>_You can view [your badges on your Steem Board](https://steemitboard.com/@octav) and compare to others on the [Steem Ranking](https://steemitboard.com/ranking/index.php?name=octav)_</sub>
<sub>_If you no longer want to receive notifications, reply to this comment with the word_ `STOP`</sub>


To support your work, I also upvoted your post!


###### [Vote for @Steemitboard as a witness](https://v2.steemconnect.com/sign/account-witness-vote?witness=steemitboard&approve=1) to get one more award and increased upvotes!
properties (22)
authorsteemitboard
permlinksteemitboard-notify-octav-20190818t125105000z
categorypython
json_metadata{"image":["https://steemitboard.com/img/notify.png"]}
created2019-08-18 12:51:03
last_update2019-08-18 12:51:03
depth1
children0
last_payout2019-08-25 12:51:03
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length875
author_reputation38,975,615,169,260
root_title"Tensorflow ImageDataGenerator 'DirectoryIterator' object has no attribute 'shape'"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id89,664,154
net_rshares0