<p>In <a href="https://github.com/mlpack/mlpack/pull/465#discussion_r43120492">src/mlpack/methods/sparse_autoencoder/maximal_inputs.cpp</a>:</p>
<pre style='color:#555'>&gt; +  int const squareRows = (int)std::sqrt(paramTemp.n_cols);
&gt; +  int const buf = 1;
&gt; +
&gt; +  int const offset = squareRows+buf;
&gt; +  output.ones(buf+rows*(offset),
&gt; +              buf+cols*(offset));
&gt; +
&gt; +  VisualizeHiddenUnit(rows, cols, squareRows,
&gt; +                      offset, paramTemp, output);
&gt; +
&gt; +  double const max = output.max();
&gt; +  double const min = output.min();
&gt; +  if((max - min) != 0)
&gt; +  {
&gt; +    output = (output - min) / (max - min) * 255;
&gt; +  }
</pre>
<p>This scales the output to the range [0, 255], but is that always what the user will want?  Maybe it's worth considering a few more parameters to <code>MaximalInputs()</code> for scaling?  i.e. <code>bool scale</code>, <code>double min</code>, <code>double max</code>, and you could use defaults.  What do you think?  I don't know if everyone is going to want to be saving specifically to PGM (or another 8-bit grayscale image format) when using this function.</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/465/files#r43120492">view it on GitHub</a>.<img alt="" height="1" src="https://github.com/notifications/beacon/AJ4bFNi6FqHaRNiZja1n7Qhk3-Rs3qEYks5o_3QKgaJpZM4GWT_f.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/465/files#r43120492"></link>
  <meta itemprop="name" content="View Pull Request"></meta>
</div>
<meta itemprop="description" content="View this Pull Request on GitHub"></meta>
</div>