Files
mlpack/doc/html/classmlpack_1_1sparse__coding_1_1SparseCoding.html
T

1161 lines
64 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::sparse_coding::SparseCoding 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
&#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_1sparse__coding.html">sparse_coding</a></li><li class="navelem"><a class="el" href="classmlpack_1_1sparse__coding_1_1SparseCoding.html">SparseCoding</a></li> </ul>
</div>
</div><!-- top -->
<div class="header">
<div class="summary">
<a href="#pub-methods">Public Member Functions</a> &#124;
<a href="#pri-attribs">Private Attributes</a> &#124;
<a href="classmlpack_1_1sparse__coding_1_1SparseCoding-members.html">List of all members</a> </div>
<div class="headertitle">
<div class="title">mlpack::sparse_coding::SparseCoding Class Reference</div> </div>
</div><!--header-->
<div class="contents">
<p>An implementation of Sparse Coding with Dictionary Learning that achieves sparsity via an l1-norm regularizer on the codes (LASSO) or an (l1+l2)-norm regularizer on the codes (the Elastic Net).
<a href="classmlpack_1_1sparse__coding_1_1SparseCoding.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:a6a00e8188578c374b2d6036d64bb64dd"><td class="memTemplParams" colspan="2">template&lt;typename DictionaryInitializer = DataDependentRandomInitializer&gt; </td></tr>
<tr class="memitem:a6a00e8188578c374b2d6036d64bb64dd"><td class="memTemplItemLeft" align="right" valign="top">&#160;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="classmlpack_1_1sparse__coding_1_1SparseCoding.html#a6a00e8188578c374b2d6036d64bb64dd">SparseCoding</a> (const arma::mat &amp;data, const size_t <a class="el" href="classmlpack_1_1sparse__coding_1_1SparseCoding.html#af9b3bf2d390d108c626f7ea7368328b0">atoms</a>, const double <a class="el" href="classmlpack_1_1sparse__coding_1_1SparseCoding.html#ab4711495fe1881bc4f61a3252b660166">lambda1</a>, const double <a class="el" href="classmlpack_1_1sparse__coding_1_1SparseCoding.html#a8b2505fdc424c72f9925060631f9d2cc">lambda2</a>=0, const size_t <a class="el" href="classmlpack_1_1sparse__coding_1_1SparseCoding.html#ac2e86cbe516dc6c8a66541853e7c8e2f">maxIterations</a>=0, const double <a class="el" href="classmlpack_1_1sparse__coding_1_1SparseCoding.html#a6b04b57a6c0c93afd1f166549bed6d65">objTolerance</a>=0.01, const double <a class="el" href="classmlpack_1_1sparse__coding_1_1SparseCoding.html#ad9474bd8956404954370c4fa75fb883a">newtonTolerance</a>=1e-6, const DictionaryInitializer &amp;initializer=DictionaryInitializer())</td></tr>
<tr class="memdesc:a6a00e8188578c374b2d6036d64bb64dd"><td class="mdescLeft">&#160;</td><td class="mdescRight">Set the parameters to <a class="el" href="classmlpack_1_1sparse__coding_1_1SparseCoding.html" title="An implementation of Sparse Coding with Dictionary Learning that achieves sparsity via an l1-norm reg...">SparseCoding</a>. <a href="#a6a00e8188578c374b2d6036d64bb64dd">More...</a><br /></td></tr>
<tr class="separator:a6a00e8188578c374b2d6036d64bb64dd"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a7849a56a97f599479aa38bcbd34f80b8"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classmlpack_1_1sparse__coding_1_1SparseCoding.html#a7849a56a97f599479aa38bcbd34f80b8">SparseCoding</a> (const size_t <a class="el" href="classmlpack_1_1sparse__coding_1_1SparseCoding.html#af9b3bf2d390d108c626f7ea7368328b0">atoms</a>=0, const double <a class="el" href="classmlpack_1_1sparse__coding_1_1SparseCoding.html#ab4711495fe1881bc4f61a3252b660166">lambda1</a>=0, const double <a class="el" href="classmlpack_1_1sparse__coding_1_1SparseCoding.html#a8b2505fdc424c72f9925060631f9d2cc">lambda2</a>=0, const size_t <a class="el" href="classmlpack_1_1sparse__coding_1_1SparseCoding.html#ac2e86cbe516dc6c8a66541853e7c8e2f">maxIterations</a>=0, const double <a class="el" href="classmlpack_1_1sparse__coding_1_1SparseCoding.html#a6b04b57a6c0c93afd1f166549bed6d65">objTolerance</a>=0.01, const double <a class="el" href="classmlpack_1_1sparse__coding_1_1SparseCoding.html#ad9474bd8956404954370c4fa75fb883a">newtonTolerance</a>=1e-6)</td></tr>
<tr class="memdesc:a7849a56a97f599479aa38bcbd34f80b8"><td class="mdescLeft">&#160;</td><td class="mdescRight">Set the parameters to <a class="el" href="classmlpack_1_1sparse__coding_1_1SparseCoding.html" title="An implementation of Sparse Coding with Dictionary Learning that achieves sparsity via an l1-norm reg...">SparseCoding</a>. <a href="#a7849a56a97f599479aa38bcbd34f80b8">More...</a><br /></td></tr>
<tr class="separator:a7849a56a97f599479aa38bcbd34f80b8"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a953c6a16d66622fffb3be8a703e22554"><td class="memItemLeft" align="right" valign="top">size_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classmlpack_1_1sparse__coding_1_1SparseCoding.html#a953c6a16d66622fffb3be8a703e22554">Atoms</a> () const </td></tr>
<tr class="memdesc:a953c6a16d66622fffb3be8a703e22554"><td class="mdescLeft">&#160;</td><td class="mdescRight">Access the number of atoms. <a href="#a953c6a16d66622fffb3be8a703e22554">More...</a><br /></td></tr>
<tr class="separator:a953c6a16d66622fffb3be8a703e22554"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a777e19b014ebeb2e9f0a033afe684d3c"><td class="memItemLeft" align="right" valign="top">size_t &amp;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classmlpack_1_1sparse__coding_1_1SparseCoding.html#a777e19b014ebeb2e9f0a033afe684d3c">Atoms</a> ()</td></tr>
<tr class="memdesc:a777e19b014ebeb2e9f0a033afe684d3c"><td class="mdescLeft">&#160;</td><td class="mdescRight">Modify the number of atoms. <a href="#a777e19b014ebeb2e9f0a033afe684d3c">More...</a><br /></td></tr>
<tr class="separator:a777e19b014ebeb2e9f0a033afe684d3c"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:af9f8ca70ece9948605d25fb2e9ee76d5"><td class="memItemLeft" align="right" valign="top">const arma::mat &amp;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classmlpack_1_1sparse__coding_1_1SparseCoding.html#af9f8ca70ece9948605d25fb2e9ee76d5">Dictionary</a> () const </td></tr>
<tr class="memdesc:af9f8ca70ece9948605d25fb2e9ee76d5"><td class="mdescLeft">&#160;</td><td class="mdescRight">Access the dictionary. <a href="#af9f8ca70ece9948605d25fb2e9ee76d5">More...</a><br /></td></tr>
<tr class="separator:af9f8ca70ece9948605d25fb2e9ee76d5"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ab069f805f1db24a672b6f38a6d9cf755"><td class="memItemLeft" align="right" valign="top">arma::mat &amp;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classmlpack_1_1sparse__coding_1_1SparseCoding.html#ab069f805f1db24a672b6f38a6d9cf755">Dictionary</a> ()</td></tr>
<tr class="memdesc:ab069f805f1db24a672b6f38a6d9cf755"><td class="mdescLeft">&#160;</td><td class="mdescRight">Modify the dictionary. <a href="#ab069f805f1db24a672b6f38a6d9cf755">More...</a><br /></td></tr>
<tr class="separator:ab069f805f1db24a672b6f38a6d9cf755"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a1a83718fbf6b44326e9309775ec5bd93"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classmlpack_1_1sparse__coding_1_1SparseCoding.html#a1a83718fbf6b44326e9309775ec5bd93">Encode</a> (const arma::mat &amp;data, arma::mat &amp;codes)</td></tr>
<tr class="memdesc:a1a83718fbf6b44326e9309775ec5bd93"><td class="mdescLeft">&#160;</td><td class="mdescRight">Sparse code each point in the given dataset via LARS, using the current dictionary and store the encoded data in the codes matrix. <a href="#a1a83718fbf6b44326e9309775ec5bd93">More...</a><br /></td></tr>
<tr class="separator:a1a83718fbf6b44326e9309775ec5bd93"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a47d91644f8f0cc08961c3caf43cd81a9"><td class="memItemLeft" align="right" valign="top">double&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classmlpack_1_1sparse__coding_1_1SparseCoding.html#a47d91644f8f0cc08961c3caf43cd81a9">Lambda1</a> () const </td></tr>
<tr class="memdesc:a47d91644f8f0cc08961c3caf43cd81a9"><td class="mdescLeft">&#160;</td><td class="mdescRight">Access the L1 regularization term. <a href="#a47d91644f8f0cc08961c3caf43cd81a9">More...</a><br /></td></tr>
<tr class="separator:a47d91644f8f0cc08961c3caf43cd81a9"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a431d1dc6ec0c629c0168eb44d76e59c1"><td class="memItemLeft" align="right" valign="top">double &amp;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classmlpack_1_1sparse__coding_1_1SparseCoding.html#a431d1dc6ec0c629c0168eb44d76e59c1">Lambda1</a> ()</td></tr>
<tr class="memdesc:a431d1dc6ec0c629c0168eb44d76e59c1"><td class="mdescLeft">&#160;</td><td class="mdescRight">Modify the L1 regularization term. <a href="#a431d1dc6ec0c629c0168eb44d76e59c1">More...</a><br /></td></tr>
<tr class="separator:a431d1dc6ec0c629c0168eb44d76e59c1"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a54f409dd73bb45d60b769e2b759eb3c4"><td class="memItemLeft" align="right" valign="top">double&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classmlpack_1_1sparse__coding_1_1SparseCoding.html#a54f409dd73bb45d60b769e2b759eb3c4">Lambda2</a> () const </td></tr>
<tr class="memdesc:a54f409dd73bb45d60b769e2b759eb3c4"><td class="mdescLeft">&#160;</td><td class="mdescRight">Access the L2 regularization term. <a href="#a54f409dd73bb45d60b769e2b759eb3c4">More...</a><br /></td></tr>
<tr class="separator:a54f409dd73bb45d60b769e2b759eb3c4"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a90a77a7f18df81b2332ab55492878e61"><td class="memItemLeft" align="right" valign="top">double &amp;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classmlpack_1_1sparse__coding_1_1SparseCoding.html#a90a77a7f18df81b2332ab55492878e61">Lambda2</a> ()</td></tr>
<tr class="memdesc:a90a77a7f18df81b2332ab55492878e61"><td class="mdescLeft">&#160;</td><td class="mdescRight">Modify the L2 regularization term. <a href="#a90a77a7f18df81b2332ab55492878e61">More...</a><br /></td></tr>
<tr class="separator:a90a77a7f18df81b2332ab55492878e61"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:afbb6a1afa961fe55837defb7d020d693"><td class="memItemLeft" align="right" valign="top">size_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classmlpack_1_1sparse__coding_1_1SparseCoding.html#afbb6a1afa961fe55837defb7d020d693">MaxIterations</a> () const </td></tr>
<tr class="memdesc:afbb6a1afa961fe55837defb7d020d693"><td class="mdescLeft">&#160;</td><td class="mdescRight">Get the maximum number of iterations. <a href="#afbb6a1afa961fe55837defb7d020d693">More...</a><br /></td></tr>
<tr class="separator:afbb6a1afa961fe55837defb7d020d693"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a309ec92833b38a75c7a1e83927166ecb"><td class="memItemLeft" align="right" valign="top">size_t &amp;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classmlpack_1_1sparse__coding_1_1SparseCoding.html#a309ec92833b38a75c7a1e83927166ecb">MaxIterations</a> ()</td></tr>
<tr class="memdesc:a309ec92833b38a75c7a1e83927166ecb"><td class="mdescLeft">&#160;</td><td class="mdescRight">Modify the maximum number of iterations. <a href="#a309ec92833b38a75c7a1e83927166ecb">More...</a><br /></td></tr>
<tr class="separator:a309ec92833b38a75c7a1e83927166ecb"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a982c9d648fb8eed1258110e2709b753e"><td class="memItemLeft" align="right" valign="top">double&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classmlpack_1_1sparse__coding_1_1SparseCoding.html#a982c9d648fb8eed1258110e2709b753e">NewtonTolerance</a> () const </td></tr>
<tr class="memdesc:a982c9d648fb8eed1258110e2709b753e"><td class="mdescLeft">&#160;</td><td class="mdescRight">Get the tolerance for Newton's method (dictionary optimization step). <a href="#a982c9d648fb8eed1258110e2709b753e">More...</a><br /></td></tr>
<tr class="separator:a982c9d648fb8eed1258110e2709b753e"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a1bf33eeef675654898572456d67ce572"><td class="memItemLeft" align="right" valign="top">double &amp;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classmlpack_1_1sparse__coding_1_1SparseCoding.html#a1bf33eeef675654898572456d67ce572">NewtonTolerance</a> ()</td></tr>
<tr class="memdesc:a1bf33eeef675654898572456d67ce572"><td class="mdescLeft">&#160;</td><td class="mdescRight">Modify the tolerance for Newton's method (dictionary optimization step). <a href="#a1bf33eeef675654898572456d67ce572">More...</a><br /></td></tr>
<tr class="separator:a1bf33eeef675654898572456d67ce572"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a018fe8a03cd5788ae42c32c10fc0bb00"><td class="memItemLeft" align="right" valign="top">double&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classmlpack_1_1sparse__coding_1_1SparseCoding.html#a018fe8a03cd5788ae42c32c10fc0bb00">Objective</a> (const arma::mat &amp;data, const arma::mat &amp;codes) const </td></tr>
<tr class="memdesc:a018fe8a03cd5788ae42c32c10fc0bb00"><td class="mdescLeft">&#160;</td><td class="mdescRight">Compute the objective function. <a href="#a018fe8a03cd5788ae42c32c10fc0bb00">More...</a><br /></td></tr>
<tr class="separator:a018fe8a03cd5788ae42c32c10fc0bb00"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a9118842bfcd0c5f760aa1e139a2352bc"><td class="memItemLeft" align="right" valign="top">double&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classmlpack_1_1sparse__coding_1_1SparseCoding.html#a9118842bfcd0c5f760aa1e139a2352bc">ObjTolerance</a> () const </td></tr>
<tr class="memdesc:a9118842bfcd0c5f760aa1e139a2352bc"><td class="mdescLeft">&#160;</td><td class="mdescRight">Get the objective tolerance. <a href="#a9118842bfcd0c5f760aa1e139a2352bc">More...</a><br /></td></tr>
<tr class="separator:a9118842bfcd0c5f760aa1e139a2352bc"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a77437cec620b2d34d81fa17acf029b04"><td class="memItemLeft" align="right" valign="top">double &amp;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classmlpack_1_1sparse__coding_1_1SparseCoding.html#a77437cec620b2d34d81fa17acf029b04">ObjTolerance</a> ()</td></tr>
<tr class="memdesc:a77437cec620b2d34d81fa17acf029b04"><td class="mdescLeft">&#160;</td><td class="mdescRight">Modify the objective tolerance. <a href="#a77437cec620b2d34d81fa17acf029b04">More...</a><br /></td></tr>
<tr class="separator:a77437cec620b2d34d81fa17acf029b04"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a74bd6bdf548cdf4cafdc2dfd9bf088d6"><td class="memItemLeft" align="right" valign="top">double&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classmlpack_1_1sparse__coding_1_1SparseCoding.html#a74bd6bdf548cdf4cafdc2dfd9bf088d6">OptimizeDictionary</a> (const arma::mat &amp;data, const arma::mat &amp;codes, const arma::uvec &amp;adjacencies)</td></tr>
<tr class="memdesc:a74bd6bdf548cdf4cafdc2dfd9bf088d6"><td class="mdescLeft">&#160;</td><td class="mdescRight">Learn dictionary via Newton method based on Lagrange dual. <a href="#a74bd6bdf548cdf4cafdc2dfd9bf088d6">More...</a><br /></td></tr>
<tr class="separator:a74bd6bdf548cdf4cafdc2dfd9bf088d6"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a893395402ca5da626cd262a41a28848c"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classmlpack_1_1sparse__coding_1_1SparseCoding.html#a893395402ca5da626cd262a41a28848c">ProjectDictionary</a> ()</td></tr>
<tr class="memdesc:a893395402ca5da626cd262a41a28848c"><td class="mdescLeft">&#160;</td><td class="mdescRight">Project each atom of the dictionary back onto the unit ball, if necessary. <a href="#a893395402ca5da626cd262a41a28848c">More...</a><br /></td></tr>
<tr class="separator:a893395402ca5da626cd262a41a28848c"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a1d54b3fc3ff871f2febfe576ce146fb7"><td class="memTemplParams" colspan="2">template&lt;typename Archive &gt; </td></tr>
<tr class="memitem:a1d54b3fc3ff871f2febfe576ce146fb7"><td class="memTemplItemLeft" align="right" valign="top">void&#160;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="classmlpack_1_1sparse__coding_1_1SparseCoding.html#a1d54b3fc3ff871f2febfe576ce146fb7">Serialize</a> (Archive &amp;ar, const unsigned int)</td></tr>
<tr class="memdesc:a1d54b3fc3ff871f2febfe576ce146fb7"><td class="mdescLeft">&#160;</td><td class="mdescRight">Serialize the sparse coding model. <a href="#a1d54b3fc3ff871f2febfe576ce146fb7">More...</a><br /></td></tr>
<tr class="separator:a1d54b3fc3ff871f2febfe576ce146fb7"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a523ba5f1facb8ae4cafd734c33a1d230"><td class="memTemplParams" colspan="2">template&lt;typename DictionaryInitializer = DataDependentRandomInitializer&gt; </td></tr>
<tr class="memitem:a523ba5f1facb8ae4cafd734c33a1d230"><td class="memTemplItemLeft" align="right" valign="top">void&#160;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="classmlpack_1_1sparse__coding_1_1SparseCoding.html#a523ba5f1facb8ae4cafd734c33a1d230">Train</a> (const arma::mat &amp;data, const DictionaryInitializer &amp;initializer=DictionaryInitializer())</td></tr>
<tr class="memdesc:a523ba5f1facb8ae4cafd734c33a1d230"><td class="mdescLeft">&#160;</td><td class="mdescRight">Train the sparse coding model on the given dataset. <a href="#a523ba5f1facb8ae4cafd734c33a1d230">More...</a><br /></td></tr>
<tr class="separator:a523ba5f1facb8ae4cafd734c33a1d230"><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:af9b3bf2d390d108c626f7ea7368328b0"><td class="memItemLeft" align="right" valign="top">size_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classmlpack_1_1sparse__coding_1_1SparseCoding.html#af9b3bf2d390d108c626f7ea7368328b0">atoms</a></td></tr>
<tr class="memdesc:af9b3bf2d390d108c626f7ea7368328b0"><td class="mdescLeft">&#160;</td><td class="mdescRight">Number of atoms. <a href="#af9b3bf2d390d108c626f7ea7368328b0">More...</a><br /></td></tr>
<tr class="separator:af9b3bf2d390d108c626f7ea7368328b0"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a930b87c1b123d6ffdbc244d68790d098"><td class="memItemLeft" align="right" valign="top">arma::mat&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classmlpack_1_1sparse__coding_1_1SparseCoding.html#a930b87c1b123d6ffdbc244d68790d098">dictionary</a></td></tr>
<tr class="memdesc:a930b87c1b123d6ffdbc244d68790d098"><td class="mdescLeft">&#160;</td><td class="mdescRight">Dictionary (columns are atoms). <a href="#a930b87c1b123d6ffdbc244d68790d098">More...</a><br /></td></tr>
<tr class="separator:a930b87c1b123d6ffdbc244d68790d098"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ab4711495fe1881bc4f61a3252b660166"><td class="memItemLeft" align="right" valign="top">double&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classmlpack_1_1sparse__coding_1_1SparseCoding.html#ab4711495fe1881bc4f61a3252b660166">lambda1</a></td></tr>
<tr class="memdesc:ab4711495fe1881bc4f61a3252b660166"><td class="mdescLeft">&#160;</td><td class="mdescRight">l1 regularization term. <a href="#ab4711495fe1881bc4f61a3252b660166">More...</a><br /></td></tr>
<tr class="separator:ab4711495fe1881bc4f61a3252b660166"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a8b2505fdc424c72f9925060631f9d2cc"><td class="memItemLeft" align="right" valign="top">double&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classmlpack_1_1sparse__coding_1_1SparseCoding.html#a8b2505fdc424c72f9925060631f9d2cc">lambda2</a></td></tr>
<tr class="memdesc:a8b2505fdc424c72f9925060631f9d2cc"><td class="mdescLeft">&#160;</td><td class="mdescRight">l2 regularization term. <a href="#a8b2505fdc424c72f9925060631f9d2cc">More...</a><br /></td></tr>
<tr class="separator:a8b2505fdc424c72f9925060631f9d2cc"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ac2e86cbe516dc6c8a66541853e7c8e2f"><td class="memItemLeft" align="right" valign="top">size_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classmlpack_1_1sparse__coding_1_1SparseCoding.html#ac2e86cbe516dc6c8a66541853e7c8e2f">maxIterations</a></td></tr>
<tr class="memdesc:ac2e86cbe516dc6c8a66541853e7c8e2f"><td class="mdescLeft">&#160;</td><td class="mdescRight">Maximum number of iterations during training. <a href="#ac2e86cbe516dc6c8a66541853e7c8e2f">More...</a><br /></td></tr>
<tr class="separator:ac2e86cbe516dc6c8a66541853e7c8e2f"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ad9474bd8956404954370c4fa75fb883a"><td class="memItemLeft" align="right" valign="top">double&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classmlpack_1_1sparse__coding_1_1SparseCoding.html#ad9474bd8956404954370c4fa75fb883a">newtonTolerance</a></td></tr>
<tr class="memdesc:ad9474bd8956404954370c4fa75fb883a"><td class="mdescLeft">&#160;</td><td class="mdescRight">Tolerance for Newton's method (dictionary training). <a href="#ad9474bd8956404954370c4fa75fb883a">More...</a><br /></td></tr>
<tr class="separator:ad9474bd8956404954370c4fa75fb883a"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a6b04b57a6c0c93afd1f166549bed6d65"><td class="memItemLeft" align="right" valign="top">double&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classmlpack_1_1sparse__coding_1_1SparseCoding.html#a6b04b57a6c0c93afd1f166549bed6d65">objTolerance</a></td></tr>
<tr class="memdesc:a6b04b57a6c0c93afd1f166549bed6d65"><td class="mdescLeft">&#160;</td><td class="mdescRight">Tolerance for main objective. <a href="#a6b04b57a6c0c93afd1f166549bed6d65">More...</a><br /></td></tr>
<tr class="separator:a6b04b57a6c0c93afd1f166549bed6d65"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>An implementation of Sparse Coding with Dictionary Learning that achieves sparsity via an l1-norm regularizer on the codes (LASSO) or an (l1+l2)-norm regularizer on the codes (the Elastic Net). </p>
<p>Let d be the number of dimensions in the original space, m the number of training points, and k the number of atoms in the dictionary (the dimension of the learned feature space). The training data X is a d-by-m matrix where each column is a point and each row is a dimension. The dictionary D is a d-by-k matrix, and the sparse codes matrix Z is a k-by-m matrix. This program seeks to minimize the objective:</p>
<p class="formulaDsp">
<img class="formulaDsp" alt="\[ \min_{D,Z} 0.5 ||X - D Z||_{F}^2\ + \lambda_1 \sum_{i=1}^m ||Z_i||_1 + 0.5 \lambda_2 \sum_{i=1}^m ||Z_i||_2^2 \]" src="form_91.png"/>
</p>
<p>subject to <img class="formulaInl" alt="$ ||D_j||_2 &lt;= 1 $" src="form_92.png"/> for <img class="formulaInl" alt="$ 1 &lt;= j &lt;= k $" src="form_93.png"/> where typically <img class="formulaInl" alt="$ lambda_1 &gt; 0 $" src="form_94.png"/> and <img class="formulaInl" alt="$ lambda_2 = 0 $" src="form_95.png"/>.</p>
<p>This problem is solved by an algorithm that alternates between a dictionary learning step and a sparse coding step. The dictionary learning step updates the dictionary D using a Newton method based on the Lagrange dual (see the paper below for details). The sparse coding step involves solving a large number of sparse linear regression problems; this can be done efficiently using LARS, an algorithm that can solve the LASSO or the Elastic Net (papers below).</p>
<p>Here are those papers:</p>
<div class="fragment"><div class="line">@incollection{lee2007efficient,</div><div class="line"> title = {Efficient sparse coding algorithms},</div><div class="line"> author = {Honglak Lee and Alexis Battle and Rajat Raina and Andrew Y. Ng},</div><div class="line"> booktitle = {Advances in Neural Information Processing Systems 19},</div><div class="line"> editor = {B. Sch\<span class="stringliteral">&quot;{o}lkopf and J. Platt and T. Hoffman},</span></div><div class="line"><span class="stringliteral"> publisher = {MIT Press},</span></div><div class="line"><span class="stringliteral"> address = {Cambridge, MA},</span></div><div class="line"><span class="stringliteral"> pages = {801--808},</span></div><div class="line"><span class="stringliteral"> year = {2007}</span></div><div class="line"><span class="stringliteral">}</span></div></div><!-- fragment --><div class="fragment"><div class="line">@article{efron2004least,</div><div class="line"> title={Least angle regression},</div><div class="line"> author={Efron, B. and Hastie, T. and Johnstone, I. and Tibshirani, R.},</div><div class="line"> journal={The Annals of statistics},</div><div class="line"> volume={32},</div><div class="line"> number={2},</div><div class="line"> pages={407--499},</div><div class="line"> year={2004},</div><div class="line"> publisher={Institute of Mathematical Statistics}</div><div class="line">}</div></div><!-- fragment --><div class="fragment"><div class="line">@article{zou2005regularization,</div><div class="line"> title={Regularization and variable selection via the elastic net},</div><div class="line"> author={Zou, H. and Hastie, T.},</div><div class="line"> journal={Journal of the Royal Statistical Society Series B},</div><div class="line"> volume={67},</div><div class="line"> number={2},</div><div class="line"> pages={301--320},</div><div class="line"> year={2005},</div><div class="line"> publisher={Royal Statistical Society}</div><div class="line">}</div></div><!-- fragment --><p>Note that the implementation here does not use the feature-sign search algorithm from Honglak Lee's paper, but instead the LARS algorithm suggested in that paper.</p>
<p>When <a class="el" href="classmlpack_1_1sparse__coding_1_1SparseCoding.html#a523ba5f1facb8ae4cafd734c33a1d230" title="Train the sparse coding model on the given dataset. ">Train()</a> is called, the dictionary is initialized using the DictionaryInitializationPolicy class. Possible choices include the <a class="el" href="classmlpack_1_1sparse__coding_1_1RandomInitializer.html" title="A DictionaryInitializer for use with the SparseCoding class. ">RandomInitializer</a>, which provides an entirely random dictionary, the <a class="el" href="classmlpack_1_1sparse__coding_1_1DataDependentRandomInitializer.html" title="A data-dependent random dictionary initializer for SparseCoding. ">DataDependentRandomInitializer</a>, which provides a random dictionary based loosely on characteristics of the dataset, and the <a class="el" href="classmlpack_1_1sparse__coding_1_1NothingInitializer.html" title="A DictionaryInitializer for SparseCoding which does not initialize anything; it is useful for when th...">NothingInitializer</a>, which does not initialize the dictionary &ndash; instead, the user should set the dictionary using the <a class="el" href="classmlpack_1_1sparse__coding_1_1SparseCoding.html#ab069f805f1db24a672b6f38a6d9cf755" title="Modify the dictionary. ">Dictionary()</a> mutator method.</p>
<p>Once a dictionary is trained with <a class="el" href="classmlpack_1_1sparse__coding_1_1SparseCoding.html#a523ba5f1facb8ae4cafd734c33a1d230" title="Train the sparse coding model on the given dataset. ">Train()</a>, another matrix may be encoded with the <a class="el" href="classmlpack_1_1sparse__coding_1_1SparseCoding.html#a1a83718fbf6b44326e9309775ec5bd93" title="Sparse code each point in the given dataset via LARS, using the current dictionary and store the enco...">Encode()</a> function.</p>
<dl class="tparams"><dt>Template Parameters</dt><dd>
<table class="tparams">
<tr><td class="paramname">DictionaryInitializationPolicy</td><td>The class to use to initialize the dictionary; must have 'void Initialize(const arma::mat&amp; data, arma::mat&amp; dictionary)' function. </td></tr>
</table>
</dd>
</dl>
<p>Definition at line <a class="el" href="sparse__coding_8hpp_source.html#l00115">115</a> of file <a class="el" href="sparse__coding_8hpp_source.html">sparse_coding.hpp</a>.</p>
</div><h2 class="groupheader">Constructor &amp; Destructor Documentation</h2>
<a class="anchor" id="a6a00e8188578c374b2d6036d64bb64dd"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename DictionaryInitializer = DataDependentRandomInitializer&gt; </div>
<table class="memname">
<tr>
<td class="memname">mlpack::sparse_coding::SparseCoding::SparseCoding </td>
<td>(</td>
<td class="paramtype">const arma::mat &amp;&#160;</td>
<td class="paramname"><em>data</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const size_t&#160;</td>
<td class="paramname"><em>atoms</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const double&#160;</td>
<td class="paramname"><em>lambda1</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const double&#160;</td>
<td class="paramname"><em>lambda2</em> = <code>0</code>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const size_t&#160;</td>
<td class="paramname"><em>maxIterations</em> = <code>0</code>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const double&#160;</td>
<td class="paramname"><em>objTolerance</em> = <code>0.01</code>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const double&#160;</td>
<td class="paramname"><em>newtonTolerance</em> = <code>1e-6</code>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const DictionaryInitializer &amp;&#160;</td>
<td class="paramname"><em>initializer</em> = <code>DictionaryInitializer()</code>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Set the parameters to <a class="el" href="classmlpack_1_1sparse__coding_1_1SparseCoding.html" title="An implementation of Sparse Coding with Dictionary Learning that achieves sparsity via an l1-norm reg...">SparseCoding</a>. </p>
<p>lambda2 defaults to 0. This constructor will train the model. If that is not desired, call the other constructor that does not take a data matrix. This constructor will also initialize the dictionary using the given DictionaryInitializer before training.</p>
<p>If you want to initialize the dictionary to a custom matrix, consider either writing your own DictionaryInitializer class (with void Initialize(const arma::mat&amp; data, arma::mat&amp; dictionary) function), or call the constructor that does not take a data matrix, then call <a class="el" href="classmlpack_1_1sparse__coding_1_1SparseCoding.html#ab069f805f1db24a672b6f38a6d9cf755" title="Modify the dictionary. ">Dictionary()</a> to set the dictionary matrix to a matrix of your choosing, and then call <a class="el" href="classmlpack_1_1sparse__coding_1_1SparseCoding.html#a523ba5f1facb8ae4cafd734c33a1d230" title="Train the sparse coding model on the given dataset. ">Train()</a> with <a class="el" href="classmlpack_1_1sparse__coding_1_1NothingInitializer.html" title="A DictionaryInitializer for SparseCoding which does not initialize anything; it is useful for when th...">NothingInitializer</a> (i.e. Train&lt;NothingInitializer&gt;(data)).</p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">data</td><td>Data matrix. </td></tr>
<tr><td class="paramname">atoms</td><td>Number of atoms in dictionary. </td></tr>
<tr><td class="paramname">lambda1</td><td>Regularization parameter for l1-norm penalty. </td></tr>
<tr><td class="paramname">lambda2</td><td>Regularization parameter for l2-norm penalty. </td></tr>
<tr><td class="paramname">maxIterations</td><td>Maximum number of iterations to run algorithm. If 0, the algorithm will run until convergence (or forever). </td></tr>
<tr><td class="paramname">objTolerance</td><td>Tolerance for objective function. When an iteration of the algorithm produces an improvement smaller than this, the algorithm will terminate. </td></tr>
<tr><td class="paramname">newtonTolerance</td><td>Tolerance for the Newton's method dictionary optimization step. </td></tr>
</table>
</dd>
</dl>
</div>
</div>
<a class="anchor" id="a7849a56a97f599479aa38bcbd34f80b8"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">mlpack::sparse_coding::SparseCoding::SparseCoding </td>
<td>(</td>
<td class="paramtype">const size_t&#160;</td>
<td class="paramname"><em>atoms</em> = <code>0</code>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const double&#160;</td>
<td class="paramname"><em>lambda1</em> = <code>0</code>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const double&#160;</td>
<td class="paramname"><em>lambda2</em> = <code>0</code>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const size_t&#160;</td>
<td class="paramname"><em>maxIterations</em> = <code>0</code>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const double&#160;</td>
<td class="paramname"><em>objTolerance</em> = <code>0.01</code>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const double&#160;</td>
<td class="paramname"><em>newtonTolerance</em> = <code>1e-6</code>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Set the parameters to <a class="el" href="classmlpack_1_1sparse__coding_1_1SparseCoding.html" title="An implementation of Sparse Coding with Dictionary Learning that achieves sparsity via an l1-norm reg...">SparseCoding</a>. </p>
<p>lambda2 defaults to 0. This constructor will not train the model, and a subsequent call to <a class="el" href="classmlpack_1_1sparse__coding_1_1SparseCoding.html#a523ba5f1facb8ae4cafd734c33a1d230" title="Train the sparse coding model on the given dataset. ">Train()</a> will be required before the model can encode points with <a class="el" href="classmlpack_1_1sparse__coding_1_1SparseCoding.html#a1a83718fbf6b44326e9309775ec5bd93" title="Sparse code each point in the given dataset via LARS, using the current dictionary and store the enco...">Encode()</a>.</p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">atoms</td><td>Number of atoms in dictionary. </td></tr>
<tr><td class="paramname">lambda1</td><td>Regularization parameter for l1-norm penalty. </td></tr>
<tr><td class="paramname">lambda2</td><td>Regularization parameter for l2-norm penalty. </td></tr>
<tr><td class="paramname">maxIterations</td><td>Maximum number of iterations to run algorithm. If 0, the algorithm will run until convergence (or forever). </td></tr>
<tr><td class="paramname">objTolerance</td><td>Tolerance for objective function. When an iteration of the algorithm produces an improvement smaller than this, the algorithm will terminate. </td></tr>
<tr><td class="paramname">newtonTolerance</td><td>Tolerance for the Newton's method dictionary optimization step. </td></tr>
</table>
</dd>
</dl>
</div>
</div>
<h2 class="groupheader">Member Function Documentation</h2>
<a class="anchor" id="a953c6a16d66622fffb3be8a703e22554"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">size_t mlpack::sparse_coding::SparseCoding::Atoms </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>Access the number of atoms. </p>
<p>Definition at line <a class="el" href="sparse__coding_8hpp_source.html#l00226">226</a> of file <a class="el" href="sparse__coding_8hpp_source.html">sparse_coding.hpp</a>.</p>
<p>References <a class="el" href="sparse__coding_8hpp_source.html#l00261">atoms</a>.</p>
</div>
</div>
<a class="anchor" id="a777e19b014ebeb2e9f0a033afe684d3c"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">size_t&amp; mlpack::sparse_coding::SparseCoding::Atoms </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>Modify the number of atoms. </p>
<p>Definition at line <a class="el" href="sparse__coding_8hpp_source.html#l00228">228</a> of file <a class="el" href="sparse__coding_8hpp_source.html">sparse_coding.hpp</a>.</p>
<p>References <a class="el" href="sparse__coding_8hpp_source.html#l00261">atoms</a>.</p>
</div>
</div>
<a class="anchor" id="af9f8ca70ece9948605d25fb2e9ee76d5"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">const arma::mat&amp; mlpack::sparse_coding::SparseCoding::Dictionary </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>Access the dictionary. </p>
<p>Definition at line <a class="el" href="sparse__coding_8hpp_source.html#l00221">221</a> of file <a class="el" href="sparse__coding_8hpp_source.html">sparse_coding.hpp</a>.</p>
<p>References <a class="el" href="sparse__coding_8hpp_source.html#l00264">dictionary</a>.</p>
</div>
</div>
<a class="anchor" id="ab069f805f1db24a672b6f38a6d9cf755"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">arma::mat&amp; mlpack::sparse_coding::SparseCoding::Dictionary </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>Modify the dictionary. </p>
<p>Definition at line <a class="el" href="sparse__coding_8hpp_source.html#l00223">223</a> of file <a class="el" href="sparse__coding_8hpp_source.html">sparse_coding.hpp</a>.</p>
<p>References <a class="el" href="sparse__coding_8hpp_source.html#l00264">dictionary</a>.</p>
</div>
</div>
<a class="anchor" id="a1a83718fbf6b44326e9309775ec5bd93"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void mlpack::sparse_coding::SparseCoding::Encode </td>
<td>(</td>
<td class="paramtype">const arma::mat &amp;&#160;</td>
<td class="paramname"><em>data</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">arma::mat &amp;&#160;</td>
<td class="paramname"><em>codes</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Sparse code each point in the given dataset via LARS, using the current dictionary and store the encoded data in the codes matrix. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">data</td><td>Input data matrix to be encoded. </td></tr>
<tr><td class="paramname">codes</td><td>Output codes matrix. </td></tr>
</table>
</dd>
</dl>
</div>
</div>
<a class="anchor" id="a47d91644f8f0cc08961c3caf43cd81a9"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">double mlpack::sparse_coding::SparseCoding::Lambda1 </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>Access the L1 regularization term. </p>
<p>Definition at line <a class="el" href="sparse__coding_8hpp_source.html#l00231">231</a> of file <a class="el" href="sparse__coding_8hpp_source.html">sparse_coding.hpp</a>.</p>
<p>References <a class="el" href="sparse__coding_8hpp_source.html#l00267">lambda1</a>.</p>
</div>
</div>
<a class="anchor" id="a431d1dc6ec0c629c0168eb44d76e59c1"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">double&amp; mlpack::sparse_coding::SparseCoding::Lambda1 </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>Modify the L1 regularization term. </p>
<p>Definition at line <a class="el" href="sparse__coding_8hpp_source.html#l00233">233</a> of file <a class="el" href="sparse__coding_8hpp_source.html">sparse_coding.hpp</a>.</p>
<p>References <a class="el" href="sparse__coding_8hpp_source.html#l00267">lambda1</a>.</p>
</div>
</div>
<a class="anchor" id="a54f409dd73bb45d60b769e2b759eb3c4"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">double mlpack::sparse_coding::SparseCoding::Lambda2 </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>Access the L2 regularization term. </p>
<p>Definition at line <a class="el" href="sparse__coding_8hpp_source.html#l00236">236</a> of file <a class="el" href="sparse__coding_8hpp_source.html">sparse_coding.hpp</a>.</p>
<p>References <a class="el" href="sparse__coding_8hpp_source.html#l00269">lambda2</a>.</p>
</div>
</div>
<a class="anchor" id="a90a77a7f18df81b2332ab55492878e61"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">double&amp; mlpack::sparse_coding::SparseCoding::Lambda2 </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>Modify the L2 regularization term. </p>
<p>Definition at line <a class="el" href="sparse__coding_8hpp_source.html#l00238">238</a> of file <a class="el" href="sparse__coding_8hpp_source.html">sparse_coding.hpp</a>.</p>
<p>References <a class="el" href="sparse__coding_8hpp_source.html#l00269">lambda2</a>.</p>
</div>
</div>
<a class="anchor" id="afbb6a1afa961fe55837defb7d020d693"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">size_t mlpack::sparse_coding::SparseCoding::MaxIterations </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 maximum number of iterations. </p>
<p>Definition at line <a class="el" href="sparse__coding_8hpp_source.html#l00241">241</a> of file <a class="el" href="sparse__coding_8hpp_source.html">sparse_coding.hpp</a>.</p>
<p>References <a class="el" href="sparse__coding_8hpp_source.html#l00272">maxIterations</a>.</p>
</div>
</div>
<a class="anchor" id="a309ec92833b38a75c7a1e83927166ecb"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">size_t&amp; mlpack::sparse_coding::SparseCoding::MaxIterations </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>Modify the maximum number of iterations. </p>
<p>Definition at line <a class="el" href="sparse__coding_8hpp_source.html#l00243">243</a> of file <a class="el" href="sparse__coding_8hpp_source.html">sparse_coding.hpp</a>.</p>
<p>References <a class="el" href="sparse__coding_8hpp_source.html#l00272">maxIterations</a>.</p>
</div>
</div>
<a class="anchor" id="a982c9d648fb8eed1258110e2709b753e"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">double mlpack::sparse_coding::SparseCoding::NewtonTolerance </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 tolerance for Newton's method (dictionary optimization step). </p>
<p>Definition at line <a class="el" href="sparse__coding_8hpp_source.html#l00251">251</a> of file <a class="el" href="sparse__coding_8hpp_source.html">sparse_coding.hpp</a>.</p>
<p>References <a class="el" href="sparse__coding_8hpp_source.html#l00276">newtonTolerance</a>.</p>
</div>
</div>
<a class="anchor" id="a1bf33eeef675654898572456d67ce572"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">double&amp; mlpack::sparse_coding::SparseCoding::NewtonTolerance </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>Modify the tolerance for Newton's method (dictionary optimization step). </p>
<p>Definition at line <a class="el" href="sparse__coding_8hpp_source.html#l00253">253</a> of file <a class="el" href="sparse__coding_8hpp_source.html">sparse_coding.hpp</a>.</p>
<p>References <a class="el" href="sparse__coding_8hpp_source.html#l00276">newtonTolerance</a>, and <a class="el" href="classmlpack_1_1sparse__coding_1_1SparseCoding.html#a1d54b3fc3ff871f2febfe576ce146fb7">Serialize()</a>.</p>
</div>
</div>
<a class="anchor" id="a018fe8a03cd5788ae42c32c10fc0bb00"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">double mlpack::sparse_coding::SparseCoding::Objective </td>
<td>(</td>
<td class="paramtype">const arma::mat &amp;&#160;</td>
<td class="paramname"><em>data</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const arma::mat &amp;&#160;</td>
<td class="paramname"><em>codes</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td> const</td>
</tr>
</table>
</div><div class="memdoc">
<p>Compute the objective function. </p>
</div>
</div>
<a class="anchor" id="a9118842bfcd0c5f760aa1e139a2352bc"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">double mlpack::sparse_coding::SparseCoding::ObjTolerance </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 objective tolerance. </p>
<p>Definition at line <a class="el" href="sparse__coding_8hpp_source.html#l00246">246</a> of file <a class="el" href="sparse__coding_8hpp_source.html">sparse_coding.hpp</a>.</p>
<p>References <a class="el" href="sparse__coding_8hpp_source.html#l00274">objTolerance</a>.</p>
</div>
</div>
<a class="anchor" id="a77437cec620b2d34d81fa17acf029b04"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">double&amp; mlpack::sparse_coding::SparseCoding::ObjTolerance </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>Modify the objective tolerance. </p>
<p>Definition at line <a class="el" href="sparse__coding_8hpp_source.html#l00248">248</a> of file <a class="el" href="sparse__coding_8hpp_source.html">sparse_coding.hpp</a>.</p>
<p>References <a class="el" href="sparse__coding_8hpp_source.html#l00274">objTolerance</a>.</p>
</div>
</div>
<a class="anchor" id="a74bd6bdf548cdf4cafdc2dfd9bf088d6"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">double mlpack::sparse_coding::SparseCoding::OptimizeDictionary </td>
<td>(</td>
<td class="paramtype">const arma::mat &amp;&#160;</td>
<td class="paramname"><em>data</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const arma::mat &amp;&#160;</td>
<td class="paramname"><em>codes</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const arma::uvec &amp;&#160;</td>
<td class="paramname"><em>adjacencies</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Learn dictionary via Newton method based on Lagrange dual. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">data</td><td>Data matrix. </td></tr>
<tr><td class="paramname">codes</td><td>Matrix of codes. </td></tr>
<tr><td class="paramname">adjacencies</td><td>Indices of entries (unrolled column by column) of the coding matrix Z that are non-zero (the adjacency matrix for the bipartite graph of points and atoms). </td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>the norm of the gradient of the Lagrange dual with respect to the dual variables </dd></dl>
</div>
</div>
<a class="anchor" id="a893395402ca5da626cd262a41a28848c"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void mlpack::sparse_coding::SparseCoding::ProjectDictionary </td>
<td>(</td>
<td class="paramname"></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Project each atom of the dictionary back onto the unit ball, if necessary. </p>
</div>
</div>
<a class="anchor" id="a1d54b3fc3ff871f2febfe576ce146fb7"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename Archive &gt; </div>
<table class="memname">
<tr>
<td class="memname">void mlpack::sparse_coding::SparseCoding::Serialize </td>
<td>(</td>
<td class="paramtype">Archive &amp;&#160;</td>
<td class="paramname"><em>ar</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const unsigned&#160;</td>
<td class="paramname"><em>int</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Serialize the sparse coding model. </p>
<p>Referenced by <a class="el" href="sparse__coding_8hpp_source.html#l00253">NewtonTolerance()</a>.</p>
</div>
</div>
<a class="anchor" id="a523ba5f1facb8ae4cafd734c33a1d230"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename DictionaryInitializer = DataDependentRandomInitializer&gt; </div>
<table class="memname">
<tr>
<td class="memname">void mlpack::sparse_coding::SparseCoding::Train </td>
<td>(</td>
<td class="paramtype">const arma::mat &amp;&#160;</td>
<td class="paramname"><em>data</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const DictionaryInitializer &amp;&#160;</td>
<td class="paramname"><em>initializer</em> = <code>DictionaryInitializer()</code>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Train the sparse coding model on the given dataset. </p>
</div>
</div>
<h2 class="groupheader">Member Data Documentation</h2>
<a class="anchor" id="af9b3bf2d390d108c626f7ea7368328b0"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">size_t mlpack::sparse_coding::SparseCoding::atoms</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>Number of atoms. </p>
<p>Definition at line <a class="el" href="sparse__coding_8hpp_source.html#l00261">261</a> of file <a class="el" href="sparse__coding_8hpp_source.html">sparse_coding.hpp</a>.</p>
<p>Referenced by <a class="el" href="sparse__coding_8hpp_source.html#l00226">Atoms()</a>.</p>
</div>
</div>
<a class="anchor" id="a930b87c1b123d6ffdbc244d68790d098"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">arma::mat mlpack::sparse_coding::SparseCoding::dictionary</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>Dictionary (columns are atoms). </p>
<p>Definition at line <a class="el" href="sparse__coding_8hpp_source.html#l00264">264</a> of file <a class="el" href="sparse__coding_8hpp_source.html">sparse_coding.hpp</a>.</p>
<p>Referenced by <a class="el" href="sparse__coding_8hpp_source.html#l00221">Dictionary()</a>.</p>
</div>
</div>
<a class="anchor" id="ab4711495fe1881bc4f61a3252b660166"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">double mlpack::sparse_coding::SparseCoding::lambda1</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>l1 regularization term. </p>
<p>Definition at line <a class="el" href="sparse__coding_8hpp_source.html#l00267">267</a> of file <a class="el" href="sparse__coding_8hpp_source.html">sparse_coding.hpp</a>.</p>
<p>Referenced by <a class="el" href="sparse__coding_8hpp_source.html#l00231">Lambda1()</a>.</p>
</div>
</div>
<a class="anchor" id="a8b2505fdc424c72f9925060631f9d2cc"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">double mlpack::sparse_coding::SparseCoding::lambda2</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>l2 regularization term. </p>
<p>Definition at line <a class="el" href="sparse__coding_8hpp_source.html#l00269">269</a> of file <a class="el" href="sparse__coding_8hpp_source.html">sparse_coding.hpp</a>.</p>
<p>Referenced by <a class="el" href="sparse__coding_8hpp_source.html#l00236">Lambda2()</a>.</p>
</div>
</div>
<a class="anchor" id="ac2e86cbe516dc6c8a66541853e7c8e2f"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">size_t mlpack::sparse_coding::SparseCoding::maxIterations</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>Maximum number of iterations during training. </p>
<p>Definition at line <a class="el" href="sparse__coding_8hpp_source.html#l00272">272</a> of file <a class="el" href="sparse__coding_8hpp_source.html">sparse_coding.hpp</a>.</p>
<p>Referenced by <a class="el" href="sparse__coding_8hpp_source.html#l00241">MaxIterations()</a>.</p>
</div>
</div>
<a class="anchor" id="ad9474bd8956404954370c4fa75fb883a"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">double mlpack::sparse_coding::SparseCoding::newtonTolerance</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>Tolerance for Newton's method (dictionary training). </p>
<p>Definition at line <a class="el" href="sparse__coding_8hpp_source.html#l00276">276</a> of file <a class="el" href="sparse__coding_8hpp_source.html">sparse_coding.hpp</a>.</p>
<p>Referenced by <a class="el" href="sparse__coding_8hpp_source.html#l00251">NewtonTolerance()</a>.</p>
</div>
</div>
<a class="anchor" id="a6b04b57a6c0c93afd1f166549bed6d65"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">double mlpack::sparse_coding::SparseCoding::objTolerance</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>Tolerance for main objective. </p>
<p>Definition at line <a class="el" href="sparse__coding_8hpp_source.html#l00274">274</a> of file <a class="el" href="sparse__coding_8hpp_source.html">sparse_coding.hpp</a>.</p>
<p>Referenced by <a class="el" href="sparse__coding_8hpp_source.html#l00246">ObjTolerance()</a>.</p>
</div>
</div>
<hr/>The documentation for this class was generated from the following file:<ul>
<li>src/mlpack/methods/sparse_coding/<a class="el" href="sparse__coding_8hpp_source.html">sparse_coding.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>