不要打印函数的结果 [英] don't print results of a function

查看:85
本文介绍了不要打印函数的结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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?

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

!!!! 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.

这是我的代码

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,例如:

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?

这篇关于不要打印函数的结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