Esempio n. 1
0
 private async Task PerformLearning(DataSet data, Network network)
 {
     await Task.Run(() =>
     {
         List <float> errorHistory = new List <float>();
         Random rand = new Random(network.Seed);
         for (int i = 0; i < network.Iterations; i++)
         {
             float error = 0.0f;
             error       = LearningHelper.Learn(network, data);
             LearningHelper.RandomizeSet(rand, data);
             Console.WriteLine("-----------------------------------------");
             Console.WriteLine("Epoka " + i + " / " + network.Iterations);
             Console.WriteLine("Error " + error + " %");
             errorHistory.Add(error);
         }
         errorsHistory = errorHistory;
     });
 }
Esempio n. 2
0
        private async Task PerformLearning(DataSet data, Network network, string dir, int index)
        {
            await Task.Run(() =>
            {
                List <float> errorHistory = new List <float>();
                Random rand = new Random(network.Seed);
                Logger(network.ToString(), dir);
                for (int i = 0; i < network.Iterations; i++)
                {
                    float error = 0.0f;
                    error       = LearningHelper.Learn(network, data);
                    LearningHelper.RandomizeSet(rand, data);
                    string txt   = "";
                    txt         += "-----------------------------------------" + Environment.NewLine;
                    string timer = string.Format("{0:dd.MM.yyyy_hh:mm:ss}",
                                                 DateTime.Now);
                    txt += timer + Environment.NewLine;
                    txt += "Epoka " + i + " / " + network.Iterations + Environment.NewLine;
                    txt += "Mean Squared Error " + error + " %" + Environment.NewLine;
                    Logger(txt, dir);

                    errorHistory.Add(error);
                }
                errorsHistory = errorHistory;

                float testingError = TestingHelper.GetTestingSetError(network, new DataSet(unknownSet, network.Classes));
                string txt2        = "";
                txt2         += "-----------------------------------------" + Environment.NewLine;
                txt2         += "------------FINAL TESTING ERROR----------" + Environment.NewLine;
                txt2         += "-----------------------------------------" + Environment.NewLine;
                string timer2 = string.Format("{0:dd.MM.yyyy_hh:mm:ss}",
                                              DateTime.Now);
                txt2 += timer2 + Environment.NewLine;
                txt2 += "Testing Error " + testingError + "%" + Environment.NewLine;
                Logger(txt2, dir);

                Console.WriteLine("-----------------------------------------------------");
                Console.WriteLine(timer2 + ": test " + index + " przeprowadzono");
            });
        }