深度学习库Neon DataIterator / ArrayIterator init错误

时间:2016-02-01 01:24:03

标签: python machine-learning deep-learning dataset

按照neon tutorial中的说明尝试设置DataIterator时。

from neon.data import DataIterator
import numpy as np

X = np.random.rand(10000, 3072)
y = np.random.randint(1, 11, 10000)

train = DataIterator(X=X, y=y, nclass=10, lshape=(3, 32, 32))

我遇到了一个奇怪的错误:

ERROR:neon.data.dataiterator:DataIterator class has been deprecated and  renamed"ArrayIterator" please use that name.
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "neon/data/dataiterator.py", line 168, in __init__
    super(DataIterator, self).__init__(*args, **kwargs)
  File "neon/data/dataiterator.py", line 82, in __init__
    self.Xdev = [self.be.array(x) for x in X]
AttributeError: 'NoneType' object has no attribute 'array'

然后我尝试使用ArrayIterator,保持X,y相同。

ArrayIterator(X=X, y=y, nclass=10, lshape=(3,32,32))

使用相同的NoneType错误:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "neon/data/dataiterator.py", line 82, in __init__
    self.Xdev = [self.be.array(x) for x in X]
AttributeError: 'NoneType' object has no attribute 'array'

为什么会出现这种情况?有一个简单的解决方法吗?

1 个答案:

答案 0 :(得分:1)

通过生成backend来解决问题。

from neon.backends import gen_backend

be = gen_backend()
(...)