Class HyperbolicTangent
- All Implemented Interfaces:
Serializable
,Function
,DotProductKernel
- Direct Known Subclasses:
BinarySparseHyperbolicTangentKernel
,HyperbolicTangentKernel
,SparseHyperbolicTangentKernel
k(u, v) = tanh(γ uTv - λ)
where γ is the scale of the used inner product and λ is the offset of the used inner product. If the offset is negative the likelihood of obtaining a kernel matrix that is not positive definite is much higher (since then even some diagonal elements may be negative), hence if this kernel has to be used, the offset should always be positive. Note, however, that this is no guarantee that the kernel will be positive.
The hyperbolic tangent kernel was quite popular for support vector machines due to its origin from neural networks. However, it should be used carefully since the kernel matrix may not be positive semi-definite. Besides, it was reported the hyperbolic tangent kernel is not better than the Gaussian kernel in general.
- See Also:
-
Constructor Summary
ConstructorDescriptionHyperbolicTangent
(double scale, double offset, double[] lo, double[] hi) Constructor. -
Method Summary
Modifier and TypeMethodDescriptiondouble
k
(double dot) Computes the dot product kernel function.double[]
kg
(double dot) Computes the dot product kernel function and its gradient over hyperparameters.double
offset()
Returns the offset of kernel.double
scale()
Returns the scale of kernel.toString()
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface smile.math.kernel.DotProductKernel
apply, f, K
-
Constructor Details
-
HyperbolicTangent
public HyperbolicTangent(double scale, double offset, double[] lo, double[] hi) Constructor.- Parameters:
scale
- The scale parameter.offset
- The offset parameter.lo
- The lower bound of scale and offset for hyperparameter tuning.hi
- The upper bound of scale and offset for hyperparameter tuning.
-
-
Method Details
-
scale
public double scale()Returns the scale of kernel.- Returns:
- the scale of kernel.
-
offset
public double offset()Returns the offset of kernel.- Returns:
- the offset of kernel.
-
toString
-
k
public double k(double dot) Description copied from interface:DotProductKernel
Computes the dot product kernel function.- Specified by:
k
in interfaceDotProductKernel
- Parameters:
dot
- the dot product.- Returns:
- the kernel value.
-
kg
public double[] kg(double dot) Description copied from interface:DotProductKernel
Computes the dot product kernel function and its gradient over hyperparameters.- Specified by:
kg
in interfaceDotProductKernel
- Parameters:
dot
- The dot product.- Returns:
- the kernel value and gradient.
-