[opengm] 122/386: adding more safeguards

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Wed Aug 31 08:35:43 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 10ee8160691a6e4219fd4cbb6ffde6ffa73c08d8
Author: mschiegg <martin.schiegg at iwr.uni-heidelberg.de>
Date:   Thu Dec 18 15:34:49 2014 +0100

    adding more safeguards
---
 include/opengm/learning/dataset/dataset.hxx         | 10 +++++++---
 include/opengm/learning/dataset/editabledataset.hxx |  6 +++---
 include/opengm/learning/dataset/testdatasets.hxx    |  8 ++++++++
 3 files changed, 18 insertions(+), 6 deletions(-)

diff --git a/include/opengm/learning/dataset/dataset.hxx b/include/opengm/learning/dataset/dataset.hxx
index 3fc724a..f9c1a6e 100644
--- a/include/opengm/learning/dataset/dataset.hxx
+++ b/include/opengm/learning/dataset/dataset.hxx
@@ -63,13 +63,17 @@ namespace opengm {
             weights_(Weights(0)),
             lossParams_(std::vector<LossParameterType>(numInstances))
       {
-      }; 
+      }
 
 
      template<class GM, class LOSS>
      void Dataset<GM, LOSS>::buildModelWithLoss(size_t i){
-         gmsWithLoss_[i] = gms_[i];
-         LOSS loss(lossParams_[i]);
+         OPENGM_ASSERT_OP(i, <, lossParams_.size());
+         OPENGM_ASSERT_OP(i, <, gmsWithLoss_.size());
+         OPENGM_ASSERT_OP(i, <, gms_.size());
+         OPENGM_ASSERT_OP(i, <, gts_.size());
+         gmsWithLoss_[i] = gms_[i];    
+         LOSS loss(lossParams_[i]);         
          loss.addLoss(gmsWithLoss_[i], gts_[i].begin());
       }
 
diff --git a/include/opengm/learning/dataset/editabledataset.hxx b/include/opengm/learning/dataset/editabledataset.hxx
index ed84663..7bab7e6 100644
--- a/include/opengm/learning/dataset/editabledataset.hxx
+++ b/include/opengm/learning/dataset/editabledataset.hxx
@@ -63,9 +63,9 @@ namespace opengm {
         this->gts_.push_back(gt);
         this->lossParams_.push_back(p);
         this->gmsWithLoss_.resize(this->gts_.size());
-        this->buildModelWithLoss(this->gts_.size()-1);
-        this->count_.push_back(0);
-        this->isCached_.push_back(bool());
+        this->isCached_.resize(this->gts_.size());
+        this->count_.resize(this->gts_.size());
+        this->buildModelWithLoss(this->gts_.size()-1);        
         OPENGM_CHECK_OP(this->gms_.size(), ==, this->gts_.size(),"");
         OPENGM_CHECK_OP(this->gms_.size(), ==, this->lossParams_.size(),"");
         OPENGM_CHECK_OP(this->gms_.size(), ==, this->gmsWithLoss_.size(),"");
diff --git a/include/opengm/learning/dataset/testdatasets.hxx b/include/opengm/learning/dataset/testdatasets.hxx
index fde3751..2753695 100644
--- a/include/opengm/learning/dataset/testdatasets.hxx
+++ b/include/opengm/learning/dataset/testdatasets.hxx
@@ -75,6 +75,8 @@ namespace opengm {
       template<class GM, class LOSS>
       TestDataset0<GM,LOSS>::TestDataset0(size_t numModels)
       { 
+         this->lossParams_.resize(numModels);
+         this->isCached_.resize(numModels);
          this->count_.resize(numModels,0);
          this->weights_ = Weights(1);
          LabelType numberOfLabels = 2;
@@ -123,6 +125,8 @@ namespace opengm {
       template<class GM, class LOSS>
       TestDataset1<GM,LOSS>::TestDataset1(size_t numModels)
       { 
+         this->lossParams_.resize(numModels);
+         this->isCached_.resize(numModels);
          this->count_.resize(numModels,0);
          this->weights_ = Weights(1);
          LabelType numberOfLabels = 2;
@@ -180,6 +184,8 @@ namespace opengm {
       template<class GM, class LOSS>
       TestDataset2<GM,LOSS>::TestDataset2(size_t numModels)
       { 
+         this->lossParams_.resize(numModels);
+         this->isCached_.resize(numModels);
          this->count_.resize(numModels,0);
          this->weights_ = Weights(3);
          LabelType numberOfLabels = 2;
@@ -244,6 +250,8 @@ namespace opengm {
       template<class GM, class LOSS>
       TestDatasetSimple<GM,LOSS>::TestDatasetSimple(size_t numModels)
       { 
+         this->lossParams_.resize(numModels);
+         this->isCached_.resize(numModels);
          this->count_.resize(numModels,0);
          this->weights_ = Weights(2);
          LabelType numberOfLabels = 2;

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