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


Python FeedForwardNetwork.outmodules方法代码示例

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


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

示例1: train

# 需要导入模块: from pybrain.structure import FeedForwardNetwork [as 别名]
# 或者: from pybrain.structure.FeedForwardNetwork import outmodules [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
开发者ID:HKou,项目名称:pybrain,代码行数:46,代码来源:deepbelief.py


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