[opengm] 59/386: change to new testmodels
Ghislain Vaillant
ghisvail-guest at moszumanska.debian.org
Wed Aug 31 08:35:05 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 7c396bebf43384226b88ad6fb34a91cf65e71bfb
Author: joergkappes <kappes at math.uni-heidelberg.de>
Date: Tue Dec 16 10:59:03 2014 +0100
change to new testmodels
---
include/opengm/learning/dataset/dataset.hxx | 27 +++--
include/opengm/learning/dataset/dataset_io.hxx | 95 ++++++++++++-----
include/opengm/learning/dataset/testdataset.hxx | 15 ++-
include/opengm/learning/dataset/testdataset2.hxx | 14 ++-
include/opengm/learning/dataset/testdatasets.hxx | 125 +++++++++++++++++++----
src/unittest/learning/test_dataset.cxx | 15 ++-
src/unittest/learning/test_dataset_io.cxx | 22 ++--
src/unittest/test_gridsearch_learner.cxx | 19 ++--
8 files changed, 246 insertions(+), 86 deletions(-)
diff --git a/include/opengm/learning/dataset/dataset.hxx b/include/opengm/learning/dataset/dataset.hxx
index 4d07dbf..c48ecab 100644
--- a/include/opengm/learning/dataset/dataset.hxx
+++ b/include/opengm/learning/dataset/dataset.hxx
@@ -16,24 +16,28 @@ namespace opengm {
public:
typedef GM GMType;
typedef GM GMWITHLOSS;
+ typedef LOSS LossType;
typedef typename GM::ValueType ValueType;
typedef typename GM::IndexType IndexType;
typedef typename GM::LabelType LabelType;
typedef opengm::learning::Weights<ValueType> Weights;
- bool lockModel(const size_t i) { ++count_[i]; }
- bool unlockModel(const size_t i) { OPENGM_ASSERT(count_[i]>0); --count_[i]; }
- const GM& getModel(const size_t i) { return gms_[i]; }
- const GMWITHLOSS& getModelWithLoss(const size_t i) { return gmsWithLoss_[i]; }
- const std::vector<LabelType>& getGT(const size_t i) { return gt_[i]; }
- Weights& getWeights() { return weights_; }
- size_t getNumberOfWeights() { return weights_.numberOfWeights(); }
- size_t getNumberOfModels() { return gms_.size(); }
+ bool lockModel(const size_t i) { ++count_[i]; }
+ bool unlockModel(const size_t i) { OPENGM_ASSERT(count_[i]>0); --count_[i]; }
+ const GM& getModel(const size_t i) const { return gms_[i]; }
+ const GMWITHLOSS& getModelWithLoss(const size_t i)const { return gmsWithLoss_[i]; }
+ const std::vector<LabelType>& getGT(const size_t i) const { return gt_[i]; }
+ Weights& getWeights() { return weights_; }
+ size_t getNumberOfWeights() const { return weights_.numberOfWeights(); }
+ size_t getNumberOfModels() const { return gms_.size(); }
Dataset();
- void loadAll(std::string path,std::string prefix);
+ //void loadAll(std::string path,std::string prefix);
+
+ friend class DatasetSerialization;
+ // friend void loadAll<Dataset<GM,LOSS> > (const std::string datasetpath, const std::string prefix, Dataset<GM,LOSS>& ds);
- private:
+ protected:
std::vector<size_t> count_;
std::vector<bool> isCached_;
std::vector<GM> gms_;
@@ -65,7 +69,7 @@ namespace opengm {
loss.addLoss(gmsWithLoss_[i], gt_[i].begin());
}
-
+/*
template<class GM, class LOSS>
void Dataset<GM, LOSS>::loadAll(std::string datasetpath,std::string prefix){
@@ -96,6 +100,7 @@ namespace opengm {
}
};
+*/
}
} // namespace opengm
diff --git a/include/opengm/learning/dataset/dataset_io.hxx b/include/opengm/learning/dataset/dataset_io.hxx
index 8445d62..a4154f1 100644
--- a/include/opengm/learning/dataset/dataset_io.hxx
+++ b/include/opengm/learning/dataset/dataset_io.hxx
@@ -8,34 +8,79 @@
//#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> numWeights(1,dataset.getNumberOfWeights());
- std::vector<size_t> numModels(1,dataset.getNumberOfModels());
+ namespace datasets{
+
+ class DatasetSerialization{
+ public:
+ template<class DATASET>
+ static void save(const DATASET& dataset, const std::string datasetpath, const std::string prefix="");
+ template<class DATASET>
+ static void loadAll(const std::string datasetpath, const std::string prefix, DATASET& dataset);
+ };
+
+ template<class DATASET>
+ void DatasetSerialization::save(const DATASET& dataset, const std::string datasetpath, const std::string prefix) {
+ typedef typename DATASET::GMType GMType;
+ typedef typename GMType::LabelType LabelType;
+ typedef typename GMType::ValueType ValueType;
+
+ std::vector<size_t> numWeights(1,dataset.getNumberOfWeights());
+ 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,"numberOfWeights",numWeights);
- 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);
+ 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,"numberOfWeights",numWeights);
+ 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);
+ }
+
+ };
+
+ template<class DATASET>
+ void DatasetSerialization::loadAll(const std::string datasetpath, const std::string prefix, DATASET& dataset) {
+ typedef typename DATASET::GMType GMType;
+ typedef typename GMType::LabelType LabelType;
+ typedef typename GMType::ValueType ValueType;
+
+ //Load Header
+ std::stringstream hss;
+ hss << datasetpath << "/"<<prefix<<"info.h5";
+ hid_t file = marray::hdf5::openFile(hss.str());
+ std::vector<size_t> temp(1);
+ marray::hdf5::loadVec(file, "numberOfWeights", temp);
+ size_t numWeights = temp[0];
+ marray::hdf5::loadVec(file, "numberOfModels", temp);
+ size_t numModel = temp[0];
marray::hdf5::closeFile(file);
- }
+
+ dataset.gms_.resize(numModel);
+ dataset.gmsWithLoss_.resize(numModel);
+ dataset.gt_.resize(numModel);
+ dataset.weights_ = opengm::learning::Weights<ValueType>(numWeights);
+ //Load Models and ground truth
+ for(size_t m=0; m<numModel; ++m){
+ std::stringstream ss;
+ ss << datasetpath <<"/"<<prefix<<"gm_" << m <<".h5";
+ hid_t file = marray::hdf5::openFile(ss.str());
+ marray::hdf5::loadVec(file, "gt", dataset.gt_[m]);
+ marray::hdf5::closeFile(file);
+ opengm::hdf5::load(dataset.gms_[m],ss.str(),"gm");
+ dataset.buildModelWithLoss(m);
+ }
+ };
- };
+ }
}
#endif
diff --git a/include/opengm/learning/dataset/testdataset.hxx b/include/opengm/learning/dataset/testdataset.hxx
index 4e807eb..c1a0670 100644
--- a/include/opengm/learning/dataset/testdataset.hxx
+++ b/include/opengm/learning/dataset/testdataset.hxx
@@ -1,3 +1,8 @@
+
+//make it obsolet
+#define OPENGM_TESTDATASET_HXX
+
+
#pragma once
#ifndef OPENGM_TESTDATASET_HXX
#define OPENGM_TESTDATASET_HXX
@@ -19,11 +24,11 @@ namespace opengm {
typedef typename GM::LabelType LabelType;
typedef opengm::learning::Weights<ValueType> Weights;
- GM& getModel(const size_t i) { return gms_[i]; }
- const std::vector<LabelType>& getGT(const size_t i) { return gt_; }
- Weights& getWeights() { return weights_; }
- size_t getNumberOfWeights() { return 1; }
- size_t getNumberOfModels() { return gms_.size(); }
+ const GM& getModel(const size_t i) const { return gms_[i]; }
+ const std::vector<LabelType>& getGT(const size_t i) const { return gt_; }
+ Weights& getWeights() { return weights_; }
+ size_t getNumberOfWeights() const { return 1; }
+ size_t getNumberOfModels() const { return gms_.size(); }
TestDataset(size_t numModels=10);
diff --git a/include/opengm/learning/dataset/testdataset2.hxx b/include/opengm/learning/dataset/testdataset2.hxx
index 449216e..762158a 100644
--- a/include/opengm/learning/dataset/testdataset2.hxx
+++ b/include/opengm/learning/dataset/testdataset2.hxx
@@ -1,3 +1,7 @@
+
+//Make it obsolet
+#define OPENGM_TESTDATASET2_HXX
+
#pragma once
#ifndef OPENGM_TESTDATASET2_HXX
#define OPENGM_TESTDATASET2_HXX
@@ -20,11 +24,11 @@ namespace opengm {
typedef typename GM::LabelType LabelType;
typedef opengm::learning::Weights<ValueType> Weights;
- GM& getModel(const size_t i) { return gms_[i]; }
- const std::vector<LabelType>& getGT(const size_t i) { return gt_; }
- Weights& getWeights() { return weights_; }
- size_t getNumberOfWeights() { return 3; }
- size_t getNumberOfModels() { return gms_.size(); }
+ const GM& getModel(const size_t i)const { return gms_[i]; }
+ const std::vector<LabelType>& getGT(const size_t i)const { return gt_; }
+ Weights& getWeights() { return weights_; }
+ size_t getNumberOfWeights()const { return 3; }
+ size_t getNumberOfModels()const { return gms_.size(); }
TestDataset2(size_t numModels=4);
diff --git a/include/opengm/learning/dataset/testdatasets.hxx b/include/opengm/learning/dataset/testdatasets.hxx
index 69201e9..948fe1e 100644
--- a/include/opengm/learning/dataset/testdatasets.hxx
+++ b/include/opengm/learning/dataset/testdatasets.hxx
@@ -7,65 +7,154 @@
#include <opengm/learning/dataset/dataset.hxx>
#include <opengm/functions/learnable/lpotts.hxx>
+#include <opengm/functions/learnable/sum_of_experts.hxx>
namespace opengm {
namespace datasets{
template<class GM, class LOSS>
- class TestDataset1 : public Dataset<GM,LOSS>{
+ class TestDataset1 : public Dataset<GM,LOSS>{
+ public:
+ typedef GM GMType;
+ typedef GM GMWITHLOSS;
+ typedef LOSS LossType;
+ typedef typename GM::ValueType ValueType;
+ typedef typename GM::IndexType IndexType;
+ typedef typename GM::LabelType LabelType;
+ typedef opengm::learning::Weights<ValueType> Weights;
+
TestDataset1(size_t numModels=10);
};
template<class GM, class LOSS>
+ class TestDataset2 : public Dataset<GM,LOSS>{
+ public:
+ typedef GM GMType;
+ typedef GM GMWITHLOSS;
+ typedef LOSS LossType;
+ typedef typename GM::ValueType ValueType;
+ typedef typename GM::IndexType IndexType;
+ typedef typename GM::LabelType LabelType;
+ typedef opengm::learning::Weights<ValueType> Weights;
+
+ TestDataset2(size_t numModels=10);
+ };
+
+//***********************************
+//** IMPL TestDataset 1
+//***********************************
+ template<class GM, class LOSS>
TestDataset1<GM,LOSS>::TestDataset1(size_t numModels)
- : weights_(Weights(1))
- {
+ {
+ this->weights_ = Weights(1);
LabelType numberOfLabels = 2;
- gt_.resize(64*64,0);
- for(size_t i=32*64; i<64*64; ++i){
- gt_[i] = 1;
+ this->gt_.resize(numModels,std::vector<size_t>(64*64,0));
+ for(size_t m=0;m<numModels;++m){
+ for(size_t i=32*64; i<64*64; ++i){
+ this->gt_[m][i] = 1;
+ }
}
- gms_.resize(numModels);
+ this->gms_.resize(numModels);
for(size_t m=0; m<numModels; ++m){
std::srand(m);
- for (int j = 0; j < 64*64; j++)
- gms_[m].addVariable(2);
+ for (int j = 0; j < 64*64; j++)
+ this->gms_[m].addVariable(2);
for(size_t y = 0; y < 64; ++y){
for(size_t x = 0; x < 64; ++x) {
// function
const size_t shape[] = {numberOfLabels};
ExplicitFunction<ValueType> f(shape, shape + 1);
- ValueType val = (double)(gt_[y*64+x]) + (double)(std::rand()) / (double) (RAND_MAX) * 1.5 - 0.75 ;
+ ValueType val = (double)(this->gt_[m][y*64+x]) + (double)(std::rand()) / (double) (RAND_MAX) * 1.5 - 0.75 ;
f(0) = std::fabs(val-0);
f(1) = std::fabs(val-1);
- typename GM::FunctionIdentifier fid = gms_[m].addFunction(f);
+ typename GM::FunctionIdentifier fid = this->gms_[m].addFunction(f);
// factor
size_t variableIndices[] = {y*64+x};
- gms_[m].addFactor(fid, variableIndices, variableIndices + 1);
+ this->gms_[m].addFactor(fid, variableIndices, variableIndices + 1);
}
}
- opengm::functions::learnable::LPotts<ValueType,IndexType,LabelType> f(weights_,2,std::vector<size_t>(1,0),std::vector<ValueType>(1,1));
- typename GM::FunctionIdentifier fid = gms_[m].addFunction(f);
+ opengm::functions::learnable::LPotts<ValueType,IndexType,LabelType> f(this->weights_,2,std::vector<size_t>(1,0),std::vector<ValueType>(1,1));
+ typename GM::FunctionIdentifier fid = this->gms_[m].addFunction(f);
for(size_t y = 0; y < 64; ++y){
for(size_t x = 0; x < 64; ++x) {
if(x + 1 < 64) { // (x, y) -- (x + 1, y)
size_t variableIndices[] = {y*64+x, y*64+x+1};
//sort(variableIndices, variableIndices + 2);
- gms_[m].addFactor(fid, variableIndices, variableIndices + 2);
+ this->gms_[m].addFactor(fid, variableIndices, variableIndices + 2);
}
if(y + 1 < 64) { // (x, y) -- (x, y + 1)
size_t variableIndices[] = {y*64+x, (y+1)*64+x};
//sort(variableIndices, variableIndices + 2);
- gms_[m].addFactor(fid, variableIndices, variableIndices + 2);
+ this->gms_[m].addFactor(fid, variableIndices, variableIndices + 2);
}
}
}
- }
-
+ }
};
+//***********************************
+//** IMPL TestDataset 2
+//***********************************
+ template<class GM, class LOSS>
+ TestDataset2<GM,LOSS>::TestDataset2(size_t numModels)
+ {
+ this->weights_ = Weights(3);
+ LabelType numberOfLabels = 2;
+ this->gt_.resize(numModels,std::vector<size_t>(64*64,0));
+ for(size_t m=0;m<numModels;++m){
+ for(size_t i=32*64; i<64*64; ++i){
+ this->gt_[m][i] = 1;
+ }
+ }
+ this->gms_.resize(numModels);
+ for(size_t m=0; m<numModels; ++m){
+ std::srand(m);
+ for (int j = 0; j < 64*64; j++)
+ this->gms_[m].addVariable(2);
+ for(size_t y = 0; y < 64; ++y){
+ for(size_t x = 0; x < 64; ++x) {
+ // function
+ const size_t numExperts = 2;
+ const std::vector<size_t> shape(1,numberOfLabels);
+ std::vector<marray::Marray<ValueType> > feat(numExperts,marray::Marray<ValueType>(shape.begin(), shape.end()));
+ ValueType val0 = (double)(this->gt_[m][y*64+x]) + (double)(std::rand()) / (double) (RAND_MAX) * 1.0 - 0.5 ;
+ feat[0](0) = std::fabs(val0-0);
+ feat[0](1) = std::fabs(val0-1);
+ ValueType val1 = (double)(this->gt_[m][y*64+x]) + (double)(std::rand()) / (double) (RAND_MAX) * 2.0 - 1.0 ;
+ feat[1](0) = std::fabs(val1-0);
+ feat[1](1) = std::fabs(val1-1);
+ std::vector<size_t> wID(2);
+ wID[0]=1; wID[1]=2;
+ opengm::functions::learnable::SumOfExperts<ValueType,IndexType,LabelType> f(shape,this->weights_, wID, feat);
+ typename GM::FunctionIdentifier fid = this->gms_[m].addFunction(f);
+
+ // factor
+ size_t variableIndices[] = {y*64+x};
+ this->gms_[m].addFactor(fid, variableIndices, variableIndices + 1);
+ }
+ }
+
+ opengm::functions::learnable::LPotts<ValueType,IndexType,LabelType> f(this->weights_,2,std::vector<size_t>(1,0),std::vector<ValueType>(1,1));
+ typename GM::FunctionIdentifier fid = this->gms_[m].addFunction(f);
+ for(size_t y = 0; y < 64; ++y){
+ for(size_t x = 0; x < 64; ++x) {
+ if(x + 1 < 64) { // (x, y) -- (x + 1, y)
+ size_t variableIndices[] = {y*64+x, y*64+x+1};
+ //sort(variableIndices, variableIndices + 2);
+ this->gms_[m].addFactor(fid, variableIndices, variableIndices + 2);
+ }
+ if(y + 1 < 64) { // (x, y) -- (x, y + 1)
+ size_t variableIndices[] = {y*64+x, (y+1)*64+x};
+ //sort(variableIndices, variableIndices + 2);
+ this->gms_[m].addFactor(fid, variableIndices, variableIndices + 2);
+ }
+ }
+ }
+ }
+ };
+
}
} // namespace opengm
diff --git a/src/unittest/learning/test_dataset.cxx b/src/unittest/learning/test_dataset.cxx
index 60cbbc9..7e4d4aa 100644
--- a/src/unittest/learning/test_dataset.cxx
+++ b/src/unittest/learning/test_dataset.cxx
@@ -10,10 +10,12 @@
#include <opengm/functions/learnable/lpotts.hxx>
#include <opengm/functions/learnable/sum_of_experts.hxx>
-#include <opengm/learning/dataset/testdataset.hxx>
-#include <opengm/learning/dataset/testdataset2.hxx>
+//#include <opengm/learning/dataset/testdataset.hxx>
+//#include <opengm/learning/dataset/testdataset2.hxx>
#include <opengm/learning/dataset/dataset_io.hxx>
#include <opengm/learning/dataset/dataset.hxx>
+#include <opengm/learning/dataset/testdatasets.hxx>
+#include <opengm/learning/loss/noloss.hxx>
//*************************************
@@ -22,8 +24,13 @@ typedef size_t IndexType;
typedef size_t LabelType;
typedef opengm::meta::TypeListGenerator<opengm::ExplicitFunction<ValueType,IndexType,LabelType>, opengm::functions::learnable::LPotts<ValueType,IndexType,LabelType>, opengm::functions::learnable::SumOfExperts<ValueType,IndexType,LabelType> >::type FunctionListType;
typedef opengm::GraphicalModel<ValueType,opengm::Adder, FunctionListType, opengm::DiscreteSpace<IndexType,LabelType> > GM;
-typedef opengm::datasets::TestDataset<GM> DS1;
-typedef opengm::datasets::Dataset<GM> DS;
+//typedef opengm::datasets::TestDataset<GM> DS1;
+//typedef opengm::datasets::Dataset<GM> DS;
+
+typedef opengm::learning::NoLoss LOSS;
+typedef opengm::datasets::TestDataset1<GM,LOSS> DS1;
+typedef opengm::datasets::TestDataset2<GM,LOSS> DS2;
+typedef opengm::datasets::Dataset<GM,LOSS> DS;
//*************************************
diff --git a/src/unittest/learning/test_dataset_io.cxx b/src/unittest/learning/test_dataset_io.cxx
index 6a1c8f4..fc86946 100644
--- a/src/unittest/learning/test_dataset_io.cxx
+++ b/src/unittest/learning/test_dataset_io.cxx
@@ -10,10 +10,12 @@
#include <opengm/functions/learnable/lpotts.hxx>
#include <opengm/functions/learnable/sum_of_experts.hxx>
-#include <opengm/learning/dataset/testdataset.hxx>
-#include <opengm/learning/dataset/testdataset2.hxx>
+//#include <opengm/learning/dataset/testdataset.hxx>
+//#include <opengm/learning/dataset/testdataset2.hxx>
#include <opengm/learning/dataset/dataset_io.hxx>
#include <opengm/learning/dataset/dataset.hxx>
+#include <opengm/learning/dataset/testdatasets.hxx>
+#include <opengm/learning/loss/noloss.hxx>
//*************************************
@@ -22,9 +24,10 @@ typedef size_t IndexType;
typedef size_t LabelType;
typedef opengm::meta::TypeListGenerator<opengm::ExplicitFunction<ValueType,IndexType,LabelType>, opengm::functions::learnable::LPotts<ValueType,IndexType,LabelType>, opengm::functions::learnable::SumOfExperts<ValueType,IndexType,LabelType> >::type FunctionListType;
typedef opengm::GraphicalModel<ValueType,opengm::Adder, FunctionListType, opengm::DiscreteSpace<IndexType,LabelType> > GM;
-typedef opengm::datasets::TestDataset<GM> DS1;
-typedef opengm::datasets::TestDataset2<GM> DS2;
-typedef opengm::datasets::Dataset<GM> DS;
+typedef opengm::learning::NoLoss LOSS;
+typedef opengm::datasets::TestDataset1<GM,LOSS> DS1;
+typedef opengm::datasets::TestDataset2<GM,LOSS> DS2;
+typedef opengm::datasets::Dataset<GM,LOSS> DS;
//*************************************
@@ -35,20 +38,21 @@ int main() {
{
DS1 dataset;
std::cout << "Dataset includes " << dataset.getNumberOfModels() << " instances and has " << dataset.getNumberOfWeights() << " parameters."<<std::endl;
- opengm::save(dataset,"./","dataset1_");
+ opengm::datasets::DatasetSerialization::save(dataset,"./","dataset1_");
std::cout <<"done!" <<std::endl;
}
{
DS2 dataset;
std::cout << "Dataset includes " << dataset.getNumberOfModels() << " instances and has " << dataset.getNumberOfWeights() << " parameters."<<std::endl;
- opengm::save(dataset,"./","dataset2_");
+ opengm::datasets::DatasetSerialization::save(dataset,"./","dataset2_");
std::cout <<"done!" <<std::endl;
}
{
- DS ds;
- ds.loadAll("./","dataset2_");
+ DS ds;
+ opengm::datasets::DatasetSerialization::loadAll("./","dataset2_",ds);
+ //ds.loadAll("./","dataset2_");
}
}
diff --git a/src/unittest/test_gridsearch_learner.cxx b/src/unittest/test_gridsearch_learner.cxx
index bbb948a..71e8a4b 100644
--- a/src/unittest/test_gridsearch_learner.cxx
+++ b/src/unittest/test_gridsearch_learner.cxx
@@ -12,9 +12,9 @@
#include <opengm/functions/learnable/sum_of_experts.hxx>
#include <opengm/learning/gridsearch-learning.hxx>
#include <opengm/learning/loss/hammingloss.hxx>
-#include <opengm/learning/dataset/testdataset.hxx>
-#include <opengm/learning/dataset/testdataset2.hxx>
-//#include <opengm/learning/dataset/testdatasets.hxx>
+//#include <opengm/learning/dataset/testdataset.hxx>
+//#include <opengm/learning/dataset/testdataset2.hxx>
+#include <opengm/learning/dataset/testdatasets.hxx>
//*************************************
@@ -23,18 +23,19 @@ typedef size_t IndexType;
typedef size_t LabelType;
typedef opengm::meta::TypeListGenerator<opengm::ExplicitFunction<ValueType,IndexType,LabelType>, opengm::functions::learnable::LPotts<ValueType,IndexType,LabelType>, opengm::functions::learnable::SumOfExperts<ValueType,IndexType,LabelType> >::type FunctionListType;
typedef opengm::GraphicalModel<ValueType,opengm::Adder, FunctionListType, opengm::DiscreteSpace<IndexType,LabelType> > GM;
-typedef opengm::datasets::TestDataset<GM> DS;
-//typedef opengm::datasets::TestDataset1<GM> DS1;
-typedef opengm::datasets::TestDataset2<GM> DS2;
+//typedef opengm::datasets::TestDataset<GM> DS;
+//typedef opengm::datasets::TestDataset2<GM> DS2;
typedef opengm::learning::HammingLoss LOSS;
typedef opengm::ICM<GM,opengm::Minimizer> INF;
+typedef opengm::datasets::TestDataset1<GM,LOSS> DS1;
+typedef opengm::datasets::TestDataset2<GM,LOSS> DS2;
//*************************************
int main() {
std::cout << " Includes are fine :-) " << std::endl;
-
+ /*
{
DS dataset;
std::cout << "Dataset includes " << dataset.getNumberOfModels() << " instances and has " << dataset.getNumberOfWeights() << " parameters."<<std::endl;
@@ -51,7 +52,7 @@ int main() {
learner.learn<INF>(infPara);
}
-/*
+ */
{
DS1 dataset;
std::cout << "Dataset includes " << dataset.getNumberOfModels() << " instances and has " << dataset.getNumberOfWeights() << " parameters."<<std::endl;
@@ -68,7 +69,7 @@ int main() {
learner.learn<INF>(infPara);
}
-*/
+
{
DS2 dataset;
std::cout << "Dataset includes " << dataset.getNumberOfModels() << " instances and has " << dataset.getNumberOfWeights() << " parameters."<<std::endl;
--
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