Ejemplo n.º 1
0
        public static void TestSpeedGetData()
        {
            var tmp = new np4load(@"..\..\..\NeuralNetworks\Cardiology\инфаркт_миокарда.np4");

            Console.WriteLine("Executing sequential loop...");
            Stopwatch stopwatch = new Stopwatch();
            stopwatch.Start();
            var data1 = tmp.GetTrainingDataNotParallel();
            stopwatch.Stop();
            Console.WriteLine("Sequential loop time in milliseconds: {0}", stopwatch.ElapsedMilliseconds);

            // Reset timer and results matrix.
            stopwatch.Reset();

            // Do the parallel loop.
            Console.WriteLine("Executing parallel loop...");
            stopwatch.Start();
            var data2 = tmp.GetTrainingData();
            stopwatch.Stop();
            Console.WriteLine("Parallel loop time in milliseconds: {0}", stopwatch.ElapsedMilliseconds);

            // Keep the console window open in debug mode.
            Console.WriteLine("Press any key to exit.");
            Console.ReadKey();
        }
Ejemplo n.º 2
0
 public static void GetAllWeidtg()
 {
     var tmp = new np4load(@"..\..\..\NeuralNetworks\Cardiology\инфаркт_миокарда.np4");
     var neuralNet = tmp.GetNeuralNetwork();
     var w = tmp.GetWeigth();
     neuralNet.DecodeFromArray(w);
 }
Ejemplo n.º 3
0
        private void cbTrainsLog_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (cbTrainsLog.SelectedItem != null)
            {
                InitEvent ie = cbTrainsLog.SelectedItem as InitEvent;
                //ist<int> ageNum = new List<int>(ie.IterationCount);
                //int[] ageNum2 = new int[ie.IterationCount];
                //Parallel.For(1, ie.IterationCount+1, i => ageNum2[i-1] = i);
                //for (int i = 1; i <= ie.IterationCount; i++)
                //    ageNum.Add(i);
                iterations = rep.GetIteration(ie.Sid).OrderBy(x => x.AgeNumber);
                cbAgeNumber.ItemsSource = iterations;

                currentXmlNet = new np4load(ie.Path);
                neuralNetIter = currentXmlNet.GetNeuralNetwork();
                trainingData = currentXmlNet.GetTrainingData();
                graphIterations = null;
                testD.ClearAll();
                pairDiagram.ClearAll();
            }
        }
Ejemplo n.º 4
0
        public static void TrainNet()
        {
            var tmp = new np4load(@"..\..\..\NeuralNetworks\Cardiology\инфаркт_миокарда.np4");

            TrainLogger tLog = TrainLogger.GetTrainLogger();

            Dictionary<string, object> dLog = new Dictionary<string, object>();

            var stopParam = tmp.GetTrainingStopParams();
            int iterCount = 2500;//13943;

            dLog.Add("event", "init");
            dLog.Add("NeuralNetName", "инфаркт_миокарда.np4");
            dLog.Add("Path", @"..\..\..\NeuralNetworks\Cardiology\инфаркт_миокарда.np4");
            dLog.Add("Анкета", "Кардиология");
            dLog.Add("IterationCount", iterCount);
            dLog.Add("Time", DateTime.Now);

            BasicMLDataSet tData = (BasicMLDataSet) tmp.GetTrainingData();
            dLog.Add("TrainDataSize", tData.Count);
            //записать входные данные и проскалированные
            tLog.WriteEvent(dLog);

            BasicNetwork neuralNet = tmp.GetNeuralNetwork();

            MediatorNsimLinearScale scale = new MediatorNsimLinearScale();
            DataProcessorConf dp = tmp.GetDataProcessor();
            scale.DataProcessorM(dp);

            //SearchHashForm search = new SearchHashForm();
            //Guid[] gidForm = search.GetGIDForm(tData);

            BasicMLDataSet tDataScale = scale.ProcessDataSet(tData);

            IMLTrain trainMetod;
            switch (tmp.GetNameTrainMetod())
            {
                case "ResilientPropagation":
                    {
                        trainMetod = new ResilientPropagation(neuralNet, tDataScale);
                        break;
                    }
                default:
                    {
                        trainMetod = new ResilientPropagation(neuralNet, tDataScale);
                        break;
                    }
            }

            //trainMetod.Iteration(stopParam.Iterations);

            trainMetod.Iteration(iterCount);
            //var arrWeight = neuralNet.DumpWeights().Split(',');

            //using (FileLogger fl = FileLogger.GetLogger())
            //{
            //    fl.WriteString(neuralNet.DumpWeights());
            //    for (int i = 0; i < tDataScale.Data.Count; i++)//var item in tDataScale.Data)
            //    {
            //        fl.WriteString("Входной вектор: " + GetString(tData.Data[i].InputArray));

            //        var res = neuralNet.Compute(tDataScale.Data[i].Input);

            //        fl.WriteString("Результат: " + GetString(res.Data));

            //        var sRes = scale.RestoreIdealVector(res);

            //        fl.WriteString("Результат востановленный: " + GetString(sRes.Data));
            //        fl.WriteString("\n");
            //    }
            //}

            trainMetod.FinishTraining();
            //int countW = neuralNet.EncodedArrayLength();
            //double[] w = new double[countW];
            //neuralNet.EncodeToArray(w);

            Console.WriteLine("!!!");
            //for (int i = 0; i < stopParam.Iterations; i++)
            //{
            //    trainMetod.Iteration(
            //}
        }