Description: Ubuntu 18.04.5 LTS
Codename: bionic
python: 3.7.7
出错部分的简略代码:
from image_iter import FaceImageIter
train_dataiter = FaceImageIter(...)
train_dataiter = mx.io.PrefetchingIter(train_dataiter)
报错有两条:
- AttributeError: ‘FaceImageIter’ object has no attribute ‘provide_data’
- AttributeError: ‘PrefetchingIter’ object has no attribute ‘data_taken’
详细:
Traceback (most recent call last):File "train_0723.py", line 489, in <module>main()File "train_0723.py", line 485, in maintrain_net()File "train_0723.py", line 455, in train_nettrain_dataiter = mx.io.PrefetchingIter(train_dataiter)File "/home/usr1/miniconda3/envs/py377/lib/python3.7/site-packages/mxnet/io/io.py", line 383, in __init__self.batch_size = self.provide_data[0][1][0]File "/home/usr1/miniconda3/envs/py377/lib/python3.7/site-packages/mxnet/io/io.py", line 419, in provide_datareturn sum([i.provide_data for i in self.iters], [])File "/home/usr1/miniconda3/envs/py377/lib/python3.7/site-packages/mxnet/io/io.py", line 419, in <listcomp>return sum([i.provide_data for i in self.iters], [])
AttributeError: 'FaceImageIter' object has no attribute 'provide_data'
Exception ignored in: <function PrefetchingIter.__del__ at 0x7f290100b9e0>
Traceback (most recent call last):File "/home/usr1/miniconda3/envs/py377/lib/python3.7/site-packages/mxnet/io/io.py", line 411, in __del__for i in self.data_taken:
AttributeError: 'PrefetchingIter' object has no attribute 'data_taken'
第一条特别奇怪,明明自己代码中定义的FaceImageIter是有provide_data这个属性的,偏偏就识别不到。
解决:
解决这个报错的经过更奇怪:我把这部分涉及的代码(报错的这句及在这句之前所有关联的)抠出来,在自己定义的FaceImageIter类中,self.provide_data属性赋值下面加了个print语句,再运行一遍就ok了。
...
self.provide_data = [(data_name, (batch_size,) + data_shape)]
print('self.provide_data: ', self.provide_data)
...
可能是之前本地代码和服务器没有同步?做了修改后同步了?
不得而知,仅供参考。