Keras-FCN icon indicating copy to clipboard operation
Keras-FCN copied to clipboard

ValueError: If printing histograms, validation_data must be provided, and cannot be a generator.

Open xiaofengqing opened this issue 7 years ago • 11 comments

After i trained the first epoch,i meet this error File "/home/s405/pengcheng/project/Keras-FCN/train.py", line 232, in label_suffix=label_suffix, ignore_label=ignore_label, label_cval=label_cval) File "/home/s405/pengcheng/project/Keras-FCN/train.py", line 164, in train class_weight=class_weight File "/usr/local/lib/python3.4/dist-packages/keras/legacy/interfaces.py", line 87, in wrapper return func(*args, **kwargs) File "/usr/local/lib/python3.4/dist-packages/keras/engine/training.py", line 2082, in fit_generator callbacks.on_epoch_end(epoch, epoch_logs) File "/usr/local/lib/python3.4/dist-packages/keras/callbacks.py", line 77, in on_epoch_end callback.on_epoch_end(epoch, logs) File "/usr/local/lib/python3.4/dist-packages/keras/callbacks.py", line 751, in on_epoch_end raise ValueError('If printing histograms, validation_data must be ' ValueError: If printing histograms, validation_data must be provided, and cannot be a generator.

I don't know how to fix this problem, can you give me some suggestions?

xiaofengqing avatar Nov 09 '17 09:11 xiaofengqing

I have also meet this error and I could not solve it yet ! Need help also!

zwlshine avatar Nov 09 '17 10:11 zwlshine

@xiaofengqing Comment out this code: # if K.backend() == 'tensorflow': # tensorboard = TensorBoard(log_dir=os.path.join(save_path, 'logs'), histogram_freq=10, write_graph=True) # callbacks.append(tensorboard)

Then it can run.

zwlshine avatar Nov 15 '17 06:11 zwlshine

Change histogram_freq=10 to histogram_freq=0 you can still use tensor board with this fix rather than removing it all together.

IsaacTegeler avatar Nov 29 '17 16:11 IsaacTegeler

It is general issue with keras/tboard that you cannot get histograms with a validation_generator, changing histogram_freq=0 stops it trying to produce them.

peachthiefmedia avatar Feb 23 '18 11:02 peachthiefmedia

@zwlshine I tried following lines and did not work for me. if K.backend() == 'tensorflow': tensorboard = TensorBoard(log_dir=os.path.join(save_path, 'logs'), histogram_freq=10, write_graph=True) callbacks.append(tensorboard)

@IsaacIsOkay When I turned histogram_freq to zero, it worked.

NoushNabi avatar Apr 09 '18 20:04 NoushNabi

How is turning histogram_freq to zero a fix?! I need those histograms.

mueller91 avatar Aug 02 '18 14:08 mueller91

@mueller91 you can pass validation data separately to generate the histograms I think in a separate step, but yeah it isn't whats needed really.

peachthiefmedia avatar Sep 08 '18 13:09 peachthiefmedia

@mueller91 I am not sure if you still have this issue, but this issue https://github.com/keras-team/keras/issues/3358 and the suggested solution by juiceboxjoe helped me.

MaximilianPavon avatar Nov 14 '18 14:11 MaximilianPavon

Change histogram_freq=10 to histogram_freq=0 you can still use tensor board with this fix rather than removing it all together.

the original callbacks.py is with histogram_freq=0, but i still have ValueError: If printing histograms, validation_data must be provided, and cannot be a generator.

lucy9410 avatar Nov 19 '18 19:11 lucy9410

Is there a method from a validation generator, that would just spit out a bunch of them to test with? something along the line of get_validation(validation_generator) that would return what we need to add there?

guysoft avatar Dec 20 '18 14:12 guysoft

It is general issue with keras/tboard that you cannot get histograms with a validation_generator, changing histogram_freq=0 stops it trying to produce them.

What's the issue? Why it is not possible when the validation set is a generator?

WittmannF avatar Jun 12 '19 18:06 WittmannF