Newer
Older
Martin Beseda
committed
//
// Created by martin on 9.2.19.
//
#ifndef LIB4NEURO_LEVENBERGMARQUARDT_H
#define LIB4NEURO_LEVENBERGMARQUARDT_H
#include <memory>
#include "LearningMethod.h"
namespace lib4neuro {
enum LM_UPDATE_TYPE {
MARQUARDT,
QUADRATIC,
NIELSEN
};
/**
* Method implementing Levenberg-Marquardt optimization algorithm
*
* This version is described in the paper:
* Gavin, Henri. "The Levenberg-Marquardt method for nonlinear least squares curve-fitting problems."
* Department of Civil and Environmental Engineering, Duke University (2011): 1-15.
*/
class LevenbergMarquardt : public GradientLearningMethod {
private:
struct LevenbergMarquardtImpl;
std::shared_ptr<LevenbergMarquardtImpl> p_impl;
Martin Beseda
committed
public:
LevenbergMarquardt(int max_iters,

Michal Kravcenko
committed
unsigned long bs = 0,
Martin Beseda
committed
double tolerance=1e-2,
double tolerance_gradient=1e-3,
double tolerance_parameters=1e-3,
double LM_step_acceptance_threshold=1e-1,
double lambda_initial=1e-2,
double lambda_increase=11,
double lambda_decrease=9);
void optimize(ErrorFunction &ef, std::ofstream* ofs = nullptr);
Martin Beseda
committed
LM_UPDATE_TYPE update_type,
std::ofstream* ofs = nullptr);
Martin Beseda
committed
std::shared_ptr<std::vector<double>> get_parameters() override;
Martin Beseda
committed
~LevenbergMarquardt();
};
}
#endif //LIB4NEURO_LEVENBERGMARQUARDT_H