[opengm] 169/386: Adapt python wrapper to changes in struct max margin learner

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Wed Aug 31 08:37:21 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 a62e8a93e08922578a14815ecd09592de5da0c44
Author: Carsten Haubold <carstenhaubold at googlemail.com>
Date:   Fri Dec 19 15:23:17 2014 +0100

    Adapt python wrapper to changes in struct max margin learner
---
 src/interfaces/python/opengm/learning/__init__.py             | 10 ++++++++--
 .../python/opengm/learning/pyStructMaxMarginLearner.cxx       | 11 ++++++++---
 2 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/src/interfaces/python/opengm/learning/__init__.py b/src/interfaces/python/opengm/learning/__init__.py
index 67b4892..0d2d061 100644
--- a/src/interfaces/python/opengm/learning/__init__.py
+++ b/src/interfaces/python/opengm/learning/__init__.py
@@ -67,7 +67,7 @@ def gridSearchLearner(dataset, lowerBounds, upperBounds, nTestPoints):
 
 
 
-def structMaxMarginLearner(dataset, regularizerWeight=1.0, minGap=1e-5, nSteps=0, optimizer='bundle'):
+def structMaxMarginLearner(dataset, regularizerWeight=1.0, minEps=1e-5, nSteps=0, epsStrategy='change', optimizer='bundle'):
 
     if opengmConfig.withCplex or opengmConfig.withGurobi :
         if optimizer != 'bundle':
@@ -80,7 +80,13 @@ def structMaxMarginLearner(dataset, regularizerWeight=1.0, minGap=1e-5, nSteps=0
             learnerCls = StructMaxMargin_Bundle_GeneralizedHammingLoss
             learnerParamCls = StructMaxMargin_Bundle_GeneralizedHammingLossParameter
 
-        param = learnerParamCls(regularizerWeight, minGap, nSteps)
+        epsFromGap = False
+        if epsStrategy == 'gap':
+            epsFromGap = True
+        elif epsStrategy == 'change'
+            epsFromGap = False
+
+        param = learnerParamCls(regularizerWeight, minEps, nSteps, epsFromGap)
         learner = learnerCls(dataset, param)
         
         return learner
diff --git a/src/interfaces/python/opengm/learning/pyStructMaxMarginLearner.cxx b/src/interfaces/python/opengm/learning/pyStructMaxMarginLearner.cxx
index 8173733..0c3ebde 100644
--- a/src/interfaces/python/opengm/learning/pyStructMaxMarginLearner.cxx
+++ b/src/interfaces/python/opengm/learning/pyStructMaxMarginLearner.cxx
@@ -22,13 +22,18 @@ namespace opengm{
     template<class PARAM>
     PARAM * pyStructMaxMarginBundleParamConstructor(
         double regularizerWeight,
-        op::GmValueType minGap,
-        unsigned int steps
+        op::GmValueType minEps,
+        unsigned int steps,
+        bool eps_from_gap = true
     ){
         PARAM * p  = new PARAM();
         p->optimizerParameter_.lambda  = regularizerWeight;
-        p->optimizerParameter_.min_gap = minGap;
+        p->optimizerParameter_.min_eps = minEps;
         p->optimizerParameter_.steps   = steps;
+        if(eps_from_gap)
+            p->optimizerParameter_.epsStrategy = ol::BundleOptimizer<op::GmValueType>::EpsFromGap;
+        else
+            p->optimizerParameter_.epsStrategy = ol::BundleOptimizer<op::GmValueType>::EpsFromChange;
         return 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