<p>Another problem of making the layers templatize is how could the users modify the value of the layers?<br>
I would like to allow the users pass in the layers by constructor.</p>

<pre><code>SparseAutoencoder(const arma::mat&amp; data,
                  size_t visibleSize,
                  size_t hiddenSize,
                  double lambda = 0.0001,
                  double beta = 3,
                  double rho = 0.01,
                  HiddenLayer &amp;&amp;hiddenLayer = HiddenLayer(),
                  OutputLayer &amp;&amp;outputLayer = OutputLayer());
</code></pre>

<p>This api do not looks good since there are too many parameters, it reminds me of legacy c codes or c with classes. Another constructor maybe a better choice</p>

<pre><code> SparseAutoencoder(const arma::mat&amp; data,
                   size_t visibleSize,
                   size_t hiddenSize,
                   HiddenLayer &amp;&amp;hiddenLayer = HiddenLayer(),
                   OutputLayer &amp;&amp;outputLayer = OutputLayer());
</code></pre>

<p>I use &amp;&amp; because some layer maybe expensive to copy, this way the users can only pass in the HiddenLayer and OutputLayer by rvalue, then the constructor will be able to move them. Let the SparseAutoencoder keep the layers could make codes easier to deal with(the users do not need to create another variables to keep the layers alive, let SparseAutoencoder handle them).</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#issuecomment-150392565">view it on GitHub</a>.<img alt="" height="1" src="https://github.com/notifications/beacon/AJ4bFIa6_LoO_Cjg3qUEzV5oyBHB1MsZks5o-XMugaJpZM4GAqt4.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#issuecomment-150392565"></link>
  <meta itemprop="name" content="View Pull Request"></meta>
</div>
<meta itemprop="description" content="View this Pull Request on GitHub"></meta>
</div>