本文整理汇总了Python中pybrain.datasets.SupervisedDataSet.data['input']方法的典型用法代码示例。如果您正苦于以下问题:Python SupervisedDataSet.data['input']方法的具体用法?Python SupervisedDataSet.data['input']怎么用?Python SupervisedDataSet.data['input']使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pybrain.datasets.SupervisedDataSet
的用法示例。
在下文中一共展示了SupervisedDataSet.data['input']方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: train
# 需要导入模块: from pybrain.datasets import SupervisedDataSet [as 别名]
# 或者: from pybrain.datasets.SupervisedDataSet import data['input'] [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)