python - PyBrain - how to validate my trained network against a test data? -


so have classificationdataset in pybrain have trained appropriate data. namely, input following:

trainset.addsample([0,0,0,0],[1]) trainset.addsample([0,0,0,1],[0]) trainset.addsample([0,0,1,0],[0]) trainset.addsample([0,0,1,1],[1]) trainset.addsample([0,1,0,0],[0]) trainset.addsample([0,1,0,1],[1]) trainset.addsample([0,1,1,0],[1]) trainset.addsample([0,1,1,1],[0]) trainset.addsample([1,0,0,0],[0]) trainset.addsample([1,0,0,1],[1]) 

the pattern simple. if there number of 1's output should 1, otherwise 0. want run following inputs:

[1,0,0,1],[1] [1,1,0,1],[0] [1,0,1,1],[0] [1,0,1,0],[1] 

and see whether neural network recognise pattern. said previously, i've trained network. how validate against inputs above?

thanks time!

you first have create network , train on dataset.

then have use activate result inputs , test if matches desired output.

one easy way is:

testoutput = { [1,0,0,1] : [1], [1,1,0,1] : [0], [1,0,1,1]:[0], [1,0,1,0]:[1] }  input, expectedoutput in testinput.items():     output = net.activate(input)     if output != expectedoutput:         print "{} didn't match desired output."          print "expected {}, got {}".format(input, expectedoutput, output) 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -