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


Python SupervisedDataSet.data['target']方法代码示例

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


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

示例1: train

# 需要导入模块: from pybrain.datasets import SupervisedDataSet [as 别名]
# 或者: from pybrain.datasets.SupervisedDataSet import data['target'] [as 别名]
 def train(self, training_files, learningrate=0.01, scaling=True, noise=False, verbose=True):
     print "building dataset..."
     ds = SupervisedDataSet(SensorModel.array_length(self.sensor_ids), 1)
     # read training file line, create sensormodel object, do backprop
     a = None
     s = None
     for logfile in training_files:
         print "loading file", logfile
         with open(logfile) as f:
             for line in f:
                 if line.startswith("Received:"):
                     s = SensorModel(string=line.split(' ', 1)[1])
                 elif line.startswith("Sending:"):
                     a = Actions.from_string(string=line.split(' ', 1)[1])
                 if s is not None and a is not None:
                     ds.addSample(inp=s.get_array(self.sensor_ids), target=a[self.action_ids[0]])
                     if noise:
                         # add the same training sample again but with noise in the sensors
                         s.add_noise()
                         ds.addSample(inp=s.get_array(self.sensor_ids), target=a[self.action_ids[0]])
                     s = None
                     a = None
     print "dataset size:", len(ds)
     if scaling:
         print "scaling dataset"
         self.scaler_input = StandardScaler(with_mean=True, with_std=False).fit(ds.data['input'])
         ds.data['input'] = self.scaler_input.transform(ds.data['input'])
         ds.data['target'] = ds.data['target']
     #self.trainer = BackpropTrainer(self.net, learningrate=learningrate, verbose=verbose)
     self.trainer = RPropMinusTrainer(self.net, verbose=verbose, batchlearning=True)
     print "training network..."
     self.trainer.trainUntilConvergence(dataset=ds, validationProportion=0.25, maxEpochs=10, continueEpochs=2)
开发者ID:lqrz,项目名称:computational_intelligence,代码行数:34,代码来源:network.py


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