[mlpack] 267/324: Hierarchical model support
Barak A. Pearlmutter
barak+git at cs.nuim.ie
Sun Aug 17 08:22:17 UTC 2014
This is an automated email from the git hooks/post-receive script.
bap pushed a commit to branch svn-trunk
in repository mlpack.
commit aac864556f24f4c887a584d6754537d835e9fdbf
Author: michaelfox99 <michaelfox99 at 9d5b8971-822b-0410-80eb-d18c1038ef23>
Date: Tue Aug 5 13:11:31 2014 +0000
Hierarchical model support
git-svn-id: http://svn.cc.gatech.edu/fastlab/mlpack/trunk@16951 9d5b8971-822b-0410-80eb-d18c1038ef23
---
src/mlpack/core/util/save_restore_utility.hpp | 48 ++++++++++++++++++++++-----
1 file changed, 40 insertions(+), 8 deletions(-)
diff --git a/src/mlpack/core/util/save_restore_utility.hpp b/src/mlpack/core/util/save_restore_utility.hpp
index d27e7f2..f4674ae 100644
--- a/src/mlpack/core/util/save_restore_utility.hpp
+++ b/src/mlpack/core/util/save_restore_utility.hpp
@@ -33,11 +33,18 @@ class SaveRestoreUtility
std::map<std::string, std::string> parameters;
/**
+ * children contains a list of names in string format and child
+ * models in the model hierarchy in SaveRestoreUtility format
+ */
+ std::map<std::string, SaveRestoreUtility> children;
+
+ /**
* RecurseOnNodes performs a depth first search of the XML tree.
*/
void RecurseOnNodes(xmlNode* n);
public:
+
SaveRestoreUtility() {}
~SaveRestoreUtility() { parameters.clear(); }
@@ -45,6 +52,7 @@ class SaveRestoreUtility
* ReadFile reads an XML tree from a file.
*/
bool ReadFile(const std::string& filename);
+ void ReadFile(xmlNode* n);
/**
* WriteFile writes the XML tree to a file.
@@ -55,28 +63,29 @@ class SaveRestoreUtility
* LoadParameter loads a parameter from the parameters map.
*/
template<typename T>
- T& LoadParameter(T& t, const std::string& name);
+ T& LoadParameter(T& t, const std::string& name) const;
/**
* LoadParameter loads a parameter from the parameters map.
*/
template<typename T>
- std::vector<T>& LoadParameter(std::vector<T>& v, const std::string& name);
+ std::vector<T>& LoadParameter(std::vector<T>& v, const std::string& name)
+ const;
/**
* LoadParameter loads a character from the parameters map.
*/
- char LoadParameter(char c, const std::string& name);
+ char LoadParameter(char c, const std::string& name) const;
/**
* LoadParameter loads a string from the parameters map.
*/
- std::string LoadParameter(std::string& str, const std::string& name);
+ std::string LoadParameter(std::string& str, const std::string& name) const;
/**
* LoadParameter loads an arma::mat from the parameters map.
*/
- arma::mat& LoadParameter(arma::mat& matrix, const std::string& name);
+ arma::mat& LoadParameter(arma::mat& matrix, const std::string& name) const;
/**
* SaveParameter saves a parameter to the parameters map.
@@ -84,8 +93,6 @@ class SaveRestoreUtility
template<typename T>
void SaveParameter(const T& t, const std::string& name);
-
-
/**
* SaveParameter saves a parameter to the parameters map.
*/
@@ -101,18 +108,43 @@ class SaveRestoreUtility
* SaveParameter saves an arma::mat to the parameters map.
*/
void SaveParameter(const arma::mat& mat, const std::string& name);
+
+ /**
+ * SaveSubModel saves a SaveRestoreUtility to the children map.
+ */
+ void AddChild(SaveRestoreUtility& mn, const std::string& name);
+
+ /**
+ * Return the children.
+ */
+ const std::map<std::string, SaveRestoreUtility> Children() const { return
+ children; }
+
+ /**
+ * Return modifiable copy of the children.
+ */
+ std::map<std::string, SaveRestoreUtility> Children() { return children; }
+
+ private:
+ /**
+ * WriteFile creates XML tree recursively.
+ */
+ void WriteFile(xmlNode* n);
+
};
//! Specialization for arma::vec.
template<>
arma::vec& SaveRestoreUtility::LoadParameter(arma::vec& t,
- const std::string& name);
+ const std::string& name) const;
//! Specialization for arma::vec.
template<>
void SaveRestoreUtility::SaveParameter(const arma::vec& t,
const std::string& name);
+
+
}; /* namespace util */
}; /* namespace mlpack */
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/mlpack.git
More information about the debian-science-commits
mailing list