예제 #1
0
        public List <NeuralPathway> GetPathways(Dynamic o)
        {
            var pathways = new List <NeuralPathway>();
            var path     = new NeuralPathway();

            path.Path.Add(o);
            path.Weightings.Add(1);
            var paths = o.ExtendPathway(path);

            pathways.AddRange(paths);
            return(pathways);
        }
예제 #2
0
        public NeuralPathway Copy()
        {
            var copy = new NeuralPathway();

            foreach (var p in Path)
            {
                copy.Path.Add(p);
            }
            foreach (var w in Weightings)
            {
                copy.Weightings.Add(w);
            }
            return(copy);
        }
예제 #3
0
        public override double GetOutput(NeuralPathway path = null)
        {
            if (path != null)
            {
                if (path.Path.Count(Equivelant) > 2)
                {
                    return(0);
                }
                path.Path.Add(this);
            }
            var sum = Dendrites.Aggregate <Dendrite, double>(0, (current, d) => current + (d.GetSignal(path)));

            return(Function(sum));
        }
예제 #4
0
        /**
         * backpropagate
         * sends weighted error back through the network
         * re-weights input based on error.
         * @param error (double)
         */
        public override void Backpropagate(double error, NeuralPathway path = null)
        {
            if (path != null)
            {
                if (path.Path.Count(Equivelant) > 2)
                {
                    return;
                }
                path.Path.Add(this);
            }

            //http://home.agh.edu.pl/~vlsi/AI/backp_t_en/backprop.html
            foreach (var d in Dendrites)
            {
                d.Neuron.Backpropagate(error * d.Weight, path);
                Reweight(d, error, path);
            }
        }
예제 #5
0
        public IEnumerable <NeuralPathway> ExtendPathway(NeuralPathway pathway)
        {
            var pathways = new List <NeuralPathway>();

            if (Dendrites.Count <= 0)
            {
                return new List <NeuralPathway>()
                       {
                           pathway
                       }
            }
            ;
            foreach (var d in Dendrites)
            {
                var path = pathway.Copy();

                path.Path.Add(d.Neuron);
                path.Weightings.Add(d.Weight);
                var paths = d.Neuron.ExtendPathway(path);
                pathways.AddRange(paths);
            }
            return(pathways);
        }
    }
예제 #6
0
        /**
         * reweight
         * Sets the weight of the given dendrite based on its error.
         * @param dendrite (Dendrite) to be reweighted
         * @param error (double)
         */
        private void Reweight(Dendrite dendrite, double error, NeuralPathway path = null)
        {
            var weight = dendrite.Weight + LearningRate * error * Derivative(GetOutput(path)) * dendrite.Neuron.GetOutput(path);

            dendrite.Weight = weight;
        }
예제 #7
0
 /**
  * backpropagate
  * all nodes must backpropagate errors
  * @param error (double)
  */
 public abstract void Backpropagate(double error, NeuralPathway path = null);
예제 #8
0
 /**
  * getOutput
  * Abstract, all nodes must return an output
  * @return double value
  */
 public abstract double GetOutput(NeuralPathway path = null);
예제 #9
0
파일: Input.cs 프로젝트: jackrust/AFLTipper
 /**
  * backpropagate
  * Static neurons do not need to backpropagate
  */
 public override void Backpropagate(double error, NeuralPathway path = null)
 {
 }
예제 #10
0
파일: Input.cs 프로젝트: jackrust/AFLTipper
 /**
  * getOutput
  * Static INeurons return their value
  * @return double value
  */
 public override double GetOutput(NeuralPathway path = null)
 {
     return(Value);
 }
예제 #11
0
 public double GetWeightedOutput(NeuralPathway path = null)
 {
     return(Weight * Neuron.GetOutput(path));
 }
예제 #12
0
 public double GetSignal(NeuralPathway path = null)
 {
     return(GetWeightedOutput(path));
 }