<blockquote>
<p>just return net (which is the FFN) and saved it to another auto'd variable from main.</p>
</blockquote>

<p>Like theSundayProgrammer said, if you create your net by std::tie, the type of your net would take the reference of the layers, but not copy/move the layer(remember to define ARMA_USE_CXX11, else the matrix of armadillo cannot move). Return reference of the stack is not a good idea, because the stack will be destroy after you exit from scope. </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/issues/531#issuecomment-191013956">view it on GitHub</a>.<img alt="" height="1" src="https://github.com/notifications/beacon/AJ4bFFO1f6t48XJHO7SpOeQpSB6a_fRhks5ppOv2gaJpZM4HmbCC.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/issues/531#issuecomment-191013956"></link>
  <meta itemprop="name" content="View Issue"></meta>
</div>
<meta itemprop="description" content="View this Issue on GitHub"></meta>
</div>