Пример #1
0
 public void AddInputNeuron(INeuron n)
 {
     NeuronInput inp = new NeuronInput();
     inp.n = n;
     inp.w = randomWeight();
     inp.bias = 0;
     inputs.Add(inp);            
 }
Пример #2
0
        public void AddInputNeuron(INeuron n)
        {
            NeuronInput inp = new NeuronInput();

            inp.n    = n;
            inp.w    = randomWeight();
            inp.bias = 0;
            inputs.Add(inp);
        }
Пример #3
0
 public Neuron(bool nonlinear)
 {
     rand = new Random((int)(Neuron.randomSeed++));
     Neuron.randomSeed = Neuron.randomSeed % 56264563;
     inputs = new List<NeuronInput>();
     NeuronInput inp = new NeuronInput();
     inp.n = null;
     inp.w = randomWeight();
     inp.bias = 1;
     inputs.Add(inp);
     this.nonlinear = nonlinear;
 }
Пример #4
0
        public void LoadNN(string filename)
        {
            TextReader     tr         = new StreamReader(filename);
            string         line       = tr.ReadLine();
            List <INeuron> layer      = null;
            Neuron         n          = null;
            int            ni_counter = 0;

            while (line != "E")
            {
                if (line == "M")
                {
                    mlp = new List <List <INeuron> >();
                }
                if (line == "L")
                {
                    layer = new List <INeuron>();
                    mlp.Add(layer);
                }
                if (line == "I")
                {
                    layer.Add(new InputNeuron());
                }
                if ((line == "Pn") || (line == "P"))
                {
                    n          = new Neuron(true);
                    ni_counter = 0;
                    layer.Add(n);
                }
                if (line == "Pl")
                {
                    n          = new Neuron(false);
                    ni_counter = 0;
                    layer.Add(n);
                }
                if (line == "b")
                {
                    string w = tr.ReadLine();
                    n.inputs[0].w = double.Parse(w, CultureInfo.InvariantCulture);
                }
                if (line == "w")
                {
                    string      w  = tr.ReadLine();
                    NeuronInput ni = new NeuronInput();
                    ni.w = double.Parse(w, CultureInfo.InvariantCulture);
                    ni.n = mlp[mlp.Count - 2][ni_counter];
                    n.inputs.Add(ni);
                    ni_counter++;
                }
                line = tr.ReadLine();
            }
            tr.Close();
        }
Пример #5
0
        public Neuron(bool nonlinear)
        {
            rand = new Random((int)(Neuron.randomSeed++));
            Neuron.randomSeed = Neuron.randomSeed % 56264563;
            inputs            = new List <NeuronInput>();
            NeuronInput inp = new NeuronInput();

            inp.n    = null;
            inp.w    = randomWeight();
            inp.bias = 1;
            inputs.Add(inp);
            this.nonlinear = nonlinear;
        }
Пример #6
0
        public double WeightSensibilityToError(int index, double error)
        {
            NeuronInput input = inputs[index];
            double      x;

            if (input.n != null)
            {
                x = input.n.Output();
            }
            else
            {
                x = input.bias;
            }
            return(delta * x / error);
        }
Пример #7
0
 public void LoadNN(string filename)
 {
     TextReader tr = new StreamReader(filename);
     string line = tr.ReadLine();
     List<INeuron> layer = null;
     Neuron n = null;
     int ni_counter = 0;
     while (line != "E")
     {
         if (line == "M") mlp = new List<List<INeuron>>();
         if (line == "L")
         {
             layer = new List<INeuron>();
             mlp.Add(layer);
         }
         if (line == "I") layer.Add(new InputNeuron());
         if ((line == "Pn")||(line == "P"))
         {
             n = new Neuron(true);
             ni_counter = 0;
             layer.Add(n);
         }
         if (line == "Pl")
         {
             n = new Neuron(false);
             ni_counter = 0;
             layer.Add(n);
         }
         if (line == "b")
         {
             string w = tr.ReadLine();
             n.inputs[0].w = double.Parse(w, CultureInfo.InvariantCulture);                    
         }
         if (line == "w")
         {
             string w = tr.ReadLine();
             NeuronInput ni = new NeuronInput();
             ni.w = double.Parse(w, CultureInfo.InvariantCulture);
             ni.n = mlp[mlp.Count - 2][ni_counter];                    
             n.inputs.Add(ni);
             ni_counter++;                        
         }
         line = tr.ReadLine();
     }
     tr.Close();
 }