Exemple #1
0
 public Brain(BrainLayer _input, BrainLayer[] _hidden, BrainLayer _output)
 {
     input  = _input;
     hidden = _hidden;
     output = _output;
     output.StartUp();
     if (hidden.Length > 0)
     {
         hiddenConnection   = new Connection[hidden.Length];
         repitionConnection = new Connection[hiddenConnection];
         maxHC = 0;
         maxHN = 0;
         for (int i = 0; i < hidden.Length; i++)
         {
             if (i == 0)
             {
                 hiddenConnection[0] = new Connection(_input, hidden[0]);
             }
             else
             {
                 hiddenConnection[i] = new Connection(hidden[i - 1], hidden[i]);
             }
             hidden[i].StartUp();
             if (hidden[i].repition)
             {
                 repitionConnection[i] = new Connection(hidden[i], hidden[i]);
             }
             else
             {
                 repitionConnection[i] = null;
             }
             if (hidden[i].neuronAmount > maxHN)
             {
                 maxHN = hidden[i].neuronAmount;
             }
             if (hiddenConnection[i].connectionAmount > maxHC)
             {
                 maxHC = hiddenConnection[i].connectionAmount;
             }
         }
         outputConnection = new Connection(hidden[hidden.Length - 1], output);
         if (outputConnection.connectionAmount > maxHC)
         {
             maxHC = outputConnection.connectionAmount;
         }
     }
     else
     {
         maxHN            = 0;
         maxHC            = 0;
         outputConnection = new Connection(_input, _output);
         if (outputConnection.connectionAmount > maxHC)
         {
             maxHC = outputConnection.connectionAmount;
         }
     }
 }
Exemple #2
0
 public Brain(Brain brain)
 {
     input  = new BrainLayer(brain.input);
     hidden = new BrainLayer[brain.hidden.Length];
     for (int i = 0; i < hidden.Length; i++)
     {
         hidden[i] = new BrainLayer(brain.hidden[i]);
         hidden[i].StartUp();
     }
     output = new BrainLayer(brain.output);
     output.StartUp();
     if (hidden.Length > 0)
     {
         hiddenConnection   = new Connection[hidden.Length];
         repitionConnection = new Connection[hidden.Length];
         maxHN = 0;
         maxHC = 0;
         for (int i = 0; i < hidden.Length; i++)
         {
             if (i == 0)
             {
                 hiddenConnection[0] = new Connection(input, hidden[0]);
             }
             else
             {
                 hiddenConnection[i] = new Connection(hidden[i - 1], hidden[i]);
             }
             if (hidden[i].repition)
             {
                 repitionConnection[i] = new Connection(hidden[i], hidden[i]);
             }
             else
             {
                 repitionConnection[i] = null;
             }
             if (hidden[i].neuronAmount > maxHN)
             {
                 maxHN = hidden[i].neuronAmount;
             }
             if (hiddenConnection[i].connectionAmount > maxHC)
             {
                 maxHC = hiddenConnection[i].connectionAmount;
             }
         }
         outputConnection = new Connection(hidden[hidden.Length - 1], output); // considers the hidden layer as input and output layer as the output
         if (outputConnection.connectionAmount > maxHC)
         {
             maxHC = outputConnection.connectionAmount;
         }
     }
     else
     {
         maxHN            = 0;
         maxHC            = 0;
         outputConnection = new Connection(input, output);
         if (outputConnection.connectionAmount > maxHC)
         {
             maxHC = outputConnection.connectionAmount;
         }
     }
 }