Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to give input to a trained and tested PyBrain network and how to get the result

I am predicting a value, I have 2 input layer and an output layer. Here is my code in which I have trained a PyBrain network and then tested it, I am missing how should I give a set of input to the network and how do I get the result. Please help me to proceed forward.

 ds = SupervisedDataSet(2,1)
 tf = open('data.csv','r')
 for line in tf.readlines():
 data = [float(x) for x in line.strip().split(',') if x != '']
 indata =  tuple(data[:2])
 outdata = tuple(data[2:])
 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)

what I should do next to give an input and predict on the input, How do I get the result for that set of input. Thanks!!

like image 419
soupso Avatar asked Nov 05 '12 11:11

soupso


People also ask

How is data trained neural network?

What Is Training Data? In a real-life scenario, training samples consist of measured data of some kind combined with the “solutions” that will help the neural network to generalize all this information into a consistent input–output relationship.

What is gradient check in PyBrain?

PyBrain already includes a function that does just that, gradientCheck(). You can pass it to any network containing a structural component that you have programmed. It will check if the numeric gradients are (roughly) equal to the gradient specified by the _backwardImplementation() methods.


1 Answers

By calling the .activate() method of the network supplying your input. There's also a more practicle activate on dataset.

And a little tip, you may use the python's native csv module

like image 150
Paolo Casciello Avatar answered Oct 14 '22 11:10

Paolo Casciello