[opengm] 90/386: mychanges

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Wed Aug 31 08:35:10 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 16a3bedaa969aff5c8ef83ac87c01441e2a82079
Author: DerThorsten <thorsten.beier at iwr.uni-heidelberg.de>
Date:   Wed Dec 17 14:24:33 2014 +0100

    mychanges
---
 include/opengm/learning/gridsearch-learning.hxx      | 13 +++++++------
 include/opengm/python/opengmpython.hxx               |  9 +++++++++
 src/interfaces/python/opengm/learning/CMakeLists.txt |  4 ++++
 src/interfaces/python/opengm/learning/learning.cxx   |  6 ++++++
 .../python/opengm/learning/pyGridSearchLearner.cxx   | 20 ++++++++------------
 5 files changed, 34 insertions(+), 18 deletions(-)

diff --git a/include/opengm/learning/gridsearch-learning.hxx b/include/opengm/learning/gridsearch-learning.hxx
index f6ac484..ab70958 100644
--- a/include/opengm/learning/gridsearch-learning.hxx
+++ b/include/opengm/learning/gridsearch-learning.hxx
@@ -8,11 +8,12 @@
 namespace opengm {
    namespace learning {
 
-      template<class DATASET, class LOSS>
+      template<class DATASET>
       class GridSearchLearner
       {
       public: 
          typedef typename DATASET::GMType   GMType; 
+         typedef typename DATASET::LossType LossType;
          typedef typename GMType::ValueType ValueType;
          typedef typename GMType::IndexType IndexType;
          typedef typename GMType::LabelType LabelType; 
@@ -42,8 +43,8 @@ namespace opengm {
          Parameter para_;
       }; 
 
-      template<class DATASET, class LOSS>
-      GridSearchLearner<DATASET, LOSS>::GridSearchLearner(DATASET& ds, Parameter& p )
+      template<class DATASET>
+      GridSearchLearner<DATASET>::GridSearchLearner(DATASET& ds, Parameter& p )
          : dataset_(ds), para_(p)
       {
          weights_ = opengm::learning::Weights<double>(ds.getNumberOfWeights());
@@ -56,16 +57,16 @@ namespace opengm {
       }
 
 
-      template<class DATASET, class LOSS>
+      template<class DATASET>
       template<class INF>
-      void GridSearchLearner<DATASET, LOSS>::learn(typename INF::Parameter& para){
+      void GridSearchLearner<DATASET>::learn(typename INF::Parameter& para){
          // generate model Parameters
          opengm::learning::Weights<double> modelPara( dataset_.getNumberOfWeights() );
          opengm::learning::Weights<double> bestModelPara( dataset_.getNumberOfWeights() );
          double                            bestLoss = 100000000.0; 
          std::vector<size_t> itC(dataset_.getNumberOfWeights(),0);
 
-         LOSS lossFunction;
+         LossType lossFunction;
          bool search=true;
          while(search){
             // Get Parameter
diff --git a/include/opengm/python/opengmpython.hxx b/include/opengm/python/opengmpython.hxx
index 840b5cc..ef97043 100644
--- a/include/opengm/python/opengmpython.hxx
+++ b/include/opengm/python/opengmpython.hxx
@@ -26,6 +26,10 @@
 #include <opengm/python/numpyview.hxx>
 #include <opengm/python/pythonfunction.hxx>
 
+#include <opengm/learning/dataset/editabledataset.hxx>
+#include <opengm/learning/loss/hammingloss.hxx>
+#include <opengm/learning/loss/generalized-hammingloss.hxx>
+#include <opengm/learning/loss/noloss.hxx>
 
 #include <algorithm>
 #include <vector>
@@ -115,6 +119,11 @@ namespace python{
       FTLGen<GmValueType,GmIndexType>::type
    >::type   GmAdder;
 
+
+   typedef opengm::datasets::Dataset<GmAdder, opengm::learning::HammingLoss > GmAdderHammingLossDataset;
+
+
+
    typedef GmAdder::FactorType FactorGmAdder;
    typedef FactorGmAdder GmAdderFactor;
 
diff --git a/src/interfaces/python/opengm/learning/CMakeLists.txt b/src/interfaces/python/opengm/learning/CMakeLists.txt
index e865415..dc0dec0 100644
--- a/src/interfaces/python/opengm/learning/CMakeLists.txt
+++ b/src/interfaces/python/opengm/learning/CMakeLists.txt
@@ -22,12 +22,16 @@ if(APPLE)
             pyWeights.cxx
             pyDataset.cxx
             pyLoss.cxx
+            pyGridSearchLearner.cxx
+
     )
 else()
     add_library(_learning SHARED  learning.cxx
             pyWeights.cxx
             pyDataset.cxx
             pyLoss.cxx
+            pyGridSearchLearner.cxx
+
     )
 endif(APPLE)
 
diff --git a/src/interfaces/python/opengm/learning/learning.cxx b/src/interfaces/python/opengm/learning/learning.cxx
index 00daf80..913f421 100644
--- a/src/interfaces/python/opengm/learning/learning.cxx
+++ b/src/interfaces/python/opengm/learning/learning.cxx
@@ -23,6 +23,9 @@ namespace opengm{
 
     template<class GM>
     void export_loss();
+
+    template<class DATASET>
+    void export_grid_search_learner(const std::string & clsName);
 }
 
 
@@ -44,4 +47,7 @@ BOOST_PYTHON_MODULE_INIT(_learning) {
     // templated datasets
     opengm::export_dataset<op::GmAdder, ol::HammingLoss >("DatasetWithHammingLoss");
     opengm::export_dataset<op::GmAdder, ol::NoLoss >("DatasetWithNoLoss");
+
+
+    opengm::export_grid_search_learner<GmAdderHammingLossDataset>("GridSearch_HammingLoss");
 }
diff --git a/src/interfaces/python/opengm/learning/pyGridSearchLearner.cxx b/src/interfaces/python/opengm/learning/pyGridSearchLearner.cxx
index 4211e80..7d352eb 100644
--- a/src/interfaces/python/opengm/learning/pyGridSearchLearner.cxx
+++ b/src/interfaces/python/opengm/learning/pyGridSearchLearner.cxx
@@ -12,22 +12,18 @@ namespace ol = opengm::learning;
 
 namespace opengm{
 
-    template<class V>
-    learning::Weights<V>  * pyWeightsConstructor(
-        python::NumpyView<V, 1> values                                           
-    ){
-        learning::Weights<V>   * f = new learning::Weights<V> (values.shape(0));
-        for(size_t i=0; i<values.shape(0); ++i){
-            f->setWeight(i, values(i));
-        }
-        return f;
-    }
+
 
 
     template<class DATASET>
     void export_grid_search_learner(const std::string & clsName){
-        
-    }
+        typedef learning::GridSearchLearner<DATASET> PyLearner;
 
+        bp::class_<PyLearner>(clsName.c_str(),)
+    }
 
+    template void 
+    export_dataset<op::GmAdderHammingLossDataset> (const std::string& className);
 }
+
+

-- 
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