Skip to content
Snippets Groups Projects
GradientDescent.h 1.59 KiB
Newer Older
  • Learn to ignore specific revisions
  • /**
     * DESCRIPTION OF THE FILE
     *
     * @author Michal Kravčenko
     * @date 30.7.18 -
     */
    
    #ifndef INC_4NEURO_GRADIENTDESCENT_H
    #define INC_4NEURO_GRADIENTDESCENT_H
    
    
    David Vojtek's avatar
    David Vojtek committed
    #include "../settings.h"
    #include "../constants.h"
    #include "ILearningMethods.h"
    #include "../ErrorFunction/ErrorFunctions.h"
    
    David Vojtek's avatar
    David Vojtek committed
    namespace lib4neuro {
        class GradientDescent : public ILearningMethods {
    
    David Vojtek's avatar
    David Vojtek committed
        private:
    
    David Vojtek's avatar
    David Vojtek committed
            /**
             *
             */
            double tolerance;
    
    		double max_error;
    
    David Vojtek's avatar
    David Vojtek committed
            /**
             *
             */
            size_t restart_frequency;
    
    		size_t batch;
    
    		size_t iter_max;
    
    David Vojtek's avatar
    David Vojtek committed
    
            std::vector<double> *optimal_parameters;
    
            /**
             *
             * @param gamma
             * @param beta
             * @param c
             * @param grad_norm_prev
             * @param grad_norm
             * @param fi
             * @param fim
             */
            virtual void
    
            eval_step_size_mk(double &gamma, double beta, long double &c,long double grad_norm_prev,long double grad_norm, double fi,
    
    David Vojtek's avatar
    David Vojtek committed
                              double fim);
    
    
        public:
    
            /**
             *
             * @param epsilon
             */
    
            LIB4NEURO_API GradientDescent(double epsilon = 1e-3, size_t n_to_restart = 100, size_t batch = 0, size_t iter_max = 0, double max_error=1e-3);
    
    David Vojtek's avatar
    David Vojtek committed
    
            /**
             *
             */
            LIB4NEURO_API ~GradientDescent();
    
            /**
             *
             * @param ef
             */
            LIB4NEURO_API virtual void optimize(lib4neuro::ErrorFunction &ef);
    
            /**
             *
             * @return
             */
            LIB4NEURO_API virtual std::vector<double> *get_parameters();
    
    
        };
    
    }
    
    
    #endif //INC_4NEURO_GRADIENTDESCENT_H