I tried simple regression example.
but, I received following error messages.
import sys, os
import numpy as np
from learning2rank.regression import NN
X = np.array([[1, 1, 1], [2, 2, 2], [3, 3, 3]])
y = np.array([[1], [2], [3]])
Model = NN.NN()
Model.fit(X, y)
X = np.array([[1, 1, 1]])
Model.predict(X)
AssertionError Traceback (most recent call last)
in ()
11
12 X = np.array([[1, 1, 1]])
---> 13 Model.predict(X)
/root/learning2rank/utils/NNfuncs.pyc in predict(self, predict_X)
66
67 def predict(self, predict_X):
---> 68 return self.model.predict(predict_X.astype(np.float32))
69
70 # def predict(self, predict_X, batchsize=100):
/root/learning2rank/regression/NN.pyc in predict(self, x)
41
42 def predict(self, x):
---> 43 h1 = F.relu(self.l1(x))
44 h2 = F.relu(self.l2(h1))
45 h = F.relu(self.l3(h2))
/root/.pyenv/versions/anaconda3-5.2.0/envs/python27/lib/python2.7/site-packages/chainer/links/connection/linear.pyc in __call__(self, x)
63
64 """
---> 65 return linear.linear(x, self.W, self.b)
/root/.pyenv/versions/anaconda3-5.2.0/envs/python27/lib/python2.7/site-packages/chainer/functions/connection/linear.pyc in linear(x, W, b)
79 return LinearFunction()(x, W)
80 else:
---> 81 return LinearFunction()(x, W, b)
/root/.pyenv/versions/anaconda3-5.2.0/envs/python27/lib/python2.7/site-packages/chainer/function.pyc in __call__(self, *inputs)
100 in_data = tuple([x.data for x in inputs])
101 if self.type_check_enable:
--> 102 self._check_data_type_forward(in_data)
103 # Forward prop
104 with cuda.get_device(*in_data):
/root/.pyenv/versions/anaconda3-5.2.0/envs/python27/lib/python2.7/site-packages/chainer/function.pyc in _check_data_type_forward(self, in_data)
134
135 def _check_data_type_forward(self, in_data):
--> 136 in_type = type_check.get_types(in_data, 'in_types', False)
137 try:
138 self.check_type_forward(in_type)
/root/.pyenv/versions/anaconda3-5.2.0/envs/python27/lib/python2.7/site-packages/chainer/utils/type_check.pyc in get_types(data, name, accept_none)
44
45 info = TypeInfoTuple(
---> 46 _get_type(name, i, x, accept_none) for i, x in enumerate(data))
47 # I don't know a method to set an attribute in an initializer of tuple.
48 info.name = name
/root/.pyenv/versions/anaconda3-5.2.0/envs/python27/lib/python2.7/site-packages/chainer/utils/type_check.pyc in ((i, x))
44
45 info = TypeInfoTuple(
---> 46 _get_type(name, i, x, accept_none) for i, x in enumerate(data))
47 # I don't know a method to set an attribute in an initializer of tuple.
48 info.name = name
/root/.pyenv/versions/anaconda3-5.2.0/envs/python27/lib/python2.7/site-packages/chainer/utils/type_check.pyc in _get_type(name, index, array, accept_none)
58
59 assert(isinstance(array, numpy.ndarray) or
---> 60 isinstance(array, cuda.ndarray))
61 return Variable(TypeInfo(array.shape, array.dtype), var)
62
AssertionError:
I tried simple regression example. but, I received following error messages.
import sys, os import numpy as np from learning2rank.regression import NN
X = np.array([[1, 1, 1], [2, 2, 2], [3, 3, 3]]) y = np.array([[1], [2], [3]])
Model = NN.NN() Model.fit(X, y)
X = np.array([[1, 1, 1]]) Model.predict(X)
AssertionError Traceback (most recent call last)