Advertisement
Guest User

Styling sample

a guest
May 7th, 2016
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.23 KB | None | 0 0
  1. public WetNetwork( WetNetData<TNeuron, TData> data ) {
  2.     var allNeurons = new List<Neuron<TData>>();
  3.     foreach( var layerData in data.Layers ) {
  4.         var newLayer = new WetNetworkLayer<TNeuron, TData>( layerData );
  5.         m_layers.Add( newLayer );
  6.        
  7.         allNeurons.AddRange( newLayer.Neurons );
  8.     }
  9.    
  10.     var unaccountedPipes = new List<UnaccountedPipe>();
  11.     foreach( var neuronA in allNeurons ) {
  12.         foreach( var connection in neuronA.AssignedData.Inputs ) {
  13.             var neuronB = allNeurons.Find( (x) => { return x.ID == connection.Key; } );
  14.             if( neuronB == null ) {
  15.                 var lostPipe = new UnaccountedPipe( neuronA, connection.Key, connection.Value );
  16.                 unaccountedPipes.Add( lostPipe );
  17.             }
  18.             else {
  19.                 neuronA.AddInput( neuronB.Output, connection.Value );
  20.             }
  21.         }
  22.     }
  23.    
  24.     var inputPipes = new List<Pipe<TData>>();
  25.     foreach( var pipeData in unaccountedPipes ) {
  26.         var pipeFound = inputPipes.Find( (x) => { return x.PipeID == pipeData.ConnectionTo; } );
  27.         if( pipeFound == null ) {
  28.             pipeFound = new Pipe<TData>();
  29.             pipeFound.SetExplicitID( pipeData.ConnectionTo );
  30.             inputPipes.Add( pipeFound );
  31.         }
  32.        
  33.         pipeData.Neuron.AddInput( pipeFound, pipeData.ConnectionWeight );
  34.     }
  35.     Inputs = inputPipes;
  36.    
  37.     NextNeuronID = data.NextNeuronID;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement