Ejemplo n.º 1
0
        public void Pulse(NeuralLayer layer)
        {
            Output = 0;

            foreach (Connection item in Input)
            {
                Output += item.Input.Output * item.Weight;
            }
            Output += Bias;
            Sum     = Output;

            Output = ActivateFunction(Output);
        }
Ejemplo n.º 2
0
        public void Init(int seed, int inputNeurons, int hiddenNeurons, int outputNeurons)
        {
            InputLayer  = new NeuralLayer();
            HiddenLayer = new NeuralLayer();
            OutputLayer = new NeuralLayer();
            Random rand = new Random(seed);

            int i, j;

            for (i = 0; i < inputNeurons; i++)
            {
                InputLayer.neurons.Add(new Neuron(0));
            }

            for (i = 0; i < hiddenNeurons; i++)
            {
                HiddenLayer.neurons.Add(new Neuron(rand.NextDouble()));
            }

            for (i = 0; i < outputNeurons; i++)
            {
                OutputLayer.neurons.Add(new Neuron(rand.NextDouble()));
            }

            //Wire input together with the hidden layer
            for (i = 0; i < HiddenLayer.neurons.Count; i++)
            {
                for (j = 0; j < InputLayer.neurons.Count; j++)
                {
                    HiddenLayer.neurons[i].Input.Add(new Connection(InputLayer.neurons[j], rand.NextDouble()));
                }
            }

            //Wire output together with hidden layer
            for (i = 0; i < OutputLayer.neurons.Count; i++)
            {
                for (j = 0; j < HiddenLayer.neurons.Count; j++)
                {
                    OutputLayer.neurons[i].Input.Add(new Connection(HiddenLayer.neurons[j], rand.NextDouble()));
                }
            }
        }