[opengm] 188/386: fixed bug in gridesearchlearning

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Wed Aug 31 08:37:37 UTC 2016


This is an automated email from the git hooks/post-receive script.

ghisvail-guest pushed a commit to branch debian/master
in repository opengm.

commit 23298dd6e51269f85b9c80ec2740e5c80b2828bd
Author: DerThorsten <thorsten.beier at iwr.uni-heidelberg.de>
Date:   Sat Dec 20 18:19:31 2014 +0100

    fixed bug in gridesearchlearning
---
 include/opengm/learning/gridsearch-learning.hxx | 19 ++++---------------
 1 file changed, 4 insertions(+), 15 deletions(-)

diff --git a/include/opengm/learning/gridsearch-learning.hxx b/include/opengm/learning/gridsearch-learning.hxx
index def2990..750c844 100644
--- a/include/opengm/learning/gridsearch-learning.hxx
+++ b/include/opengm/learning/gridsearch-learning.hxx
@@ -7,6 +7,7 @@
 namespace opengm {
    namespace learning {
 
+      
       template<class DATASET>
       class GridSearchLearner
       {
@@ -63,10 +64,9 @@ namespace opengm {
          // generate model Parameters
          opengm::learning::Weights<double> modelPara( dataset_.getNumberOfWeights() );
          opengm::learning::Weights<double> bestModelPara( dataset_.getNumberOfWeights() );
-         double                            bestLoss = 100000000.0; 
+         double bestLoss = std::numeric_limits<double>::infinity();
          std::vector<size_t> itC(dataset_.getNumberOfWeights(),0);
-
-         LossType lossFunction;
+         
          bool search=true;
          while(search){
             // Get Parameter
@@ -76,22 +76,12 @@ namespace opengm {
             // Evaluate Loss
             opengm::learning::Weights<double>& mp =  dataset_.getWeights();
             mp = modelPara;
-            std::vector< std::vector<typename INF::LabelType> > confs( dataset_.getNumberOfModels() );
-            double loss = 0;
-            for(size_t m=0; m<dataset_.getNumberOfModels(); ++m){
-               INF inf( dataset_.getModel(m),para);
-               inf.infer();
-               inf.arg(confs[m]);
-               const std::vector<typename INF::LabelType>& gt =  dataset_.getGT(m);
-               loss += lossFunction.loss(dataset_.getModel(m),confs[m].begin(), confs[m].end(), gt.begin(), gt.end());
-            }
-            
+            const double loss = dataset_. template getTotalLoss<INF>(para);
            
 
             // **************
 
             if(loss<bestLoss){
-
                  // *call visitor*
                 for(size_t p=0; p<dataset_.getNumberOfWeights(); ++p){
                    std::cout << modelPara[p] <<" ";
@@ -117,7 +107,6 @@ namespace opengm {
                      search = false; 
                }             
             }
-
          }
          std::cout << "Best"<<std::endl;
          for(size_t p=0; p<dataset_.getNumberOfWeights(); ++p){

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/opengm.git



More information about the debian-science-commits mailing list