I am trying to use PyBrain for some simple NN training. What I don't know how to do is to load the training data from a file. It is not explained in their website anywhere. I don't care about the format because I can build it now, but I need to do it in a file instead of adding row by row manually, because I will have several hundreds of rows.
Here is how I did it:
ds = SupervisedDataSet(6,3) tf = open('mycsvfile.csv','r') for line in tf.readlines(): data = [float(x) for x in line.strip().split(',') if x != ''] indata = tuple(data[:6]) outdata = tuple(data[6:]) ds.addSample(indata,outdata) n = buildNetwork(ds.indim,8,8,ds.outdim,recurrent=True) t = BackpropTrainer(n,learningrate=0.01,momentum=0.5,verbose=True) t.trainOnDataset(ds,1000) t.testOnData(verbose=True)
In this case the neural network has 6 inputs and 3 outputs. The csv file has 9 values on each line separated by a comma. The first 6 values are input values and the last three are outputs.