From c84ef9590d11819b7f8441a53b1699a912d949e1 Mon Sep 17 00:00:00 2001 From: Chris Dyer Date: Tue, 26 Jun 2012 13:03:46 -0400 Subject: minrisk impl --- minrisk/minrisk_optimize.cc | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'minrisk/minrisk_optimize.cc') 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 weights; const string weightsf = conf["weights"].as(); 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 kis; cerr << "Loading hypergraphs...\n"; -- cgit v1.2.3