How to do supervised deepbelief training in PyBrain?

风格不统一 提交于 2019-12-20 10:23:51

问题


I have trouble getting the DeepBeliefTrainer to work on my data in PyBrain/Python. Since I can't find any examples other than unsupervised on how to use the deep learning in PyBrain, I hope that someone can give examples that would show a basic concept of usage.

I have tried to initialize using:

epochs = 100
layerDims = [768,100,100,1]

net = buildNetwork(*layerDims)
dataset = self.dataset
trainer = DeepBeliefTrainer(net, dataset=dataSet)
trainer.trainEpochs(epochs)

I try to use a SupervisedDataset for regression, but the training just fails. Have anyone succeded with using deeplearning trainer for supervised machine learning? And how did you do it?

Error I get:

File "/Library/Python/2.7/site-packages/PyBrain-0.3.1-py2.7.egg/pybrain/structure/networks/rbm.py", line 39, in __init__
self.con = self.net.connections[self.visible][0]
KeyError: None

回答1:


It's because your initial network: net = buildNetwork(*layerDims) doesn't have a layer with the name of the visible layer in your deep belief network, which is 'visible'. So, in order to find it mapped in the initial network, you can do something like:

net.addInputModule(LinearLayer(input_dim, 'visible'))
[...]
trainer = DeepBeliefTrainer(net, dataset=dataSet)


来源:https://stackoverflow.com/questions/15161295/how-to-do-supervised-deepbelief-training-in-pybrain

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!