本文整理汇总了Python中pybrain.structure.FeedForwardNetwork.outdim方法的典型用法代码示例。如果您正苦于以下问题:Python FeedForwardNetwork.outdim方法的具体用法?Python FeedForwardNetwork.outdim怎么用?Python FeedForwardNetwork.outdim使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pybrain.structure.FeedForwardNetwork
的用法示例。
在下文中一共展示了FeedForwardNetwork.outdim方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: train
# 需要导入模块: from pybrain.structure import FeedForwardNetwork [as 别名]
# 或者: from pybrain.structure.FeedForwardNetwork import outdim [as 别名]
def train(self):
# We will build up a network piecewise in order to create a new dataset
# for each layer.
dataset = self.dataset
piecenet = FeedForwardNetwork()
piecenet.addInputModule(copy.deepcopy(self.net.inmodules[0]))
# Add a bias
bias = BiasUnit()
piecenet.addModule(bias)
# Add the first visible layer
firstRbm = self.iterRbms().next()
visible = copy.deepcopy(firstRbm.visible)
piecenet.addModule(visible)
# For saving the rbms and their inverses
self.invRbms = []
self.rbms = []
for rbm in self.iterRbms():
self.net.sortModules()
# Train the first layer with an rbm trainer for `epoch` epochs.
trainer = self.trainerKlass(rbm, dataset, self.cfg)
for _ in xrange(self.epochs):
trainer.train()
self.invRbms.append(trainer.invRbm)
self.rbms.append(rbm)
# Add the connections and the hidden layer of the rbm to the net.
hidden = copy.deepcopy(rbm.hidden)
biascon = FullConnection(bias, hidden)
biascon.params[:] = rbm.biasWeights
con = FullConnection(visible, hidden)
con.params[:] = rbm.weights
piecenet.addConnection(biascon)
piecenet.addConnection(con)
piecenet.addModule(hidden)
# Overwrite old outputs
piecenet.outmodules = [hidden]
piecenet.outdim = rbm.hiddenDim
piecenet.sortModules()
dataset = UnsupervisedDataSet(rbm.hiddenDim)
for sample, in self.dataset:
new_sample = piecenet.activate(sample)
dataset.addSample(new_sample)
visible = hidden