1
我正在尝试使用scikit-neuralnetwork库构建神经网络回归器。千层面函数参数的形状不正确
据我了解,NY NN似乎正在建设很好,但我一直运行到下面的错误在nn.predict()
电话:
[email protected]:~/Sandbox$ sudo python NNScript.py
Traceback (most recent call last):
File "NNScript.py", line 15, in <module>
print nn.predict(X_train[0])
File "https://stackoverflow.com/users/rmichael/scikit-neuralnetwork/sknn/mlp.py", line 309, in predict
return super(Regressor, self)._predict(X)
File "https://stackoverflow.com/users/rmichael/scikit-neuralnetwork/sknn/mlp.py", line 256, in _predict
return self._backend._predict_impl(X)
File "https://stackoverflow.com/users/rmichael/scikit-neuralnetwork/sknn/backend/lasagne/mlp.py", line 242, in _predict_impl
return self.f(X)
File "/usr/local/lib/python2.7/dist-packages/theano/compile/function_module.py", line 786, in __call__
allow_downcast=s.allow_downcast)
File "/usr/local/lib/python2.7/dist-packages/theano/tensor/type.py", line 177, in filter
data.shape))
TypeError: ('Bad input argument to theano function with name "https://stackoverflow.com/users/rmichael/scikit-neuralnetwork/sknn/backend/lasagne/mlp.py:199" at index 0(0-based)', 'Wrong number of dimensions: expected 2, got 1 with shape (59,).')
[email protected]:~/Sandbox$
我的代码如下:
import numpy as np
from sknn.mlp import Regressor, Layer
X_train = np.genfromtxt("OnlineNewsPopularity.csv", dtype=float, delimiter=',', skip_header=1, usecols=range(1,60))
y_train = np.genfromtxt("OnlineNewsPopularity.csv", dtype=float, delimiter=',', names=True, usecols=(60))
nn = Regressor(
layers=[
Layer("Rectifier", units=1),
Layer("Linear")],
learning_rate=0.02,
n_iter=1)
nn.fit(X_train, y_train)
print nn.predict(X_train[0])
这里可能有人知道这里出了什么问题?任何帮助将不胜感激。