public override void Evaluate(TrainingDatas td) { // I just realized I need the BP error function here // TODO: use proper cost function Parallel.ForEach(Species, new ParallelOptions() { MaxDegreeOfParallelism = Rng.Cores }, (Specie) => { // Loop through species Specie.Fitness = 0; for (int iTd = 0; iTd < td.Count; iTd++) { // Loop through training datas float[] pred = Specie.GetPrediction(td[iTd].Input); for (int i = 0; i < pred.Length; i++) { // Loop througo output neurons //float _cost = pred[i] && td[iTd].Target[i]; float _cost = Rng.FloatingAnd(pred[i], td[iTd].Target[i]); Specie.Fitness += _cost; } } }); }
public override void StartChaos(TrainingDatas tds, int mutationIteration = 3600) { for (int i = 0; i < mutationIteration; i++) { foreach (Tribe tribe in tribes) { tribe.Train(tds); } } }
public override void StartChaos(TrainingDatas tds, int mutationIteration = 3600) { for (int i = 0; i < mutationIteration; i++) { Parallel.ForEach(tribes, new ParallelOptions() { MaxDegreeOfParallelism = Rng.Cores }, (tribe) => { tribe.Train(tds); }); } }
public override void Train(TrainingDatas td, int mutationIteration = 3600) { for (int i = 0; i < 3600; i++) { Mutate(); } Evaluate(td); int purgeRNG = new Random().Next(1, 12); for (int i = 0; i < purgeRNG; i++) { Purge(); } Reproduce(); Evaluate(td); }
public override void Evaluate(TrainingDatas td) { for (int iSpecie = 0; iSpecie < Species.Count; iSpecie++) { // Loop through species Species[iSpecie].Fitness = 0; for (int iTd = 0; iTd < td.Count; iTd++) { // Loop through training datas float[] pred = Species[iSpecie].GetPrediction(td[iTd].Input); for (int i = 0; i < pred.Length; i++) { // Loop througo output neurons //float _cost = pred[i] && td[iTd].Target[i]; float _cost = Rng.FloatingAnd(pred[i], td[iTd].Target[i]); Species[iSpecie].Fitness += _cost; } } } }
/// <summary> /// Start Chaos /// </summary> /// <param name="td"></param> public abstract void Train(TrainingDatas td, int mutationIteration = 3600);
public abstract void Evaluate(TrainingDatas td);
public abstract void StartChaos(TrainingDatas tds, int mutationIteration = 3600);