运行sknn.mlp.Classifier时出错

时间:2016-03-28 10:46:39

标签: python-2.7 scikit-learn

我正在尝试使用sknn。与此问题相关的代码如下:

import sknn.mlp as nn
alg = nn.Classifier(random_state=1, layers=[nn.Layer(type="Softmax", units=10)], n_iter=500)
alg.fit(data, labels)

从经典mnist数据集导入数据和标签。这适用于我尝试的任何其他sklearn模型,如LogisticRegression和RandomForestClassifiers,因此我知道数据正在正确导入。但是,当我从sknn.mlp运行分类器时,出现错误:

  File "/Applications/Anaconda/anaconda/lib/python2.7/site-packages/sknn/mlp.py", line 390, in fit
    return super(Classifier, self)._fit(X, yp, w)

  File "/Applications/Anaconda/anaconda/lib/python2.7/site-packages/sknn/mlp.py", line 232, in _fit
    self._train(X, y, w)

  File "/Applications/Anaconda/anaconda/lib/python2.7/site-packages/sknn/mlp.py", line 151, in _train
    avg_train_error = self._backend._train_impl(X, y, w)

  File "/Applications/Anaconda/anaconda/lib/python2.7/site-packages/sknn/backend/lasagne/mlp.py", line 305, in _train_impl
    return self._batch_impl(X, y, w, self.trainer, mode='train', output='.', shuffle=True)

  File "/Applications/Anaconda/anaconda/lib/python2.7/site-packages/sknn/backend/lasagne/mlp.py", line 286, in _batch_impl
    for Xb, yb, wb, _ in self._iterate_data(self.batch_size, X, y, w, shuffle):

  File "/Applications/Anaconda/anaconda/lib/python2.7/site-packages/sknn/backend/lasagne/mlp.py", line 275, in _iterate_data
    Xb, yb, wb = cast(X, excerpt), cast(y, excerpt), cast(w, excerpt)

  File "/Applications/Anaconda/anaconda/lib/python2.7/site-packages/sknn/backend/lasagne/mlp.py", line 261, in cast
    array = array[indices]

  File "/Applications/Anaconda/anaconda/lib/python2.7/site-packages/pandas/core/frame.py", line 1986, in __getitem__
    return self._getitem_array(key)

  File "/Applications/Anaconda/anaconda/lib/python2.7/site-packages/pandas/core/frame.py", line 2031, in _getitem_array
    return self.take(indexer, axis=1, convert=True)

  File "/Applications/Anaconda/anaconda/lib/python2.7/site-packages/pandas/core/generic.py", line 1628, in take
    convert=True, verify=True)

  File "/Applications/Anaconda/anaconda/lib/python2.7/site-packages/pandas/core/internals.py", line 3637, in take
    indexer = maybe_convert_indices(indexer, n)

  File "/Applications/Anaconda/anaconda/lib/python2.7/site-packages/pandas/core/indexing.py", line 1810, in maybe_convert_indices
    raise IndexError("indices are out-of-bounds")

IndexError: indices are out-of-bounds

任何人都知道这可能来自何处?

0 个答案:

没有答案