Skip to content Skip to sidebar Skip to footer

Keras Valueerror: Output Of Generator Should Be A Tuple (x, Y, Sample_weight) Or (x, Y). Found: None

I have Unet model from Retina Unet, However I have augmented the images as well as the masks. Now? it gives me this error ValueError: output of generator should be a tuple (x, y,

Solution 1:

In case someone run to the same issue later.

The problem is generator issue. fixed below

def batch_generator(X_gen,Y_gen): while true: yield(X_gen.next(),Y_gen.next())

Solution 2:

In my case adding class_mode to the generator solved the issue. For example:

train_generator = train_datagen.flow_from_directory(
    train_dir,
    target_size=(image_size, image_size),
    batch_size=batch_size,
    class_mode='categorical')

You can choose from:

  • binary : 1D numpy array of binary labels

  • categorical : 2D numpy array of one-hot encoded labels. Supports multi-label output.

  • sparse : 1D numpy array of integer labels

  • input : images identical to input images (mainly used to work with autoencoders)

  • other : numpy array of y_col data

Btw None should have also work.. but this was the solution for me

Post a Comment for "Keras Valueerror: Output Of Generator Should Be A Tuple (x, Y, Sample_weight) Or (x, Y). Found: None"