Exemplo n.º 1
0
        public static void Run()
        {
            //目標とするフィルタを作成(実践であればココは不明な値となる)
            Deconvolution2D decon_core = new Deconvolution2D(1, 1, 15, 1, 7, gpuEnable: true)
            {
                Weight = { Data = MakeOneCore() }
            };

            Deconvolution2D model = new Deconvolution2D(1, 1, 15, 1, 7, gpuEnable: true);

            SGD optimizer = new SGD(learningRate: 0.00005); //大きいと発散する

            model.SetOptimizer(optimizer);
            MeanSquaredError meanSquaredError = new MeanSquaredError();

            //移植元では同じ教育画像で教育しているが、より実践に近い学習に変更
            for (int i = 0; i < 11; i++)
            {
                //ランダムに点が打たれた画像を生成
                NdArray img_p = getRandomImage();

                //目標とするフィルタで学習用の画像を出力
                NdArray[] img_core = decon_core.Forward(img_p);

                //未学習のフィルタで画像を出力
                NdArray[] img_y = model.Forward(img_p);

                Real loss = meanSquaredError.Evaluate(img_y, img_core);

                model.Backward(img_y);
                model.Update();

                Console.WriteLine("epoch" + i + " : " + loss);
            }
        }
Exemplo n.º 2
0
        public static void Run()
        {
            // Create a target filter (In case of practice, here is the unknown value)
            Deconvolution2D decon_core = new Deconvolution2D(true, 1, 1, 15, 1, 7, gpuEnable: true)
            {
                Weight = { Data = MakeOneCore() }
            };

            Deconvolution2D model = new Deconvolution2D(true, 1, 1, 15, 1, 7, gpuEnable: true);

            SGD optimizer = new SGD(learningRate: 0.00005); // diverge if big

            model.SetOptimizer(optimizer);
            MeanSquaredError meanSquaredError = new MeanSquaredError();

            // I am educating with the same educational image at the transplanting source, but changing to learning closer to practice
            for (int i = 0; i < 11; i++)
            {
                // Generate an image with randomly struck points
                NdArray img_p = getRandomImage();

                // Output a learning image with a target filter
                NdArray[] img_core = decon_core.Forward(true, img_p);

                // Output an image with an unlearned filter
                NdArray[] img_y = model.Forward(true, img_p);

                Real loss = meanSquaredError.Evaluate(img_y, img_core);

                model.Backward(true, img_y);
                model.Update();

                RILogManager.Default?.SendDebug("epoch" + i + " : " + loss);
            }
        }
Exemplo n.º 3
0
        public static void Run()
        {
            //Create a target filter (If it is practical, here is an unknown value)
            Deconvolution2D decon_core = new Deconvolution2D(1, 1, 15, 1, 7, gpuEnable: true)
            {
                Weight = { Data = MakeOneCore() }
            };

            Deconvolution2D model = new Deconvolution2D(1, 1, 15, 1, 7, gpuEnable: true);

            SGD optimizer = new SGD(learningRate: 0.00005); //When it is big, it diverges.

            model.SetOptimizer(optimizer);
            MeanSquaredError meanSquaredError = new MeanSquaredError();

            //At the transplant source, we are educating with the same educational image, but changing to learning closer to practice
            for (int i = 0; i < 11; i++)
            {
                //Generate random dotted images
                NdArray img_p = getRandomImage();

                //Output a learning image with a target filter
                NdArray[] img_core = decon_core.Forward(img_p);

                //Output an image with an unlearned filter
                NdArray[] img_y = model.Forward(img_p);

                Real loss = meanSquaredError.Evaluate(img_y, img_core);

                model.Backward(img_y);
                model.Update();

                Console.WriteLine("epoch" + i + " : " + loss);
            }
        }
Exemplo n.º 4
0
        public Test13WinForm()
        {
            InitializeComponent();

            ClientSize = new Size(128 * 4, 128 * 4);

            //目標とするフィルタを作成(実践であればココは不明な値となる)
            decon_core = new Deconvolution2D(1, 1, 15, 1, 7, gpuEnable: true)
            {
                Weight = { Data = MakeOneCore() }
            };

            model = new Deconvolution2D(1, 1, 15, 1, 7, gpuEnable: true);

            optimizer = new SGD(learningRate: 0.01); //大きいと発散する
            model.SetOptimizer(optimizer);
        }
Exemplo n.º 5
0
        public Test13WinForm()
        {
            InitializeComponent();

            ClientSize = new Size(128 * 4, 128 * 4);

            // Create a target filter (In case of practice, here is the unknown value)
            decon_core = new Deconvolution2D(true, 1, 1, 15, 1, 7, gpuEnable: true)
            {
                Weight = { Data = MakeOneCore() }
            };

            model = new Deconvolution2D(true, 1, 1, 15, 1, 7, gpuEnable: true);

            optimizer = new SGD(learningRate: 0.01); // diverge if big
            model.SetOptimizer(optimizer);
        }