我需要訓練網絡,然後逐個輸入測試數據。包含它的示例或文檔是否存在?如何用一個條目(已經訓練過的網絡)喂pybrain ffn?
爲了達到這個目的,我序列化了經過培訓的網絡,並將其與每個新的入境條目一起使用。 問題是,我從_convertToOneOfMany
崩潰,甚至我明白它的目的(從here)我不明白它是如何工作的。
它的行爲對我來說並不確定。它必須解釋某種類別和標籤,並且必須有一些我缺少的要求。它適用於整個數據集,但是如果我採用隨機行,它會變得瘋狂。
Traceback (most recent call last):
File "ffn_iris.py", line 29, in <module>
tstdata._convertToOneOfMany()
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/PyBrain-0.3-py2.6.egg/pybrain/datasets/classification.py", line 142, in _convertToOneOfMany
newtarg[i, int(oldtarg[i])] = bounds[1]
IndexError: index (2) out of range (0<=index<1) in dimension 1
編輯: 更精確,讓我告訴你,我在做什麼:我要培養網絡上最著名的NN例在互聯網上) - 虹膜數據集。
這是類似的東西:
5.1,3.5,1.4,0.2,0
4.9,3.0,1.4,0.2,0
4.7,3.2,1.3,0.2,0
4.6,3.1,1.5,0.2,0
etc...
最後的零它的類。整個數據集包含60行。 20爲0,20 1和20爲2
我讀取數據文件並構建數據集:
alldata = ClassificationDataSet(4, class_labels=['Iris-setosa',
'Iris-versicolor',
'Iris-virginica'])
--- loop here ---
alldata.addSample(line[0:4], line[4])
--- create testing and training sets ---
tstdata, trndata = alldata.splitWithProportion(0.7)
--- converted matrixes ---
trndata._convertToOneOfMany()
tstdata._convertToOneOfMany()
--- not important, just for completeness ----
fnn = buildNetwork(trndata.indim, 10, trndata.outdim, outclass=SoftmaxLayer)
trainer = BackpropTrainer(fnn, dataset=trndata,
momentum=0.01, verbose=True,
weightdecay=0.01)
我的問題涉及_convertToOneOfMany()
。當數據集或數據文件只包含幾個條目(不是60,分爲三個類)時,它會從問題開始時異常崩潰。崩潰datset的
實施例:
6.5,3.0,5.2,2.0,1
6.5,3.0,5.2,2.0,1
6.2,3.4,5.4,2.3,2
6.5,3.0,5.2,2.0,0
工作一個示例:
6.5,3.0,5.2,2.0,1
6.2,3.4,5.4,2.3,2
6.5,3.0,5.2,2.0,0
如何convertToOneOfMany()
被連接到在所述數據集或一類子集的大小的項的數目?一行條目崩潰以及..
我擴大了這個問題 - 你可以看看嗎?謝謝!有沒有經驗豐富的PyBrain用戶的論壇或郵件列表? – user425720