Note that we need to iterate over the indices of ``y`` and not over the elements of ``y``. The reason is that scan create a placeholder variable for its internal function and this placeholder variable does not have the same dependencies than the variables that will replace it.
Note that we need to iterate over the indices of ``y`` and not over the elements of ``y``. The reason is that scan create a placeholder variable for its internal function and this placeholder variable does not have the same dependencies than the variables that will replace it.
**Scan Example: Accumulate number of loop during a scan**
**Scan Example: Accumulate number of loop during a scan**
...
@@ -225,46 +224,46 @@ Note that we need to iterate over the indices of ``y`` and not over the elements
...
@@ -225,46 +224,46 @@ Note that we need to iterate over the indices of ``y`` and not over the elements
Note that if you want to use a random variable ``d`` that will not be updated through scan loops, you should pass this variable as a ``non_sequences`` arguments.
Note that if you want to use a random variable ``d`` that will not be updated through scan loops, you should pass this variable as a ``non_sequences`` arguments.
**Scan Example: Computing pow(A,k)**
**Scan Example: Computing pow(A,k)**
.. code-block:: python
.. code-block:: python
...
@@ -286,11 +285,11 @@ Note that if you want to use a random variable ``d`` that will not be updated th
...
@@ -286,11 +285,11 @@ Note that if you want to use a random variable ``d`` that will not be updated th
# Scan has provided us with A ** 1 through A ** k. Keep only the last
# Scan has provided us with A ** 1 through A ** k. Keep only the last
# value. Scan notices this and does not waste memory saving them.
# value. Scan notices this and does not waste memory saving them.
final_result = result[-1]
final_result = result[-1]
power = theano.function(inputs=[A, k], outputs=final_result,
power = theano.function(inputs=[A, k], outputs=final_result,