[opengm] 32/386: add missing file for dataset-io

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Wed Aug 31 08:35:01 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 82eca1495cfd867a4baef40a7c479df0ab1d6856
Author: joergkappes <kappes at math.uni-heidelberg.de>
Date:   Fri Nov 21 08:23:57 2014 +0100

    add missing file for dataset-io
---
 include/opengm/learning/dataset/dataset_io.hxx | 41 ++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)

diff --git a/include/opengm/learning/dataset/dataset_io.hxx b/include/opengm/learning/dataset/dataset_io.hxx
new file mode 100644
index 0000000..e35cc60
--- /dev/null
+++ b/include/opengm/learning/dataset/dataset_io.hxx
@@ -0,0 +1,41 @@
+#pragma once
+#ifndef OPENGM_DATASET_IO_HXX
+#define OPENGM_DATASET_IO_HXX
+
+#include <vector>
+#include <cstdlib>
+#include <opengm/graphicalmodel/graphicalmodel_hdf5.hxx>
+#include "H5Cpp.h"
+
+namespace opengm{
+   template<class DATASET>
+   void save(DATASET& dataset, std::string datasetpath, std::string prefix=""){
+
+      typedef typename DATASET::GMType   GMType;
+      typedef typename GMType::LabelType LabelType;
+     
+      std::vector<size_t> numPara(1,dataset.getNumberOfParameters());
+      std::vector<size_t> numModels(1,dataset.getNumberOfModels());
+  
+      std::stringstream hss;
+      hss << datasetpath << "/"<<prefix<<"info.h5";
+      hid_t file = marray::hdf5::createFile(hss.str(), marray::hdf5::DEFAULT_HDF5_VERSION);
+      marray::hdf5::save(file,"numberOfParameters",numPara);
+      marray::hdf5::save(file,"numberOfModels",numModels);
+      marray::hdf5::closeFile(file); 
+
+      for(size_t m=0; m<dataset.getNumberOfModels(); ++m){
+         const GMType&                 gm = dataset.getModel(m); 
+         const std::vector<LabelType>& gt = dataset.getGT(m);
+         std::stringstream ss, ss2;
+         ss  << datasetpath <<"/"<<prefix<<"gm_" << m <<".h5"; 
+         opengm::hdf5::save(gm,ss.str(),"gm");
+         hid_t file = marray::hdf5::openFile(ss.str(), marray::hdf5::READ_WRITE);
+         marray::hdf5::save(file,"gt",gt);
+         marray::hdf5::closeFile(file);
+      }
+
+   };
+}
+
+#endif

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