Ejemplo n.º 1
0
        //async void test(int iter)
        //{
        //    var idx = pos % resultData.input.Count;

        //    var net = network.Clone();
        //    net.learningRate = network.learningRate;
        //    await Task.Run(() =>
        //    {
        //        try
        //        {
        //            var rmseTrain = CalcRMSE(net, trainData, 250) * KeypointData.origImgSize;
        //            var rmseTest = CalcRMSE(net, testData, 250) * KeypointData.origImgSize;

        //            zedTrain.Add(iter, rmseTrain);
        //            zedTrain.Sort((a, b) => a.X.CompareTo(b.X));
        //            zedTest.Add(iter, rmseTest);
        //            zedTest.Sort((a, b) => a.X.CompareTo(b.X));
        //            Console.WriteLine();
        //            Console.WriteLine("iteration: " + idx);
        //            Console.WriteLine("learning rate: " + net.learningRate);
        //            Console.WriteLine("train: " + rmseTrain);
        //            Console.WriteLine("test: " + rmseTest);
        //            Console.WriteLine();
        //        }
        //        catch (Exception e)
        //        {
        //            Console.WriteLine();
        //            Console.WriteLine(e);
        //            Console.WriteLine();
        //        }
        //    });



        //    // net.Save("network_" + iter + ".dat");
        //    clonedNet = net;


        //    zedGraphControl1.AxisChange();

        //    pos++;
        //    Refresh();
        //}

        void test(int iter)
        {
            var idx = pos % resultData.input.Count;

            var net = network.Clone();

            net.learningRate = network.learningRate;

            try
            {
                var rmseTrain = CalcRMSE(net, trainData, 250) * KeypointData.origImgSize;
                var rmseTest  = CalcRMSE(net, testData, 250) * KeypointData.origImgSize;

                zedTrain.Add(iter, rmseTrain);
                zedTrain.Sort((a, b) => a.X.CompareTo(b.X));
                zedTest.Add(iter, rmseTest);
                zedTest.Sort((a, b) => a.X.CompareTo(b.X));
                Console.WriteLine();
                Console.WriteLine("iteration: " + idx);
                Console.WriteLine("learning rate: " + net.learningRate);
                Console.WriteLine("train: " + rmseTrain);
                Console.WriteLine("test: " + rmseTest);
                Console.WriteLine();
            }
            catch (Exception e)
            {
                Console.WriteLine();
                Console.WriteLine(e);
                Console.WriteLine();
            }



            // net.Save("network_" + iter + ".dat");
            clonedNet = net;


            zedGraphControl1.AxisChange();

            pos++;
            Refresh();
        }