当前位置: 首页>>代码示例>>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;未经允许,请勿转载。