AttributeError:'generator'对象没有属性'next'

时间:2018-02-18 03:13:19

标签: python tensorflow tflearn

使用python 3.6,我从image_preloader

导入tflearn.data_utils 然后我写了

X, Y = image_preloader("\\all\\train", image_shape=(128, 128), mode='folder', categorical_labels=True, normalize=True)

train文件夹中有标签的文件夹。这些标签文件夹里面是图像。

我收到此错误:

    C:\Users\Daman\.conda\envs\TF\python.exe 
    "C:/Users/Daman/PycharmProjects/Coin Classification/main.py"
    hdf5 is not supported on this machine (please install/reinstall h5py for                         
    optimal experience)
    curses is not supported on this machine (please install/reinstall curses                 
    for an optimal experience)
    Scipy not supported!
    Traceback (most recent call last):
      File "C:\Users\Daman\.conda\envs\TF\lib\site-
    packages\tflearn\data_utils.py", line 730, in directory_to_samples
        classes = sorted(os.walk(directory).next()[1])
    AttributeError: 'generator' object has no attribute 'next'

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "C:/Users/Daman/PycharmProjects/Coin Classification/main.py", line 
    3, in <module>
        X, Y = image_preloader("\\all\\train", image_shape=(640,480), 
    mode='folder', categorical_labels=True, normalize=True)
      File "C:\Users\Daman\.conda\envs\TF\lib\site-
    packages\tflearn\data_utils.py", line 512, in image_preloader
        flags=files_extension, filter_channel=filter_channel)
      File "C:\Users\Daman\.conda\envs\TF\lib\site-
    packages\tflearn\data_utils.py", line 732, in directory_to_samples
         classes = sorted(os.walk(directory).__next__()[1])
    StopIteration

如何解决此错误?

1 个答案:

答案 0 :(得分:0)

我正在处理相同的问题, g.next()受python 2支持,现在您可以使用 next(g) python 3