Ejemplo n.º 1
0
        public virtual double[] Minimize(IDiffFunction function, double functionTolerance, double[] initial, int maxIterations)
        {
            Sayln("SGDToQNMinimizer called on function of " + function.DomainDimension() + " variables;");
            // check for stochastic derivatives
            if (!(function is AbstractStochasticCachingDiffFunction))
            {
                throw new NotSupportedException();
            }
            AbstractStochasticCachingDiffFunction dfunction = (AbstractStochasticCachingDiffFunction)function;

            dfunction.method = StochasticCalculateMethods.GradientOnly;
            ScaledSGDMinimizer sgd = new ScaledSGDMinimizer(this.gain, this.bSize, this.SGDPasses, 1, this.outputIterationsToFile);
            QNMinimizer        qn  = new QNMinimizer(this.QNMem, true);

            double[]           x      = sgd.Minimize(dfunction, functionTolerance, initial, this.SGDPasses);
            QNMinimizer.QNInfo qnInfo = new QNMinimizer.QNInfo(this, sgd.sList, sgd.yList);
            qnInfo.d = sgd.diag;
            qn.Minimize(dfunction, functionTolerance, x, this.QNPasses, qnInfo);
            log.Info(string.Empty);
            log.Info("Minimization complete.");
            log.Info(string.Empty);
            log.Info("Exiting for Debug");
            return(x);
        }
Ejemplo n.º 2
0
 public SetFixedGain(ScaledSGDMinimizer <Q> _enclosing, ScaledSGDMinimizer min)
 {
     this._enclosing = _enclosing;
     this.parent     = min;
 }