0

我正在为神经网络使用 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,))
4

1 回答 1

0

你可以使用 try/except,像这样:

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

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

于 2013-06-06T12:46:15.707 回答