简体   繁体   English

不要打印函数的结果

[英]don't print results of a function

I am using python and pybrain for Neural Networks. 我正在将python和pybrain用于神经网络。 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. 这不是python错误。 It's pybrain feature. 这是pybrain功能。 It's print the difference of the prediction and the real sample. 它打印出预测值与实际样本的差异。 For example "error: 0.00424". 例如“错误: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 / except,如下所示:

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? 您能否将错误添加到您的问题中?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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