Loading README.md +0 −2 Original line number Diff line number Diff line Loading @@ -72,8 +72,6 @@ int main() // There are ConstantStepSize, BarzilaiBorwein and // WolfeBacktracking available. (Default is BarzilaiBorwein) // // You can additionally specify a Callback functor as template parameter. // // You can additionally specify a FiniteDifferences functor as template // parameter. There are Forward-, Backward- and CentralDifferences // available. (Default is CentralDifferences) Loading examples/ackley.cpp +0 −2 Original line number Diff line number Diff line Loading @@ -33,8 +33,6 @@ int main() // There are ConstantStepSize, BarzilaiBorwein and // WolfeBacktracking available. (Default is BarzilaiBorwein) // // You can additionally specify a Callback functor as template parameter. // // You can additionally specify a FiniteDifferences functor as template // parameter. There are Forward-, Backward- and CentralDifferences // available. (Default is CentralDifferences) Loading examples/paraboloid.cpp +0 −2 Original line number Diff line number Diff line Loading @@ -28,8 +28,6 @@ int main() // There are ConstantStepSize, BarzilaiBorwein and // WolfeBacktracking available. (Default is BarzilaiBorwein) // // You can additionally specify a Callback functor as template parameter. // // You can additionally specify a FiniteDifferences functor as template // parameter. There are Forward-, Backward- and CentralDifferences // available. (Default is CentralDifferences) Loading include/gdcpp.h +4 −18 Original line number Diff line number Diff line Loading @@ -208,21 +208,6 @@ namespace gdc } }; /** Dummy callback functor, which does nothing. */ template<typename Scalar> struct NoCallback { using Vector = TNL::Containers::Vector<Scalar, TNL::Devices::Host, Index>; bool operator()(const Index, const Vector &, const Scalar, const Vector &) const { return true; } }; /** Step size functor, which returns a constant step size. */ template<typename Scalar> class ConstantStepSize Loading Loading @@ -691,12 +676,12 @@ namespace gdc template<typename Scalar, typename Objective, typename StepSize=BarzilaiBorwein<Scalar>, typename Callback=NoCallback<Scalar>, typename FiniteDifferences=CentralDifferences<Scalar>> class GradientDescent { public: using Vector = TNL::Containers::Vector<Scalar, TNL::Devices::Host, Index>; using Callback = std::function<bool(Index iterations, const Vector & xval, Scalar fval, const Vector & gradient)>; struct Result { Loading Loading @@ -846,6 +831,7 @@ namespace gdc step = momentum_ * step + (1 - momentum_) * stepSize * gradient; stepLen = TNL::l2Norm(step); // evaluate callback an save its result if(callback_) callbackResult = callback_(iterations, xval, fval, gradient); if(verbosity_ > 0) Loading @@ -858,7 +844,7 @@ namespace gdc << " stepsize=" << stepSize << " steplen=" << stepLen; if(verbosity_ > 2) if(callback_ && verbosity_ > 2) ss << " callback=" << (callbackResult ? "true" : "false"); ss << " fval=" << fval; Loading Loading
README.md +0 −2 Original line number Diff line number Diff line Loading @@ -72,8 +72,6 @@ int main() // There are ConstantStepSize, BarzilaiBorwein and // WolfeBacktracking available. (Default is BarzilaiBorwein) // // You can additionally specify a Callback functor as template parameter. // // You can additionally specify a FiniteDifferences functor as template // parameter. There are Forward-, Backward- and CentralDifferences // available. (Default is CentralDifferences) Loading
examples/ackley.cpp +0 −2 Original line number Diff line number Diff line Loading @@ -33,8 +33,6 @@ int main() // There are ConstantStepSize, BarzilaiBorwein and // WolfeBacktracking available. (Default is BarzilaiBorwein) // // You can additionally specify a Callback functor as template parameter. // // You can additionally specify a FiniteDifferences functor as template // parameter. There are Forward-, Backward- and CentralDifferences // available. (Default is CentralDifferences) Loading
examples/paraboloid.cpp +0 −2 Original line number Diff line number Diff line Loading @@ -28,8 +28,6 @@ int main() // There are ConstantStepSize, BarzilaiBorwein and // WolfeBacktracking available. (Default is BarzilaiBorwein) // // You can additionally specify a Callback functor as template parameter. // // You can additionally specify a FiniteDifferences functor as template // parameter. There are Forward-, Backward- and CentralDifferences // available. (Default is CentralDifferences) Loading
include/gdcpp.h +4 −18 Original line number Diff line number Diff line Loading @@ -208,21 +208,6 @@ namespace gdc } }; /** Dummy callback functor, which does nothing. */ template<typename Scalar> struct NoCallback { using Vector = TNL::Containers::Vector<Scalar, TNL::Devices::Host, Index>; bool operator()(const Index, const Vector &, const Scalar, const Vector &) const { return true; } }; /** Step size functor, which returns a constant step size. */ template<typename Scalar> class ConstantStepSize Loading Loading @@ -691,12 +676,12 @@ namespace gdc template<typename Scalar, typename Objective, typename StepSize=BarzilaiBorwein<Scalar>, typename Callback=NoCallback<Scalar>, typename FiniteDifferences=CentralDifferences<Scalar>> class GradientDescent { public: using Vector = TNL::Containers::Vector<Scalar, TNL::Devices::Host, Index>; using Callback = std::function<bool(Index iterations, const Vector & xval, Scalar fval, const Vector & gradient)>; struct Result { Loading Loading @@ -846,6 +831,7 @@ namespace gdc step = momentum_ * step + (1 - momentum_) * stepSize * gradient; stepLen = TNL::l2Norm(step); // evaluate callback an save its result if(callback_) callbackResult = callback_(iterations, xval, fval, gradient); if(verbosity_ > 0) Loading @@ -858,7 +844,7 @@ namespace gdc << " stepsize=" << stepSize << " steplen=" << stepLen; if(verbosity_ > 2) if(callback_ && verbosity_ > 2) ss << " callback=" << (callbackResult ? "true" : "false"); ss << " fval=" << fval; Loading