这是我的训练功能:
def train(input_layer_data, output_layer_data, dnn, stn):
ds = SupervisedDataSet(len(input_layer_data), len(output_layer_data))
ds.addSample(input_layer_data, output_layer_data)
if 'network' in dnn[stn]:
net_dumped = dnn[stn]['network']
net = pickle.loads(net_dumped)
else:
net = buildNetwork(len(input_layer_data), 50, len(output_layer_data), hiddenclass=SigmoidLayer, outclass = SigmoidLayer)
trainer = BackpropTrainer(net, ds)
trainer.trainEpochs(1)
trnresult = percentError( trainer.testOnClassData(), input_layer_data )
print "epoch: %4d" % trainer.totalepochs, \
" train error: %5.2f%%" % trnresult
return net
我用一个输入和输出数据重复调用此函数。
这是它产生的输出,
inp=[48, 48, 8, 69, 69, 8, 57, 57, 8, 67, 67, 8, 71, 71, 8, 75, 75, 8, 71, 71, 8]
out=[27, 27, 8, 71, 71, 8, 75, 75, 8, 71, 71, 8, 67, 67, 8, 57, 57, 8, 69, 69, 8]
epoch: 0 train error: 2100.00%
FeedForwardNetwork-152
Modules:
[<BiasUnit 'bias'>, <LinearLayer 'in'>, <SigmoidLayer 'hidden0'>, <SigmoidLayer 'out'>]
Connections:
[<FullConnection 'FullConnection-148': 'bias' -> 'out'>, <FullConnection 'FullConnection-149': 'bias' -> 'hidden0'>, <FullConnection 'FullConnection-150': 'in' -> 'hidden0'>, <FullConnection 'FullConnection-151': 'hidden0' -> 'out'>]
我不明白这么大的错误。 错误在整个程序中继续(这只是一次调用)。
如何减少错误?