[mlpack-svn] r12740 - mlpack/trunk/src/mlpack/core/kernels

fastlab-svn at coffeetalk-1.cc.gatech.edu fastlab-svn at coffeetalk-1.cc.gatech.edu
Mon May 21 11:54:43 EDT 2012


Author: rcurtin
Date: 2012-05-21 11:54:42 -0400 (Mon, 21 May 2012)
New Revision: 12740

Modified:
   mlpack/trunk/src/mlpack/core/kernels/cosine_distance_impl.hpp
   mlpack/trunk/src/mlpack/core/kernels/gaussian_kernel.hpp
   mlpack/trunk/src/mlpack/core/kernels/polynomial_kernel.hpp
Log:
Update kernels in ugly ways that need to be removed later.


Modified: mlpack/trunk/src/mlpack/core/kernels/cosine_distance_impl.hpp
===================================================================
--- mlpack/trunk/src/mlpack/core/kernels/cosine_distance_impl.hpp	2012-05-21 15:54:30 UTC (rev 12739)
+++ mlpack/trunk/src/mlpack/core/kernels/cosine_distance_impl.hpp	2012-05-21 15:54:42 UTC (rev 12740)
@@ -16,7 +16,7 @@
 double CosineDistance::Evaluate(const VecType& a, const VecType& b)
 {
   // Since we are using the L2 inner product, this is easy.
-  return 1 - dot(a, b) / (norm(a, 2) * norm(b, 2));
+  return dot(a, b) / (norm(a, 2) * norm(b, 2));
 }
 
 }; // namespace kernel

Modified: mlpack/trunk/src/mlpack/core/kernels/gaussian_kernel.hpp
===================================================================
--- mlpack/trunk/src/mlpack/core/kernels/gaussian_kernel.hpp	2012-05-21 15:54:30 UTC (rev 12739)
+++ mlpack/trunk/src/mlpack/core/kernels/gaussian_kernel.hpp	2012-05-21 15:54:42 UTC (rev 12740)
@@ -121,6 +121,18 @@
   double gamma;
 };
 
+class GaussianStaticKernel
+{
+ public:
+  GaussianStaticKernel() { }
+
+  template<typename VecType>
+  static double Evaluate(const VecType& a, const VecType& b)
+  {
+    return exp(-0.5 * metric::SquaredEuclideanDistance::Evaluate(a, b));
+  }
+};
+
 }; // namespace kernel
 }; // namespace mlpack
 

Modified: mlpack/trunk/src/mlpack/core/kernels/polynomial_kernel.hpp
===================================================================
--- mlpack/trunk/src/mlpack/core/kernels/polynomial_kernel.hpp	2012-05-21 15:54:30 UTC (rev 12739)
+++ mlpack/trunk/src/mlpack/core/kernels/polynomial_kernel.hpp	2012-05-21 15:54:42 UTC (rev 12740)
@@ -82,6 +82,19 @@
   }
 };
 
+template<int denominator>
+class PolynomialFractionKernel
+{
+ public:
+  PolynomialFractionKernel();
+
+  template<typename VecType>
+  static double Evaluate(const VecType& a, const VecType& b)
+  {
+    return pow((arma::dot(a, b)), 1.0 / (double) denominator);
+  }
+};
+
 }; // namespace kernel
 }; // namespace mlpack
 




More information about the mlpack-svn mailing list