Beispiel #1
0
        //---------MAIN LOOP-------------------//

        public void run(int iterations, PerfGraph graph, bool useGraph)
        {
            for (int i = 0; i < weights.Length; i++)
            {
                initialWeights[i] = weights[i];
            }
            for (int i = 0; i < nodes.Count; i++)
            {
                for (int j = 0; j < nodes[i].weights.Length; j++)
                {
                    initialNodeWeights[i, j] = nodes[i].weights[j];
                }
            }
            for (int i = 0; i < iterations; i++)
            {
                bool done = true;
                graph.updateLabel_individual("MLP on epoch:" + i);
                for (int j = 0; (j < inputs.Count); j++)
                {
                    setNodeOutputs(j);
                    setOutput(j);

                    setOutputError(j);
                    setNodeErrors(j);

                    changeOutputWeights(j);
                    changeInputWeights(j);
                    if (useGraph)
                    {
                        graph.updateRates(inputs[j].expectedOutput, inputs[j].output);
                        //Console.WriteLine(inputs[j].error);
                    }
                    if (Math.Abs(inputs[j].error) > 0.01)
                    {
                        done = false;
                    }
                }

                if (useGraph)
                {
                    graph.updateMSE(meanSquaredError());
                }
                if (done)
                {
                    break;
                }
            }
        }
Beispiel #2
0
 public EvolutionMgr(PerfGraph graph, string file, bool evolveWeights, bool evolveFunction, int popSize, int iterations, double mutationRate, double crossoverRate, int minWeight, int maxWeight, bool useGraph)
 {
     this.file           = file;
     this.popSize        = popSize;
     this.iterations     = iterations;
     this.mutationRate   = mutationRate;
     this.crossoverRate  = crossoverRate;
     this.minWeight      = minWeight;
     this.maxWeight      = maxWeight;
     this.evolveFunction = evolveFunction;
     this.evolveWeights  = evolveWeights;
     this.graph          = graph;
     this.useGraph       = useGraph;
     initMLP();
     calculatePopToEvolve();
 }
Beispiel #3
0
        //---------MAIN LOOP-------------------//
        public void run(int iterations, PerfGraph graph, bool useGraph)
        {
            for (int i = 0; i < weights.Length; i++)
            {
                initialWeights[i] = weights[i];
            }
            for(int i = 0; i < nodes.Count; i++)
            {
                for(int j = 0; j< nodes[i].weights.Length; j++)
                {
                    initialNodeWeights[i, j] = nodes[i].weights[j];
                }
            }
            for(int i = 0; i < iterations; i ++)
            {
                bool done = true;
                graph.updateLabel_individual("MLP on epoch:" + i);
                for (int j = 0; (j<inputs.Count); j++)
                {
                    setNodeOutputs(j);
                    setOutput(j);

                    setOutputError(j);
                    setNodeErrors(j);

                    changeOutputWeights(j);
                    changeInputWeights(j);
                    if (useGraph)
                    {
                        graph.updateRates(inputs[j].expectedOutput, inputs[j].output);
                        //Console.WriteLine(inputs[j].error);
                    }
                        if (Math.Abs(inputs[j].error) > 0.01)
                    {
                        done = false;
                    }
                }

                if (useGraph)
                {
                    graph.updateMSE(meanSquaredError());
                }
                if (done)
                {
                    break;
                }
            }
        }