pybrain NNregression工具参数

时间:2016-02-27 00:40:55

标签: python machine-learning neural-network regression pybrain

我试图在pybrain中使用NNregression工具:http://pybrain.org/docs/api/tools.html

我有我的数据集:

ds = SupervisedDataSet(20,1)
for x, y in zip(inputs, outputs):
    ds.appendLinked(x,y)

我可以通过以下初始化来训练网络......

n = NNregression(ds)

...但它突然停止并出现以下错误:

epoch   1000  total error       8.5458   avg weight          6.28
epoch   1001  total error       8.5313   avg weight        6.2823
epoch   1002  total error       8.5149   avg weight        6.2851
epoch   1003  total error       8.5003   avg weight        6.2882
epoch   1004  total error       8.4801   avg weight        6.2922
Traceback (most recent call last):
  File "regression.py", line 108, in <module>
    trainer = BackpropTrainer(n, ds, verbose = True)
  File "/mounts/u-zon-d2/ugrad/kmwe236/pybrain/pybrain/supervised/trainers/backprop.py", line 37, in __init__
    self.setData(dataset)
  File "/mounts/u-zon-d2/ugrad/kmwe236/pybrain/pybrain/supervised/trainers/trainer.py", line 22, in setData
    assert dataset.indim == self.module.indim

所以我尝试更改参数以包含验证器和测试集等文档要求:

val_data = SupervisedDataSet(20,1)
for x, y in zip(validator_inputs, validator_outputs):
    val_data.appendLinked(x,y)

test_data = SupervisedDataSet(20,1)
for x, y in zip(prediction_inputs, prediction_outputs):
    test_data.appendLinked(x,y)


n = NNregression(dataset=ds, hidden=3, TDS=test_data, VDS=val_data, epoinc=750)

但是当我尝试执行它时会抱怨参数的数量:

violet:~/pybrain> python regression.py
Traceback (most recent call last):
  File "regression.py", line 95, in <module>
    n = NNregression(dataset=ds, hidden=3, tds=test_data, vds=val_data, epoinc=750)
TypeError: __init__() takes exactly 2 arguments (1 given)

1 个答案:

答案 0 :(得分:1)

至少对我来说,它无法识别关键字'dataset'。它获得1个参数(self),但它需要self和数据集。尝试将行更改为:

n = NNregression(ds,hidden = 3,tds = test_data,vds = val_data,epoinc = 750)