PyBrain neuron manipulation

Viewed 1177

Is there a good way to add/remove a neuron and its associated connections into/from a fully connected PyBrain network? Say I start with:

from pybrain.tools.shortcuts import buildNetwork
net = buildNetwork(2,3,1)

How would I go about making it a (2,4,1) or a (2,2,1) network WHILE maintaining all the old weights (and initializing any new ones to be random as is done when initializing the network)? The reason I want to do this is because I am attempting to use an evolutionary learning strategy to determine the best architecture and the 'mutation' step involves adding/removing nodes with some probability. (The input and output modules should always remain the same.)

edit: I found NeuronDecomposableNetwork which should make this easier, but it still seems that I have to keep track of neurons and connections separately.

1 Answers
Related