本文整理匯總了Python中pybrain.tools.customxml.NetworkWriter.appendToFile方法的典型用法代碼示例。如果您正苦於以下問題:Python NetworkWriter.appendToFile方法的具體用法?Python NetworkWriter.appendToFile怎麽用?Python NetworkWriter.appendToFile使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pybrain.tools.customxml.NetworkWriter
的用法示例。
在下文中一共展示了NetworkWriter.appendToFile方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: BackpropTrainer
# 需要導入模塊: from pybrain.tools.customxml import NetworkWriter [as 別名]
# 或者: from pybrain.tools.customxml.NetworkWriter import appendToFile [as 別名]
t = BackpropTrainer(n, learningrate = 0.01 ,
momentum = mom)
#train the neural network from the train DataSet
cterrori=1.0
print "trainer momentum:"+str(mom)
for iter in range(25):
t.trainOnDataset(trndata, 1000)
ctrndata = mv.calculateModuleOutput(n,trndata)
cterr = v.MSE(ctrndata,trndata['target'])
relerr = abs(cterr-cterrori)
cterrori = cterr
print 'iteration:',iter+1,'MSE error:',cterr
myplot(trndata,ctrndata,iter=iter+1)
if cterr < 1.e-5 or relerr < 1.e-7:
break
#write the network using xml file
myneuralnet = os.path.join(os.getcwd(),'myneuralnet.xml')
if os.path.isfile(myneuralnet):
NetworkWriter.appendToFile(n,myneuralnet)
else:
NetworkWriter.writeToFile(n,myneuralnet)
#calculate the test DataSet based on the trained Neural Network
ctsts = mv.calculateModuleOutput(n,tsts)
tserr = v.MSE(ctsts,tsts['target'])
print 'MSE error on TSTS:',tserr
myplot(trndata,ctrndata,tsts,ctsts)
pylab.show()