[opengm] 109/386: improved python learning

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

    improved python learning
---
 src/interfaces/python/opengm/learning/__init__.py | 35 +++++++++++++++++++++++
 1 file changed, 35 insertions(+)

diff --git a/src/interfaces/python/opengm/learning/__init__.py b/src/interfaces/python/opengm/learning/__init__.py
index b71b5b4..756c976 100644
--- a/src/interfaces/python/opengm/learning/__init__.py
+++ b/src/interfaces/python/opengm/learning/__init__.py
@@ -1,6 +1,7 @@
 from _learning import *
 import numpy
 import struct
+from opengm import index_type,value_type, label_type
 
 DatasetWithHammingLoss.lossType = 'hamming'
 DatasetWithGeneralizedHammingLoss.lossType = 'generalized-hamming'
@@ -43,3 +44,37 @@ def gridSearchLearner(dataset, lowerBounds, upperBounds, nTestPoints):
     learner = learnerCls(dataset, param)
 
     return learner
+
+
+
+
+
+def lPottsFunctions(nFunctions, numberOfLabels, features, weightIds):
+
+    # check that features has the correct shape
+    if features.ndim != 2:
+        raise RuntimeError("feature must be two-dimensional")
+    if features.shape[0] != nFunctions :
+        raise RuntimeError("nFunctions.shape[0] must be equal to nFunctions")
+
+
+    # check that weights has the correct shape
+    if features.ndim != 1:
+        raise RuntimeError("weightIds must be one-dimensional")
+    if weightIds.shape[0] != features.shape[1] :
+        raise RuntimeError("weightIds.shape[0]  must be equal to features.shape[1]")
+
+
+    # require the correct types
+    features = numpy.require(features, dtype=value_type)
+    weightIds = numpy.require(weightIds, dtype=index_type)
+    numberOfLabels = int(numberOfLabels)
+    nFunctions = int(nFunctions)
+
+    # do the c++ call here
+    # which generates a function generator
+
+    raise RuntimeError("not yet implemented")
+
+def lUnaryFunctions(nFunctions, numberOfLabels, features, weightIds):
+    raise RuntimeError("not yet implemented")

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