[opengm] 148/386: remove obsolete learnable functions

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Wed Aug 31 08:36:42 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 45f36638d1fdb4befa1e10dc471955f619918066
Author: mschiegg <martin.schiegg at iwr.uni-heidelberg.de>
Date:   Fri Dec 19 10:20:42 2014 +0100

    remove obsolete learnable functions
---
 include/opengm/functions/l_potts.hxx           | 203 -------------------------
 include/opengm/functions/learnablefunction.hxx | 144 ------------------
 2 files changed, 347 deletions(-)

diff --git a/include/opengm/functions/l_potts.hxx b/include/opengm/functions/l_potts.hxx
deleted file mode 100644
index 07d7a07..0000000
--- a/include/opengm/functions/l_potts.hxx
+++ /dev/null
@@ -1,203 +0,0 @@
-#pragma once
-#ifndef OPENGM_L_POTTS_FUNCTION_HXX
-#define OPENGM_L_POTTS_FUNCTION_HXX
-
-#include <algorithm>
-#include <vector>
-#include <cmath>
-
-#include "opengm/opengm.hxx"
-#include "opengm/functions/function_registration.hxx"
-#include "opengm/functions/function_properties_base.hxx"
-#include "opengm/graphicalmodel/weights.hxx"
-
-namespace opengm {
-
-/// Potts function for two variables
-///
-/// \ingroup functions
-template<class T, class I = size_t, class L = size_t>
-class LPottsFunction
-: public FunctionBase<LPottsFunction<T, I, L>, T, I, L>
-{
-public:
-   typedef T ValueType;
-   typedef L LabelType;
-   typedef I IndexType;
-
-   LPottsFunction(
-      const LabelType,
-      const LabelType,
-      const opengm::learning::Weights<ValueType> & parameters,
-      const IndexType valueNotEqual
-   );
-   LabelType shape(const size_t) const;
-   size_t size() const;
-   size_t dimension() const;
-   template<class ITERATOR> ValueType operator()(ITERATOR) const;
-   bool operator==(const LPottsFunction& ) const;
-   // specializations
-   bool isPotts() const;
-   bool isGeneralizedPotts() const;
-   ValueType min() const;
-   ValueType max() const;
-   ValueType sum() const;
-   ValueType product() const;
-   MinMaxFunctor<ValueType> minMax() const;
-
-   // parameters
-   size_t numberOfWeights()const{
-      return 1;
-   }
-   IndexType weightIndex(const size_t paramNumber)const{
-      return piValueNotEqual_;
-   }
-
-
-private:
-   LabelType numberOfLabels1_;
-   LabelType numberOfLabels2_;
-
-   const opengm::learning::Weights<ValueType> * weights_;
-
-   IndexType piValueNotEqual_;
-
-friend class FunctionSerialization<LPottsFunction<T, I, L> > ;
-};
-
-
-template<class T, class I, class L>
-struct FunctionRegistration<LPottsFunction<T, I, L> > {
-   enum ID {
-      Id = opengm::FUNCTION_TYPE_ID_OFFSET + 100 + 6
-   };
-};
-
-
-
-
-
-template <class T, class I, class L>
-inline
-LPottsFunction<T, I, L>::LPottsFunction
-(
-   const L numberOfLabels1,
-   const L numberOfLabels2,
-   const opengm::learning::Weights<ValueType> & weights,
-   const IndexType valueNotEqual
-)
-:  numberOfLabels1_(numberOfLabels1),
-   numberOfLabels2_(numberOfLabels2),
-   weights_(&weights),
-   piValueNotEqual_(valueNotEqual)
-{}
-
-template <class T, class I, class L>
-template <class ITERATOR>
-inline T
-LPottsFunction<T, I, L>::operator()
-(
-   ITERATOR begin
-) const {
-   return (begin[0]==begin[1] ? 
-      static_cast<ValueType>(0.0) : weights_->getWeight(piValueNotEqual_) );
-}
-
-
-
-template <class T, class I, class L>
-inline L
-LPottsFunction<T, I, L>::shape
-(
-   const size_t i
-) const {
-   OPENGM_ASSERT(i < 2);
-   return (i==0 ? numberOfLabels1_ : numberOfLabels2_);
-}
-
-template <class T, class I, class L>
-inline size_t
-LPottsFunction<T, I, L>::dimension() const {
-   return 2;
-}
-
-template <class T, class I, class L>
-inline size_t
-LPottsFunction<T, I, L>::size() const {
-   return numberOfLabels1_*numberOfLabels2_;
-}
-
-
-template<class T, class I, class L>
-inline bool
-LPottsFunction<T, I, L>::operator==
-(
-   const LPottsFunction & fb
-   )const{
-   return  numberOfLabels1_ == fb.numberOfLabels1_ &&
-      numberOfLabels2_ == fb.numberOfLabels2_ &&
-      piValueNotEqual_   == fb.piValueNotEqual_;
-}
-
-
-template<class T, class I, class L>
-inline bool
-LPottsFunction<T, I, L>::isPotts() const
-{
-   return true;
-}
-
-template<class T, class I, class L>
-inline bool
-LPottsFunction<T, I, L>::isGeneralizedPotts() const
-{
-   return true;
-}
-
-template<class T, class I, class L>
-inline typename LPottsFunction<T, I, L>::ValueType
-LPottsFunction<T, I, L>::min() const
-{
-   const T val = weights_->getWeight(piValueNotEqual_);
-   return 0.0<val ? 0.0 :val;
-}
-
-template<class T, class I, class L>
-inline typename LPottsFunction<T, I, L>::ValueType
-LPottsFunction<T, I, L>::max() const
-{
-  const T val = weights_->getWeight(piValueNotEqual_);
-  return 0.0>val ? 0.0 :val;
-}
-
-template<class T, class I, class L>
-inline typename LPottsFunction<T, I, L>::ValueType
-LPottsFunction<T, I, L>::sum() const
-{
-    const T val = weights_->getWeight(piValueNotEqual_);
-    const LabelType minLabels = std::min(numberOfLabels1_, numberOfLabels2_);
-    return val * static_cast<T>(numberOfLabels1_ * numberOfLabels2_ - minLabels);
-}
-
-template<class T, class I, class L>
-inline typename LPottsFunction<T, I, L>::ValueType
-LPottsFunction<T, I, L>::product() const
-{
-   return static_cast<ValueType>(0);
-}
-
-template<class T, class I, class L>
-inline MinMaxFunctor<typename LPottsFunction<T, I, L>::ValueType>
-LPottsFunction<T, I, L>::minMax() const
-{
-   if(static_cast<ValueType>(0) < piValueNotEqual_) {
-      return MinMaxFunctor<T>(static_cast<ValueType>(0), weights_[piValueNotEqual_]);
-   }
-   else {
-      return MinMaxFunctor<T>(weights_[piValueNotEqual_], static_cast<ValueType>(0));
-   }
-}
-
-} // namespace opengm
-
-#endif // #ifndef OPENGM_L_POTTS_FUNCTION_HXX
diff --git a/include/opengm/functions/learnablefunction.hxx b/include/opengm/functions/learnablefunction.hxx
deleted file mode 100644
index 314fbd9..0000000
--- a/include/opengm/functions/learnablefunction.hxx
+++ /dev/null
@@ -1,144 +0,0 @@
-#pragma once
-#ifndef OPENGM_LEARNABLE_FEATURE_FUNCTION_HXX
-#define OPENGM_LEARNABLE_FEATURE_FUNCTION_HXX
-
-#include <algorithm>
-#include <vector>
-#include <cmath>
-
-#include "opengm/opengm.hxx"
-#include "opengm/functions/function_registration.hxx"
-#include "opengm/functions/function_properties_base.hxx"
-
-namespace opengm {
-
-
-
-
-
-/// Learnable feature function for two variables
-///
-/// f(x) = w * A(x) * feat
-///  - w    = parameter vector
-///  - feat = feature vector
-///  - A    = assignment matrix variant to the labeling x
-///
-/// derive from this class and implement the function
-///   paramaterGradient(i,x)= A(x)_{i,*}*feat
-///  
-/// \ingroup functions
-template<class T, class I = size_t, class L = size_t>
-class LearnableFeatureFunction
-: public FunctionBase<LearnableFeatureFunction<T, I, L>, T, I, L>
-{
-public:
-   typedef T ValueType;
-   typedef L LabelType;
-   typedef I IndexType;
-
-   LearnableFeatureFunction(const opengm::learning::Weights<T>& weights,
-      const std::vector<L>& shape,
-      const std::vector<size_t>& weightIDs,
-      const std::vector<T>& feat
-      );
-   L shape(const size_t) const;
-   size_t size() const;
-   size_t dimension() const;
-   template<class ITERATOR> T operator()(ITERATOR) const;
- 
-   // parameters
-   size_t numberOfWeights()const
-     {return weightIDs_.size();}
-   I weightIndex(const size_t weightNumber) const
-     {return weightIDs_[weightNumber];} //dummy
-   template<class ITERATOR> 
-   T weightGradient(size_t,ITERATOR) const;
-
-protected:
-   const opengm::learning::Weights<T> * weights_;
-   const std::vector<L> shape_;
-   const std::vector<size_t> weightIDs_;
-   const std::vector<T> feat_;
-
-
-friend class FunctionSerialization<LearnableFeatureFunction<T, I, L> > ;
-};
-
-
-template<class T, class I, class L>
-struct FunctionRegistration<LearnableFeatureFunction<T, I, L> > {
-   enum ID {
-      Id = opengm::FUNCTION_TYPE_ID_OFFSET + 100 + 64
-   };
-};
-
-template <class T, class I, class L>
-inline
-LearnableFeatureFunction<T, I, L>::LearnableFeatureFunction
-( 
-   const opengm::learning::Weights<T>& weights,
-   const std::vector<L>& shape,
-   const std::vector<size_t>& weightIDs,
-   const std::vector<T>& feat
-   )
-   :  weights_(&weights), shape_(shape), weightIDs_(weightIDs),feat_(feat)
-{}
-
-template <class T, class I, class L>
-template <class ITERATOR>
-inline T
-LearnableFeatureFunction<T, I, L>::weightGradient
-(
-   size_t weightNumber,
-   ITERATOR begin
-) const {
-   OPENGM_ASSERT(weightNumber< numberOfWeights());
-   return 0; // need to be implemented
-}
-
-
-template <class T, class I, class L>
-template <class ITERATOR>
-inline T
-LearnableFeatureFunction<T, I, L>::operator()
-(
-   ITERATOR begin
-) const {
-   T val = 0;
-   for(size_t i=0;i<numberOfWeights();++i){
-      val += weights_->getWeight(i) * weightGradient(i,begin);
-   }
-}
-
-
-template <class T, class I, class L>
-inline L
-LearnableFeatureFunction<T, I, L>::shape
-(
-   const size_t i
-) const {
-   return shape_[i];
-}
-
-template <class T, class I, class L>
-inline size_t
-LearnableFeatureFunction<T, I, L>::dimension() const {
-   return shape_.size();
-}
-
-template <class T, class I, class L>
-inline size_t
-LearnableFeatureFunction<T, I, L>::size() const {
-   size_t s = 1;
-   for(size_t i=0;i<dimension(); ++i)
-      s *= shape(i);
-   return s;
-}
-
-
-
-
-
-} // namespace opengm
-
-#endif // #ifndef OPENGM_LEARNABLE_FUNCTION_HXX

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