Keras 报错:StopIterator

报错:

Traceback (most recent call last):

  File "E:\Anaconda\lib\site-packages\keras\utils\data_utils.py", line 555, in get
    inputs = self.queue.get(block=True).get()
  File "E:\Anaconda\lib\multiprocessing\pool.py", line 608, in get
    raise self._value
  File "E:\Anaconda\lib\multiprocessing\pool.py", line 119, in worker
    result = (True, func(*args, **kwds))
  File "E:\Anaconda\lib\site-packages\keras\utils\data_utils.py", line 392, in get_index
    return _SHARED_SEQUENCES[uid][i]
  File "E:\Anaconda\lib\site-packages\keras\preprocessing\image.py", line 800, in __getitem__
    return self._get_batches_of_transformed_samples(index_array)
  File "E:\Anaconda\lib\site-packages\keras\preprocessing\image.py", line 846, in _get_batches_of_transformed_samples
    raise NotImplementedError
NotImplementedError


The above exception was the direct cause of the following exception:


Traceback (most recent call last):
  File "main.py", line 116, in
    main('F:/人工智能/论文/Person Re-Identification/CVPR2015-CNN for P Re-id/Implementation-CVPR2015-CNN-for-ReID-master/CUHK03/cuhk-03.h5')
  File "main.py", line 21, in main
    train(model, dataset_path)
  File "main.py", line 55, in train
    validation_steps=nb_val_samples)
  File "E:\Anaconda\lib\site-packages\keras\legacy\interfaces.py", line 91, in wrapper
    return func(*args, **kwargs)
  File "E:\Anaconda\lib\site-packages\keras\engine\training.py", line 2145, in fit_generator
    generator_output = next(output_generator)
  File "E:\Anaconda\lib\site-packages\keras\utils\data_utils.py", line 561, in get
    six.raise_from(StopIteration(e), e)
  File "", line 3, in raise_from

StopIteration

错误原因:

在kerea 2.0.8以后,在image.Iterator模块文档中加入了一句话:

Every Iterator must implement the _get_batches_of_transformed_samples method.

所以要想继承Iterator 类,必须覆写_get_batches_of_transformed_samples

 

你可能感兴趣的:(机器学习,模式识别,python,深度学习框架)