This class offers methods for the usage of the Resilient-Backpropagation-algorithm with/out weight-backtracking. More...
#include <shark/Algorithms/GradientDescent/Rprop.h>
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, ResultType > | ObjectiveFunctionType |
typedef TypedFlags< Feature > | Features |
typedef TypedFeatureNotAvailableException< Feature > | FeatureNotAvailableException |
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 SolutionType & | solution () const |
returns the current solution of the optimizer | |
Public Member Functions inherited from shark::AbstractOptimizer< PointType, double, SingleObjectiveResultSet< PointType > > | |
const Features & | features () 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. | |
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
typedef AbstractObjectiveFunction<SearchPointType,double> shark::Rprop< SearchPointType >::ObjectiveFunctionType |
shark::Rprop< SearchPointType >::Rprop | ( | ) |
|
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.
void shark::Rprop< SearchPointType >::init | ( | ObjectiveFunctionType const & | objectiveFunction, |
SearchPointType const & | startingPoint | ||
) |
Referenced by main(), main(), run_one_trial(), and trainProblem().
void shark::Rprop< SearchPointType >::init | ( | ObjectiveFunctionType const & | objectiveFunction, |
SearchPointType const & | startingPoint, | ||
double | initDelta | ||
) |
|
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().
|
inlinevirtual |
From INameable: return the class name.
Reimplemented from shark::INameable.
|
virtual |
Read the component from the supplied archive.
[in,out] | archive | The archive to read from. |
Reimplemented from shark::ISerializable.
|
inline |
set decrease factor
Definition at line 158 of file Rprop.h.
References shark::Rprop< SearchPointType >::m_decreaseFactor, and RANGE_CHECK.
|
inline |
set increase factor
Definition at line 165 of file Rprop.h.
References shark::Rprop< SearchPointType >::m_increaseFactor, and RANGE_CHECK.
|
inline |
set upper limit on update
Definition at line 171 of file Rprop.h.
References shark::Rprop< SearchPointType >::m_maxDelta, and RANGE_CHECK.
|
inline |
set lower limit on update
Definition at line 177 of file Rprop.h.
References shark::Rprop< SearchPointType >::m_minDelta, and RANGE_CHECK.
|
inline |
Definition at line 192 of file Rprop.h.
References shark::Rprop< SearchPointType >::m_useBacktracking.
|
inline |
Definition at line 189 of file Rprop.h.
References shark::Rprop< SearchPointType >::m_useFreezing.
|
inline |
Definition at line 182 of file Rprop.h.
References shark::AbstractOptimizer< PointType, double, SingleObjectiveResultSet< PointType > >::m_features, shark::Rprop< SearchPointType >::m_useOldValue, shark::AbstractOptimizer< PointType, double, SingleObjectiveResultSet< PointType > >::REQUIRES_VALUE, and shark::TypedFlags< Flag >::reset().
void shark::Rprop< SearchPointType >::step | ( | ObjectiveFunctionType const & | objectiveFunction | ) |
Referenced by main(), main(), run_one_trial(), and trainProblem().
|
virtual |
Write the component to the supplied archive.
[in,out] | archive | The archive to write to. |
Reimplemented from shark::ISerializable.
|
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().
|
protected |
The absolute update values (increment) for all weights.
Definition at line 230 of file Rprop.h.
Referenced by shark::Rprop< SearchPointType >::maxDelta().
|
protected |
|
protected |
Definition at line 206 of file Rprop.h.
Referenced by shark::Rprop< SearchPointType >::derivative().
|
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().
|
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().
|
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().
|
protected |
|
protected |
|
protected |
|
protected |
Definition at line 233 of file Rprop.h.
Referenced by shark::Rprop< SearchPointType >::setUseBacktracking().
|
protected |
Definition at line 232 of file Rprop.h.
Referenced by shark::Rprop< SearchPointType >::setUseFreezing().
|
protected |
Definition at line 234 of file Rprop.h.
Referenced by shark::Rprop< SearchPointType >::setUseOldValue().