This class offers methods for the usage of the Resilient-Backpropagation-algorithm with/out weight-backtracking. More...

#include <shark/Algorithms/GradientDescent/Rprop.h>

+ Inheritance diagram for shark::Rprop< SearchPointType >:

Public Types

typedef AbstractObjectiveFunction< SearchPointType, double > ObjectiveFunctionType
 
- Public Types inherited from shark::AbstractSingleObjectiveOptimizer< PointType >
typedef base_type::SearchPointType SearchPointType
 
typedef base_type::SolutionType SolutionType
 
typedef base_type::ResultType ResultType
 
typedef base_type::ObjectiveFunctionType ObjectiveFunctionType
 
- Public Types inherited from shark::AbstractOptimizer< PointType, double, SingleObjectiveResultSet< PointType > >
enum  Feature
 Models features that the optimizer requires from the objective function. More...
 
typedef PointType SearchPointType
 
typedef double ResultType
 
typedef SingleObjectiveResultSet< PointType > SolutionType
 
typedef AbstractObjectiveFunction< PointType, ResultTypeObjectiveFunctionType
 
typedef TypedFlags< FeatureFeatures
 
typedef TypedFeatureNotAvailableException< FeatureFeatureNotAvailableException
 

Public Member Functions

 Rprop ()
 
std::string name () const
 From INameable: return the class name.
 
void init (ObjectiveFunctionType const &objectiveFunction, SearchPointType const &startingPoint)
 
void init (ObjectiveFunctionType const &objectiveFunction, SearchPointType const &startingPoint, double initDelta)
 
void step (ObjectiveFunctionType const &objectiveFunction)
 
virtual void read (InArchive &archive)
 Read the component from the supplied archive.
 
virtual void write (OutArchive &archive) const
 Write the component to the supplied archive.
 
void setEtaMinus (double etaMinus)
 set decrease factor
 
void setEtaPlus (double etaPlus)
 set increase factor
 
void setMaxDelta (double d)
 set upper limit on update
 
void setMinDelta (double d)
 set lower limit on update
 
void setUseOldValue (bool useOldValue)
 
void setUseFreezing (bool useFreezing)
 
void setUseBacktracking (bool useBacktracking)
 
double maxDelta () const
 return the maximal step size component
 
SearchPointType const & derivative () const
 Returns the derivative at the current point. Can be used for stopping criteria.
 
- Public Member Functions inherited from shark::AbstractSingleObjectiveOptimizer< PointType >
std::size_t numInitPoints () const
 By default most single objective optimizers only require a single point.
 
virtual void init (ObjectiveFunctionType const &function, std::vector< SearchPointType > const &initPoints)
 Initialize the optimizer for the supplied objective function using a set of initialisation points.
 
virtual void init (ObjectiveFunctionType const &function, SearchPointType const &startingPoint)=0
 initializes the optimizer using a predefined starting point
 
virtual const SolutionTypesolution () const
 returns the current solution of the optimizer
 
- Public Member Functions inherited from shark::AbstractOptimizer< PointType, double, SingleObjectiveResultSet< PointType > >
const Featuresfeatures () const
 
virtual void updateFeatures ()
 
bool requiresValue () const
 
bool requiresFirstDerivative () const
 
bool requiresSecondDerivative () const
 
bool canSolveConstrained () const
 
bool requiresClosestFeasible () const
 
virtual ~AbstractOptimizer ()
 
virtual void init (ObjectiveFunctionType const &function)
 Initialize the optimizer for the supplied objective function.
 
virtual void step (ObjectiveFunctionType const &function)=0
 Carry out one step of the optimizer for the supplied objective function.
 
- Public Member Functions inherited from shark::INameable
virtual ~INameable ()
 
- Public Member Functions inherited from shark::ISerializable
virtual ~ISerializable ()
 Virtual d'tor.
 
void load (InArchive &archive, unsigned int version)
 Versioned loading of components, calls read(...).
 
void save (OutArchive &archive, unsigned int version) const
 Versioned storing of components, calls write(...).
 
 BOOST_SERIALIZATION_SPLIT_MEMBER ()
 

Protected Attributes

SearchPointType m_derivative
 
double m_increaseFactor
 The increase factor \( \eta^+ \), set to 1.2 by default.
 
double m_decreaseFactor
 The decrease factor \( \eta^- \), set to 0.5 by default.
 
double m_maxDelta
 The upper limit of the increments \( \Delta w_i^{(t)} \), set to 1e100 by default.
 
