pybrain深信念错误 - “属性错误:'NoneType'对象没有属性'indim'”

时间:2015-07-22 02:32:41

标签: python pybrain

我正在尝试使用反复出现的神经网络和深刻的信念来训练它。这是我的代码:

net = RecurrentNetwork()
net.addInputModule(LinearLayer(2, name='visible'))
net.addModule(SigmoidLayer(30, name='hidden1'))
net.addModule(SigmoidLayer(30, name='hidden2'))
net.addModule(SigmoidLayer(30, name='hidden3'))
net.addModule(SigmoidLayer(30, name='hidden4'))
net.addModule(SigmoidLayer(30, name='hidden5'))
net.addModule(SigmoidLayer(30, name='hidden6'))
net.addModule(SigmoidLayer(30, name='hidden7'))
net.addModule(SigmoidLayer(30, name='hidden8'))
net.addModule(SigmoidLayer(30, name='hidden9'))
bias = BiasUnit('bias')
net.addModule(bias)
net.addOutputModule(LinearLayer(1, name='out'))
net.addConnection(FullConnection(net['visible'], net['hidden1'], name='c1'))
net.addConnection(FullConnection(net['hidden1'], net['hidden2'], name='c2'))
net.addConnection(FullConnection(net['hidden2'], net['hidden3'], name='c3'))
net.addConnection(FullConnection(net['hidden3'], net['hidden4'], name='c4'))
net.addConnection(FullConnection(net['hidden4'], net['hidden5'], name='c5'))
net.addConnection(FullConnection(net['hidden5'], net['hidden6'], name='c6'))
net.addConnection(FullConnection(net['hidden6'], net['hidden7'], name='c7'))
net.addConnection(FullConnection(net['hidden7'], net['hidden8'], name='c8'))
net.addConnection(FullConnection(net['hidden8'], net['hidden9'], name='c9'))
net.addConnection(FullConnection(net['hidden9'], net['out'], name='c10'))
net.addConnection(FullConnection(net['bias'], net['hidden1'], name='b1'))
net.addConnection(FullConnection(net['bias'], net['hidden2'], name='b2'))
net.addConnection(FullConnection(net['bias'], net['hidden3'], name='b3'))
net.addConnection(FullConnection(net['bias'], net['hidden4'], name='b4'))
net.addConnection(FullConnection(net['bias'], net['hidden5'], name='b5'))
net.addConnection(FullConnection(net['bias'], net['hidden6'], name='b6'))
net.addConnection(FullConnection(net['bias'], net['hidden7'], name='b7'))
net.addConnection(FullConnection(net['bias'], net['hidden8'], name='b8'))
net.addConnection(FullConnection(net['bias'], net['hidden9'], name='b9'))
net.addConnection(FullConnection(net['bias'], net['out'], name='b10'))
net.sortModules()
trainer = DeepBeliefTrainer(net, ds)
trainer.trainEpochs(epochs=30)
print(trainer)
answer = (net.activate([1,1]))
print(answer)

和我得到的错误:

Traceback (most recent call last):
  File "/Users/spudzee1111/Desktop/Code/YTAcademy/pyBrainClassifier.command", line 80, in <module>
    trainer.trainEpochs(epochs=30)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/PyBrain-0.3.3-py3.4.egg/pybrain/supervised/trainers/trainer.py", line 37, in trainEpochs
    self.train(*args, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/PyBrain-0.3.3-py3.4.egg/pybrain/unsupervised/trainers/deepbelief.py", line 101, in train
    biascon = FullConnection(bias, hidden)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/PyBrain-0.3.3-py3.4.egg/pybrain/structure/connections/full.py", line 17, in __init__
    Connection.__init__(self, *args, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/PyBrain-0.3.3-py3.4.egg/pybrain/structure/connections/connection.py", line 37, in __init__
    self.outSliceTo = outmod.indim
AttributeError: 'NoneType' object has no attribute 'indim'

我试着查看产生错误的代码(connection.py,full.py,...),但由于我不熟悉很多算法,所以我无法推断出任何东西。如果由于我的模块/连接的命名而发生这种情况,我不会感到惊讶,因为存在类似的问题,这要求我将输入层重命名为“可见”以修复它。

0 个答案:

没有答案