summaryrefslogtreecommitdiff
path: root/minrisk/minrisk_optimize.cc
diff options
context:
space:
mode:
authorChris Dyer <cdyer@cs.cmu.edu>2012-06-26 13:03:46 -0400
committerChris Dyer <cdyer@cs.cmu.edu>2012-06-26 13:03:46 -0400
commitb3a7f6c5d97acac3cd6b14de194eadaa18175fda (patch)
tree0c95ac19bfb50bcd1076ca8b1145aaf2ce06c268 /minrisk/minrisk_optimize.cc
parent9c1dd817177331baeea66441861682fa29cf0262 (diff)
minrisk impl
Diffstat (limited to 'minrisk/minrisk_optimize.cc')
-rw-r--r--minrisk/minrisk_optimize.cc7
1 files changed, 7 insertions, 0 deletions
diff --git a/minrisk/minrisk_optimize.cc b/minrisk/minrisk_optimize.cc
index 5096acc1..6e651994 100644
--- a/minrisk/minrisk_optimize.cc
+++ b/minrisk/minrisk_optimize.cc
@@ -105,6 +105,13 @@ int main(int argc, char** argv) {
vector<weight_t> weights;
const string weightsf = conf["weights"].as<string>();
Weights::InitFromFile(weightsf, &weights);
+ double t = 0;
+ for (unsigned i = 0; i < weights.size(); ++i)
+ t += weights[i] * weights[i];
+ if (t > 0) {
+ for (unsigned i = 0; i < weights.size(); ++i)
+ weights[i] /= sqrt(t);
+ }
string line, file;
vector<training::CandidateSet> kis;
cerr << "Loading hypergraphs...\n";