qubvel / segmentation_models

Segmentation models with pretrained backbones. Keras and TensorFlow Keras.
MIT License
4.74k stars 1.03k forks source link

Issue while training( example: binary segmentation) --->training_generator.py in _get_next_batch(generator, mode) raise ValueError('Output of generator should be a tuple `(x, y, sample_weight)` or `(x, y)`. Found: ' + str(generator_output)) #239

Open aayushsin opened 4 years ago

aayushsin commented 4 years ago

While running binary segmentation (camvid) notebook, on step # train model history = model.fit_generator( train_dataloader, steps_per_epoch=len(train_dataloader), epochs=EPOCHS, callbacks=callbacks, validation_data=valid_dataloader, validation_steps=len(valid_dataloader), ) encountered following error:

Epoch 1/40

ValueError Traceback (most recent call last)

in 6 callbacks=callbacks, 7 validation_data=valid_dataloader, ----> 8 validation_steps=len(valid_dataloader), 9 ) D:\Users\\Anaconda3\envs\aayush\lib\site-packages\tensorflow\python\keras\engine\training.py in fit_generator(self, generator, steps_per_epoch, epochs, verbose, callbacks, validation_data, validation_steps, validation_freq, class_weight, max_queue_size, workers, use_multiprocessing, shuffle, initial_epoch) 1177 shuffle=shuffle, 1178 initial_epoch=initial_epoch, -> 1179 steps_name='steps_per_epoch') 1180 1181 def evaluate_generator(self, D:\Users\\Anaconda3\envs\aayush\lib\site-packages\tensorflow\python\keras\engine\training_generator.py in model_iteration(model, data, steps_per_epoch, epochs, verbose, callbacks, validation_data, validation_steps, validation_freq, class_weight, max_queue_size, workers, use_multiprocessing, shuffle, initial_epoch, mode, batch_size, steps_name, **kwargs) 218 step = 0 219 while step < target_steps: --> 220 batch_data = _get_next_batch(generator, mode) 221 if batch_data is None: 222 if is_dataset: D:\Users\\Anaconda3\envs\aayush\lib\site-packages\tensorflow\python\keras\engine\training_generator.py in _get_next_batch(generator, mode) 370 raise ValueError('Output of generator should be ' 371 'a tuple `(x, y, sample_weight)` ' --> 372 'or `(x, y)`. Found: ' + str(generator_output)) 373 374 if len(generator_output) < 1 or len(generator_output) > 3: ValueError: Output of generator should be a tuple `(x, y, sample_weight)` or `(x, y)`. Found: [array([[[[-2.117904 , -2.0357141 , -1.8044444 ], [-2.117904 , -2.0357141 , -1.8044444 ], [-2.117904 , -2.0357141 , -1.8044444 ], ..., [ 2.2489083 , 2.4285715 , 2.64 ], [ 2.2489083 , 2.4285715 , 2.64 ], [ 2.2489083 , 2.4285715 , 2.64 ]], [[-2.117904 , -2.0357141 , -1.8044444 ], [-2.117904 , -2.0357141 , -1.8044444 ], [-2.117904 , -2.0357141 , -1.8044444 ], ..., [ 2.2489083 , 2.4285715 , 2.64 ], [ 2.2489083 , 2.4285715 , 2.64 ], [ 2.2489083 , 2.4285715 , 2.64 ]],
aayushsin commented 4 years ago

Keras version is 2.2.4-tf

ntelo007 commented 4 years ago

Did anyone solve this issue?