cxxnet
cxxnet copied to clipboard
python wrapper error
Hi,
after i prepare necessary parameters(config, data, labels, parameter dictionary) for training, when i call train function, it raises following output:
finish initialization with 1 devices Initializing layer: fc1 FullcLayer: input need to be a matrix
here is how i use CxxNet, am i doing something wrong ? data and label are ndarray,
cfg = """ netconfig=start layer[+1:fc1] = fullc:fc1 nhidden = 100 init_sigma = 0.01 layer[+1:sg1] = sigmoid:se1 layer[sg1->fc2] = fullc:fc2 nhidden = 10 init_sigma = 0.01 layer[+0] = softmax netconfig=end random_type = gaussian """
param = {} param['eta'] = 0.1 param['dev'] = 'cpu' param['momentum'] = 0.9 param['metric'] = 'logloss' num_round = 10
net = cxxnet.train(cfg, data, label, num_round, param)
I think you are missing the input_shape parameters, currently, we require the user to specify the input shape of the data. Maybe you can checkout https://github.com/dmlc/cxxnet/blob/master/example/MNIST/mnist.py for more details
@tqchen
cfg = """ netconfig=start layer[+1:fc1] = fullc:fc1 nhidden = 100 init_sigma = 0.01 layer[+1:sg1] = sigmoid:se1 layer[sg1->fc2] = fullc:fc2 nhidden = 10 init_sigma = 0.01 layer[+0] = softmax netconfig=end
input_shape = 1,1,93 batch_size = 100 random_type = gaussian """
i changed my config as above but it gives this error now,
net = cxxnet.train(cfg, data, label, num_round, param)
File "/home/davut/Desktop/kaggle/cxxnet-master/wrapper/cxxnet.py", line 306, in train net.update(data=data, label=label) File "/home/davut/Desktop/kaggle/cxxnet-master/wrapper/cxxnet.py", line 163, in update raise Exception('Net.update: need 4 dimensional tensor (batch, channel, height, width)') Exception: Net.update: need 4 dimensional tensor (batch, channel, height, width)
You need to reshape the input to shape [batch, 1, 1, dim]... I will make a demo when I have time
but this time when i get the prediction results for multi class softmax, it returns one dimension list (with size of instances), it is supposed to return [n_instance,n_classes], what would be the problem this time?