当前位置: 首页>>代码示例>>Python>>正文


Python BackpropTrainer.testOnData方法代码示例

本文整理汇总了Python中pybrain.supervised.BackpropTrainer.testOnData方法的典型用法代码示例。如果您正苦于以下问题:Python BackpropTrainer.testOnData方法的具体用法?Python BackpropTrainer.testOnData怎么用?Python BackpropTrainer.testOnData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pybrain.supervised.BackpropTrainer的用法示例。


在下文中一共展示了BackpropTrainer.testOnData方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: generate_and_test_nn

# 需要导入模块: from pybrain.supervised import BackpropTrainer [as 别名]
# 或者: from pybrain.supervised.BackpropTrainer import testOnData [as 别名]
def generate_and_test_nn():
    d = load_training_set()
    n = buildNetwork(d.indim, 13, d.outdim, hiddenclass=LSTMLayer, outclass=SoftmaxLayer, outputbias=False, recurrent=True)
    t = BackpropTrainer(n, learningrate=0.01, momentum=0.99, verbose=True)
    t.trainOnDataset(d, 1000)
    t.testOnData(verbose=True)
    return (n, d)
开发者ID:YangLeoZhao,项目名称:Tailor,代码行数:9,代码来源:feed_forward_nn.py

示例2: testOldTraining

# 需要导入模块: from pybrain.supervised import BackpropTrainer [as 别名]
# 或者: from pybrain.supervised.BackpropTrainer import testOnData [as 别名]
def testOldTraining(hidden=15, n=None):
    d = XORDataSet()
    if n is None:
        n = buildNetwork(d.indim, hidden, d.outdim, recurrent=False)
    t = BackpropTrainer(n, learningrate=0.01, momentum=0., verbose=False)
    t.trainOnDataset(d, 250)
    t.testOnData(verbose=True)
开发者ID:bitfort,项目名称:py-optim,代码行数:9,代码来源:test_xor.py

示例3: initializeNetwork

# 需要导入模块: from pybrain.supervised import BackpropTrainer [as 别名]
# 或者: from pybrain.supervised.BackpropTrainer import testOnData [as 别名]
    def initializeNetwork(self):
        can1 = NNTrainData.NNTrainData(cv2.imread('NNTrain/can1.png'), self.encodingDict["can"])
        can2 = NNTrainData.NNTrainData(cv2.imread('NNTrain/can2.png'), self.encodingDict["can"])
        can3 = NNTrainData.NNTrainData(cv2.imread('NNTrain/can3.png'), self.encodingDict["can"])
        stain1 = NNTrainData.NNTrainData(cv2.imread('NNTrain/stain1.png'), self.encodingDict["stain"])
        stain2 = NNTrainData.NNTrainData(cv2.imread('NNTrain/stain2.png'), self.encodingDict["stain"])
        stain3 = NNTrainData.NNTrainData(cv2.imread('NNTrain/stain3.png'), self.encodingDict["stain"])
        dirt1 = NNTrainData.NNTrainData(cv2.imread('NNTrain/dirt1.png'), self.encodingDict["dirt"])
        dirt2 = NNTrainData.NNTrainData(cv2.imread('NNTrain/dirt2.png'), self.encodingDict["dirt"])
        dirt3 = NNTrainData.NNTrainData(cv2.imread('NNTrain/dirt3.png'), self.encodingDict["dirt"])

        self.trainData.append(can1)
        self.trainData.append(can2)
        self.trainData.append(can3)
        self.trainData.append(stain1)
        self.trainData.append(stain2)
        self.trainData.append(stain3)
        self.trainData.append(dirt1)
        self.trainData.append(dirt2)
        self.trainData.append(dirt3)

        for x in self.trainData:
            x.prepareTrainData()

        self.net = buildNetwork(4, 3, 3, hiddenclass=TanhLayer, outclass=SoftmaxLayer)
        ds = SupervisedDataSet(4, 3)

        for x in self.trainData:
            ds.addSample((x.contours/100.0, x.color[0]/1000.0, x.color[1]/1000.0, x.color[2]/1000.0), x.output)

        trainer = BackpropTrainer(self.net, momentum=0.1, verbose=True, weightdecay=0.01)
        trainer.trainOnDataset(ds, 1000)
        trainer.testOnData(verbose=True)
        print "\nSiec nauczona\n"
开发者ID:maciejbiesek,项目名称:InteligentnyOdkurzacz,代码行数:36,代码来源:NeuralNetwork.py

示例4: testTraining

