Home | 简体中文 | 繁体中文 | 杂文 | Github | 知乎专栏 | Facebook | Linkedin | Youtube | 打赏(Donations) | About
知乎专栏

13.5. FAQ

13.5.1. AttributeError: '_MultiProcessingDataLoaderIter' object has no attribute 'next'

抛出异常如下

			
Traceback (most recent call last):
  File "/Users/neo/PycharmProjects/netkiller/test/cifar10.py", line 150, in <module>
    main()
  File "/Users/neo/PycharmProjects/netkiller/test/cifar10.py", line 47, in main
    images, labels = dataiter.next()
                     ^^^^^^^^^^^^^
AttributeError: '_MultiProcessingDataLoaderIter' object has no attribute 'next'			
			
			

出现问题的代码行

			
images, labels = dataiter.next()
			
			

解决方案,修改如下:

			
# 将
images, labels = dataiter.next()
# 修改为
images, labels = next(dataiter)