diff options
author | Patrick Simianer <p@simianer.de> | 2011-10-19 14:02:34 +0200 |
---|---|---|
committer | Patrick Simianer <p@simianer.de> | 2011-10-19 14:02:34 +0200 |
commit | 9beaeb42b71fa504bfa41a402cb17eb6ac4001af (patch) | |
tree | 0add4afabc526391753e4e6b9443a7bf21e3e2c3 /utils/weights.h | |
parent | ce3b4db94d40c111ede321ac6de2bb061a81c4af (diff) | |
parent | 09297047e446f49804d3f48bf320cdbd38d6396a (diff) |
merge upstream/master
Diffstat (limited to 'utils/weights.h')
-rw-r--r-- | utils/weights.h | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/utils/weights.h b/utils/weights.h index 86701add..30f71db0 100644 --- a/utils/weights.h +++ b/utils/weights.h @@ -2,25 +2,29 @@ #define _WEIGHTS_H_ #include <string> -#include <map> #include <vector> #include "sparse_vector.h" +// warning: in the future this will become float +typedef double weight_t; + class Weights { public: - Weights() {} - void InitFromFile(const std::string& fname, std::vector<std::string>* feature_list = NULL); - void WriteToFile(const std::string& fname, bool hide_zero_value_features = true, const std::string* extra = NULL) const; - void InitVector(std::vector<double>* w) const; - void InitSparseVector(SparseVector<double>* w) const; - void InitFromVector(const std::vector<double>& w); - void InitFromVector(const SparseVector<double>& w); - void SetWeight(SparseVector<double>* v, const std::string f, const double w); - void SetWeight(SparseVector<double>* v, const WordID fid, const double w); - std::vector<double>* getw() { return &wv_; }; // probably a hack - void sz(); + static void InitFromFile(const std::string& fname, + std::vector<weight_t>* weights, + std::vector<std::string>* feature_list = NULL); + static void WriteToFile(const std::string& fname, + const std::vector<weight_t>& weights, + bool hide_zero_value_features = true, + const std::string* extra = NULL); + static void InitSparseVector(const std::vector<weight_t>& dv, + SparseVector<weight_t>* sv); + // check for infinities, NaNs, etc + static void SanityCheck(const std::vector<weight_t>& w); + // write weights with largest magnitude to cerr + static void ShowLargestFeatures(const std::vector<weight_t>& w); private: - std::vector<double> wv_; + Weights(); }; #endif |