示例#1
0
        public static void Connect(Perceptron main, Perceptron perceptron, Synapse synapse)
        {
            main.perceptrons_to.Add(perceptron);
            main.synapses_to.Add(synapse);

            perceptron.perceptrons_from.Add(main);
            perceptron.synapses_from.Add(synapse);

            perceptron.index_in_other_perceptrons.Add(perceptron.perceptrons_from.Count - 1);
        }
示例#2
0
        public void BackPropagation(float lr, float mr)
        {
            int len = perceptrons_to.Count;

            for (int i = 0; i < len; i++)
            {
                Perceptron perc = perceptrons_to[i];
                Synapse    syn  = synapses_to[i];
                syn.error = (lr * activation() * perc.error) + (mr * syn.error);
                syn.x    += syn.error;
            }
        }
示例#3
0
 public void FeedForward()
 {
     if (type == PerceptronType.Type.hidden || type == PerceptronType.Type.output)
     {
         state = 0f;
         int len = perceptrons_from.Count;
         for (int i = 0; i < len; i++)
         {
             Perceptron perc = perceptrons_from[index_in_other_perceptrons[i]];
             Synapse    syn  = synapses_from[index_in_other_perceptrons[i]];
             state += perc.activation() * syn.x;
         }
     }
 }
示例#4
0
        public void BlackError()
        {
            var x        = activation();
            var derivate = activation(true);

            if (type == PerceptronType.Type.output)
            {
                error = (desired - x) * derivate;
            }
            else
            {
                int len = perceptrons_to.Count;

                float er = 0f;
                for (int i = 0; i < len; i++)
                {
                    Perceptron perc = perceptrons_to[i];
                    Synapse    syn  = synapses_to[i];
                    er += perc.error * syn.x;
                }

                error = derivate * er;
            }
        }