<p>In <a href="https://github.com/mlpack/mlpack/pull/451#discussion_r40166914">src/mlpack/methods/ann/sparse_autoencoder_function.hpp</a>:</p>
<pre style='color:#555'>&gt; + *   //using SAEF = nn::SparseAutoencoderFunction;
&gt; + *
&gt; + *   size_t const Features = 16*16;
&gt; + *   arma::mat data = randu&lt;mat&gt;(Features, 10000);
&gt; + *
&gt; + *   SAEF encoderFunction(data, Features, Features / 2);
&gt; + *   const size_t numIterations = 100; // Maximum number of iterations.
&gt; + *   const size_t numBasis = 10;
&gt; + *   optimization::L_BFGS&lt;SAEF&gt; optimizer(encoderFunction, numBasis, numIterations);
&gt; + *
&gt; + *   arma::mat parameters = encoderFunction.GetInitialPoint();
&gt; + *
&gt; + *   // Train the model.
&gt; + *   Timer::Start(&quot;sparse_autoencoder_optimization&quot;);
&gt; + *   const double out = optimizer.Optimize(parameters);
&gt; + *   Timer::Stop(&quot;sparse_autoencoder_optimization&quot;);
</pre>
<p>The API here is the way Siddharth originally wrote it, using the standard mlpack optimizers to optimize the weights of the network.  But maybe it would be a better idea to make this class work with the <code>Trainer</code> class in <code>src/mlpack/methods/ann/</code>?  Kind of like the examples in <code>convolutional_network_test.cpp</code> and <code>feedforward_network_test.cpp</code>:</p>

<pre><code>SAEF autoencoder(...);
Trainer&lt;SAEF&gt; trainer(autoencoder, ...);
trainer.Train(...);
</code></pre>

<p>This would help make all of the ANN-related code in mlpack have a unified interface.  I'd be interested in zoq's comments on this too, since I don't know his plans for what the API there will eventually look like.</p>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">&mdash;<br>Reply to this email directly or <a href="https://github.com/mlpack/mlpack/pull/451/files#r40166914">view it on GitHub</a>.<img alt="" height="1" src="https://github.com/notifications/beacon/AJ4bFJLznHl4q9cPCk8NbJwMAR0Iw4z7ks5o0gpSgaJpZM4GAqt4.gif" width="1" /></p>
<div itemscope itemtype="http://schema.org/EmailMessage">
<div itemprop="action" itemscope itemtype="http://schema.org/ViewAction">
  <link itemprop="url" href="https://github.com/mlpack/mlpack/pull/451/files#r40166914"></link>
  <meta itemprop="name" content="View Pull Request"></meta>
</div>
<meta itemprop="description" content="View this Pull Request on GitHub"></meta>
</div>