Пример #1
0
        protected void CanOptimizeRosenbrock(OptimizerBase <float> optimizer)
        {
            var weight = new NeuroWeight <float>(Matrix <float> .Build.Dense(2, 1));

            //_output.WriteLine($"Rosenbrock: {Rosenbrock(weight.Weight)}");
            //_output.WriteLine(weight.Weight.ToMatrixString());

            var watch = new Stopwatch();

            watch.Start();
            for (int i = 0; i < 10000; i++)
            {
                RosenbrockGrad(weight.Weight, weight.Gradient);
                optimizer.Optimize(weight);
                //_output.WriteLine($"Rosenbrock: {Rosenbrock(weight.Weight)}");
                //_output.WriteLine(weight.Weight.ToMatrixString());
            }
            watch.Stop();

            double result = Rosenbrock(weight.Weight);

            result.ShouldBeLessThanOrEqualTo(6e-5);

            _output.WriteLine($"Rosenbrock: {result}");
            _output.WriteLine($"Optimized in {watch.Elapsed}");
        }
Пример #2
0
        public override void Optimize(OptimizerBase <T> optimizer)
        {
            optimizer.Optimize(_bxr);
            optimizer.Optimize(_bxz);
            optimizer.Optimize(_bxh);

            optimizer.Optimize(_bhr);
            optimizer.Optimize(_bhz);
            optimizer.Optimize(_bhh);

            optimizer.Optimize(_wxr);
            optimizer.Optimize(_wxz);
            optimizer.Optimize(_wxh);

            optimizer.Optimize(_whr);
            optimizer.Optimize(_whz);
            optimizer.Optimize(_whh);
        }
Пример #3
0
 public override void Optimize(OptimizerBase <T> optimizer)
 {
     optimizer.Optimize(_weights);
     optimizer.Optimize(_bias);
 }