繁体   English   中英

不要打印函数的结果

[英]don't print results of a function

我正在将python和pybrain用于神经网络。 不幸的是,我的样本很大,当程序在训练中打印出错误时,在程序完成之前我的记忆已满。

反正有没有不打印功能中的错误?

!!!! 这不是python错误。 这是pybrain功能。 它打印出预测值与实际样本的差异。 例如“错误:0.00424”。

每次进行预测时,都会打印此字符串。

这是我的代码

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,))

您可以使用try / except,如下所示:

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

或者您可以找到错误的来源。 您能否将错误添加到您的问题中?

暂无
暂无

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

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