# 需要导入模块: from pybrain.supervised import BackpropTrainer [as 别名]
# 或者: from pybrain.supervised.BackpropTrainer import testOnData [as 别名]
def testTraining():
    d = PrimesDataSet()
    d._convertToOneOfMany()
    n = buildNetwork(d.indim, 8, d.outdim, recurrent=True)
    t = BackpropTrainer(n, learningrate = 0.01, momentum = 0.99, verbose = True)
    t.trainOnDataset(d, 1000)
    t.testOnData(verbose=True)
    for i in range(15):
        print "Guess: %s || Real: %s" % (str(n.activate(i)), str(i in d.generatePrimes(10)))
    print d
开发者ID:oskanberg,项目名称:pyconomy,代码行数:12,代码来源:neuralTest.py

示例5: testTraining

# 需要导入模块: from pybrain.supervised import BackpropTrainer [as 别名]
# 或者: from pybrain.supervised.BackpropTrainer import testOnData [as 别名]
def testTraining():
    print "Reading data"
    d = XORDataSet()
    traind,testd = d.splitWithProportion(0.8)
    print "Building network"
    n = buildNetwork(traind.indim, 4, traind.outdim, recurrent=True)
    print "Training"
    t = BackpropTrainer(n, learningrate = 0.01, momentum = 0.99, verbose = True)
    t.trainOnDataset(traind,100)
    testd = XORDataSet(begin=60000,end=80000)
    print t.module.params
    t.testOnData(testd,verbose= True)
开发者ID:Miyayx,项目名称:FakeReview-Detector,代码行数:14,代码来源:backpropxor.py

示例6: execute

# 需要导入模块: from pybrain.supervised import BackpropTrainer [as 别名]
# 或者: from pybrain.supervised.BackpropTrainer import testOnData [as 别名]
    def execute(self):
        network = self.networkFactoryMethod()
        trainer = BackpropTrainer(network, learningrate = self.learningrate, momentum = self.momentum)
        trainer.trainOnDataset(self.datasetForTraining, self.epochs)
        averageError = trainer.testOnData(self.datasetForTest)
        self.collectedErrors.append(averageError)

        return averageError
开发者ID:Kelewap,项目名称:most-fancy-msi-toolkit,代码行数:10,代码来源:msi.py

示例7: __init__

# 需要导入模块: from pybrain.supervised import BackpropTrainer [as 别名]
# 或者: from pybrain.supervised.BackpropTrainer import testOnData [as 别名]
    def __init__(self, stock_to_predict, days_of_prediction = 10, days_of_training = 450):

        self.number_of_days_before = 8
        self.days_of_prediction = days_of_prediction

        self.downloader = StockDownloader()

        stock_training_data = self.downloader.download_stock(stock_to_predict, days_of_training, days_of_prediction)
        self.stock_prediction_data = self.downloader.download_stock(stock_to_predict, days_of_prediction)

        self.starting_price = self.stock_prediction_data[0]

        self.dataset = StockSupervisedDataSet(self.number_of_days_before, stock_training_data)
        self.network = buildNetwork(self.dataset.indim, 10, self.dataset.outdim, recurrent=True)
        t = BackpropTrainer(self.network, learningrate = 0.00005,  momentum=0., verbose = True)
        t.trainOnDataset(self.dataset, 200)
        t.testOnData(verbose= True)

        self.starting_prices = self.dataset['input'][-1]
开发者ID:pobed2,项目名称:NeuralNetworkStock,代码行数:21,代码来源:stock_predicter.py

示例8: __init__

# 需要导入模块: from pybrain.supervised import BackpropTrainer [as 别名]
# 或者: from pybrain.supervised.BackpropTrainer import testOnData [as 别名]
    def __init__(self):
        self.code = {
            'cat': [1, 0, 0],
            'dust': [0, 1, 0],
            'water': [0, 0, 1]
        }

        pack = 'media.images_train'
        train_data = [
            (Neuron(load(file_path(pack, 'cat1.png'))), self.code['cat']),
            (Neuron(load(file_path(pack, 'cat2.png'))), self.code['cat']),
            (Neuron(load(file_path(pack, 'cat3.png'))), self.code['cat']),
            (Neuron(load(file_path(pack, 'dust1.png'))), self.code['dust']),
            (Neuron(load(file_path(pack, 'dust2.png'))), self.code['dust']),
            (Neuron(load(file_path(pack, 'dust3.png'))), self.code['dust']),
            (Neuron(load(file_path(pack, 'water1.png'))), self.code['water']),
            (Neuron(load(file_path(pack, 'water2.png'))), self.code['water']),
            (Neuron(load(file_path(pack, 'water3.png'))), self.code['water']),
        ]

        for x, output in train_data:
            x.prepare()

        self.net = buildNetwork(
            4, 3, 3, hiddenclass=TanhLayer, outclass=SoftmaxLayer
        )
        data = SupervisedDataSet(4, 3)

        for x, output in train_data:
            data.addSample(
                (
                    x.contours / 100.0, x.color[0] / 1000.0,
                    x.color[1] / 1000.0, x.color[2] / 1000.0,
                ),
                output
            )

        trainer = BackpropTrainer(
            self.net, momentum=0.1, verbose=True, weightdecay=0.01
        )
        trainer.trainOnDataset(data, 1000)  # 1000 iterations
        trainer.testOnData(verbose=True)
开发者ID:pawelzar,项目名称:python-ai-cleaner,代码行数:44,代码来源:neuron.py

示例9: train

# 需要导入模块: from pybrain.supervised import BackpropTrainer [as 别名]
# 或者: from pybrain.supervised.BackpropTrainer import testOnData [as 别名]
    def train(self, train_data_set, test_data_set, epoch=100):
        trainer = BackpropTrainer(self.network, train_data_set)

        progress_bar = ProgressBar(epoch)

        for i in range(epoch):
            progress_bar.update(i+1)
            time.sleep(0.01)
            trainer.train()

        return trainer.testOnData(test_data_set, verbose=True)
开发者ID:piruty-joy,项目名称:voice_actor_recog,代码行数:13,代码来源:NN.py

示例10: train

# 需要导入模块: from pybrain.supervised import BackpropTrainer [as 别名]
# 或者: from pybrain.supervised.BackpropTrainer import testOnData [as 别名]
def train():
    f = open('train_tower.csv', 'r')

    csvreader = csv.reader(f)

    dataset = SupervisedDataSet(64, 2)
    for d in csvreader:
        if d[64] == '0':
            dataset.addSample(d[0:64], [1, 0])
        else:
            dataset.addSample(d[0:64], [0, 1])

    network = buildNetwork(64, 19, 2)
    trainer = BackpropTrainer(network, dataset)
    for i in range(100):
        trainer.train()
    trainer.testOnData(dataset, verbose=True)

    NetworkWriter.writeToFile(network, "tower.xml")

    f.close()
开发者ID:piruty-joy,项目名称:imagedetecter,代码行数:23,代码来源:tower_detector.py

示例11: testTraining

# 需要导入模块: from pybrain.supervised import BackpropTrainer [as 别名]
# 或者: from pybrain.supervised.BackpropTrainer import testOnData [as 别名]
def testTraining():
    d = SequentialXORDataSet()
    n = buildNetwork(d.indim, 4, d.outdim, recurrent=True)
    t = BackpropTrainer(n, learningrate=0.01, momentum=0.99, verbose=True)
    t.trainOnDataset(d, 1000)
    t.testOnData(verbose=True)
开发者ID:firestrand,项目名称:pybrain-gpu,代码行数:8,代码来源:xor.py

示例12: SequentialDataSet

# 需要导入模块: from pybrain.supervised import BackpropTrainer [as 别名]
# 或者: from pybrain.supervised.BackpropTrainer import testOnData [as 别名]
import csv
from numpy import *
from pybrain.datasets import SequentialDataSet,UnsupervisedDataSet
from pybrain.tools.shortcuts import buildNetwork
from pybrain.supervised import BackpropTrainer

sequencia = []
NEURONIOS = 10e4

if __name__ == "__main__":

    sequencias = SequentialDataSet(1,1)

    for x in range(0,100):
        sequencia.append(x)

    for i,v in enumerate(sequencia):
        if i+1 < len(sequencia):
            sequencias.addSample(v, sequencia[i+1])

    print(sequencias)

    rn = buildNetwork(sequencias.indim, NEURONIOS, sequencias.outdim, recurrent=True)
    sorteio = BackpropTrainer(rn, sequencias, learningrate=1/(NEURONIOS/100))
    while 1:
        try:
            print(sorteio.train())
        except KeyboardInterrupt:
            sorteio.testOnData(verbose=True)
            break
开发者ID:hansbonini,项目名称:moneymachine,代码行数:32,代码来源:test.py

示例13: SupervisedDataSet

