diff options
author | bojar <bojar@1f5c12ca-751b-0410-a591-d2e778427230> | 2011-07-04 01:01:16 +0400 |
---|---|---|
committer | bojar <bojar@1f5c12ca-751b-0410-a591-d2e778427230> | 2011-07-04 01:01:16 +0400 |
commit | 1ba2de3c0241c2b532d6f5c11e096ed361e467f1 (patch) | |
tree | 24542303705bcdfb1c963add6d8bf97355577099 /mert/Point.cpp | |
parent | 52ce9269011a16870bd0998a02ea13ae9b936196 (diff) |
- cmert: added support for passing min and max values for weights
(used to be in old cmert but not in new cmert, i.e. moses/mert/)
- modified mert-moses.pl accordingly, esp. set min&max to 0&1 as it used to be
hardwired in the new cmert
- adding mert-moses-ondrej.pl, a simplification of mert-moses.pl, please test it
git-svn-id: https://mosesdecoder.svn.sourceforge.net/svnroot/mosesdecoder/trunk@4066 1f5c12ca-751b-0410-a591-d2e778427230
Diffstat (limited to 'mert/Point.cpp')
-rw-r--r-- | mert/Point.cpp | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/mert/Point.cpp b/mert/Point.cpp index af57aaa98..2bb53744b 100644 --- a/mert/Point.cpp +++ b/mert/Point.cpp @@ -14,12 +14,16 @@ map<unsigned,statscore_t> Point::fixedweights; unsigned Point::pdim=0; unsigned Point::ncall=0; -void Point::Randomize(const vector<parameter_t>& min,const vector<parameter_t>& max) +vector<parameter_t> Point::m_min; +vector<parameter_t> Point::m_max; + +void Point::Randomize() { - assert(min.size()==Point::dim); - assert(max.size()==Point::dim); + assert(m_min.size()==Point::dim); + assert(m_max.size()==Point::dim); for (unsigned int i=0; i<size(); i++) - operator[](i)= min[i] + (float)random()/(float)RAND_MAX * (float)(max[i]-min[i]); + operator[](i)= m_min[i] + + (float)random()/(float)RAND_MAX * (float)(m_max[i]-m_min[i]); } void Point::NormalizeL2() @@ -47,15 +51,26 @@ void Point::NormalizeL1() } //Can initialize from a vector of dim or pdim -Point::Point(const vector<parameter_t>& init):vector<parameter_t>(Point::dim) +Point::Point(const vector<parameter_t>& init, + const vector<parameter_t>& min, + const vector<parameter_t>& max + ):vector<parameter_t>(Point::dim) { + m_min.resize(Point::dim); + m_max.resize(Point::dim); if(init.size()==dim) { - for (unsigned int i=0; i<Point::dim; i++) + for (unsigned int i=0; i<Point::dim; i++) { operator[](i)=init[i]; + m_min[i] = min[i]; + m_max[i] = max[i]; + } } else { assert(init.size()==pdim); - for (unsigned int i=0; i<Point::dim; i++) + for (unsigned int i=0; i<Point::dim; i++) { operator[](i)=init[optindices[i]]; + m_min[i] = min[optindices[i]]; + m_max[i] = max[optindices[i]]; + } } }; |