Pybrain神经网络的精确度非常高

2024-10-02 14:28:23 发布

您现在位置:Python中文网/ 问答频道 /正文

i=0
noofclasses = 2
alldata = ClassificationDataSet(400, 1, noofclasses)
while i<len(data):
    alldata.addSample(data[i],labels[i])
    i=i+1
tstdata_temp, trndata_temp = alldata.splitWithProportion( 10 )

tstdata = ClassificationDataSet(400, 1, noofclasses) 
for n in xrange(0, tstdata_temp.getLength()):
    tstdata.addSample( tstdata_temp.getSample(n)[0], tstdata_temp.getSample(n)[1] ) 

trndata = ClassificationDataSet(400, 1, noofclasses) 

for n in xrange(0, trndata_temp.getLength()): 
    trndata.addSample( trndata_temp.getSample(n)[0], trndata_temp.getSample(n)[1] ) 

trndata._convertToOneOfMany( )
tstdata._convertToOneOfMany( )

fnn = buildNetwork( trndata.indim, 10, trndata.outdim, outclass=SoftmaxLayer )
trainer = BackpropTrainer( fnn, dataset=trndata, momentum=0.1, verbose=True, weightdecay=0.01)
trainer.trainEpochs( 20 )

我试着增加时代的数量和隐藏的数量神经元。还是准确度没有提高。”“数据”是400维(像素值为20x20图像),标签如下所示: [0,0,0,….1,1,1]


Tags: infordatatempxrangegetlengthalldataaddsample