How to feed pybrain ffn with one record (to an already prepared network)?

I need to train the network and then submit it with test data one at a time. Is there any example or document including it?

To achieve this serialized serialized network, I use it with every new incoming record. The problem is that I got a crash from _convertToOneOfManyand even understand its purpose (from here ) I don’t understand how it works.

His behavior is not determined for me. It must interpret the classes and labels somehow, and there must be some requirement that I am missing. It works for the whole data set, however, if I take only a random string, it goes crazy.

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

EDIT: more precisely, let me tell you what I'm doing: I want to train the network for the most famous example of NN on the Internet;) - Iris Dataset.

This is something like this:

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...

Last zero is the class. The complete data set contains 60 rows. 20 for 0, 20 for 1 and 20 for 2.

I read the data file and built a data set:

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)

My problem is related to _convertToOneOfMany(). When a data set or data file contains only a couple of records (not 60, divided into three classes), it is ruled out from the very beginning of the question.

Datset crash example:

 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

Worker example:

 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

How can one relate convertToOneOfMany()to the number of records in a dataset or the size of one subset of classes? One line failure also ...

+5
source share
1 answer

, . , : http://pybrain.org/docs/quickstart/network.html : net.activate([2, 1]) 2 , 2 1

0

All Articles