Monday, 15 September 2014

python - Pybrain Feedforward neural network training error completely stuck -



python - Pybrain Feedforward neural network training error completely stuck -

hey guys need bit of help pybrain code. loads fine, after trains first time training error doesn't go down. in fact, stays stuck there @ 13.3484055174. i've been checking code many times , comparing other examples, consistently same problem. i've tried changing number of hidden units, learningrate, momentum, weightdecay no avail. i've checked parameters , starts off [-1 1] blows ~240-250. wondering if can see why it's not working. i'm sure it's simple 1-liner i'm missing.

i'm working on kaggle 0-9 digit classification dataset. i've gotten randomforest work want create neural network work too. help appreciated.

#learn digit classification nerual network import pybrain pybrain.datasets import * pybrain.tools.shortcuts import buildnetwork pybrain.supervised.trainers import backproptrainer pybrain.structure.modules import softmaxlayer pybrain.utilities import percenterror import numpy print "importing training , test data" info = numpy.genfromtxt('trainr.csv', delimiter = ',') info = data[1:] traindata = data[:(len(data)/2)] testdata = data[(len(data)/2)+1:] print "importing actual data" actualdata = numpy.genfromtxt('trainr.csv', delimiter = ',') print "adding samples dataset , setting neural network" ds = classificationdataset(784, 10, nb_classes = 10) x in traindata: ds.addsample(tuple(x[1:]),tuple(x[0:1])) ds._converttooneofmany( bounds=[0,1] ) net = buildnetwork(784, 100, 10, bias=true, outclass=softmaxlayer) print "training neural network" trainer = backproptrainer(net, dataset=ds, momentum = 0.1, verbose = true, weightdecay = 0.01) in range(3): # train network 1 epoch trainer.trainepochs( 1 ) # evaluate result on training , test info trnresult = percenterror( trainer.testonclassdata(), [x[0] x in traindata] ) # print result print "epoch: " + str(trainer.totalepochs) + " train error: " + str(trnresult) print "" print "predicting neural network" answerlist = [] row in testdata: reply = numpy.argmax(net.activate(row[1:])) answerlist.append(answer) tstresult = percenterror(answerlist, [x[0] x in testdata]) print "test error: " + str(tstresult)

try changing

ds = classificationdataset(784, 10, nb_classes = 10)

to

ds = classificationdataset(784, 1, nb_classes = 10)

i think classificationdataset sec argument dimensions of targets rather number of classes given nb_classes. depends on how info organized. best thing come in each target integer each class , utilize _converttooneofmany()

it useful if provided first sample

python neural-network pybrain feed-forward

No comments:

Post a Comment