级联前向神经网络

时间:2015-01-15 01:48:50

标签: python neural-network pybrain

我知道我们可以在pybrain中创建前馈神经网络

example of feed forward neural network

但是,我们还可以在pybrain中创建级联前向神经网络吗?

example of cascade forward neural network

1 个答案:

答案 0 :(得分:3)

如果我理解正确,您希望将输入图层连接到隐藏图层并直接连接到输出图层。

如果只是从输入层到输出层创建一个额外的FullConnection怎么办?

from pybrain.structure import FeedForwardNetwork
n = FeedForwardNetwork()
from pybrain.structure import LinearLayer, SigmoidLayer
inLayer = LinearLayer(2)
hiddenLayer = SigmoidLayer(3)
outLayer = SigmoidLayer(1)

n.addInputModule(inLayer)
n.addModule(hiddenLayer)
n.addOutputModule(outLayer)

from pybrain.structure import FullConnection
in_to_hidden = FullConnection(inLayer, hiddenLayer)
hidden_to_out = FullConnection(hiddenLayer, outLayer)
in_to_out = FullConnection(inLayer, outLayer)

n.addConnection(in_to_hidden)
n.addConnection(hidden_to_out)
n.addConnection(in_to_out)

n.sortModules()

print n

这似乎有效。