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


Python BackpropTrainer.verbose方法代码示例

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


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

示例1: testTrainingOnSepervisedDataset

# 需要导入模块: from pybrain.supervised.trainers import BackpropTrainer [as 别名]
# 或者: from pybrain.supervised.trainers.BackpropTrainer import verbose [as 别名]
 def testTrainingOnSepervisedDataset(self):
     DS = SupervisedDataSet(2, 1)
     DS.addSample([ 0, 0 ] , [0])
     DS.addSample([ 0, 1 ] , [1])
     DS.addSample([ 1, 0 ] , [1])
     DS.addSample([ 1, 1 ] , [0])
     
     network = N = buildNetwork(2, 4, 1)
     trainer = BackpropTrainer(N, learningrate = 0.01, momentum = 0.99)
     trainer.verbose = False
     
     nnf = NeuralNetworkFactory(network, trainer, seed=2, iterationsNum=500)
     nnClassifier = nnf.buildClassifier(DS)
     
     self.assertAlmostEqual(nnClassifier.getPrediction([0, 0]), 0, delta=0.01) 
     self.assertAlmostEqual(nnClassifier.getPrediction([0, 1]), 1, delta=0.01)
     self.assertAlmostEqual(nnClassifier.getPrediction([1, 0]), 1, delta=0.01)
     self.assertAlmostEqual(nnClassifier.getPrediction([1, 1]), 0, delta=0.01)  
开发者ID:mushketyk,项目名称:pybrain,代码行数:20,代码来源:test_neuralnetwork.py

示例2: ClassificationDataSet

# 需要导入模块: from pybrain.supervised.trainers import BackpropTrainer [as 别名]
# 或者: from pybrain.supervised.trainers.BackpropTrainer import verbose [as 别名]
# Imports
import numpy as np
from pybrain.datasets            import ClassificationDataSet
from pybrain.tools.shortcuts     import buildNetwork
from pybrain.supervised.trainers import BackpropTrainer
from pybrain.structure.modules   import SigmoidLayer

# Data and outputs
X = np.array([[-1,-1],[-1,1],[1,-1],[1,1]]).transpose()
y = np.array([0, 1, 1, 0])
data = ClassificationDataSet(2,1)
for i in range(0,X.shape[1]):
    data.addSample(X[:,i],y[i])

### Add your code here!
#inLayer = LinearLayer(2)
#hiddenLayer = SigmoidLayer(4)
#outLayer = LinearLayer(1)
#build network
net = buildNetwork(2,4,1, hiddenclass=SigmoidLayer, outclass=SigmoidLayer)
#create BackpropTrainer
trainer = BackpropTrainer(net, dataset=data, learningrate=1, momentum=0.001, weightdecay=0.000001, batchlearning=True)
#train the network
trainer.trainEpochs( 3000 )
#or can be used :
for i in range(30):
    trainer.trainEpochs(99)
    trainer.verbose=True
    trainer.trainEpochs(1)
    trainer.verbose=False
开发者ID:sergiubuciumas,项目名称:-exploredatascience,代码行数:32,代码来源:XOR_WITH_PYBRAIN.py


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