Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public WetNetwork( WetNetData<TNeuron, TData> data ) {
- var allNeurons = new List<Neuron<TData>>();
- foreach( var layerData in data.Layers ) {
- var newLayer = new WetNetworkLayer<TNeuron, TData>( layerData );
- m_layers.Add( newLayer );
- allNeurons.AddRange( newLayer.Neurons );
- }
- var unaccountedPipes = new List<UnaccountedPipe>();
- foreach( var neuronA in allNeurons ) {
- foreach( var connection in neuronA.AssignedData.Inputs ) {
- var neuronB = allNeurons.Find( (x) => { return x.ID == connection.Key; } );
- if( neuronB == null ) {
- var lostPipe = new UnaccountedPipe( neuronA, connection.Key, connection.Value );
- unaccountedPipes.Add( lostPipe );
- }
- else {
- neuronA.AddInput( neuronB.Output, connection.Value );
- }
- }
- }
- var inputPipes = new List<Pipe<TData>>();
- foreach( var pipeData in unaccountedPipes ) {
- var pipeFound = inputPipes.Find( (x) => { return x.PipeID == pipeData.ConnectionTo; } );
- if( pipeFound == null ) {
- pipeFound = new Pipe<TData>();
- pipeFound.SetExplicitID( pipeData.ConnectionTo );
- inputPipes.Add( pipeFound );
- }
- pipeData.Neuron.AddInput( pipeFound, pipeData.ConnectionWeight );
- }
- Inputs = inputPipes;
- NextNeuronID = data.NextNeuronID;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement