//---------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; } } }
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(); }
//---------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; } } }