double m_minDelta
 The lower limit of the increments \( \Delta w_i^{(t)} \), set to 0.0 by default.
 
double m_oldValue
 The last function value observed.
 
size_t m_parameterSize
 
SearchPointType m_oldDerivative
 The last error gradient.
 
SearchPointType m_deltaw
 the step eprformed last. used for weight backtracking
 
SearchPointType m_delta
 The absolute update values (increment) for all weights.
 
bool m_useFreezing
 
bool m_useBacktracking
 
bool m_useOldValue
 
- Protected Attributes inherited from shark::AbstractSingleObjectiveOptimizer< PointType >
SolutionType m_best
 Current solution of the optimizer.
 
- Protected Attributes inherited from shark::AbstractOptimizer< PointType, double, SingleObjectiveResultSet< PointType > >
Features m_features
 

Additional Inherited Members

- Protected Member Functions inherited from shark::AbstractOptimizer< PointType, double, SingleObjectiveResultSet< PointType > >
void checkFeatures (ObjectiveFunctionType const &objectiveFunction)
 Convenience function that checks whether the features of the supplied objective function match with the required features of the optimizer.
 

Detailed Description

template<class SearchPointType = RealVector>
class shark::Rprop< SearchPointType >

This class offers methods for the usage of the Resilient-Backpropagation-algorithm with/out weight-backtracking.

The Rprop algorithm is an improvement of the algorithms with adaptive learning rates, which use increments for the update of the weights which are independent from the absolute partial derivatives. This makes sense, because large flat regions in the search space (plateaus) lead to small absolute partial derivatives and so the increments are chosen small, but the increments should be large to skip the plateau. In contrast, the absolute partial derivatives are very large at the "slopes" of very "narrow canyons", which leads to large increments that will skip the minimum lying at the bottom of the canyon, but it would make more sense to chose small increments to hit the minimum.

So, the Rprop algorithm only uses the signs of the partial derivatives and not the absolute values to adapt the parameters.
Instead of individual learning rates, it uses the parameter \(\Delta_i^{(t)}\) for weight \(w_i,\ i = 1, \dots, n\) in iteration \(t\), where the parameter will be adapted before the change of the weights:

