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])
這裏可能有人知道這裏出了什麼問題?任何幫助將不勝感激。