Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/moses-smt/mosesdecoder.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Cherry <colin.a.cherry@gmail.com>2012-05-29 21:38:57 +0400
committerColin Cherry <colin.a.cherry@gmail.com>2012-05-29 21:38:57 +0400
commitfd577d7a65cab923b9102d61873a032654d573a1 (patch)
tree24dddd8e7a412f29f2f55e8ecad0b6055f8530c0 /mert/MiraFeatureVector.h
parent6d1165654caf8edc995a41a4c6c9666e65ebce96 (diff)
Batch k-best MIRA is written and integrated into mert-moses.pl
Regression tests all check out, and kbmira seems to work fine on a Hansard French->English task. HypPackEnumerator class may be of interest to pro.cpp and future optimizers, as it abstracts a lot of the boilerplate involved in enumerating multiple k-best lists. MiraWeightVector is not really mira-specific - just a weight vector that enables efficient averaging. Could be useful to a perceptron as well. Same goes for MiraFeatureVector. Interaction with sparse features is written, but untested.
Diffstat (limited to 'mert/MiraFeatureVector.h')
-rw-r--r--mert/MiraFeatureVector.h51
1 files changed, 51 insertions, 0 deletions
diff --git a/mert/MiraFeatureVector.h b/mert/MiraFeatureVector.h
new file mode 100644
index 000000000..14336c56f
--- /dev/null
+++ b/mert/MiraFeatureVector.h
@@ -0,0 +1,51 @@
+/*
+ * MiraFeatureVector.h
+ * kbmira - k-best Batch MIRA
+ *
+ * An alternative to the existing SparseVector
+ * and FeatureDataItem combo. Should be as memory
+ * efficient, and a little more time efficient,
+ * and should save me from constantly hacking
+ * SparseVector
+ */
+
+#ifndef MERT_MIRA_FEATURE_VECTOR_H
+#define MERT_MIRA_FEATURE_VECTOR_H
+
+#include <vector>
+
+#include "FeatureDataIterator.h"
+
+using namespace std;
+
+typedef FeatureStatsType ValType;
+
+class MiraFeatureVector {
+public:
+ MiraFeatureVector(const FeatureDataItem& vec);
+ MiraFeatureVector(const MiraFeatureVector& other);
+ MiraFeatureVector(const vector<ValType>& dense,
+ const vector<size_t>& sparseFeats,
+ const vector<ValType>& sparseVals);
+
+ ValType val(size_t index) const;
+ size_t feat(size_t index) const;
+ size_t size() const;
+ ValType sqrNorm() const;
+
+ friend MiraFeatureVector operator-(const MiraFeatureVector& a,
+ const MiraFeatureVector& b);
+
+private:
+ vector<ValType> m_dense;
+ vector<size_t> m_sparseFeats;
+ vector<ValType> m_sparseVals;
+};
+
+#endif // MERT_FEATURE_VECTOR_H
+
+// --Emacs trickery--
+// Local Variables:
+// mode:c++
+// c-basic-offset:2
+// End: