[opengm] 96/386: added embarrassingly simple dataset
Ghislain Vaillant
ghisvail-guest at moszumanska.debian.org
Wed Aug 31 08:35:11 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 f7f459a5cff072d903687ca8ca8d8d50bd899d20
Author: Jan Funke <funke at ini.ch>
Date: Wed Dec 17 14:41:58 2014 +0100
added embarrassingly simple dataset
---
include/opengm/learning/dataset/testdatasets.hxx | 56 ++++++++++++++++++++++++
1 file changed, 56 insertions(+)
diff --git a/include/opengm/learning/dataset/testdatasets.hxx b/include/opengm/learning/dataset/testdatasets.hxx
index 1517088..4ecc355 100644
--- a/include/opengm/learning/dataset/testdatasets.hxx
+++ b/include/opengm/learning/dataset/testdatasets.hxx
@@ -55,6 +55,20 @@ namespace opengm {
TestDataset2(size_t numModels=4);
};
+ template<class GM, class LOSS>
+ class TestDatasetSimple : 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;
+
+ TestDatasetSimple(size_t numModels=1);
+ };
+
//***********************************
//** IMPL TestDataset 0
//***********************************
@@ -223,6 +237,48 @@ namespace opengm {
this->buildModelWithLoss(m);
}
};
+
+//***********************************
+//** Embarrassingly simple dataset
+//***********************************
+ template<class GM, class LOSS>
+ TestDatasetSimple<GM,LOSS>::TestDatasetSimple(size_t numModels)
+ {
+ this->count_.resize(numModels,0);
+ this->weights_ = Weights(2);
+ LabelType numberOfLabels = 2;
+ this->gt_.resize(numModels,std::vector<size_t>(1,0));
+ for(size_t m=0; m<numModels; ++m){
+ this->gt_[m][0] = 0;
+ }
+ this->gms_.resize(numModels);
+ this->gmsWithLoss_.resize(numModels);
+ for(size_t m=0; m<numModels; ++m){
+ std::srand(m);
+ this->gms_[m].addVariable(2);
+
+ // 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 = 0.5;
+ feat[0](0) = val0;
+ feat[0](1) = val0-1;
+ ValueType val1 = -0.25;
+ feat[1](0) = val1;
+ feat[1](1) = val1-1;
+ std::vector<size_t> wID(2);
+ wID[0]=0; wID[1]=1;
+ 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[] = {0};
+ this->gms_[m].addFactor(fid, variableIndices, variableIndices + 1);
+
+ this->buildModelWithLoss(m);
+ }
+ };
}
} // namespace opengm
--
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