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


Python RPropMinusTrainer.testOnData方法代碼示例

本文整理匯總了Python中pybrain.supervised.trainers.RPropMinusTrainer.testOnData方法的典型用法代碼示例。如果您正苦於以下問題:Python RPropMinusTrainer.testOnData方法的具體用法?Python RPropMinusTrainer.testOnData怎麽用?Python RPropMinusTrainer.testOnData使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在pybrain.supervised.trainers.RPropMinusTrainer的用法示例。


在下文中一共展示了RPropMinusTrainer.testOnData方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: ClassificationDataSet

# 需要導入模塊: from pybrain.supervised.trainers import RPropMinusTrainer [as 別名]
# 或者: from pybrain.supervised.trainers.RPropMinusTrainer import testOnData [as 別名]
        #1-N output encoding , N=10 
        trndata = ClassificationDataSet(np.shape(train)[1], 10, nb_classes=10) 
        for i in xrange(np.shape(train)[0]):
            trndata.addSample(train[i], traint[i])
        validata = ClassificationDataSet(np.shape(valid)[1], 10, nb_classes=10) 
        for i in xrange(np.shape(valid)[0]):
            trndata.addSample(valid[i], validt[i])
        testdata = ClassificationDataSet(np.shape(test)[1], 10, nb_classes=10)
        for i in xrange(np.shape(test)[0]):
            testdata.addSample(test[i], testt[i])
        
        #Build the network 
        if nlayers > 1:
            net = buildNetwork(trndata.indim, nhidden, nhiddeno, trndata.outdim, outclass=SoftmaxLayer )
        else:
            net = buildNetwork(trndata.indim, nhidden, trndata.outdim, outclass=SoftmaxLayer )
        #construct the trainer object
        #We can also train Bprop using pybrain using the same argumets as below: trainer = BackpropTrainer(...)
        trainer = RPropMinusTrainer(net, dataset=trndata, momentum=0.9, verbose=True, weightdecay=0.01, learningrate=0.1)
        #train and test
        trainer.trainUntilConvergence(maxEpochs=percent_dataset_usage*300)#,trainingData=trndata,validationData = validata)
        trainer.testOnData(verbose=True, dataset=testdata)
        
        
    print_NN_params() #remind us what architecture was tested
    print_time_elapsed(start)  #print training time
    filename = 'instances/NN_' +str(percent_dataset_usage) +'perc_'+ str(nhidden) + '_' +str(nhiddeno) +'.save'
    save_NN_instance(filename) #save trained object to disk
    
    
開發者ID:JavierCrisostomo,項目名稱:ocr_mnist,代碼行數:30,代碼來源:run_MLP.py

示例2: len

# 需要導入模塊: from pybrain.supervised.trainers import RPropMinusTrainer [as 別名]
# 或者: from pybrain.supervised.trainers.RPropMinusTrainer import testOnData [as 別名]
networkPath='20LSTMCell/TrainUntilConv.xml'
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
                                                                                                                                                
開發者ID:dnth,項目名稱:long-behavior,代碼行數:32,代碼來源:lstm-classifier.py

示例3: createDataset3

# 需要導入模塊: from pybrain.supervised.trainers import RPropMinusTrainer [as 別名]
# 或者: from pybrain.supervised.trainers.RPropMinusTrainer import testOnData [as 別名]
test_set_num = 10 #int(math.floor(len_pList*0.15))
epochs = 35
hiddenNodes = 8

print "======== Settings ========"
print "input_interval: %d, input_vector_size: %d, data_set: %d, test_set_num: %d, epochs: %d" % (interval, inputSize, len_pList, test_set_num, epochs, )
limit = len_pList-test_set_num
ds = createDataset3(pList[0:int(limit)], limit,inputSize,1)
#net = buildNetwork(1,6,1,bias=True,recurrent=True)
#trainer = BackpropTrainer(net,ds,batchlearning=False,lrdecay=0.0,momentum=0.0,learningrate=0.01)

net = buildNetwork(inputSize, hiddenNodes, 1, bias=True)
trainer = RPropMinusTrainer(net, verbose=True,)
#trainer = BackpropTrainer(net,ds,batchlearning=False,lrdecay=0.0,momentum=0.0,learningrate=0.01, verbose=True)
trainer.trainOnDataset(ds,epochs)
trainer.testOnData(verbose=True)

i = len_pList-test_set_num
last_value = normalize(pList[i-2][1])
last_last_value = normalize(pList[i-1][1])
out_data = []
print "======== Testing ========"
for i in range(len_pList-test_set_num+1, len_pList):
    value = denormalize(net.activate([last_last_value, last_value]))
    out_datum = (i, pList[i][1], value)
    out_data.append(out_datum)

    print "Index: %d Actual: %f Prediction: %f" % out_datum

    last_value = normalize(value)
    last_last_value = last_value
開發者ID:oddy555,項目名稱:bitcoinprediction,代碼行數:33,代碼來源:bitcoinprediction2.py


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