SHOGUN
3.2.1
首页
相关页面
模块
类
文件
文件列表
文件成员
全部
类
命名空间
文件
函数
变量
类型定义
枚举
枚举值
友元
宏定义
组
页
src
shogun
kernel
InverseMultiQuadricKernel.cpp
浏览该文件的文档.
1
/*
2
* This program is free software; you can redistribute it and/or modify
3
* it under the terms of the GNU General Public License as published by
4
* the Free Software Foundation; either version 3 of the License, or
5
* (at your option) any later version.
6
*
7
* Written (W) 2011 Abhinav Maurya
8
* Copyright (C) 2007-2011 Fraunhofer Institute FIRST and Max-Planck-Society
9
* Copyright (C) 2011 Indian Institute of Technology Bombay
10
*/
11
12
#include <
shogun/kernel/InverseMultiQuadricKernel.h
>
13
#include <
shogun/mathematics/Math.h
>
14
15
using namespace
shogun;
16
17
CInverseMultiQuadricKernel::CInverseMultiQuadricKernel
():
CKernel
(0),
distance
(NULL), coef(0.0001)
18
{
19
init
();
20
}
21
22
CInverseMultiQuadricKernel::CInverseMultiQuadricKernel
(int32_t cache,
float64_t
coefficient,
CDistance
* dist)
23
:
CKernel
(cache),
distance
(dist), coef(coefficient)
24
{
25
SG_REF
(
distance
);
26
init
();
27
}
28
29
CInverseMultiQuadricKernel::CInverseMultiQuadricKernel
(
CFeatures
*l,
CFeatures
*r,
float64_t
coefficient,
CDistance
* dist)
30
:
CKernel
(10),
distance
(dist), coef(coefficient)
31
{
32
SG_REF
(
distance
);
33
init
();
34
init
(l, r);
35
}
36
37
CInverseMultiQuadricKernel::~CInverseMultiQuadricKernel
()
38
{
39
cleanup
();
40
SG_UNREF
(
distance
);
41
}
42
43
bool
CInverseMultiQuadricKernel::init(
CFeatures
* l,
CFeatures
* r)
44
{
45
CKernel::init(l,r);
46
distance
->
init
(l,r);
47
return
init_normalizer
();
48
}
49
50
void
CInverseMultiQuadricKernel::load_serializable_post
() throw (
ShogunException
)
51
{
52
CKernel::load_serializable_post
();
53
}
54
55
void
CInverseMultiQuadricKernel::init()
56
{
57
SG_ADD
(&
coef
,
"coef"
,
"Kernel Coefficient."
,
MS_AVAILABLE
);
58
SG_ADD
((
CSGObject
**) &
distance
,
"distance"
,
"Distance to be used."
,
59
MS_AVAILABLE
);
60
}
61
62
float64_t
CInverseMultiQuadricKernel::compute
(int32_t idx_a, int32_t idx_b)
63
{
64
float64_t
dist =
distance
->
distance
(idx_a, idx_b);
65
return
1/sqrt(dist*dist +
coef
*
coef
);
66
}
SHOGUN
机器学习工具包 - 项目文档