Files
mlpack/doc/html/classmlpack_1_1nca_1_1SoftmaxErrorFunction.html
T

684 lines
41 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::nca::SoftmaxErrorFunction&lt; MetricType &gt; Class Template 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
&#160;<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&#160;Page</span></a></li>
<li><a href="pages.html"><span>Related&#160;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&#160;List</span></a></li>
<li><a href="classes.html"><span>Class&#160;Index</span></a></li>
<li><a href="inherits.html"><span>Class&#160;Hierarchy</span></a></li>
<li><a href="functions.html"><span>Class&#160;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_1nca.html">nca</a></li><li class="navelem"><a class="el" href="classmlpack_1_1nca_1_1SoftmaxErrorFunction.html">SoftmaxErrorFunction</a></li> </ul>
</div>
</div><!-- top -->
<div class="header">
<div class="summary">
<a href="#pub-methods">Public Member Functions</a> &#124;
<a href="#pri-methods">Private Member Functions</a> &#124;
<a href="#pri-attribs">Private Attributes</a> &#124;
<a href="classmlpack_1_1nca_1_1SoftmaxErrorFunction-members.html">List of all members</a> </div>
<div class="headertitle">
<div class="title">mlpack::nca::SoftmaxErrorFunction&lt; MetricType &gt; Class Template Reference</div> </div>
</div><!--header-->
<div class="contents">
<p>The "softmax" stochastic neighbor assignment probability function.
<a href="classmlpack_1_1nca_1_1SoftmaxErrorFunction.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:ae91e96bf31977e0ca88c7805a7d7e978"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classmlpack_1_1nca_1_1SoftmaxErrorFunction.html#ae91e96bf31977e0ca88c7805a7d7e978">SoftmaxErrorFunction</a> (const arma::mat &amp;<a class="el" href="classmlpack_1_1nca_1_1SoftmaxErrorFunction.html#a9b4a79cbe8a8be32c8972b01ee2073d9">dataset</a>, const arma::Row&lt; size_t &gt; &amp;<a class="el" href="classmlpack_1_1nca_1_1SoftmaxErrorFunction.html#afe9c3d9edb331845c0b6ce28444cc484">labels</a>, MetricType <a class="el" href="classmlpack_1_1nca_1_1SoftmaxErrorFunction.html#abb8345f6eaaebc416f8e57808785e034">metric</a>=MetricType())</td></tr>
<tr class="memdesc:ae91e96bf31977e0ca88c7805a7d7e978"><td class="mdescLeft">&#160;</td><td class="mdescRight">Initialize with the given kernel; useful when the kernel has some state to store, which is set elsewhere. <a href="#ae91e96bf31977e0ca88c7805a7d7e978">More...</a><br /></td></tr>
<tr class="separator:ae91e96bf31977e0ca88c7805a7d7e978"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a60fcd093a9a44400cfcd6d259357d26e"><td class="memItemLeft" align="right" valign="top">double&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classmlpack_1_1nca_1_1SoftmaxErrorFunction.html#a60fcd093a9a44400cfcd6d259357d26e">Evaluate</a> (const arma::mat &amp;covariance)</td></tr>
<tr class="memdesc:a60fcd093a9a44400cfcd6d259357d26e"><td class="mdescLeft">&#160;</td><td class="mdescRight">Evaluate the softmax function for the given covariance matrix. <a href="#a60fcd093a9a44400cfcd6d259357d26e">More...</a><br /></td></tr>
<tr class="separator:a60fcd093a9a44400cfcd6d259357d26e"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aab64c0f64a6ba941e930551faa7a65b6"><td class="memItemLeft" align="right" valign="top">double&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classmlpack_1_1nca_1_1SoftmaxErrorFunction.html#aab64c0f64a6ba941e930551faa7a65b6">Evaluate</a> (const arma::mat &amp;covariance, const size_t i)</td></tr>
<tr class="memdesc:aab64c0f64a6ba941e930551faa7a65b6"><td class="mdescLeft">&#160;</td><td class="mdescRight">Evaluate the softmax objective function for the given covariance matrix on only one point of the dataset. <a href="#aab64c0f64a6ba941e930551faa7a65b6">More...</a><br /></td></tr>
<tr class="separator:aab64c0f64a6ba941e930551faa7a65b6"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a46a4bfef990e09a9e44d63750386829b"><td class="memItemLeft" align="right" valign="top">const arma::mat&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classmlpack_1_1nca_1_1SoftmaxErrorFunction.html#a46a4bfef990e09a9e44d63750386829b">GetInitialPoint</a> () const </td></tr>
<tr class="memdesc:a46a4bfef990e09a9e44d63750386829b"><td class="mdescLeft">&#160;</td><td class="mdescRight">Get the initial point. <a href="#a46a4bfef990e09a9e44d63750386829b">More...</a><br /></td></tr>
<tr class="separator:a46a4bfef990e09a9e44d63750386829b"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a98d77dc2745f01a14aed76aa4735155f"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classmlpack_1_1nca_1_1SoftmaxErrorFunction.html#a98d77dc2745f01a14aed76aa4735155f">Gradient</a> (const arma::mat &amp;covariance, arma::mat &amp;gradient)</td></tr>
<tr class="memdesc:a98d77dc2745f01a14aed76aa4735155f"><td class="mdescLeft">&#160;</td><td class="mdescRight">Evaluate the gradient of the softmax function for the given covariance matrix. <a href="#a98d77dc2745f01a14aed76aa4735155f">More...</a><br /></td></tr>
<tr class="separator:a98d77dc2745f01a14aed76aa4735155f"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a706948e7cba12f1840dc4c98cb7b1367"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classmlpack_1_1nca_1_1SoftmaxErrorFunction.html#a706948e7cba12f1840dc4c98cb7b1367">Gradient</a> (const arma::mat &amp;covariance, const size_t i, arma::mat &amp;gradient)</td></tr>
<tr class="memdesc:a706948e7cba12f1840dc4c98cb7b1367"><td class="mdescLeft">&#160;</td><td class="mdescRight">Evaluate the gradient of the softmax function for the given covariance matrix on only one point of the dataset. <a href="#a706948e7cba12f1840dc4c98cb7b1367">More...</a><br /></td></tr>
<tr class="separator:a706948e7cba12f1840dc4c98cb7b1367"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a899db3723fbab16e64238a4d567afa05"><td class="memItemLeft" align="right" valign="top">size_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classmlpack_1_1nca_1_1SoftmaxErrorFunction.html#a899db3723fbab16e64238a4d567afa05">NumFunctions</a> () const </td></tr>
<tr class="memdesc:a899db3723fbab16e64238a4d567afa05"><td class="mdescLeft">&#160;</td><td class="mdescRight">Get the number of functions the objective function can be decomposed into. <a href="#a899db3723fbab16e64238a4d567afa05">More...</a><br /></td></tr>
<tr class="separator:a899db3723fbab16e64238a4d567afa05"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pri-methods"></a>
Private Member Functions</h2></td></tr>
<tr class="memitem:a436b90591cf003ba82b8a4953b7eadaf"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classmlpack_1_1nca_1_1SoftmaxErrorFunction.html#a436b90591cf003ba82b8a4953b7eadaf">Precalculate</a> (const arma::mat &amp;coordinates)</td></tr>
<tr class="memdesc:a436b90591cf003ba82b8a4953b7eadaf"><td class="mdescLeft">&#160;</td><td class="mdescRight">Precalculate the denominators and numerators that will make up the p_ij, but only if the coordinates matrix is different than the last coordinates the <a class="el" href="classmlpack_1_1nca_1_1SoftmaxErrorFunction.html#a436b90591cf003ba82b8a4953b7eadaf" title="Precalculate the denominators and numerators that will make up the p_ij, but only if the coordinates ...">Precalculate()</a> method was run with. <a href="#a436b90591cf003ba82b8a4953b7eadaf">More...</a><br /></td></tr>
<tr class="separator:a436b90591cf003ba82b8a4953b7eadaf"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pri-attribs"></a>
Private Attributes</h2></td></tr>
<tr class="memitem:a9b4a79cbe8a8be32c8972b01ee2073d9"><td class="memItemLeft" align="right" valign="top">const arma::mat &amp;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classmlpack_1_1nca_1_1SoftmaxErrorFunction.html#a9b4a79cbe8a8be32c8972b01ee2073d9">dataset</a></td></tr>
<tr class="memdesc:a9b4a79cbe8a8be32c8972b01ee2073d9"><td class="mdescLeft">&#160;</td><td class="mdescRight">The dataset. <a href="#a9b4a79cbe8a8be32c8972b01ee2073d9">More...</a><br /></td></tr>
<tr class="separator:a9b4a79cbe8a8be32c8972b01ee2073d9"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a63f3fc50872eabdcfe5ab9eb8a6af22b"><td class="memItemLeft" align="right" valign="top">arma::vec&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classmlpack_1_1nca_1_1SoftmaxErrorFunction.html#a63f3fc50872eabdcfe5ab9eb8a6af22b">denominators</a></td></tr>
<tr class="memdesc:a63f3fc50872eabdcfe5ab9eb8a6af22b"><td class="mdescLeft">&#160;</td><td class="mdescRight">Holds denominators for calculation of p_ij, for the non-separable <a class="el" href="classmlpack_1_1nca_1_1SoftmaxErrorFunction.html#a60fcd093a9a44400cfcd6d259357d26e" title="Evaluate the softmax function for the given covariance matrix. ">Evaluate()</a> and <a class="el" href="classmlpack_1_1nca_1_1SoftmaxErrorFunction.html#a98d77dc2745f01a14aed76aa4735155f" title="Evaluate the gradient of the softmax function for the given covariance matrix. ">Gradient()</a>. <a href="#a63f3fc50872eabdcfe5ab9eb8a6af22b">More...</a><br /></td></tr>
<tr class="separator:a63f3fc50872eabdcfe5ab9eb8a6af22b"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:afe9c3d9edb331845c0b6ce28444cc484"><td class="memItemLeft" align="right" valign="top">const arma::Row&lt; size_t &gt; &amp;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classmlpack_1_1nca_1_1SoftmaxErrorFunction.html#afe9c3d9edb331845c0b6ce28444cc484">labels</a></td></tr>
<tr class="memdesc:afe9c3d9edb331845c0b6ce28444cc484"><td class="mdescLeft">&#160;</td><td class="mdescRight">Labels for each point in the dataset. <a href="#afe9c3d9edb331845c0b6ce28444cc484">More...</a><br /></td></tr>
<tr class="separator:afe9c3d9edb331845c0b6ce28444cc484"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a68407bb96a6b4a3e3b92d3661c177f88"><td class="memItemLeft" align="right" valign="top">arma::mat&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classmlpack_1_1nca_1_1SoftmaxErrorFunction.html#a68407bb96a6b4a3e3b92d3661c177f88">lastCoordinates</a></td></tr>
<tr class="memdesc:a68407bb96a6b4a3e3b92d3661c177f88"><td class="mdescLeft">&#160;</td><td class="mdescRight">Last coordinates. Used for the non-separable <a class="el" href="classmlpack_1_1nca_1_1SoftmaxErrorFunction.html#a60fcd093a9a44400cfcd6d259357d26e" title="Evaluate the softmax function for the given covariance matrix. ">Evaluate()</a> and <a class="el" href="classmlpack_1_1nca_1_1SoftmaxErrorFunction.html#a98d77dc2745f01a14aed76aa4735155f" title="Evaluate the gradient of the softmax function for the given covariance matrix. ">Gradient()</a>. <a href="#a68407bb96a6b4a3e3b92d3661c177f88">More...</a><br /></td></tr>
<tr class="separator:a68407bb96a6b4a3e3b92d3661c177f88"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:abb8345f6eaaebc416f8e57808785e034"><td class="memItemLeft" align="right" valign="top">MetricType&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classmlpack_1_1nca_1_1SoftmaxErrorFunction.html#abb8345f6eaaebc416f8e57808785e034">metric</a></td></tr>
<tr class="memdesc:abb8345f6eaaebc416f8e57808785e034"><td class="mdescLeft">&#160;</td><td class="mdescRight">The instantiated metric. <a href="#abb8345f6eaaebc416f8e57808785e034">More...</a><br /></td></tr>
<tr class="separator:abb8345f6eaaebc416f8e57808785e034"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a768e2c60c0f491e57d8a9d3e240f3c0f"><td class="memItemLeft" align="right" valign="top">arma::vec&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classmlpack_1_1nca_1_1SoftmaxErrorFunction.html#a768e2c60c0f491e57d8a9d3e240f3c0f">p</a></td></tr>
<tr class="memdesc:a768e2c60c0f491e57d8a9d3e240f3c0f"><td class="mdescLeft">&#160;</td><td class="mdescRight">Holds calculated p_i, for the non-separable <a class="el" href="classmlpack_1_1nca_1_1SoftmaxErrorFunction.html#a60fcd093a9a44400cfcd6d259357d26e" title="Evaluate the softmax function for the given covariance matrix. ">Evaluate()</a> and <a class="el" href="classmlpack_1_1nca_1_1SoftmaxErrorFunction.html#a98d77dc2745f01a14aed76aa4735155f" title="Evaluate the gradient of the softmax function for the given covariance matrix. ">Gradient()</a>. <a href="#a768e2c60c0f491e57d8a9d3e240f3c0f">More...</a><br /></td></tr>
<tr class="separator:a768e2c60c0f491e57d8a9d3e240f3c0f"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a7bc17888d9ab1ce6920c72d85f618ff7"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classmlpack_1_1nca_1_1SoftmaxErrorFunction.html#a7bc17888d9ab1ce6920c72d85f618ff7">precalculated</a></td></tr>
<tr class="memdesc:a7bc17888d9ab1ce6920c72d85f618ff7"><td class="mdescLeft">&#160;</td><td class="mdescRight">False if nothing has ever been precalculated (only at construction time). <a href="#a7bc17888d9ab1ce6920c72d85f618ff7">More...</a><br /></td></tr>
<tr class="separator:a7bc17888d9ab1ce6920c72d85f618ff7"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a11759ec30b7853559df670867e57ceb4"><td class="memItemLeft" align="right" valign="top">arma::mat&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classmlpack_1_1nca_1_1SoftmaxErrorFunction.html#a11759ec30b7853559df670867e57ceb4">stretchedDataset</a></td></tr>
<tr class="memdesc:a11759ec30b7853559df670867e57ceb4"><td class="mdescLeft">&#160;</td><td class="mdescRight">Stretched dataset. Kept internal to avoid memory reallocations. <a href="#a11759ec30b7853559df670867e57ceb4">More...</a><br /></td></tr>
<tr class="separator:a11759ec30b7853559df670867e57ceb4"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><h3>template&lt;typename MetricType = metric::SquaredEuclideanDistance&gt;<br />
class mlpack::nca::SoftmaxErrorFunction&lt; MetricType &gt;</h3>
<p>The "softmax" stochastic neighbor assignment probability function. </p>
<p>The actual function is</p>
<p>p_ij = (exp(-|| A x_i - A x_j || ^ 2)) / (sum_{k != i} (exp(-|| A x_i - A x_k || ^ 2)))</p>
<p>where x_n represents a point and A is the current scaling matrix.</p>
<p>This class is more flexible than the original paper, allowing an arbitrary metric function to be used in place of || A x_i - A x_j ||^2, meaning that the squared Euclidean distance is not the only allowed metric for <a class="el" href="classmlpack_1_1nca_1_1NCA.html" title="An implementation of Neighborhood Components Analysis, both a linear dimensionality reduction techniq...">NCA</a>. However, that is probably the best way to use this class.</p>
<p>In addition to the standard <a class="el" href="classmlpack_1_1nca_1_1SoftmaxErrorFunction.html#a60fcd093a9a44400cfcd6d259357d26e" title="Evaluate the softmax function for the given covariance matrix. ">Evaluate()</a> and <a class="el" href="classmlpack_1_1nca_1_1SoftmaxErrorFunction.html#a98d77dc2745f01a14aed76aa4735155f" title="Evaluate the gradient of the softmax function for the given covariance matrix. ">Gradient()</a> functions which mlpack optimizers use, overloads of <a class="el" href="classmlpack_1_1nca_1_1SoftmaxErrorFunction.html#a60fcd093a9a44400cfcd6d259357d26e" title="Evaluate the softmax function for the given covariance matrix. ">Evaluate()</a> and <a class="el" href="classmlpack_1_1nca_1_1SoftmaxErrorFunction.html#a98d77dc2745f01a14aed76aa4735155f" title="Evaluate the gradient of the softmax function for the given covariance matrix. ">Gradient()</a> are given which only operate on one point in the dataset. This is useful for optimizers like stochastic gradient descent (see <a class="el" href="classmlpack_1_1optimization_1_1SGD.html" title="Stochastic Gradient Descent is a technique for minimizing a function which can be expressed as a sum ...">mlpack::optimization::SGD</a>). </p>
<p>Definition at line <a class="el" href="nca__softmax__error__function_8hpp_source.html#l00042">42</a> of file <a class="el" href="nca__softmax__error__function_8hpp_source.html">nca_softmax_error_function.hpp</a>.</p>
</div><h2 class="groupheader">Constructor &amp; Destructor Documentation</h2>
<a class="anchor" id="ae91e96bf31977e0ca88c7805a7d7e978"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename MetricType = metric::SquaredEuclideanDistance&gt; </div>
<table class="memname">
<tr>
<td class="memname"><a class="el" href="classmlpack_1_1nca_1_1SoftmaxErrorFunction.html">mlpack::nca::SoftmaxErrorFunction</a>&lt; MetricType &gt;::<a class="el" href="classmlpack_1_1nca_1_1SoftmaxErrorFunction.html">SoftmaxErrorFunction</a> </td>
<td>(</td>
<td class="paramtype">const arma::mat &amp;&#160;</td>
<td class="paramname"><em>dataset</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const arma::Row&lt; size_t &gt; &amp;&#160;</td>
<td class="paramname"><em>labels</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">MetricType&#160;</td>
<td class="paramname"><em>metric</em> = <code>MetricType()</code>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Initialize with the given kernel; useful when the kernel has some state to store, which is set elsewhere. </p>
<p>If no kernel is given, an empty kernel is used; this way, you can call the constructor with no arguments. A reference to the dataset we will be optimizing over is also required.</p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">dataset</td><td>Matrix containing the dataset. </td></tr>
<tr><td class="paramname">labels</td><td>Vector of class labels for each point in the dataset. </td></tr>
<tr><td class="paramname">kernel</td><td>Instantiated kernel (optional). </td></tr>
</table>
</dd>
</dl>
</div>
</div>
<h2 class="groupheader">Member Function Documentation</h2>
<a class="anchor" id="a60fcd093a9a44400cfcd6d259357d26e"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename MetricType = metric::SquaredEuclideanDistance&gt; </div>
<table class="memname">
<tr>
<td class="memname">double <a class="el" href="classmlpack_1_1nca_1_1SoftmaxErrorFunction.html">mlpack::nca::SoftmaxErrorFunction</a>&lt; MetricType &gt;::Evaluate </td>
<td>(</td>
<td class="paramtype">const arma::mat &amp;&#160;</td>
<td class="paramname"><em>covariance</em></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Evaluate the softmax function for the given covariance matrix. </p>
<p>This is the non-separable implementation, where the objective function is not decomposed into the sum of several objective functions.</p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">covariance</td><td>Covariance matrix of Mahalanobis distance. </td></tr>
</table>
</dd>
</dl>
</div>
</div>
<a class="anchor" id="aab64c0f64a6ba941e930551faa7a65b6"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename MetricType = metric::SquaredEuclideanDistance&gt; </div>
<table class="memname">
<tr>
<td class="memname">double <a class="el" href="classmlpack_1_1nca_1_1SoftmaxErrorFunction.html">mlpack::nca::SoftmaxErrorFunction</a>&lt; MetricType &gt;::Evaluate </td>
<td>(</td>
<td class="paramtype">const arma::mat &amp;&#160;</td>
<td class="paramname"><em>covariance</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const size_t&#160;</td>
<td class="paramname"><em>i</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Evaluate the softmax objective function for the given covariance matrix on only one point of the dataset. </p>
<p>This is the separable implementation, where the objective function is decomposed into the sum of many objective functions, and here, only one of those constituent objective functions is returned.</p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">covariance</td><td>Covariance matrix of Mahalanobis distance. </td></tr>
<tr><td class="paramname">i</td><td>Index of point to use for objective function. </td></tr>
</table>
</dd>
</dl>
</div>
</div>
<a class="anchor" id="a46a4bfef990e09a9e44d63750386829b"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename MetricType = metric::SquaredEuclideanDistance&gt; </div>
<table class="memname">
<tr>
<td class="memname">const arma::mat <a class="el" href="classmlpack_1_1nca_1_1SoftmaxErrorFunction.html">mlpack::nca::SoftmaxErrorFunction</a>&lt; MetricType &gt;::GetInitialPoint </td>
<td>(</td>
<td class="paramname"></td><td>)</td>
<td> const</td>
</tr>
</table>
</div><div class="memdoc">
<p>Get the initial point. </p>
</div>
</div>
<a class="anchor" id="a98d77dc2745f01a14aed76aa4735155f"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename MetricType = metric::SquaredEuclideanDistance&gt; </div>
<table class="memname">
<tr>
<td class="memname">void <a class="el" href="classmlpack_1_1nca_1_1SoftmaxErrorFunction.html">mlpack::nca::SoftmaxErrorFunction</a>&lt; MetricType &gt;::Gradient </td>
<td>(</td>
<td class="paramtype">const arma::mat &amp;&#160;</td>
<td class="paramname"><em>covariance</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">arma::mat &amp;&#160;</td>
<td class="paramname"><em>gradient</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Evaluate the gradient of the softmax function for the given covariance matrix. </p>
<p>This is the non-separable implementation, where the objective function is not decomposed into the sum of several objective functions.</p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">covariance</td><td>Covariance matrix of Mahalanobis distance. </td></tr>
<tr><td class="paramname">gradient</td><td>Matrix to store the calculated gradient in. </td></tr>
</table>
</dd>
</dl>
</div>
</div>
<a class="anchor" id="a706948e7cba12f1840dc4c98cb7b1367"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename MetricType = metric::SquaredEuclideanDistance&gt; </div>
<table class="memname">
<tr>
<td class="memname">void <a class="el" href="classmlpack_1_1nca_1_1SoftmaxErrorFunction.html">mlpack::nca::SoftmaxErrorFunction</a>&lt; MetricType &gt;::Gradient </td>
<td>(</td>
<td class="paramtype">const arma::mat &amp;&#160;</td>
<td class="paramname"><em>covariance</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const size_t&#160;</td>
<td class="paramname"><em>i</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">arma::mat &amp;&#160;</td>
<td class="paramname"><em>gradient</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Evaluate the gradient of the softmax function for the given covariance matrix on only one point of the dataset. </p>
<p>This is the separable implementation, where the objective function is decomposed into the sum of many objective functions, and here, only one of those constituent objective functions is returned.</p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">covariance</td><td>Covariance matrix of Mahalanobis distance. </td></tr>
<tr><td class="paramname">i</td><td>Index of point to use for objective function. </td></tr>
<tr><td class="paramname">gradient</td><td>Matrix to store the calculated gradient in. </td></tr>
</table>
</dd>
</dl>
</div>
</div>
<a class="anchor" id="a899db3723fbab16e64238a4d567afa05"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename MetricType = metric::SquaredEuclideanDistance&gt; </div>
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">size_t <a class="el" href="classmlpack_1_1nca_1_1SoftmaxErrorFunction.html">mlpack::nca::SoftmaxErrorFunction</a>&lt; MetricType &gt;::NumFunctions </td>
<td>(</td>
<td class="paramname"></td><td>)</td>
<td> const</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>Get the number of functions the objective function can be decomposed into. </p>
<p>This is just the number of points in the dataset. </p>
<p>Definition at line <a class="el" href="nca__softmax__error__function_8hpp_source.html#l00114">114</a> of file <a class="el" href="nca__softmax__error__function_8hpp_source.html">nca_softmax_error_function.hpp</a>.</p>
</div>
</div>
<a class="anchor" id="a436b90591cf003ba82b8a4953b7eadaf"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename MetricType = metric::SquaredEuclideanDistance&gt; </div>
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">void <a class="el" href="classmlpack_1_1nca_1_1SoftmaxErrorFunction.html">mlpack::nca::SoftmaxErrorFunction</a>&lt; MetricType &gt;::Precalculate </td>
<td>(</td>
<td class="paramtype">const arma::mat &amp;&#160;</td>
<td class="paramname"><em>coordinates</em></td><td>)</td>
<td></td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">private</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<p>Precalculate the denominators and numerators that will make up the p_ij, but only if the coordinates matrix is different than the last coordinates the <a class="el" href="classmlpack_1_1nca_1_1SoftmaxErrorFunction.html#a436b90591cf003ba82b8a4953b7eadaf" title="Precalculate the denominators and numerators that will make up the p_ij, but only if the coordinates ...">Precalculate()</a> method was run with. </p>
<p>This method is only called by the non-separable <a class="el" href="classmlpack_1_1nca_1_1SoftmaxErrorFunction.html#a60fcd093a9a44400cfcd6d259357d26e" title="Evaluate the softmax function for the given covariance matrix. ">Evaluate()</a> and <a class="el" href="classmlpack_1_1nca_1_1SoftmaxErrorFunction.html#a98d77dc2745f01a14aed76aa4735155f" title="Evaluate the gradient of the softmax function for the given covariance matrix. ">Gradient()</a>.</p>
<p>This will update last_coordinates_ and stretched_dataset_, and also calculate the p_i and denominators_ which are used in the calculation of p_i or p_ij. The calculation will be O((n * (n + 1)) / 2), which is not great.</p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">coordinates</td><td>Coordinates matrix to use for precalculation. </td></tr>
</table>
</dd>
</dl>
</div>
</div>
<h2 class="groupheader">Member Data Documentation</h2>
<a class="anchor" id="a9b4a79cbe8a8be32c8972b01ee2073d9"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename MetricType = metric::SquaredEuclideanDistance&gt; </div>
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">const arma::mat&amp; <a class="el" href="classmlpack_1_1nca_1_1SoftmaxErrorFunction.html">mlpack::nca::SoftmaxErrorFunction</a>&lt; MetricType &gt;::dataset</td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">private</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<p>The dataset. </p>
<p>Definition at line <a class="el" href="nca__softmax__error__function_8hpp_source.html#l00118">118</a> of file <a class="el" href="nca__softmax__error__function_8hpp_source.html">nca_softmax_error_function.hpp</a>.</p>
</div>
</div>
<a class="anchor" id="a63f3fc50872eabdcfe5ab9eb8a6af22b"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename MetricType = metric::SquaredEuclideanDistance&gt; </div>
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">arma::vec <a class="el" href="classmlpack_1_1nca_1_1SoftmaxErrorFunction.html">mlpack::nca::SoftmaxErrorFunction</a>&lt; MetricType &gt;::denominators</td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">private</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<p>Holds denominators for calculation of p_ij, for the non-separable <a class="el" href="classmlpack_1_1nca_1_1SoftmaxErrorFunction.html#a60fcd093a9a44400cfcd6d259357d26e" title="Evaluate the softmax function for the given covariance matrix. ">Evaluate()</a> and <a class="el" href="classmlpack_1_1nca_1_1SoftmaxErrorFunction.html#a98d77dc2745f01a14aed76aa4735155f" title="Evaluate the gradient of the softmax function for the given covariance matrix. ">Gradient()</a>. </p>
<p>Definition at line <a class="el" href="nca__softmax__error__function_8hpp_source.html#l00133">133</a> of file <a class="el" href="nca__softmax__error__function_8hpp_source.html">nca_softmax_error_function.hpp</a>.</p>
</div>
</div>
<a class="anchor" id="afe9c3d9edb331845c0b6ce28444cc484"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename MetricType = metric::SquaredEuclideanDistance&gt; </div>
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">const arma::Row&lt;size_t&gt;&amp; <a class="el" href="classmlpack_1_1nca_1_1SoftmaxErrorFunction.html">mlpack::nca::SoftmaxErrorFunction</a>&lt; MetricType &gt;::labels</td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">private</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<p>Labels for each point in the dataset. </p>
<p>Definition at line <a class="el" href="nca__softmax__error__function_8hpp_source.html#l00120">120</a> of file <a class="el" href="nca__softmax__error__function_8hpp_source.html">nca_softmax_error_function.hpp</a>.</p>
</div>
</div>
<a class="anchor" id="a68407bb96a6b4a3e3b92d3661c177f88"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename MetricType = metric::SquaredEuclideanDistance&gt; </div>
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">arma::mat <a class="el" href="classmlpack_1_1nca_1_1SoftmaxErrorFunction.html">mlpack::nca::SoftmaxErrorFunction</a>&lt; MetricType &gt;::lastCoordinates</td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">private</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<p>Last coordinates. Used for the non-separable <a class="el" href="classmlpack_1_1nca_1_1SoftmaxErrorFunction.html#a60fcd093a9a44400cfcd6d259357d26e" title="Evaluate the softmax function for the given covariance matrix. ">Evaluate()</a> and <a class="el" href="classmlpack_1_1nca_1_1SoftmaxErrorFunction.html#a98d77dc2745f01a14aed76aa4735155f" title="Evaluate the gradient of the softmax function for the given covariance matrix. ">Gradient()</a>. </p>
<p>Definition at line <a class="el" href="nca__softmax__error__function_8hpp_source.html#l00126">126</a> of file <a class="el" href="nca__softmax__error__function_8hpp_source.html">nca_softmax_error_function.hpp</a>.</p>
</div>
</div>
<a class="anchor" id="abb8345f6eaaebc416f8e57808785e034"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename MetricType = metric::SquaredEuclideanDistance&gt; </div>
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">MetricType <a class="el" href="classmlpack_1_1nca_1_1SoftmaxErrorFunction.html">mlpack::nca::SoftmaxErrorFunction</a>&lt; MetricType &gt;::metric</td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">private</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<p>The instantiated metric. </p>
<p>Definition at line <a class="el" href="nca__softmax__error__function_8hpp_source.html#l00123">123</a> of file <a class="el" href="nca__softmax__error__function_8hpp_source.html">nca_softmax_error_function.hpp</a>.</p>
</div>
</div>
<a class="anchor" id="a768e2c60c0f491e57d8a9d3e240f3c0f"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename MetricType = metric::SquaredEuclideanDistance&gt; </div>
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">arma::vec <a class="el" href="classmlpack_1_1nca_1_1SoftmaxErrorFunction.html">mlpack::nca::SoftmaxErrorFunction</a>&lt; MetricType &gt;::p</td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">private</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<p>Holds calculated p_i, for the non-separable <a class="el" href="classmlpack_1_1nca_1_1SoftmaxErrorFunction.html#a60fcd093a9a44400cfcd6d259357d26e" title="Evaluate the softmax function for the given covariance matrix. ">Evaluate()</a> and <a class="el" href="classmlpack_1_1nca_1_1SoftmaxErrorFunction.html#a98d77dc2745f01a14aed76aa4735155f" title="Evaluate the gradient of the softmax function for the given covariance matrix. ">Gradient()</a>. </p>
<p>Definition at line <a class="el" href="nca__softmax__error__function_8hpp_source.html#l00130">130</a> of file <a class="el" href="nca__softmax__error__function_8hpp_source.html">nca_softmax_error_function.hpp</a>.</p>
</div>
</div>
<a class="anchor" id="a7bc17888d9ab1ce6920c72d85f618ff7"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename MetricType = metric::SquaredEuclideanDistance&gt; </div>
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">bool <a class="el" href="classmlpack_1_1nca_1_1SoftmaxErrorFunction.html">mlpack::nca::SoftmaxErrorFunction</a>&lt; MetricType &gt;::precalculated</td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">private</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<p>False if nothing has ever been precalculated (only at construction time). </p>
<p>Definition at line <a class="el" href="nca__softmax__error__function_8hpp_source.html#l00136">136</a> of file <a class="el" href="nca__softmax__error__function_8hpp_source.html">nca_softmax_error_function.hpp</a>.</p>
</div>
</div>
<a class="anchor" id="a11759ec30b7853559df670867e57ceb4"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename MetricType = metric::SquaredEuclideanDistance&gt; </div>
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">arma::mat <a class="el" href="classmlpack_1_1nca_1_1SoftmaxErrorFunction.html">mlpack::nca::SoftmaxErrorFunction</a>&lt; MetricType &gt;::stretchedDataset</td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">private</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<p>Stretched dataset. Kept internal to avoid memory reallocations. </p>
<p>Definition at line <a class="el" href="nca__softmax__error__function_8hpp_source.html#l00128">128</a> of file <a class="el" href="nca__softmax__error__function_8hpp_source.html">nca_softmax_error_function.hpp</a>.</p>
</div>
</div>
<hr/>The documentation for this class was generated from the following file:<ul>
<li>src/mlpack/methods/nca/<a class="el" href="nca__softmax__error__function_8hpp_source.html">nca_softmax_error_function.hpp</a></li>
</ul>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by &#160;<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>