Reputation: 409
I understand that we can create a feed forward neural network in pybrain.
However, can we also create a cascade forward neural network in pybrain?
Upvotes: 0
Views: 1572
Reputation: 2019
If i understand correctly you want to connect your input layer to both hidden layer and directly to the output layer.
What if you simply create an additional FullConnection from input layer to output layer?
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
This seems to be working.
Upvotes: 3