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


Python RPropMinusTrainer.trainOnDataset方法代码示例

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


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

示例1: RecurrentNetwork

# 需要导入模块: from pybrain.supervised.trainers import RPropMinusTrainer [as 别名]
# 或者: from pybrain.supervised.trainers.RPropMinusTrainer import trainOnDataset [as 别名]
train_set, test_set = DS.splitWithProportion(0.7)

# build our recurrent network with 10 hidden neurodes, one recurrent
# connection, using tanh activation functions
net = RecurrentNetwork()
hidden_neurodes = 10
net.addInputModule(LinearLayer(len(train_set["input"][0]), name="in"))
net.addModule(TanhLayer(hidden_neurodes, name="hidden1"))
net.addOutputModule(LinearLayer(len(train_set["target"][0]), name="out"))
net.addConnection(FullConnection(net["in"], net["hidden1"], name="c1"))
net.addConnection(FullConnection(net["hidden1"], net["out"], name="c2"))
net.addRecurrentConnection(FullConnection(net["out"], net["hidden1"], name="cout"))
net.sortModules()
net.randomize()

# train for 30 epochs (overkill) using the rprop- training algorithm
trainer = RPropMinusTrainer(net, dataset=train_set, verbose=True)
trainer.trainOnDataset(train_set, 30)

# test on training set
predictions_train = np.array([net.activate(train_set["input"][i])[0] for i in xrange(len(train_set))])
plt.plot(train_set["target"], c="k")
plt.plot(predictions_train, c="r")
plt.show()

# and on test set
predictions_test = np.array([net.activate(test_set["input"][i])[0] for i in xrange(len(test_set))])
plt.plot(test_set["target"], c="k")
plt.plot(predictions_test, c="r")
plt.show()
开发者ID:patrikdal,项目名称:BitcoinTradingAlgorithmToolkit,代码行数:32,代码来源:example.py

示例2: len

# 需要导入模块: from pybrain.supervised.trainers import RPropMinusTrainer [as 别名]
# 或者: from pybrain.supervised.trainers.RPropMinusTrainer import trainOnDataset [as 别名]
len_pList = len(pList)
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)
开发者ID:oddy555,项目名称:bitcoinprediction,代码行数:33,代码来源:bitcoinprediction2.py


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