简体   繁体   中英

don't print results of a function

I am using python and pybrain for Neural Networks. Unfortunately, my sample is realy big and when the program print the errors on the training, my memory get full before the programm completed.

Is there anyway to not print the errors from the functions?

!!!! It's not a python error. It's pybrain feature. It's print the difference of the prediction and the real sample. For example "error: 0.00424".

Each time it makes a prediction, it print this string.

Here is my code

ds = SupervisedDataSet(1, 1)
ds.addSample(x,y) <--- in a "for" to add all my sample

net = FeedForwardNetwork() 
inp = LinearLayer(1) 
h1 = SigmoidLayer(1) 
outp = LinearLayer(1)

net.addOutputModule(outp) 
net.addInputModule(inp) 
net.addModule(h1)

net.addConnection(FullConnection(inp, h1))  
net.addConnection(FullConnection(h1, outp))

net.sortModules()

trainer = BackpropTrainer(net, ds)

trainer.trainOnDataset(ds)      ###
trainer.testOnData(verbose=True)### Here is where the function print the errors

net.activate((ind,))

You could use try/except, like this:

try:
    trainer.testOnData(verbose=True)
except Exception as e:
    <exception handling code>

or you could find the source of the error. Could you add the error you get to your question?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM