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


Python RPropMinusTrainer.setData方法代碼示例

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


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

示例1: trainNetwork

# 需要導入模塊: from pybrain.supervised.trainers import RPropMinusTrainer [as 別名]
# 或者: from pybrain.supervised.trainers.RPropMinusTrainer import setData [as 別名]
def trainNetwork(net, sample_list, validate_list, net_filename, max_epochs=5500, min_epochs=300):
    count_input_samples = len(sample_list)
    count_outputs = len(validate_list)
    ds = SupervisedDataSet(count_input_samples, count_outputs)
    ds.addSample(sample_list, validate_list)
    trainer = RPropMinusTrainer(net, verbose=True)
    trainer.setData(ds)
    trainer.trainUntilConvergence(maxEpochs=max_epochs, continueEpochs=min_epochs)
    NetworkWriter.writeToFile(net, net_filename)
    return net
開發者ID:ivalykhin,項目名稱:neirohome,代碼行數:12,代碼來源:netManagement.py

示例2: createAndTrainNetworkFromList

# 需要導入模塊: from pybrain.supervised.trainers import RPropMinusTrainer [as 別名]
# 或者: from pybrain.supervised.trainers.RPropMinusTrainer import setData [as 別名]
def createAndTrainNetworkFromList(train_list, count_input_samples, net_filename, count_layers=33,
                          count_outputs=1, max_epochs=15000, min_epochs=300):
    net = buildNetwork(count_input_samples, count_layers, count_outputs)
    ds = SupervisedDataSet(count_input_samples, count_outputs)
    count_samples = len(train_list)
    for i in range(0, count_samples):
        ds.addSample(train_list[i][:-count_outputs], train_list[i][-count_outputs])
    trainer = RPropMinusTrainer(net, verbose=True)
    trainer.setData(ds)
    a = trainer.trainUntilConvergence(maxEpochs=max_epochs, continueEpochs=min_epochs, validationProportion=0.15)
    net_filename = net_filename[:-4]+str(a[0][-1])+'.xml'
    NetworkWriter.writeToFile(net, net_filename)
    result_list = [a, net_filename]
    return result_list
開發者ID:ivalykhin,項目名稱:neirohome,代碼行數:16,代碼來源:netManagement.py

示例3: createAndTrainNetworkFromFile

# 需要導入模塊: from pybrain.supervised.trainers import RPropMinusTrainer [as 別名]
# 或者: from pybrain.supervised.trainers.RPropMinusTrainer import setData [as 別名]
def createAndTrainNetworkFromFile(curs_filename, count_input_samples, count_samples, net_filename, count_layers=33,
                          count_outputs=1, max_epochs=15000, min_epochs=300):
    net = buildNetwork(count_input_samples, count_layers, count_outputs)
    ds = SupervisedDataSet(count_input_samples, count_outputs)
    wb = load_workbook(filename=curs_filename)
    ws = wb.active
    for i in range(0, count_samples):
        loaded_data = []
        for j in range(0, count_input_samples + 1):
            loaded_data.append(round(float(ws.cell(row=i+1, column=j+1).value), 4))
            #ds.addSample(loaded_data[:-1], loaded_data[-1])
        #print loaded_data[:-1], loaded_data[-1]
        ds.addSample(loaded_data[:-1], loaded_data[-1])
    trainer = RPropMinusTrainer(net, verbose=True)
    trainer.setData(ds)
    a = trainer.trainUntilConvergence(maxEpochs=max_epochs, continueEpochs=min_epochs, validationProportion=0.15)
    net_filename = net_filename[:-4]+str(a[0][-1])+'.xml'
    NetworkWriter.writeToFile(net, net_filename)
    result_list = [a, net_filename]
    return result_list
開發者ID:ivalykhin,項目名稱:neirohome,代碼行數:22,代碼來源:netManagement.py

示例4: Brain

# 需要導入模塊: from pybrain.supervised.trainers import RPropMinusTrainer [as 別名]
# 或者: from pybrain.supervised.trainers.RPropMinusTrainer import setData [as 別名]
class Brain():
    def __init__(self): 
        self.inputs = 3
        self.outputs = 1
        self.n = buildNetwork(self.inputs, 200,200,200,200,self.outputs, bias=True,hiddenclass=TanhLayer)
        self.n.sortModules()
        self.ds = SupervisedDataSet(self.inputs, self.outputs)
        self.trainer = RPropMinusTrainer(self.n)
        self.trainer.setData(self.ds)
    def wipedataset(self):
        self.ds = SupervisedDataSet(self.inputs, self.outputs)
        pass
    def cycle(self,action,state):
        return self.n.activate([action,state[0],state[1]])
    def AddToTrainingSet(self,action,state,output):
        out= "New Set","Action: ",action,"State: ", state,"Output: ", output
        f.write(str(out)+"\n")
        self.ds.addSample((action,state[0],state[1]),output)
    def train(self):
        return "ERROR",self.trainer.train()
    def traintoconverg(self):
        x = 10000
        y=0
        z=100
        print len(self.ds),"DS SIZE"
        while x > 0.0001 and y < z:
            print len(self.ds)
            x = self.trainer.train()
            print x,"ERROR",y
            y+=1
        f = open('brains/brain2000.ann','w')
        pickle.dump(self.n,f)
    def trainfinal(self):
        x = 10000
        y=0
        z=25
        while x > 0.00001 and y < z:
            x = self.trainer.train()
            print x,"ERROR",y
            y+=1
