本文整理汇总了Python中pybrain.structure.networks.feedforward.FeedForwardNetwork.randomize方法的典型用法代码示例。如果您正苦于以下问题:Python FeedForwardNetwork.randomize方法的具体用法?Python FeedForwardNetwork.randomize怎么用?Python FeedForwardNetwork.randomize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pybrain.structure.networks.feedforward.FeedForwardNetwork
的用法示例。
在下文中一共展示了FeedForwardNetwork.randomize方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: buildXor
# 需要导入模块: from pybrain.structure.networks.feedforward import FeedForwardNetwork [as 别名]
# 或者: from pybrain.structure.networks.feedforward.FeedForwardNetwork import randomize [as 别名]
def buildXor(self):
self.params['dataset'] = 'XOR'
d = ClassificationDataSet(2)
d.addSample([0., 0.], [0.])
d.addSample([0., 1.], [1.])
d.addSample([1., 0.], [1.])
d.addSample([1., 1.], [0.])
d.setField('class', [[0.], [1.], [1.], [0.]])
self.trn_data = d
self.tst_data = d
global trn_data
trn_data = self.trn_data
nn = FeedForwardNetwork()
inLayer = TanhLayer(2, name='in')
hiddenLayer = TanhLayer(3, name='hidden0')
outLayer = ThresholdLayer(1, name='out')
nn.addInputModule(inLayer)
nn.addModule(hiddenLayer)
nn.addOutputModule(outLayer)
in_to_hidden = FullConnection(inLayer, hiddenLayer)
hidden_to_out = FullConnection(hiddenLayer, outLayer)
nn.addConnection(in_to_hidden)
nn.addConnection(hidden_to_out)
nn.sortModules()
nn.randomize()
self.net_settings = str(nn.connections)
self.nn = nn
示例2: buildIris
# 需要导入模块: from pybrain.structure.networks.feedforward import FeedForwardNetwork [as 别名]
# 或者: from pybrain.structure.networks.feedforward.FeedForwardNetwork import randomize [as 别名]
def buildIris(self):
self.params['dataset'] = 'iris'
self.trn_data, self.tst_data = pybrainData(0.5)
global trn_data
trn_data = self.trn_data
nn = FeedForwardNetwork()
inLayer = TanhLayer(4, name='in')
hiddenLayer = TanhLayer(6, name='hidden0')
outLayer = ThresholdLayer(3, name='out')
nn.addInputModule(inLayer)
nn.addModule(hiddenLayer)
nn.addOutputModule(outLayer)
in_to_hidden = FullConnection(inLayer, hiddenLayer)
hidden_to_out = FullConnection(hiddenLayer, outLayer)
nn.addConnection(in_to_hidden)
nn.addConnection(hidden_to_out)
nn.sortModules()
nn.randomize()
self.net_settings = str(nn.connections)
self.nn = nn
示例3: buildParity
# 需要导入模块: from pybrain.structure.networks.feedforward import FeedForwardNetwork [as 别名]
# 或者: from pybrain.structure.networks.feedforward.FeedForwardNetwork import randomize [as 别名]
def buildParity(self):
self.params['dataset'] = 'parity'
self.trn_data = ParityDataSet(nsamples=75)
self.trn_data.setField('class', self.trn_data['target'])
self.tst_data = ParityDataSet(nsamples=75)
global trn_data
trn_data = self.trn_data
nn = FeedForwardNetwork()
inLayer = TanhLayer(4, name='in')
hiddenLayer = TanhLayer(6, name='hidden0')
outLayer = ThresholdLayer(1, name='out')
nn.addInputModule(inLayer)
nn.addModule(hiddenLayer)
nn.addOutputModule(outLayer)
in_to_hidden = FullConnection(inLayer, hiddenLayer)
hidden_to_out = FullConnection(hiddenLayer, outLayer)
nn.addConnection(in_to_hidden)
nn.addConnection(hidden_to_out)
nn.sortModules()
nn.randomize()
self.net_settings = str(nn.connections)
self.nn = nn