本文整理汇总了Python中pybrain.supervised.trainers.BackpropTrainer.trainEpoch方法的典型用法代码示例。如果您正苦于以下问题:Python BackpropTrainer.trainEpoch方法的具体用法?Python BackpropTrainer.trainEpoch怎么用?Python BackpropTrainer.trainEpoch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pybrain.supervised.trainers.BackpropTrainer
的用法示例。
在下文中一共展示了BackpropTrainer.trainEpoch方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: len
# 需要导入模块: from pybrain.supervised.trainers import BackpropTrainer [as 别名]
# 或者: from pybrain.supervised.trainers.BackpropTrainer import trainEpoch [as 别名]
trndata._convertToOneOfMany( )
tstdata._convertToOneOfMany( )
print "Number of training patterns: ", len(trndata)
print "Input and output dimensions: ", trndata.indim, trndata.outdim
print "First sample (input, target, class):"
print trndata['input'][0], trndata['target'][0], trndata['class'][0]
if os.path.isfile('food.xml'):
print "previous xml found:"
fnn = NetworkReader.readFrom('food.xml')
else:
fnn = buildNetwork( trndata.indim, 64 , trndata.outdim, outclass=SoftmaxLayer )
trainer = BackpropTrainer( fnn, dataset=trndata, momentum=0.1, verbose=True, weightdecay=0.01)
trainer.trainEpoch(50)
print 'Percent Error on Test dataset: ' , percentError( trainer.testOnClassData (
dataset=tstdata )
, tstdata['class'] )
NetworkWriter.writeToFile(fnn, 'food.xml')
# ticks = arange(-3.,6.,0.2)
# X, Y = meshgrid(ticks, ticks)
# # need column vectors in dataset, not arrays
# griddata = ClassificationDataSet(2,1, nb_classes=3)
# for i in xrange(X.size):
# griddata.addSample([X.ravel()[i],Y.ravel()[i]], [0])
# griddata._convertToOneOfMany() # this is still needed to make the fnn feel comfy
#
# for i in range(20):
# trainer.train()
# trnresult = percentError( trainer.testOnClassData(),