MLPACK
1.0.4
|
00001 00025 #ifndef SAVE_RESTORE_MODEL_HPP 00026 #define SAVE_RESTORE_MODEL_HPP 00027 00028 #include <list> 00029 #include <map> 00030 #include <sstream> 00031 #include <string> 00032 00033 #include <libxml/parser.h> 00034 #include <libxml/tree.h> 00035 00036 #include <boost/tokenizer.hpp> 00037 #include <mlpack/core.hpp> 00038 00039 namespace mlpack { 00040 namespace util { 00041 00042 class SaveRestoreUtility 00043 { 00044 private: 00048 std::map<std::string, std::string> parameters; 00049 00053 void RecurseOnNodes(xmlNode* n); 00054 00055 public: 00056 SaveRestoreUtility() {} 00057 ~SaveRestoreUtility() { parameters.clear(); } 00058 00062 bool ReadFile(const std::string& filename); 00063 00067 bool WriteFile(const std::string& filename); 00068 00072 template<typename T> 00073 T& LoadParameter(T& t, const std::string& name); 00074 00078 template<typename T> 00079 std::vector<T>& LoadParameter(std::vector<T>& v, const std::string& name); 00080 00084 char LoadParameter(char c, const std::string& name); 00085 00089 std::string LoadParameter(std::string& str, const std::string& name); 00090 00094 arma::mat& LoadParameter(arma::mat& matrix, const std::string& name); 00095 00099 template<typename T> 00100 void SaveParameter(const T& t, const std::string& name); 00101 00102 00103 00107 template<typename T> 00108 void SaveParameter(const std::vector<T>& v, const std::string& name); 00109 00113 void SaveParameter(const char c, const std::string& name); 00114 00118 void SaveParameter(const arma::mat& mat, const std::string& name); 00119 }; 00120 00122 template<> 00123 arma::vec& SaveRestoreUtility::LoadParameter(arma::vec& t, 00124 const std::string& name); 00125 00127 template<> 00128 void SaveRestoreUtility::SaveParameter(const arma::vec& t, 00129 const std::string& name); 00130 00131 }; /* namespace util */ 00132 }; /* namespace mlpack */ 00133 00134 // Include implementation. 00135 #include "save_restore_utility_impl.hpp" 00136 00137 #endif