MLPACK  1.0.11
hyperbolic_tangent_kernel.hpp
Go to the documentation of this file.
1 
22 #ifndef __MLPACK_CORE_KERNELS_HYPERBOLIC_TANGENT_KERNEL_HPP
23 #define __MLPACK_CORE_KERNELS_HYPERBOLIC_TANGENT_KERNEL_HPP
24 
25 #include <mlpack/core.hpp>
26 
27 namespace mlpack {
28 namespace kernel {
29 
39 {
40  public:
45  { }
46 
55  scale(scale), offset(offset)
56  { }
57 
67  template<typename VecType>
68  double Evaluate(const VecType& a, const VecType& b)
69  {
70  return tanh(scale * arma::dot(a, b) + offset);
71  }
72 
74  double Scale() const { return scale; }
76  double& Scale() { return scale; }
77 
79  double Offset() const { return offset; }
81  double& Offset() { return offset; }
82 
84  std::string ToString() const
85  {
86  std::ostringstream convert;
87  convert << "HyperbolicTangentKernel [" << this << "]" << std::endl;
88  convert << " Scale: " << scale << std::endl;
89  convert << " Offset: " << offset << std::endl;
90  return convert.str();
91  }
92 
93  private:
94  double scale;
95  double offset;
96 };
97 
98 }; // namespace kernel
99 }; // namespace mlpack
100 
101 #endif
std::string ToString() const
Convert object to string.
HyperbolicTangentKernel()
This constructor sets the default scale to 1.0 and offset to 0.0.
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: load.hpp:31
double Evaluate(const VecType &a, const VecType &b)
Evaluate the hyperbolic tangent kernel.
double & Offset()
Modify offset for the kernel.
HyperbolicTangentKernel(double scale, double offset)
Construct the hyperbolic tangent kernel with custom scale factor and offset.
double Offset() const
Get offset for the kernel.