376 lines
20 KiB
HTML
376 lines
20 KiB
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
|
|
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
|
|
<meta name="generator" content="Doxygen 1.8.11"/>
|
|
<title>mlpack: mlpack::kernel::ExampleKernel Class Reference</title>
|
|
<link href="tabs.css" rel="stylesheet" type="text/css"/>
|
|
<script type="text/javascript" src="jquery.js"></script>
|
|
<script type="text/javascript" src="dynsections.js"></script>
|
|
<link href="search/search.css" rel="stylesheet" type="text/css"/>
|
|
<script type="text/javascript" src="search/searchdata.js"></script>
|
|
<script type="text/javascript" src="search/search.js"></script>
|
|
<script type="text/javascript">
|
|
$(document).ready(function() { init_search(); });
|
|
</script>
|
|
<link href="doxygen.css" rel="stylesheet" type="text/css" />
|
|
<link href="extra-stylesheet.css" rel="stylesheet" type="text/css"/>
|
|
</head>
|
|
<body>
|
|
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
|
|
<div id="titlearea">
|
|
<table cellspacing="0" cellpadding="0">
|
|
<tbody>
|
|
<tr style="height: 56px;">
|
|
<td id="projectalign" style="padding-left: 0.5em;">
|
|
<div id="projectname">mlpack
|
|
 <span id="projectnumber">master</span>
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<!-- end header part -->
|
|
<!-- Generated by Doxygen 1.8.11 -->
|
|
<script type="text/javascript">
|
|
var searchBox = new SearchBox("searchBox", "search",false,'Search');
|
|
</script>
|
|
<div id="navrow1" class="tabs">
|
|
<ul class="tablist">
|
|
<li><a href="index.html"><span>Main Page</span></a></li>
|
|
<li><a href="pages.html"><span>Related Pages</span></a></li>
|
|
<li><a href="namespaces.html"><span>Namespaces</span></a></li>
|
|
<li class="current"><a href="annotated.html"><span>Classes</span></a></li>
|
|
<li><a href="files.html"><span>Files</span></a></li>
|
|
<li>
|
|
<div id="MSearchBox" class="MSearchBoxInactive">
|
|
<span class="left">
|
|
<img id="MSearchSelect" src="search/mag_sel.png"
|
|
onmouseover="return searchBox.OnSearchSelectShow()"
|
|
onmouseout="return searchBox.OnSearchSelectHide()"
|
|
alt=""/>
|
|
<input type="text" id="MSearchField" value="Search" accesskey="S"
|
|
onfocus="searchBox.OnSearchFieldFocus(true)"
|
|
onblur="searchBox.OnSearchFieldFocus(false)"
|
|
onkeyup="searchBox.OnSearchFieldChange(event)"/>
|
|
</span><span class="right">
|
|
<a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
|
|
</span>
|
|
</div>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
<div id="navrow2" class="tabs2">
|
|
<ul class="tablist">
|
|
<li><a href="annotated.html"><span>Class List</span></a></li>
|
|
<li><a href="classes.html"><span>Class Index</span></a></li>
|
|
<li><a href="inherits.html"><span>Class Hierarchy</span></a></li>
|
|
<li><a href="functions.html"><span>Class Members</span></a></li>
|
|
</ul>
|
|
</div>
|
|
<!-- window showing the filter options -->
|
|
<div id="MSearchSelectWindow"
|
|
onmouseover="return searchBox.OnSearchSelectShow()"
|
|
onmouseout="return searchBox.OnSearchSelectHide()"
|
|
onkeydown="return searchBox.OnSearchSelectKey(event)">
|
|
</div>
|
|
|
|
<!-- iframe showing the search results (closed by default) -->
|
|
<div id="MSearchResultsWindow">
|
|
<iframe src="javascript:void(0)" frameborder="0"
|
|
name="MSearchResults" id="MSearchResults">
|
|
</iframe>
|
|
</div>
|
|
|
|
<div id="nav-path" class="navpath">
|
|
<ul>
|
|
<li class="navelem"><a class="el" href="namespacemlpack.html">mlpack</a></li><li class="navelem"><a class="el" href="namespacemlpack_1_1kernel.html">kernel</a></li><li class="navelem"><a class="el" href="classmlpack_1_1kernel_1_1ExampleKernel.html">ExampleKernel</a></li> </ul>
|
|
</div>
|
|
</div><!-- top -->
|
|
<div class="header">
|
|
<div class="summary">
|
|
<a href="#pub-methods">Public Member Functions</a> |
|
|
<a href="#pub-static-methods">Static Public Member Functions</a> |
|
|
<a href="classmlpack_1_1kernel_1_1ExampleKernel-members.html">List of all members</a> </div>
|
|
<div class="headertitle">
|
|
<div class="title">mlpack::kernel::ExampleKernel Class Reference</div> </div>
|
|
</div><!--header-->
|
|
<div class="contents">
|
|
|
|
<p>An example kernel function.
|
|
<a href="classmlpack_1_1kernel_1_1ExampleKernel.html#details">More...</a></p>
|
|
<table class="memberdecls">
|
|
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-methods"></a>
|
|
Public Member Functions</h2></td></tr>
|
|
<tr class="memitem:aa2ccb2c56b15cdd07f952464e2eeb784"><td class="memItemLeft" align="right" valign="top"> </td><td class="memItemRight" valign="bottom"><a class="el" href="classmlpack_1_1kernel_1_1ExampleKernel.html#aa2ccb2c56b15cdd07f952464e2eeb784">ExampleKernel</a> ()</td></tr>
|
|
<tr class="memdesc:aa2ccb2c56b15cdd07f952464e2eeb784"><td class="mdescLeft"> </td><td class="mdescRight">The default constructor, which takes no parameters. <a href="#aa2ccb2c56b15cdd07f952464e2eeb784">More...</a><br /></td></tr>
|
|
<tr class="separator:aa2ccb2c56b15cdd07f952464e2eeb784"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:ab2e9908961dcd1510e2e8e26901303b2"><td class="memTemplParams" colspan="2">template<typename Archive > </td></tr>
|
|
<tr class="memitem:ab2e9908961dcd1510e2e8e26901303b2"><td class="memTemplItemLeft" align="right" valign="top">void </td><td class="memTemplItemRight" valign="bottom"><a class="el" href="classmlpack_1_1kernel_1_1ExampleKernel.html#ab2e9908961dcd1510e2e8e26901303b2">Serialize</a> (Archive &, const unsigned int)</td></tr>
|
|
<tr class="memdesc:ab2e9908961dcd1510e2e8e26901303b2"><td class="mdescLeft"> </td><td class="mdescRight">Serializes the kernel. <a href="#ab2e9908961dcd1510e2e8e26901303b2">More...</a><br /></td></tr>
|
|
<tr class="separator:ab2e9908961dcd1510e2e8e26901303b2"><td class="memSeparator" colspan="2"> </td></tr>
|
|
</table><table class="memberdecls">
|
|
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-static-methods"></a>
|
|
Static Public Member Functions</h2></td></tr>
|
|
<tr class="memitem:a59c724a6bfaa2678d94ea1fb7280e597"><td class="memTemplParams" colspan="2">template<typename VecTypeA , typename VecTypeB > </td></tr>
|
|
<tr class="memitem:a59c724a6bfaa2678d94ea1fb7280e597"><td class="memTemplItemLeft" align="right" valign="top">static double </td><td class="memTemplItemRight" valign="bottom"><a class="el" href="classmlpack_1_1kernel_1_1ExampleKernel.html#a59c724a6bfaa2678d94ea1fb7280e597">ConvolutionIntegral</a> (const VecTypeA &, const VecTypeB &)</td></tr>
|
|
<tr class="memdesc:a59c724a6bfaa2678d94ea1fb7280e597"><td class="mdescLeft"> </td><td class="mdescRight">Obtains the convolution integral [integral K(||x-a||)K(||b-x||)dx] for the two vectors. <a href="#a59c724a6bfaa2678d94ea1fb7280e597">More...</a><br /></td></tr>
|
|
<tr class="separator:a59c724a6bfaa2678d94ea1fb7280e597"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:ab6493b82672c90274e9c0acc1340bf8f"><td class="memTemplParams" colspan="2">template<typename VecTypeA , typename VecTypeB > </td></tr>
|
|
<tr class="memitem:ab6493b82672c90274e9c0acc1340bf8f"><td class="memTemplItemLeft" align="right" valign="top">static double </td><td class="memTemplItemRight" valign="bottom"><a class="el" href="classmlpack_1_1kernel_1_1ExampleKernel.html#ab6493b82672c90274e9c0acc1340bf8f">Evaluate</a> (const VecTypeA &, const VecTypeB &)</td></tr>
|
|
<tr class="memdesc:ab6493b82672c90274e9c0acc1340bf8f"><td class="mdescLeft"> </td><td class="mdescRight">Evaluates the kernel function for two given vectors. <a href="#ab6493b82672c90274e9c0acc1340bf8f">More...</a><br /></td></tr>
|
|
<tr class="separator:ab6493b82672c90274e9c0acc1340bf8f"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:aced4887ace203b120790584eb0f29efe"><td class="memItemLeft" align="right" valign="top">static double </td><td class="memItemRight" valign="bottom"><a class="el" href="classmlpack_1_1kernel_1_1ExampleKernel.html#aced4887ace203b120790584eb0f29efe">Normalizer</a> ()</td></tr>
|
|
<tr class="memdesc:aced4887ace203b120790584eb0f29efe"><td class="mdescLeft"> </td><td class="mdescRight">Obtains the normalizing volume for the kernel with dimension $dimension$. <a href="#aced4887ace203b120790584eb0f29efe">More...</a><br /></td></tr>
|
|
<tr class="separator:aced4887ace203b120790584eb0f29efe"><td class="memSeparator" colspan="2"> </td></tr>
|
|
</table>
|
|
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
|
|
<div class="textblock"><p>An example kernel function. </p>
|
|
<p>This is not a useful kernel, but it implements the two functions necessary to satisfy the Kernel policy (so that a class can be used whenever an mlpack method calls for a <code>typename Kernel</code> template parameter.</p>
|
|
<p>All that is necessary is a constructor and an <code><a class="el" href="classmlpack_1_1kernel_1_1ExampleKernel.html#ab6493b82672c90274e9c0acc1340bf8f" title="Evaluates the kernel function for two given vectors. ">Evaluate()</a></code> function. More methods could be added; for instance, one useful idea is a constructor which takes parameters for a kernel (for instance, the width of the Gaussian for a Gaussian kernel). However, mlpack methods cannot count on these various constructors existing, which is why most methods allow passing an already-instantiated kernel object (and by default the method will construct the kernel with the default constructor). So, for instance,</p>
|
|
<div class="fragment"><div class="line">GaussianKernel k(5.0);</div><div class="line">KernelPCA<GaussianKernel> kpca(dataset, k);</div></div><!-- fragment --><p>will set up kernel PCA using a Gaussian kernel with a width of 5.0, but</p>
|
|
<div class="fragment"><div class="line">KernelPCA<GaussianKernel> kpca(dataset);</div></div><!-- fragment --><p>will create the kernel with the default constructor. It is important (but not strictly mandatory) that your default constructor still gives a working kernel.</p>
|
|
<dl class="section note"><dt>Note</dt><dd>Not all kernels require state. For instance, the regular dot product needs no parameters. In that case, no local variables are necessary and <code><a class="el" href="classmlpack_1_1kernel_1_1ExampleKernel.html#ab6493b82672c90274e9c0acc1340bf8f" title="Evaluates the kernel function for two given vectors. ">Evaluate()</a></code> can (and should) be declared static. However, for greater generalization, mlpack methods expect all kernels to require state and hence must store instantiated kernel functions; this is why a default constructor is necessary. </dd></dl>
|
|
|
|
<p>Definition at line <a class="el" href="example__kernel_8hpp_source.html#l00077">77</a> of file <a class="el" href="example__kernel_8hpp_source.html">example_kernel.hpp</a>.</p>
|
|
</div><h2 class="groupheader">Constructor & Destructor Documentation</h2>
|
|
<a class="anchor" id="aa2ccb2c56b15cdd07f952464e2eeb784"></a>
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="mlabels">
|
|
<tr>
|
|
<td class="mlabels-left">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">mlpack::kernel::ExampleKernel::ExampleKernel </td>
|
|
<td>(</td>
|
|
<td class="paramname"></td><td>)</td>
|
|
<td></td>
|
|
</tr>
|
|
</table>
|
|
</td>
|
|
<td class="mlabels-right">
|
|
<span class="mlabels"><span class="mlabel">inline</span></span> </td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
|
|
<p>The default constructor, which takes no parameters. </p>
|
|
<p>Because our simple example kernel has no internal parameters that need to be stored, the constructor does not need to do anything. For a more complex example, see the <a class="el" href="classmlpack_1_1kernel_1_1GaussianKernel.html" title="The standard Gaussian kernel. ">GaussianKernel</a>, which stores an internal parameter. </p>
|
|
|
|
<p>Definition at line <a class="el" href="example__kernel_8hpp_source.html#l00086">86</a> of file <a class="el" href="example__kernel_8hpp_source.html">example_kernel.hpp</a>.</p>
|
|
|
|
</div>
|
|
</div>
|
|
<h2 class="groupheader">Member Function Documentation</h2>
|
|
<a class="anchor" id="a59c724a6bfaa2678d94ea1fb7280e597"></a>
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<div class="memtemplate">
|
|
template<typename VecTypeA , typename VecTypeB > </div>
|
|
<table class="mlabels">
|
|
<tr>
|
|
<td class="mlabels-left">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">static double mlpack::kernel::ExampleKernel::ConvolutionIntegral </td>
|
|
<td>(</td>
|
|
<td class="paramtype">const VecTypeA & </td>
|
|
<td class="paramname">, </td>
|
|
</tr>
|
|
<tr>
|
|
<td class="paramkey"></td>
|
|
<td></td>
|
|
<td class="paramtype">const VecTypeB & </td>
|
|
<td class="paramname"> </td>
|
|
</tr>
|
|
<tr>
|
|
<td></td>
|
|
<td>)</td>
|
|
<td></td><td></td>
|
|
</tr>
|
|
</table>
|
|
</td>
|
|
<td class="mlabels-right">
|
|
<span class="mlabels"><span class="mlabel">inline</span><span class="mlabel">static</span></span> </td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
|
|
<p>Obtains the convolution integral [integral K(||x-a||)K(||b-x||)dx] for the two vectors. </p>
|
|
<p>In this case, because our simple example kernel has no internal parameters, we can declare the function static. For a more complex example which cannot be declared static, see the <a class="el" href="classmlpack_1_1kernel_1_1GaussianKernel.html" title="The standard Gaussian kernel. ">GaussianKernel</a>, which stores an internal parameter.</p>
|
|
<dl class="tparams"><dt>Template Parameters</dt><dd>
|
|
<table class="tparams">
|
|
<tr><td class="paramname">VecTypeA</td><td>Type of first vector (arma::vec, arma::sp_vec should be expected). </td></tr>
|
|
<tr><td class="paramname">VecTypeB</td><td>Type of second vector (arma::vec, arma::sp_vec). </td></tr>
|
|
</table>
|
|
</dd>
|
|
</dl>
|
|
<dl class="params"><dt>Parameters</dt><dd>
|
|
<table class="params">
|
|
<tr><td class="paramname">a</td><td>First vector. </td></tr>
|
|
<tr><td class="paramname">b</td><td>Second vector. </td></tr>
|
|
</table>
|
|
</dd>
|
|
</dl>
|
|
<dl class="section return"><dt>Returns</dt><dd>the convolution integral value. </dd></dl>
|
|
|
|
<p>Definition at line <a class="el" href="example__kernel_8hpp_source.html#l00127">127</a> of file <a class="el" href="example__kernel_8hpp_source.html">example_kernel.hpp</a>.</p>
|
|
|
|
</div>
|
|
</div>
|
|
<a class="anchor" id="ab6493b82672c90274e9c0acc1340bf8f"></a>
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<div class="memtemplate">
|
|
template<typename VecTypeA , typename VecTypeB > </div>
|
|
<table class="mlabels">
|
|
<tr>
|
|
<td class="mlabels-left">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">static double mlpack::kernel::ExampleKernel::Evaluate </td>
|
|
<td>(</td>
|
|
<td class="paramtype">const VecTypeA & </td>
|
|
<td class="paramname">, </td>
|
|
</tr>
|
|
<tr>
|
|
<td class="paramkey"></td>
|
|
<td></td>
|
|
<td class="paramtype">const VecTypeB & </td>
|
|
<td class="paramname"> </td>
|
|
</tr>
|
|
<tr>
|
|
<td></td>
|
|
<td>)</td>
|
|
<td></td><td></td>
|
|
</tr>
|
|
</table>
|
|
</td>
|
|
<td class="mlabels-right">
|
|
<span class="mlabels"><span class="mlabel">inline</span><span class="mlabel">static</span></span> </td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
|
|
<p>Evaluates the kernel function for two given vectors. </p>
|
|
<p>In this case, because our simple example kernel has no internal parameters, we can declare the function static. For a more complex example which cannot be declared static, see the <a class="el" href="classmlpack_1_1kernel_1_1GaussianKernel.html" title="The standard Gaussian kernel. ">GaussianKernel</a>, which stores an internal parameter.</p>
|
|
<dl class="tparams"><dt>Template Parameters</dt><dd>
|
|
<table class="tparams">
|
|
<tr><td class="paramname">VecTypeA</td><td>Type of first vector (arma::vec, arma::sp_vec should be expected). </td></tr>
|
|
<tr><td class="paramname">VecTypeB</td><td>Type of second vector (arma::vec, arma::sp_vec). </td></tr>
|
|
</table>
|
|
</dd>
|
|
</dl>
|
|
<dl class="params"><dt>Parameters</dt><dd>
|
|
<table class="params">
|
|
<tr><td class="paramname">a</td><td>First vector. </td></tr>
|
|
<tr><td class="paramname">b</td><td>Second vector. </td></tr>
|
|
</table>
|
|
</dd>
|
|
</dl>
|
|
<dl class="section return"><dt>Returns</dt><dd>K(a, b). </dd></dl>
|
|
|
|
<p>Definition at line <a class="el" href="example__kernel_8hpp_source.html#l00102">102</a> of file <a class="el" href="example__kernel_8hpp_source.html">example_kernel.hpp</a>.</p>
|
|
|
|
</div>
|
|
</div>
|
|
<a class="anchor" id="aced4887ace203b120790584eb0f29efe"></a>
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="mlabels">
|
|
<tr>
|
|
<td class="mlabels-left">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">static double mlpack::kernel::ExampleKernel::Normalizer </td>
|
|
<td>(</td>
|
|
<td class="paramname"></td><td>)</td>
|
|
<td></td>
|
|
</tr>
|
|
</table>
|
|
</td>
|
|
<td class="mlabels-right">
|
|
<span class="mlabels"><span class="mlabel">inline</span><span class="mlabel">static</span></span> </td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
|
|
<p>Obtains the normalizing volume for the kernel with dimension $dimension$. </p>
|
|
<p>In this case, because our simple example kernel has no internal parameters, we can declare the function static. For a more complex example which cannot be declared static, see the <a class="el" href="classmlpack_1_1kernel_1_1GaussianKernel.html" title="The standard Gaussian kernel. ">GaussianKernel</a>, which stores an internal parameter.</p>
|
|
<dl class="params"><dt>Parameters</dt><dd>
|
|
<table class="params">
|
|
<tr><td class="paramname">dimension</td><td>the dimension of the space. </td></tr>
|
|
</table>
|
|
</dd>
|
|
</dl>
|
|
<dl class="section return"><dt>Returns</dt><dd>the normalization constant. </dd></dl>
|
|
|
|
<p>Definition at line <a class="el" href="example__kernel_8hpp_source.html#l00140">140</a> of file <a class="el" href="example__kernel_8hpp_source.html">example_kernel.hpp</a>.</p>
|
|
|
|
</div>
|
|
</div>
|
|
<a class="anchor" id="ab2e9908961dcd1510e2e8e26901303b2"></a>
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<div class="memtemplate">
|
|
template<typename Archive > </div>
|
|
<table class="mlabels">
|
|
<tr>
|
|
<td class="mlabels-left">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">void mlpack::kernel::ExampleKernel::Serialize </td>
|
|
<td>(</td>
|
|
<td class="paramtype">Archive & </td>
|
|
<td class="paramname">, </td>
|
|
</tr>
|
|
<tr>
|
|
<td class="paramkey"></td>
|
|
<td></td>
|
|
<td class="paramtype">const unsigned </td>
|
|
<td class="paramname"><em>int</em> </td>
|
|
</tr>
|
|
<tr>
|
|
<td></td>
|
|
<td>)</td>
|
|
<td></td><td></td>
|
|
</tr>
|
|
</table>
|
|
</td>
|
|
<td class="mlabels-right">
|
|
<span class="mlabels"><span class="mlabel">inline</span></span> </td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
|
|
<p>Serializes the kernel. </p>
|
|
<p>In this case, the kernel has no members, so we do not need to do anything at all. </p>
|
|
|
|
<p>Definition at line <a class="el" href="example__kernel_8hpp_source.html#l00110">110</a> of file <a class="el" href="example__kernel_8hpp_source.html">example_kernel.hpp</a>.</p>
|
|
|
|
</div>
|
|
</div>
|
|
<hr/>The documentation for this class was generated from the following file:<ul>
|
|
<li>src/mlpack/core/kernels/<a class="el" href="example__kernel_8hpp_source.html">example_kernel.hpp</a></li>
|
|
</ul>
|
|
</div><!-- contents -->
|
|
<!-- start footer part -->
|
|
<hr class="footer"/><address class="footer"><small>
|
|
Generated by  <a href="http://www.doxygen.org/index.html">
|
|
<img class="footer" src="doxygen.png" alt="doxygen"/>
|
|
</a> 1.8.11
|
|
</small></address>
|
|
</body>
|
|
<script type="text/javascript">
|
|
var x = document.getElementsByClassName("formulaDsp");
|
|
var i;
|
|
for (i = 0; i < x.length; i++)
|
|
{
|
|
x[i].width /= 4;
|
|
}
|
|
</script>
|
|
</html>
|