00001 /****************************************************************************************************************/ 00002 /* */ 00003 /* Flood: An Open Source Neural Networks C++ Library */ 00004 /* www.cimne.com/flood */ 00005 /* */ 00006 /* G R A D I E N T D E S C E N T C L A S S H E A D E R */ 00007 /* */ 00008 /* Roberto Lopez */ 00009 /* International Center for Numerical Methods in Engineering (CIMNE) */ 00010 /* Technical University of Catalonia (UPC) */ 00011 /* Barcelona, Spain */ 00012 /* E-mail: rlopez@cimne.upc.edu */ 00013 /* */ 00014 /****************************************************************************************************************/ 00015 00016 #ifndef __GRADIENTDESCENT_H__ 00017 #define __GRADIENTDESCENT_H__ 00018 00019 #include "TrainingAlgorithm.h" 00020 #include "../ObjectiveFunctional/ObjectiveFunctional.h" 00021 00022 00023 namespace Flood 00024 { 00025 00028 00029 class GradientDescent : public TrainingAlgorithm 00030 { 00031 00032 public: 00033 00034 // GENERAL CONSTRUCTOR 00035 00036 explicit GradientDescent(ObjectiveFunctional*); 00037 00038 00039 // DEFAULT CONSTRUCTOR 00040 00041 explicit GradientDescent(void); 00042 00043 00044 // DESTRUCTOR 00045 00046 virtual ~GradientDescent(void); 00047 00048 00049 // METHODS 00050 00051 // Set methods 00052 00053 void set_reserve_all_training_history(bool); 00054 00055 // Train methods 00056 00057 Vector<double> calculate_training_direction(const Vector<double>&); 00058 00059 void train(void); 00060 00061 // Training history methods 00062 00063 void resize_training_history(int); 00064 00065 std::string get_training_history_XML(bool); 00066 00067 // Utility methods 00068 00069 std::string to_XML(bool); 00070 00071 void load(const char*); 00072 }; 00073 00074 } 00075 00076 #endif