how to elegantly duplicate a graph (neural network)

Posted by macias on Stack Overflow See other posts from Stack Overflow or by macias
Published on 2010-06-02T10:28:43Z Indexed on 2010/06/02 10:34 UTC
Read the original article Hit count: 237

Filed under:
|
|
|

I have a graph (network) which consists of layers, which contains nodes (neurons). I would like to write a procedure to duplicate entire graph in most elegant way possible -- i.e. with minimal or no overhead added to the structure of the node or layer.

Or yet in other words -- the procedure could be complex, but the complexity should not "leak" to structures. They should be no complex just because they are copyable.

I wrote the code in C#, so far it looks like this:

  • neuron has additional field -- copy_of which is pointer the the neuron which base copied from, this is my additional overhead
  • neuron has parameterless method Clone()
  • neuron has method Reconnect() -- which exchanges connection from "source" neuron (parameter) to "target" neuron (parameter)
  • layer has parameterless method Clone() -- it simply call Clone() for all neurons
  • network has parameterless method Clone() -- it calls Clone() for every layer and then it iterates over all neurons and creates mappings neuron=>copy_of and then calls Reconnect to exchange all the "wiring"

I hope my approach is clear. The question is -- is there more elegant method, I particularly don't like keeping extra pointer in neuron class just in case of being copied! I would like to gather the data in one point (network's Clone) and then dispose it completely (Clone method cannot have an argument though).

© Stack Overflow or respective owner

Related posts about c#

Related posts about algorithm