<p>Refactor the codes, now the api become</p>

<pre><code>template&lt;typename EncoderType,
         typename OutputLayerType = regression::SoftmaxRegressionFunction,
         typename DataType = double,
         typename FineTuneGradient = SoftmaxFineTune&gt;
class FineTuneFunction
{
 public:        
    /**
     * Construct the class with given data
     * @param input The input data of the LayerTypes and OutputLayerType
     * @param parameters The parameters of the LayerTypes and OutputLayerType
     * @param layerTypes The type(must be tuple) of the Layer(by now only support   SparseAutoencoder)
     * @param outLayerType The type of the last layer(ex : softmax)
     */
    FineTuneFunction(arma::Mat&lt;DataType&gt; &amp;input,
                      EncoderType &amp;encoder,
                      OutputLayerType &amp;outLayerType,
                      arma::Mat&lt;DataType&gt; const &amp;outLayerParam);
};
</code></pre>

<p>construct it like</p>

<pre><code>auto stackAE = std::forward_as_tuple(sae1, sae2, sae3);
//cannot get the softmax parameter from SoftmaxRegressionFunction, so we have to pass in
FineTuneFunction&lt;decltype(stackAE)&gt; finetune(trainData, stackAE, softmaxFunction, softmaxParameter);
</code></pre>

<p>However, this class depend on the pull request <a href="https://github.com/mlpack/mlpack/pull/451" class="issue-link" title="improve speed of SparseAutoencoder and make it more flexible">#451</a>, will wait until <a href="https://github.com/mlpack/mlpack/pull/451" class="issue-link" title="improve speed of SparseAutoencoder and make it more flexible">#451</a> is merged</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/460#issuecomment-150980897">view it on GitHub</a>.<img alt="" height="1" src="https://github.com/notifications/beacon/AJ4bFH7LYXWGddxiEuiPd9rxS0rW8gWbks5o_VH-gaJpZM4GMVfZ.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/460#issuecomment-150980897"></link>
  <meta itemprop="name" content="View Pull Request"></meta>
</div>
<meta itemprop="description" content="View this Pull Request on GitHub"></meta>
</div>