開發者ID:akeenan22,項目名稱:NeuroSoccer,代碼行數:42,代碼來源:Brain.py

示例5: range

# 需要導入模塊: from pybrain.supervised.trainers import RPropMinusTrainer [as 別名]
# 或者: from pybrain.supervised.trainers.RPropMinusTrainer import setData [as 別名]
n.addConnection(FullConnection(inLayer, hiddenLayers[0]))

for i in range(1, len(hiddenLayers)):
    n.addConnection(FullConnection(hiddenLayers[i - 1], hiddenLayers[i]))

n.addConnection(FullConnection(hiddenLayers[len(hiddenLayers) - 1], outLayer))
n.sortModules()


# training set
DS = SupervisedDataSet(10, 5)

trainer = RPropMinusTrainer(n, verbose=True, batchlearning=True, learningrate=0.01, lrdecay=0.0, momentum=0.0,
                            weightdecay=0.0)
trainer.setData(DS)

data = days('btceUSD.days.csv')


def normalize(v, _max, _min):
    return 2.0 / (_max - _min) * (v - _min) - 1.0


def denormalize(v, _max, _min):
    return (v + 1.0) / 2.0 * (_max - _min) + _min


def ticks_to_inputs_outputs(ticks, ticks_forecast):
    window_prices = map(lambda (x): x[0], ticks)
    window_volumes = map(lambda (x): x[1], ticks)
開發者ID:vladignatyev,項目名稱:coin,代碼行數:32,代碼來源:test_per_prediction.py

示例6: SupervisedDataSet

# 需要導入模塊: from pybrain.supervised.trainers import RPropMinusTrainer [as 別名]
# 或者: from pybrain.supervised.trainers.RPropMinusTrainer import setData [as 別名]
                    nr.append(ratio)    
                print ratio, column   
            else:
                print column, "not an int or long"         
    return np.array(nr[:-1]), nr[-1]

data = cursor.execute("select %s from adult_data" % columns).fetchall()

dataset = SupervisedDataSet(8, 1)
for row in data:
    xd, yd = createNPRow(row)       
    dataset.addSample(xd, yd)

nn = buildNetwork(8, 3, 1)
trainer = RPropMinusTrainer(nn)
trainer.setData(dataset)

for x in range(5):
    error = trainer.train()
    print error
  
errors, success = 0,0
for row in cursor.execute("select %s from adult_test" % columns).fetchall():    
    xd, yd = createNPRow(row)    
    check = int(round(nn.activate(xd[:8])[0]))
    if check > 1: check = 1
    prediction = possibilities['relation_to_50k_plus'][check]
    actual = possibilities['relation_to_50k_plus'][yd]
    if prediction == actual:
        match = "match"
        success += 1
開發者ID:richwandell,項目名稱:python_machine_learning,代碼行數:33,代碼來源:neural_network.py

示例7: buildNetwork

# 需要導入模塊: from pybrain.supervised.trainers import RPropMinusTrainer [as 別名]
# 或者: from pybrain.supervised.trainers.RPropMinusTrainer import setData [as 別名]
		testset.append((a,random.uniform(-math.pi,-math.pi/2),-1))
		testset.append((a,random.uniform(math.pi/2,math.pi),-1))

	elif a == 1:
		testset.append((a,random.uniform(-math.pi,0),1))
		testset.append((a,random.uniform(0,math.pi),-1))
	else:
		testset.append((a,random.uniform(0,math.pi),1))
		testset.append((a,random.uniform(-math.pi,0),-1))


ann = buildNetwork(2,20,1,bias=True,hiddenclass=TanhLayer)
ds = SupervisedDataSet(2,1)
ann.sortModules()
trainer = RPropMinusTrainer(ann)
trainer.setData(ds)
for i in dataset:
	ds.addSample((i[0],i[1]),i[2])

i=10000
x=0
z=100
while i > 0.0001 and x<z:
	i = trainer.train()
	print i
	x+=1

for a in testset:
	result = ann.activate([a[0],a[1]])
	print str(a[2]) +" actual vs. output " +str(result)
開發者ID:akeenan22,項目名稱:NeuroSoccer,代碼行數:32,代碼來源:datasettest.py


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