[opengm] 106/386: added py helper function
Ghislain Vaillant
ghisvail-guest at moszumanska.debian.org
Wed Aug 31 08:35:13 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 e92907e0ade3005d2ef14826e3d3cdec6e16a3fe
Author: DerThorsten <thorsten.beier at iwr.uni-heidelberg.de>
Date: Wed Dec 17 15:32:07 2014 +0100
added py helper function
---
fubar/example1.py | 9 +++++++++
src/interfaces/python/opengm/learning/__init__.py | 20 ++++++++++++++++++++
2 files changed, 29 insertions(+)
diff --git a/fubar/example1.py b/fubar/example1.py
new file mode 100644
index 0000000..6c4aeb6
--- /dev/null
+++ b/fubar/example1.py
@@ -0,0 +1,9 @@
+import opengm
+import opengm.learning
+
+
+
+datasetA = opengm.learning.createDataset(loss='hamming')
+datasetB = opengm.learning.createDataset(loss='generalized-hamming')
+
+print datasetA, datasetB
diff --git a/src/interfaces/python/opengm/learning/__init__.py b/src/interfaces/python/opengm/learning/__init__.py
index 84afc48..384f0a3 100644
--- a/src/interfaces/python/opengm/learning/__init__.py
+++ b/src/interfaces/python/opengm/learning/__init__.py
@@ -1 +1,21 @@
from _learning import *
+
+
+
+
+
+
+
+
+def createDataset(loss='hamming', numInstances=0):
+
+ if loss not in ['hamming','h','gh','generalized-hamming']:
+ raise RuntimeError("loss must be 'hamming' /'h' or 'generalized-hamming'/'gh' ")
+
+ if loss in ['hamming','h']:
+ return DatasetWithHammingLoss(int(numInstances))
+ elif loss in ['generalized-hamming','gh']:
+ return DatasetWithGeneralizedHammingLoss(int(numInstances))
+ else:
+ raise RuntimeError("loss must be 'hamming' /'h' or 'generalized-hamming'/'gh' ")
+
--
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