示例#1
0
        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;
                    }
                }
            });
        }
示例#2
0
 public override void StartChaos(TrainingDatas tds, int mutationIteration = 3600)
 {
     for (int i = 0; i < mutationIteration; i++)
     {
         foreach (Tribe tribe in tribes)
         {
             tribe.Train(tds);
         }
     }
 }
示例#3
0
 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);
         });
     }
 }
示例#4
0
        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);
        }
示例#5
0
        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;
                    }
                }
            }
        }
示例#6
0
 /// <summary>
 /// Start Chaos
 /// </summary>
 /// <param name="td"></param>
 public abstract void Train(TrainingDatas td, int mutationIteration  = 3600);
示例#7
0
 public abstract void Evaluate(TrainingDatas td);
示例#8
0
 public abstract void StartChaos(TrainingDatas tds, int mutationIteration  = 3600);