本文整理汇总了Python中pybrain.supervised.trainers.RPropMinusTrainer.testOnClassData方法的典型用法代码示例。如果您正苦于以下问题:Python RPropMinusTrainer.testOnClassData方法的具体用法?Python RPropMinusTrainer.testOnClassData怎么用?Python RPropMinusTrainer.testOnClassData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pybrain.supervised.trainers.RPropMinusTrainer
的用法示例。
在下文中一共展示了RPropMinusTrainer.testOnClassData方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: train
# 需要导入模块: from pybrain.supervised.trainers import RPropMinusTrainer [as 别名]
# 或者: from pybrain.supervised.trainers.RPropMinusTrainer import testOnClassData [as 别名]
def train(self, trndata, valdata, hidden_neurons=5, hidden_class=SigmoidLayer, iterations=3):
print "Hidden neurons: " + str(hidden_neurons)
print "Hidden class: " + str(hidden_class)
print "Iterations: " + str(iterations)
fnn = buildNetwork(trndata.indim, hidden_neurons, trndata.outdim, outclass=SoftmaxLayer,
hiddenclass=hidden_class)
trainer = RPropMinusTrainer(fnn, dataset=trndata, verbose=False)
#trainer = BackpropTrainer(fnn, dataset=trndata, momentum=0.5, verbose=True, learningrate=0.05)
for i in range(iterations):
trainer.train()
out, tar = trainer.testOnClassData(dataset=valdata, return_targets=True, verbose=False)
#used to return final score, not used yet :D
print str(i) + " " + str(accuracy(out, tar))
self.model = trainer
示例2: len
# 需要导入模块: from pybrain.supervised.trainers import RPropMinusTrainer [as 别名]
# 或者: from pybrain.supervised.trainers.RPropMinusTrainer import testOnClassData [as 别名]
figPath='20LSTMCell/ErrorGraph'
#####################
#####################
print "Training Data Length: ", len(trndata)
print "Num of Training Seq: ", trndata.getNumSequences()
print "Validation Data Length: ", len(tstdata)
print "Num of Validation Seq: ", tstdata.getNumSequences()
print 'Start Training'
time_start = time.time()
while (tstErrorCount<100):
print "********** Classification with 20LSTMCell with RP- **********"
trnError=trainer.train()
tstError = trainer.testOnData(dataset=tstdata)
trnAccu = 100-percentError(trainer.testOnClassData(), trndata['class'])
tstAccu = 100-percentError(trainer.testOnClassData(dataset=tstdata), tstdata['class'])
trn_class_accu.append(trnAccu)
tst_class_accu.append(tstAccu)
trn_error.append(trnError)
tst_error.append(tstError)
np.savetxt(trnErrorPath, trn_error)
np.savetxt(tstErrorPath, tst_error)
np.savetxt(trnClassErrorPath, trn_class_accu)
np.savetxt(tstClassErrorPath, tst_class_accu)
if(oldtstError==0):
oldtstError = tstError
if(oldtstError<tstError):
示例3: generate_data
# 需要导入模块: from pybrain.supervised.trainers import RPropMinusTrainer [as 别名]
# 或者: from pybrain.supervised.trainers.RPropMinusTrainer import testOnClassData [as 别名]
training_dataset._convertToOneOfMany( bounds=[0,1] )
# same for the independent test data set
testing_dataset = generate_data(test=True)
testing_dataset._convertToOneOfMany( bounds=[0,1] )
# build a feed-forward network with 20 hidden units, plus
# a corresponding trainer
# fnn = buildNetwork( training_dataset.indim, 15,15, training_dataset.outdim, outclass=SoftmaxLayer )
fnn = buildNetwork( training_dataset.indim, 15, training_dataset.outdim, hiddenclass=LSTMLayer, outclass=SoftmaxLayer, outputbias=False, recurrent=True)
trainer = RPropMinusTrainer( fnn, dataset=training_dataset, verbose=True )
#trainer = BackpropTrainer( fnn, dataset=training_dataset,verbose=True)
for i in range(500):
# train the network for 1 epoch
trainer.trainEpochs( 15 )
# evaluate the result on the training and test data
trnresult = percentError( trainer.testOnClassData(),
training_dataset['class'] )
tstresult = percentError( trainer.testOnClassData(
dataset=testing_dataset ), testing_dataset['class'] )
# print the result
print "epoch: %4d" % trainer.totalepochs, \
" train error: %5.2f%%" % trnresult, \
" test error: %5.2f%%" % tstresult
if tstresult <= 0.5 :
print 'Bingo !!!!!!!!!!!!!!!!!!!!!!'
break
示例4: ClassificationDataSet
# 需要导入模块: from pybrain.supervised.trainers import RPropMinusTrainer [as 别名]
# 或者: from pybrain.supervised.trainers.RPropMinusTrainer import testOnClassData [as 别名]
testingdata = ClassificationDataSet(10,1, nb_classes=6)
for i in range(8000,10000):
testingdata.appendLinked(BallLiftJoint[i,:], [0])
for i in range(8000,10000):
testingdata.appendLinked(BallRollJoint[i,:], [1])
for i in range(8000,10000):
testingdata.appendLinked(BellRingLJoint[i,:], [2])
for i in range(8000,10000):
testingdata.appendLinked(BellRingRJoint[i,:], [3])
for i in range(8000,10000):
testingdata.appendLinked(BallRollPlateJoint[i,:], [4])
for i in range(8000,10000):
testingdata.appendLinked(RopewayJoint[i,:], [5])
testingdata._convertToOneOfMany()
print MLPClassificationNet.paramdim
testingAccu = 100-percentError(trainer.testOnClassData(dataset=testingdata), testingdata['class'])
print testingAccu
# MLPClassificationNet = NetworkReader.readFrom('153sigmoid//TrainUntilConv.xml')
# print 'Loaded Trained Network!'
# from random import randint
#
# print MLPClassificationNet.paramdim
#
#
# x = MLPClassificationNet.activate(RopewayJoint[10])
# print argmax(x)