All Downloads are FREE. Search and download functionalities are using the official Maven repository.

optimization.GradientDescent Maven / Gradle / Ivy

package optimization;

import datasets.VectorDouble;
import utils.IterativeAlgorithmResult;
import datastructs.I2DDataSet;
import datastructs.IVector;
import maths.functions.IVectorRealFunction;

public class GradientDescent implements ISupervisedOptimizer {

    /**
     * Constructor
     */
    public GradientDescent(GDInput input){

        this.input = input;
    }


    /**
     * Optimize approximate function f on the given dataset and the
     * given labels. Derived classes specify the output
     */
    @Override
    public >> OutPutType  optimize(final DataSetType data, final VectorDouble y, IVectorRealFunction f){

        // compute the value of f with the current weights
        double jOld = this.input.errF.evaluate(data, y);
        double jCurr = 0.0;

        IVector coeffs = f.getCoeffs();

        while(this.input.iterationContorller.continueIterations()){

            //the gradients of the error function.
            VectorDouble jGrads = this.input.errF.gradients(data, y);

            // update the
            for(int c=0; c




© 2015 - 2024 Weber Informatics LLC | Privacy Policy