\( \Delta_i^{(t)} = \Bigg\{ \begin{array}{ll} min( \eta^+ \cdot \Delta_i^{(t-1)}, \Delta_{max} ), & \mbox{if\ } \frac{\partial E^{(t-1)}}{\partial w_i} \cdot \frac{\partial E^{(t)}}{\partial w_i} > 0 \\ max( \eta^- \cdot \Delta_i^{(t-1)}, \Delta_{min} ), & \mbox{if\ } \frac{\partial E^{(t-1)}}{\partial w_i} \cdot \frac{\partial E^{(t)}}{\partial w_i} < 0 \\ \Delta_i^{(t-1)}, & \mbox{otherwise} \end{array} \)

The parameters \(\eta^+ > 1\) and \(0 < \eta^- < 1\) control the speed of the adaptation. To stabilize the increments, they are restricted to the interval \([\Delta_{min}, \Delta_{max}]\).
After the adaptation of the \(\Delta_i\) the update for the weights will be calculated as

\( \Delta w_i^{(t)} := - \mbox{sign} \left( \frac{\partial E^{(t)}}{\partial w_i}\right) \cdot \Delta_i^{(t)} \)

There are several variants of the algorithm depending on what happens when the optimum is overstepped, i.e. a sign change of the gradient occurs and/or the new objective value is larger than the old.

Weight-backtracking can be used to increase the stability of the method. if \(\frac{\partial E^{(t-1)}}{\partial w_i} \cdot \frac{\partial E^{(t)}}{\partial w_i} < 0\) then \(\Delta w_i^{(t)} := - \Delta w_i^{(t-1)}\). This heuristic can be improved by further taking the value of the last iteration into ccount: only undo an updated if the sign changed and the new function value is worse than the last. The idea of this modification is, that a change of the sign of the partial derivation \(\frac{\partial E}{\partial w_i}\) only states, that a minimum was skipped and not, whether this step lead to an approach to the minimum or not.

Furthermore, it has been shown to be beneficial to use gradient freezing when the rgadient changes sign, i.e. , if \(\frac{\partial E^{(t-1)}}{\partial w_i} \cdot \frac{\partial E^{(t)}}{\partial w_i} < 0\) then \(\frac{\partial E^{(t)}}{\partial w_i} := 0\); Thus, after an unsuccessful step is performed, delta is not changed for one iteration.

Based on this, 4 major algorithms can be derived: Rprop-: (no backtracking, no freezing) IRprop-: (no backtracking, freezing) Rprop+: (gradient based backtracking, freezing) IRprop+: (function value based backtracking, freezing)

By default, IRprop+ is chosen.

For further information about the algorithm, please refer to:

Martin Riedmiller and Heinrich Braun,
"A Direct Adaptive Method for Faster Backpropagation Learning: The RPROP Algorithm".
In "Proceedings of the IEEE International Conference on Neural Networks", pp. 586-591,
Published by IEEE Press in 1993

Martin Riedmiller,
"Advanced Supervised Learning in Multi-layer Perceptrons - From Backpropagation to Adaptive Learning Algorithms".
In "International Journal of Computer Standards and Interfaces", volume 16, no. 5, 1994, pp. 265-278

Christian Igel and Michael Hüsken,
"Empirical Evaluation of the Improved Rprop Learning Algorithm".
In Neurocomputing Journal, 2002, in press

Definition at line 138 of file Rprop.h.

Member Typedef Documentation

◆ ObjectiveFunctionType

template<class SearchPointType = RealVector>
typedef AbstractObjectiveFunction<SearchPointType,double> shark::Rprop< SearchPointType >::ObjectiveFunctionType

Definition at line 141 of file Rprop.h.

Constructor & Destructor Documentation

◆ Rprop()

template<class SearchPointType = RealVector>
shark::Rprop< SearchPointType >::Rprop ( )

Member Function Documentation

◆ derivative()

template<class SearchPointType = RealVector>
SearchPointType const & shark::Rprop< SearchPointType >::derivative ( ) const
inline

Returns the derivative at the current point. Can be used for stopping criteria.

Definition at line 202 of file Rprop.h.

References shark::Rprop< SearchPointType >::m_derivative.

◆ init() [1/2]

template<class SearchPointType = RealVector>
void shark::Rprop< SearchPointType >::init ( ObjectiveFunctionType const &  objectiveFunction,
SearchPointType const &  startingPoint 
)

◆ init() [2/2]

template<class SearchPointType = RealVector>
void shark::Rprop< SearchPointType >::init ( ObjectiveFunctionType const &  objectiveFunction,
SearchPointType const &  startingPoint,
double  initDelta 
)

◆ maxDelta()

template<class SearchPointType = RealVector>
double shark::Rprop< SearchPointType >::maxDelta ( ) const
inline

return the maximal step size component

Definition at line 197 of file Rprop.h.

References shark::Rprop< SearchPointType >::m_delta.

Referenced by run_one_trial().

◆ name()

template<class SearchPointType = RealVector>
std::string shark::Rprop< SearchPointType >::name ( ) const
inlinevirtual

From INameable: return the class name.

Reimplemented from shark::INameable.

Definition at line 145 of file Rprop.h.

◆ read()

template<class SearchPointType = RealVector>
virtual void shark::Rprop< SearchPointType >::read ( InArchive archive)
virtual

Read the component from the supplied archive.

Parameters
[in,out]archiveThe archive to read from.

Reimplemented from shark::ISerializable.

◆ setEtaMinus()

template<class SearchPointType = RealVector>
void shark::Rprop< SearchPointType >::setEtaMinus ( double  etaMinus)
inline

set decrease factor

Definition at line 158 of file Rprop.h.

References shark::Rprop< SearchPointType >::m_decreaseFactor, and RANGE_CHECK.

◆ setEtaPlus()

template<class SearchPointType = RealVector>
void shark::Rprop< SearchPointType >::setEtaPlus ( double  etaPlus)
inline

set increase factor

Definition at line 165 of file Rprop.h.

References shark::Rprop< SearchPointType >::m_increaseFactor, and RANGE_CHECK.

◆ setMaxDelta()

template<class SearchPointType = RealVector>
void shark::Rprop< SearchPointType >::setMaxDelta ( double  d)
inline

set upper limit on update

Definition at line 171 of file Rprop.h.

References shark::Rprop< SearchPointType >::m_maxDelta, and RANGE_CHECK.

◆ setMinDelta()

template<class SearchPointType = RealVector>
void shark::Rprop< SearchPointType >::setMinDelta ( double  d)
inline

set lower limit on update

Definition at line 177 of file Rprop.h.

References shark::Rprop< SearchPointType >::m_minDelta, and RANGE_CHECK.

◆ setUseBacktracking()

template<class SearchPointType = RealVector>
void shark::Rprop< SearchPointType >::setUseBacktracking ( bool  useBacktracking)
inline

Definition at line 192 of file Rprop.h.

References shark::Rprop< SearchPointType >::m_useBacktracking.

◆ setUseFreezing()

template<class SearchPointType = RealVector>
void shark::Rprop< SearchPointType >::setUseFreezing ( bool  useFreezing)
inline

Definition at line 189 of file Rprop.h.

References shark::Rprop< SearchPointType >::m_useFreezing.

◆ setUseOldValue()

◆ step()

template<class SearchPointType = RealVector>
void shark::Rprop< SearchPointType >::step ( ObjectiveFunctionType const &  objectiveFunction)

◆ write()

template<class SearchPointType = RealVector>
virtual void shark::Rprop< SearchPointType >::write ( OutArchive archive) const
virtual

Write the component to the supplied archive.

Parameters
[in,out]archiveThe archive to write to.

Reimplemented from shark::ISerializable.

Member Data Documentation

◆ m_decreaseFactor

template<class SearchPointType = RealVector>
double shark::Rprop< SearchPointType >::m_decreaseFactor
protected

The decrease factor \( \eta^- \), set to 0.5 by default.

Definition at line 212 of file Rprop.h.

Referenced by shark::Rprop< SearchPointType >::setEtaMinus().

◆ m_delta

template<class SearchPointType = RealVector>
SearchPointType shark::Rprop< SearchPointType >::m_delta
protected

The absolute update values (increment) for all weights.

Definition at line 230 of file Rprop.h.

Referenced by shark::Rprop< SearchPointType >::maxDelta().

◆ m_deltaw

template<class SearchPointType = RealVector>
SearchPointType shark::Rprop< SearchPointType >::m_deltaw
protected

the step eprformed last. used for weight backtracking

Definition at line 227 of file Rprop.h.

◆ m_derivative

template<class SearchPointType = RealVector>
SearchPointType shark::Rprop< SearchPointType >::m_derivative
protected

Definition at line 206 of file Rprop.h.

Referenced by shark::Rprop< SearchPointType >::derivative().

◆ m_increaseFactor

template<class SearchPointType = RealVector>
double shark::Rprop< SearchPointType >::m_increaseFactor
protected

The increase factor \( \eta^+ \), set to 1.2 by default.

Definition at line 209 of file Rprop.h.

Referenced by shark::Rprop< SearchPointType >::setEtaPlus().

◆ m_maxDelta

template<class SearchPointType = RealVector>
double shark::Rprop< SearchPointType >::m_maxDelta
protected

The upper limit of the increments \( \Delta w_i^{(t)} \), set to 1e100 by default.

Definition at line 215 of file Rprop.h.

Referenced by shark::Rprop< SearchPointType >::setMaxDelta().

◆ m_minDelta

template<class SearchPointType = RealVector>
double shark::Rprop< SearchPointType >::m_minDelta
protected

The lower limit of the increments \( \Delta w_i^{(t)} \), set to 0.0 by default.

Definition at line 218 of file Rprop.h.

Referenced by shark::Rprop< SearchPointType >::setMinDelta().

◆ m_oldDerivative

template<class SearchPointType = RealVector>
SearchPointType shark::Rprop< SearchPointType >::m_oldDerivative
protected

The last error gradient.

Definition at line 225 of file Rprop.h.

◆ m_oldValue

template<class SearchPointType = RealVector>
double shark::Rprop< SearchPointType >::m_oldValue
protected

The last function value observed.

Definition at line 220 of file Rprop.h.

◆ m_parameterSize

template<class SearchPointType = RealVector>
size_t shark::Rprop< SearchPointType >::m_parameterSize
protected

Definition at line 222 of file Rprop.h.

◆ m_useBacktracking

template<class SearchPointType = RealVector>
bool shark::Rprop< SearchPointType >::m_useBacktracking
protected

Definition at line 233 of file Rprop.h.

Referenced by shark::Rprop< SearchPointType >::setUseBacktracking().

◆ m_useFreezing

template<class SearchPointType = RealVector>
bool shark::Rprop< SearchPointType >::m_useFreezing
protected

Definition at line 232 of file Rprop.h.

Referenced by shark::Rprop< SearchPointType >::setUseFreezing().

◆ m_useOldValue

template<class SearchPointType = RealVector>
bool shark::Rprop< SearchPointType >::m_useOldValue
protected

Definition at line 234 of file Rprop.h.

Referenced by shark::Rprop< SearchPointType >::setUseOldValue().


The documentation for this class was generated from the following file: