9

as in keras documentation in the (image, mask) data generator, I created data generator to have (input, output) tuple images.
When running locally on my laptop (with tensorflow 1.13.1), it runs with no issues, but when running on a server (with tensorflow-gpu 1.13.1), I get the error:

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

so as in the example, after creating two generators with flow_from_directory:

from tensorflow import keras

...

input_gen = input_datagen.flow_from_directory(
        directory=os.path.join(path_in, dirname),
        class_mode=None,
        color_mode=color_mode,
        batch_size=batch_size,
        target_size=(img_size, img_size),
        seed=seed_in)

I combined them as in the keras documentation:

train_generator = zip(input_gen, output_gen)

and feed them to the fit_generator(...)

currently solved it using a function to generate the new combined generator as suggested here:

def combine_generator(gen1, gen2):
    while True:
        yield(gen1.next(), gen2.next())   

though I would still like to understand why the tensorflow cpu version doesn't get this error, and why the zip isn't supported in the gpu version...

2
  • from this keras rstudio issue is seems that an iterator is no longer accepted by keras which is what is returned by zip according to the docs
    – Arthur D
    Jun 18, 2019 at 18:35
  • @Yael N: Is this issue resolved now? Else, can you please share (if possible) the complete code so that we can reproduce it at our end and help you in resolving the issue. Thanks!
    – user11530462
    Feb 3, 2020 at 6:05

1 Answer 1

0

Looks like support of fit_generator in Tensorflow 1.13 has been changed. As mentioned in this issue, workaround,

Replace

train_generator = zip(input_gen, output_gen)

with

train_generator = (pair for pair in zip(input_gen, output_gen))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.