我在使用 Pybrain 训练 DBN 时遇到了一些困难。首先,我尝试以简单的方式做到这一点:
net = buildNetwork(*layerDims)
我遇到了这个问题:如何在 PyBrain 中进行有监督的深度信念训练?,而建议的解决方案只是导致了另一个错误:
File "/home/WORK/Canopy_64bit/User/lib/python2.7/site-packages/PyBrain-0.3.1- py2.7.egg/pybrain/unsupervised/trainers/deepbelief.py", line 62, in <genexpr>
layercons = (self.net.connections[i][0] for i in layers)
IndexError: list index out of range
所以我试图从头开始定义一个网络!
inp = LinearLayer(3 , 'visible')
hidden0 = SigmoidLayer(2 , 'hidden0')
hidden1= SigmoidLayer(2 , 'hidden1')
output = LinearLayer(2 , 'output')
bias = BiasUnit('bias')
net = Network()
net.addInputModule(inp)
net.addModule(hidden0)
net.addModule(hidden1)
net.addModule(output)
net.addModule(bias)
net.addConnection(FullConnection(inp, hidden0))
net.addConnection(FullConnection(hidden0, hidden1))
net.addConnection(FullConnection(hidden1, output))
net.addConnection(FullConnection(bias, hidden0))
net.addConnection(FullConnection(bias, hidden1))
net.addConnection(FullConnection(bias, output))
net.sortModules()
仍然当我运行时:
trainer = deepbelief.DeepBeliefTrainer(net1, dataset=ds)
trainer.trainEpochs(epochs)
我看到这个错误:
File "/home/WORK/Canopy_64bit/User/lib/python2.7/site-packages/PyBrain-0.3.1-py2.7.egg/pybrain/structure/connections/connection.py", line 37, in __init__
self.outSliceTo = outmod.indim
AttributeError: 'NoneType' object has no attribute 'indim'
这与相关 RBM 中的隐藏层有关。
我在这里错过了什么吗?