public Layer(int number, int neuronsCount, int previousLayerNeuronsCount, SigmoidFunction sigmoid, bool isLastLayer = false)
 {
     this.Number = number;
     if (!isLastLayer)
     {
         neuronsCount++;
     }
     this.GenerateLayerNeurons(neuronsCount, previousLayerNeuronsCount, sigmoid, isLastLayer);
 }
Exemplo n.º 2
0
        public Neuron(int index, int numberOfConnections, SigmoidFunction function, bool isbias, bool isFirstLayer = false)
        {
            this.ActivationFunction = function;
            this.NumberConnections  = numberOfConnections;
            this.Index = index;
            this.IsFirstLayerNeuron = isFirstLayer;
            this.IsBias             = isbias;

            this.LoadWeightsConfigurations();
            if (!IsFirstLayerNeuron)
            {
                this.Weights = new double[NumberConnections];
                this.Randomize();
            }
        }
        private void GenerateLayerNeurons(int neuronsCount, int previousLayerNeuronsCount, SigmoidFunction sigmoid, bool isLastLayer)
        {
            var maxIndex     = neuronsCount;
            var isFirstLayer = this.Number == 1;

            if (!isLastLayer)
            {
                var biasNeuron = new Neuron(0, previousLayerNeuronsCount, sigmoid, true, isFirstLayer);
                this.Neurons.Add(biasNeuron);
                maxIndex--;
            }

            for (var i = 0; i < maxIndex; i++)
            {
                var neuron = new Neuron(i + 1, previousLayerNeuronsCount, sigmoid, false, isFirstLayer);
                this.Neurons.Add(neuron);
            }
        }