Keras分批训练数据集bug:TypeError: evaluate_generator() got an unexpected keyword argument 'verbose'

Keras 分批训练数据集遇到的问题

在分批导入数据集时,报了个很奇怪的错误,按照着官网给的参数输入的,没理由错呀,报错如下:

Keras TypeError: evaluate_generator() got an unexpected keyword argument 'verbose'

我的代码(截取部分)如下:

model.evaluate_generator(validation_generator, steps=math.ceil(len(train_y)/batch_size), verbose=1)

看报错是因为verbose的问题,但官网显示就是这么几个参数,如下所示:
Arguments

  • generator: Generator yielding tuples (inputs, targets) or (inputs, targets, sample_weights) or an instance of Sequence (keras.utils.Sequence) object in order to avoid duplicate data when using multiprocessing.
  • steps: Total number of steps (batches of samples) to yield from generator before stopping. Optional for Sequence: if unspecified, will use the len(generator) as a number of steps.
  • callbacks: List of keras.callbacks.Callback instances. List of callbacks to apply during training. See callbacks.
  • max_queue_size: maximum size for the generator queue
  • workers: Integer. Maximum number of processes to spin up when using process based threading. If unspecified, workers will default to 1. If 0, will execute the generator on the main thread.
  • use_multiprocessing: if True, use process based threading. Note that because this implementation relies on multiprocessing, you should not pass non picklable arguments to the generator as they can’t be passed easily to children processes.
  • verbose: verbosity mode, 0 or 1.

verbose这个参数不就只有0和1,但是你设置了就是不行,你把这个参数删了,代码如下,就神奇的可以了:

model.evaluate_generator(validation_generator, steps=math.ceil(len(train_y)/batch_size))

搞不懂,搞不懂,虽然也不是必须要这个功能,但可以看看进度还是挺好的,没得看就不看也行
望各路大神指教


TypeError: evaluate_generator can accept only 3 positional arguments (‘generator’, ‘steps_per_epoch’, ‘epochs’)
我发现原来在Keras里面evaluate_generator这个函数,根本没有verbose这个参数,只有generatorsteps_per_epochepochs这三个参数,真是奇了个怪,官方文档跟实际的不符,难道Keras版本问题?
20190407更新


你可能感兴趣的:(Keras)