Exemplo n.º 1
0
        private static double CalculationZr(HiddenLayerNeuron neuron, double[] x, int r)
        {
            var result = 0D;

            for (int j = 0; j < neuron.Q.GetLength(0); j++)
            {
                result += neuron.Q[j, r] * (x[j] - neuron.C[j]);
            }
            return(result);
        }
Exemplo n.º 2
0
 public HiddenLayer(int k, int n, List <double[]> centers)
 {
     ActivationW = 0.2;// tools.MathHelper.Rnd.NextDouble();
     K           = k; N = n;
     Neurons     = new HiddenLayerNeuron[k];
     for (int i = 0; i < k; i++)
     {
         Neurons[i] = new HiddenLayerNeuron(n, centers[i]);
     }
 }
Exemplo n.º 3
0
        private static double CalculationUi(HiddenLayerNeuron neuron, double[] x)
        {
            var result = 0D;

            for (int j = 0; j < neuron.Q.GetLength(0); j++)
            {
                result += Math.Pow(CalculationZr(neuron, x, j), 2);
            }

            return(result);
        }
Exemplo n.º 4
0
 public static double CalculateOut(this HiddenLayerNeuron neuron, double[] x)
 {
     if (neuron is HiddenLayerNeuron)
     {
         var v1 = neuron.Q.Dot(x.Sub(neuron.C));
         return(Math.Exp(COEF * v1.Dot(v1.Transpose())[0]));
     }
     else
     {
         return(1);
     }
 }
Exemplo n.º 5
0
        public RecogAkshaysPictureNetwork()
        {
            Globals.LearningRateForNeurons = (decimal)0.00000000000000000043368086899420177360298112034798;
            NeuralLayer rawInputLayer = new NeuralLayer();

            for (int i = 0; i < 1024 * 1024; i++)
            {
                RawInputLayerNeuron riln = new RawInputLayerNeuron((decimal)0, (decimal)2097152);
                rawInputLayer.AddNeuronToLayer(riln);
            }
            Layers.Add(rawInputLayer);
            NeuralLayer hiddenLayer = new NeuralLayer();

            for (int i = 0; i < 1024 * 1024; i++)
            {
                HiddenLayerNeuron hln = new HiddenLayerNeuron((decimal)2199023255552);
                hiddenLayer.AddNeuronToLayer(hln);
            }
            Layers.Add(hiddenLayer);
            foreach (HiddenLayerNeuron hln in hiddenLayer.LayerNeurons)
            {
                foreach (RawInputLayerNeuron riln in rawInputLayer.LayerNeurons)
                {
                    NeuralConnection nc = new NeuralConnection(riln, hln, (decimal)2097152);
                    hln.Inputs.Add(nc);
                    riln.Outputs.Add(nc);
                }
            }
            NeuralLayer          outputLayer = new NeuralLayer();
            RawOutputLayerNeuron roln        = new RawOutputLayerNeuron((decimal)2305843009213693952);

            foreach (HiddenLayerNeuron hln in hiddenLayer.LayerNeurons)
            {
                NeuralConnection nc = new NeuralConnection(hln, roln, (decimal)2199023255552);
                hln.Outputs.Add(nc);
                roln.Inputs.Add(nc);
            }
        }
Exemplo n.º 6
0
 public static double dEdQijr(this HiddenLayerNeuron neuron, double[] x, double error, int j, int r) =>
 - dEdWi(neuron, x, error) * neuron.W * (x[j] - neuron.C[j]) * CalculationZr(neuron, x, r);
Exemplo n.º 7
0
 public static double dEdCij(this HiddenLayerNeuron neuron, double error, double[] x, int j) =>
 - dEdWi(neuron, x, error) * neuron.W * neuron.Q.GetRow(j)
 .Select((t1, r) => t1 * CalculationZr(neuron, x, r))
 .Sum();
Exemplo n.º 8
0
 public static double dEdWi(this HiddenLayerNeuron neuron, double[] x, double error) =>
 Math.Exp(COEF * CalculationUi(neuron, x)) * error;
Exemplo n.º 9
0
 public void AddNeuronToLayer(HiddenLayerNeuron hln)
 {
     LayerNeurons.Add((object)hln);
 }