Pybrain: neural network for classification doesn't learn

Refresh

December 2018

Views

554 time

2

I am trying to use pybrain to classify some inputs (made of 44 variables and the range is from -1 to +1) in 5 classes( from 0 to 4) but I have that the Total error is fixed to around 0.072 even if I change the network structure or I reduce the number of variables in the input vector. The code is:

InputT=TrainingINDF.ix[:End,:]
InputT=InputT.as_matrix()
TargetT=TrainingOUTDF.ix[:End,:]
TargetT=TargetT.as_matrix()
ds = ClassificationDataSet(44, 1, nb_classes=5)
for i in range (len(InputT)):
    ds.addSample(InputT[i,:],TargetT[i])
testdata=ClassificationDataSet(44, 1, nb_classes=5)
for i in range (len(TrainingINDF.ix[StartTS:,:])):
    testdata.addSample(TrainingINDF.ix[StartTS+i,:],TrainingOUTDF.ix[StartTS+i])
testdata._convertToOneOfMany()
ds._convertToOneOfMany()
net = buildNetwork(44,15,5,hiddenclass=TanhLayer, outclass=SoftmaxLayer)
trainer = BackpropTrainer(net,dataset=ds,momentum=0.1,verbose=True, weightdecay=0.01) 
trnerr,valerr = trainer.trainUntilConvergence(dataset=ds,maxEpochs=100)
ris = net.activateOnDataset(testdata)
out=ris.argmax(axis=1)
percenterrortest=percentError(out, testdata['class'] )
print 'Percent Error on Test dataset: ' , percentError(trainer.testOnClassData (dataset=testdata ), testdata['class'] )
print 'Percent Error on Train dataset: ' , percentError(trainer.testOnClassData (dataset=ds ), ds['class'] )

The test percent error is 61.93, and the train percent error is 60.50. What am I doing wrong? What is surprising me is that the 3 errors ( the precentages and the total error) are always around the same values; no matter what I change.

Thank you

1 answers

0

Не супер знакомы с PyBrain, но вы уверены, что выход может быть меньше, чем 0? Если выход ограничен в диапазоне от 0 до 1, например, он никогда не может быть в состоянии получить очень близко к правильному ответу.