# 需要导入模块: from pybrain.supervised import BackpropTrainer [as 别名]
# 或者: from pybrain.supervised.BackpropTrainer import testOnData [as 别名]
    ((0.3, 1.0), 1.0),
    ((1.0, 0.6), 0.0),
    ((0.7, 0.6), 0.0),
    ((0.7, 0.1), 1.0),
)

testData = (
    ((0.8, 0.0), 1.0),
    ((0.9, 0.7), 0.0),
    ((0.1, 0.1), 0.0),
    ((0.2, 0.8), 1.0),
    ((0.6, 0.6), 0.0),
    ((0.6, 1.0), 0.0),
    ((1.0, 0.3), 1.0),
    ((0.1, 0.1), 0.0),
)

datasetForTraining = SupervisedDataSet(ENTRY_DIMENSION, RESULT_DIMENSION)
for entry, expectedResult in trainingData:
    datasetForTraining.addSample(entry, [expectedResult])

datasetForTest = SupervisedDataSet(ENTRY_DIMENSION, RESULT_DIMENSION)
for entry, expectedResult in testData:
    datasetForTest.addSample(entry, [expectedResult])

HIDDEN_LAYER_DIMENSION = 4
network = buildNetwork(ENTRY_DIMENSION, HIDDEN_LAYER_DIMENSION, RESULT_DIMENSION, recurrent=True)
trainer = BackpropTrainer(network, learningrate=0.01, momentum=0.99, verbose=True)
trainer.trainOnDataset(datasetForTraining, 1)
trainer.testOnData(datasetForTest, verbose=True)
开发者ID:Kelewap,项目名称:most-fancy-msi-toolkit,代码行数:32,代码来源:testLearnXOR.py

示例14: tuple

# 需要导入模块: from pybrain.supervised import BackpropTrainer [as 别名]
# 或者: from pybrain.supervised.BackpropTrainer import testOnData [as 别名]
    # third feature is unemployment
    une.append(data[2])
    
    fund.append(data[3])

    indata =  tuple(data[:features])
    outdata = tuple(data[features:])
    ds.addSample(indata,outdata)

# this builds a network that has the number of features as input, 
# a *SINGLE* defined hidden layer and a single output neuron. 
n = buildNetwork(ds.indim,hidden,hidden,ds.outdim)
t = BackpropTrainer(n,learningrate=0.01,momentum=0.8,verbose=True)
t.trainOnDataset(ds,steps)
t.testOnData(verbose=True)

# let's plot what we have
import matplotlib.pyplot as plt

# lets ask for a prediction: GDP,CPI, Unemployment
#print n.activate([.02,.02,-.002])

x = []
y = []
#print range(len(time))
for i in range(len(time)):
    #print n.activate([gdp(i),cpi(i),une(i)])
    x.append(.25*time[i]+1954.5)
    y.append(n.activate([gdp[i],cpi[i],une[i]]))
开发者ID:secondfoundation,项目名称:Second-Foundation-Src,代码行数:31,代码来源:reservant.py

示例15: buildNetwork

# 需要导入模块: from pybrain.supervised import BackpropTrainer [as 别名]
# 或者: from pybrain.supervised.BackpropTrainer import testOnData [as 别名]
rnn = buildNetwork(trndata.indim, hidden, trndata.outdim, hiddenclass=LSTMLayer, outclass=SigmoidLayer, recurrent=True)

#rnn.randomize()

#trainer = BackpropTrainer(rnn, dataset)

#for _ in range(100):
#    print trainer.train()
# define a training method
#trainer = RPropMinusTrainer( rnn, dataset=trndata, verbose=True )
# instead, you may also try
trainer = BackpropTrainer( rnn, dataset=trndata, verbose=True)

#carry out the training
for i in xrange(1000):
    #trainer.trainEpochs( 2)
    #trainer.trainOnDataset(trndata)
    #trnresult = 100. * (1.0-testOnSequenceData(rnn, trndata))
    #print trnresult
    #tstresult = 100. * (1.0-testOnSequenceData(rnn, tstdata))
    #print "train error: %5.2f%%" % trnresult, ",  test error: %5.2f%%" % tstresult
    trainer.train()
    #print "train error: %5.2f%%" % trnresult
# just for reference, plot the first 5 timeseries
trainer.testOnData(tstdata, verbose= True)
#plot(trndata['input'][0:50,:],'-o')
#old(True)
#plot(trndata['target'][0:50,:],'-o')
#show()
开发者ID:NealSchneier,项目名称:finance,代码行数:31,代码来源:rnn.py


注:本文中的pybrain.supervised.BackpropTrainer.testOnData方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。