internal Layer(int layerIndex, int neurons, NeuronalNetwork parentNetwork, double[] neuronWeights = null)
 {
     this.parentNetwork = parentNetwork;
     this.neurons       = new Neuron[length = neurons];
     this.layerIndex    = layerIndex;
     isInputLayer       = layerIndex == 0;
     isOutputLayer      = layerIndex == parentNetwork.layers.Length - 1;
     if (!isInputLayer)
     {
         previousLayer = parentNetwork.layers[layerIndex - 1];
     }
     if (neuronWeights == null)
     {
         for (int i = 0; i < length; i++)
         {
             this.neurons[i] = new Neuron(i, this);
         }
     }
     else
     {
         for (int i = 0; i < length; i++)
         {
             this.neurons[i] = new Neuron(i, this, neuronWeights[i]);
         }
     }
 }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            NeuronalNetwork.ReadDataFromFile();
            NeuronalNetwork.Train();
            NeuronalNetwork.Test();
            //Check if the threads are started or not.. if they are running - join before program exit
            if (NeuronalNetwork.WriteHiddenWeightsFileThread.IsAlive &&
                NeuronalNetwork.WriteInputWeightsFileThread.IsAlive)
            {
                NeuronalNetwork.WriteHiddenWeightsFileThread.Join();
                NeuronalNetwork.WriteInputWeightsFileThread.Join();
            }

            Console.WriteLine("Press any key for exit!");
            Console.ReadKey();
        }