當前位置: 首頁>>代碼示例>>Python>>正文


Python RPropMinusTrainer.testOnClassData方法代碼示例

本文整理匯總了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
開發者ID:sacherus,項目名稱:pca-image,代碼行數:19,代碼來源:forest_main.py

示例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):
開發者ID:dnth,項目名稱:long-behavior,代碼行數:33,代碼來源:lstm-classifier.py

示例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
開發者ID:mfbx9da4,項目名稱:neuron-astrocyte-networks,代碼行數:32,代碼來源:googlebraintestRNN.py

示例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)

開發者ID:dnth,項目名稱:short-behavior,代碼行數:31,代碼來源:mlp-classifier.py


注:本文中的pybrain.supervised.trainers.RPropMinusTrainer.testOnClassData方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。