<p>Have you compiled mlpack without debugging symbols?  If you're using the git master branch, then debugging and profiling symbols are enabled by default (you can disable with <code>-DDEBUG=OFF -DPROFILE=OFF</code>), and if you're using a release (2.0.1, for instance), then debugging and profiling symbols are disabled by default so that should not be an issue.  And I assume you're compiling your program with <code>-O3</code> and without any debugging symbols or anything.</p>

<p>The EM algorithm may take some time to converge for a GMM.  I think maybe to figure out what is going on here, you should try removing the HMM layer and just train a GMM on its own on the data.  When you call <code>GMM::Train()</code>, you can pass in an instantiated <code>EMFit</code> object so that you can set the options, like the maximum number of iterations and the tolerance.</p>

<p>Based on your profile it seems like the major delay is possibly in these lines from <code>em_fit_impl.hpp</code> (lines 88--93):</p>

<pre><code>// Calculate the new value of the covariances using the updated
// conditional probabilities and the updated means.
arma::mat tmp = observations - (dists[i].Mean() *
    arma::ones&lt;arma::rowvec&gt;(observations.n_cols));
arma::mat tmpB = tmp % (arma::ones&lt;arma::vec&gt;(observations.n_rows) *
    trans(condProb.col(i)));
</code></pre>

<p>I wonder if that expression is not being optimized well?</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/550#issuecomment-192337638">view it on GitHub</a>.<img alt="" height="1" src="https://github.com/notifications/beacon/AJ4bFIxvLQJGr3RRIA1oFX3AKVDzlUuKks5pqFmCgaJpZM4HpaV-.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/550#issuecomment-192337638"></link>
  <meta itemprop="name" content="View Issue"></meta>
</div>
<meta itemprop="description" content="View this Issue on GitHub"></meta>
</div>