ValueError:`validation_data`应该是一个元组

时间:2018-10-10 19:39:34

标签: python keras image-segmentation data-generation

我正在处理一些代码,想知道如何解决以下错误?我正在使用类生成器(keras.utils.Sequence)来获取更多数据生成器。我正在使用dicom图像,并尝试实现keras resnet50_unet模型。任何帮助将不胜感激。谢谢。

history = model.fit_generator(train_gen, validation_data=valid_gen, 
                          epochs=25, steps_per_epoch = 200,shuffle=True, 
verbose=2)



---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-18-8e6b34e90593> in <module>()
  1 history = model.fit_generator(train_gen, validation_data=valid_gen, 
----> 2                               epochs=25, steps_per_epoch = 
200,shuffle=True, verbose=2)
  3 

/opt/conda/lib/python3.6/site-packages/keras/legacy/interfaces.py in 
wrapper(*args, **kwargs)
 89                 warnings.warn('Update your `' + object_name +
 90                               '` call to the Keras 2 API: ' + signature, 
 stacklevel=2)
 ---> 91             return func(*args, **kwargs)
 92         wrapper._original_function = func
 93         return wrapper

 /opt/conda/lib/python3.6/site-packages/keras/engine/training.py in 
 fit_generator(self, generator, steps_per_epoch, epochs, verbose, callbacks, 
 validation_data, validation_steps, class_weight, max_queue_size, workers, 
 use_multiprocessing, shuffle, initial_epoch)
 1413             use_multiprocessing=use_multiprocessing,
 1414             shuffle=shuffle,
 -> 1415             initial_epoch=initial_epoch)
 1416 
 1417     @interfaces.legacy_generator_methods_support

 /opt/conda/lib/python3.6/site-packages/keras/engine/training_generator.py 
 in fit_generator(model, generator, steps_per_epoch, epochs, verbose, 
 callbacks, validation_data, validation_steps, class_weight, max_queue_size, 
 workers, use_multiprocessing, shuffle, initial_epoch)
136                                      '`(val_x, val_y, 
val_sample_weight)` '
137                                      'or `(val_x, val_y)`. Found: ' +
--> 138                                      str(validation_data))
139                 val_x, val_y, val_sample_weights = 
model._standardize_user_data(
140                     val_x, val_y, val_sample_weight)

ValueError: `validation_data` should be a tuple `(val_x, val_y, 
val_sample_weight)` or `(val_x, val_y)`. Found: <__main__.generator object 
at 0x7f378513bac8>

0 个答案:

没有答案