diff options
author | jfouet <jfouet@1f5c12ca-751b-0410-a591-d2e778427230> | 2008-05-15 14:57:20 +0400 |
---|---|---|
committer | jfouet <jfouet@1f5c12ca-751b-0410-a591-d2e778427230> | 2008-05-15 14:57:20 +0400 |
commit | bfe36611108453efefa0ae0cba384c4f7dac4ebb (patch) | |
tree | c714cbaf181b3dddd873e31e67c8c195777eccce /mert/Point.h | |
parent | c2c30717e07b5ef3ef7b8f48e29f364c92e71d82 (diff) |
implementation of optimization on a subset of the parameters + debug mode in the makefile
git-svn-id: https://mosesdecoder.svn.sourceforge.net/svnroot/mosesdecoder/trunk@1695 1f5c12ca-751b-0410-a591-d2e778427230
Diffstat (limited to 'mert/Point.h')
-rw-r--r-- | mert/Point.h | 36 |
1 files changed, 29 insertions, 7 deletions
diff --git a/mert/Point.h b/mert/Point.h index 4a1f5b633..ffa2a438e 100644 --- a/mert/Point.h +++ b/mert/Point.h @@ -2,18 +2,40 @@ #define POINT_H #include <vector> #include "FeatureStats.h" +#include <cassert> typedef float lambda,statscore; -class Point: public std::vector<lambda>{ + +class Optimizer; + +/**class that handle the subset of the Feature weight on which we run the optimization*/ + +class Point:public vector<lambda>{ + friend class Optimizer; + private: + /**The indices over which we optimize*/ + static vector<unsigned> optindices; + /**dimension of optindices and of the parent vector*/ + static unsigned dim; + /**fixed weights in case of partial optimzation*/ + static map<unsigned,lambda> fixedweights; + /**total size of the parameter space; we have pdim=FixedWeight.size()+optinidices.size()*/ + static unsigned pdim; public: + static unsigned getdim(){return dim;} + static unsigned getpdim(){return pdim;} + static bool OptimizeAll(){return fixedweights.empty();}; statscore score; - Point(unsigned s):std::vector<lambda>(s,0.0){}; - Point(vector<lambda> init):vector<lambda>(init),score(numeric_limits<statscore>::max()){}; - void randomize(const std::vector<lambda>&min,const std::vector<lambda>& max); - double operator*(FeatureStats&)const;//compute the feature function + Point():vector<lambda>(dim){}; + Point(vector<lambda> init):vector<lambda>(init){assert(init.size()==dim);}; + void Randomize(const std::vector<lambda>&min,const std::vector<lambda>& max); + double operator*(const FeatureStats&)const;//compute the feature function Point operator+(const Point&)const; - Point operator*(float&)const;//compute the feature function - void normalize(); + Point operator*(float)const; + void Normalize(); + /**return a vector of size pdim where all weights have been put*/ + vector<lambda> GetAllWeights()const; }; #endif + |