-3
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]Pybrain - 神經網絡精度非常低
「的標籤是這樣的:[0,0,0,...,1,1, 1]「?你的意思是說你有單維標籤,所以數組中的每個元素都是一個標籤? – Andnp
標籤是單維列表,但我使用「trndata._convertToOneOfMany()」將我的標籤轉換爲二維列表,如下所示:[(1,0),(1,0)...... (0,1),(0,1)]。所以最終我的目標是二維的。 – jack