コード例 #1
0
        public double LearnIteration(FullMesh <T> net, T[][] input, T[][] output, double switchThreshold)
        {
            double temp;
            int    x   = GlobalRandom.Get.Next(0, net.Neurons.Count);
            int    y   = GlobalRandom.Get.Next(0, net.Neurons[x].Count);
            int    w   = GlobalRandom.Get.Next(0, net.Neurons[x][y].Weights.Count);
            T      old = net.Neurons[x][y].Weights[w];

            net.Neurons[x][y].Weights[w] = Permutater(net.Neurons[x][y].Weights[w]);
            temp = net.GetError(input.Select(i => net.Calc(i)).ToArray(), output);

            if (temp - net.LastError < switchThreshold)
            {
                Console.WriteLine("new Error : " + temp);
                return(temp);
            }
            else
            {
                net.Neurons[x][y].Weights[w] = old;
                return(net.LastError);
            }
        }
コード例 #2
0
        public double LearnIteration(FullMesh <T> net, T[][] input, T[][] output, double switchThreshold = -0.1)
        {
            double lastError = net.LastError;
            double temp      = 0;

            foreach (List <Neuron <T> > l in net.Neurons)
            {
                if (PrintProgress)
                {
                    Console.WriteLine("new Layer");
                }
                for (int i = 0; i < InnerIterations; i++)
                {
                    int y   = GlobalRandom.Get.Next(0, l.Count);
                    int w   = GlobalRandom.Get.Next(0, l[y].Weights.Count);
                    T   old = l[y].Weights[w];
                    l[y].Weights[w] = Permutater(l[y].Weights[w]);
                    T[][] c = input.Select(t => net.Calc(t)).ToArray();
                    temp = net.GetError(c, output);
                    if (!(temp - lastError < switchThreshold))
                    {
                        l[y].Weights[w] = old;
                    }
                    else
                    {
                        lastError = temp;
                        if (PrintProgress)
                        {
                            Console.WriteLine("new Error : " + temp);
                        }
                    }
                }
            }
            if (PrintProgress)
            {
                Console.WriteLine("finished");
            }
            return(lastError);
        }
コード例 #3
0
ファイル: BruteForce.cs プロジェクト: Cyberworm3285/NeuroNet2
        public double LearnIteration(FullMesh <T> net, T[][] input, T[][] output, double switchThreshold)
        {
            double lastError = net.LastError;
            int    counter   = 1;

            while (lastError > switchThreshold)
            {
                int x = GlobalRandom.Get.Next(0, net.Neurons.Count);
                int y = GlobalRandom.Get.Next(0, net.Neurons[x].Count);
                int w = GlobalRandom.Get.Next(0, net.Neurons[x][y].Weights.Count);
                net.Neurons[x][y].Weights[w]        = Permutater(net.Neurons[x][y].Weights[w]);
                net.Neurons[x][y].WeightingFunction = WeightingChanging();
                lastError = net.GetError(input.Select(i => net.Calc(i)).ToArray(), output);
                if (PrintProgress)
                {
                    Console.WriteLine(counter++ + ": Curr Error : " + lastError);
                }
            }
            if (PrintProgress)
            {
                Console.WriteLine("finished");
            }
            return(lastError);
        }