When is it advantageous to use theano's scan function
<p>I've been reading the Theano documentation on scan and find myself confused by two, seemingly, contradictory statements. </p>

<p>On <a href="http://deeplearning.net/software/theano/tutorial/loop.html#scan" rel="nofollow">http://deeplearning.net/software/theano/tutorial/loop.html#scan</a>, one of the advantages of scan is listed as:</p>

<pre><code>Slightly faster than using a for loop in Python with a compiled Theano function.
</code></pre>

<p>But, on <a href="http://deeplearning.net/software/theano/library/scan.html#lib-scan" rel="nofollow">http://deeplearning.net/software/theano/library/scan.html#lib-scan</a>, in a section on optimizing the use of scan, it says:</p>

<pre><code> Scan makes it possible to define simple and compact graphs that can do
 the same work as much larger and more complicated graphs. However, it 
 comes with a significant overhead. As such, **when performance is the 
 objective, a good rule of thumb is to perform as much of the computation 
 as possible outside of Scan**. This may have the effect of increasing 
 memory usage but can also reduce the overhead introduces by using Scan.
</code></pre>

<p>My reading of 'performance', here, is as a synonym for speed. So, I'm left confused as to when/if scan will lead to shorter runtimes, once compilation has been completed.</p>