提交 c4b6dca9 authored 作者: Razvan Pascanu's avatar Razvan Pascanu

polishing comments in scan.py

上级 9a9e91a8
...@@ -239,8 +239,8 @@ def scan(fn, sequences=[], outputs_info=[], non_sequences=[], ...@@ -239,8 +239,8 @@ def scan(fn, sequences=[], outputs_info=[], non_sequences=[],
If you are using shared variables over which you do not want to iterate, If you are using shared variables over which you do not want to iterate,
you do not need to provide them as arguments to ``fn``, though you can if you you do not need to provide them as arguments to ``fn``, though you can if you
wish so. The function should return the outputs after each step plus the updates for wish so. The function should return the outputs after each step plus the updates
any of the shared variables. You can either return only outputs or only for any of the shared variables. You can either return only outputs or only
updates. If you have both outputs and updates the function should return updates. If you have both outputs and updates the function should return
them as a tuple : (outputs, updates) or (updates, outputs). them as a tuple : (outputs, updates) or (updates, outputs).
...@@ -279,9 +279,10 @@ def scan(fn, sequences=[], outputs_info=[], non_sequences=[], ...@@ -279,9 +279,10 @@ def scan(fn, sequences=[], outputs_info=[], non_sequences=[],
list of ints (only negative .. since you can not use future values of outputs), list of ints (only negative .. since you can not use future values of outputs),
with the same meaning as for ``sequences`` (see above). with the same meaning as for ``sequences`` (see above).
* ``inplace`` -- theano variable pointing to one of the input sequences; this * ``inplace`` -- theano variable pointing to one of the input sequences; this
flag tells scan that the output should be computed in the memory spaced occupied flag tells scan that the output should be computed in the memory space occupied
by that input sequence. Note that scan will only do this if allowed by the by that input sequence. Note that scan will only do this if allowed by the
rest of your computational graph and if you are not using past taps of the input. rest of your computational graph and if you are not using past taps of the
input.
* ``return_steps`` how many steps to return from your output. If not given, or * ``return_steps`` how many steps to return from your output. If not given, or
0 scan will return all steps, otherwise it will return the last ``return_steps``. 0 scan will return all steps, otherwise it will return the last ``return_steps``.
Note that if you set this to something else then 0, scan will try to be smart Note that if you set this to something else then 0, scan will try to be smart
...@@ -296,8 +297,8 @@ def scan(fn, sequences=[], outputs_info=[], non_sequences=[], ...@@ -296,8 +297,8 @@ def scan(fn, sequences=[], outputs_info=[], non_sequences=[],
notation, when ``t = 0``, we would need values for ``y[-1]``, ``y[-2]`` notation, when ``t = 0``, we would need values for ``y[-1]``, ``y[-2]``
and ``y[-4]``. These values are provided by the initial state of ``y``, and ``y[-4]``. These values are provided by the initial state of ``y``,
which should have same number of dimension as ``y``, where the first which should have same number of dimension as ``y``, where the first
dimension should be large enough to cover all past values, which in this dimension should be large enough to cover all the required past values, which in
case is 4. If ``init_y`` is the variable containing the initial state this case is 4. If ``init_y`` is the variable containing the initial state
of ``y``, then ``init_y[0]`` corresponds to ``y[-4]``, ``init_y[1]`` of ``y``, then ``init_y[0]`` corresponds to ``y[-4]``, ``init_y[1]``
corresponds to ``y[-3]``, ``init_y[2]`` corresponds to ``y[-2]``, corresponds to ``y[-3]``, ``init_y[2]`` corresponds to ``y[-2]``,
``init_y[3]`` corresponds to ``y[-1]``. The default behaviour of scan is ``init_y[3]`` corresponds to ``y[-1]``. The default behaviour of scan is
...@@ -311,13 +312,13 @@ def scan(fn, sequences=[], outputs_info=[], non_sequences=[], ...@@ -311,13 +312,13 @@ def scan(fn, sequences=[], outputs_info=[], non_sequences=[],
of -1 of -1
* if you wrap an output in a dictionary but you do not provide any initial state, * if you wrap an output in a dictionary but you do not provide any initial state,
it assumes that you are not using any form of taps it assumes that you are not using any form of taps
* if you provide a ``None`` scan assumes that you will not use any taps for this * if you provide a ``None`` instead of a variable or a dictionary scan assumes
output (this would be the case for map ) that you will not use any taps for this output (this would be the case for map)
If you did not provide any information for your outputs, scan will assume by default If you did not provide any information for your outputs, scan will assume by
that you are not using any taps for any of the outputs. If you provide information for default that you are not using any taps for any of the outputs. If you provide
just a subset of outputs, scan will not know to which outputs these information information for just a subset of outputs, scan will not know to which outputs
corresponds and will raise an error. these correspond and will raise an error.
:param non_sequences: :param non_sequences:
Parameters over which scan should not iterate. These parameters are Parameters over which scan should not iterate. These parameters are
...@@ -330,18 +331,20 @@ def scan(fn, sequences=[], outputs_info=[], non_sequences=[], ...@@ -330,18 +331,20 @@ def scan(fn, sequences=[], outputs_info=[], non_sequences=[],
the input sequences. If the value is 0, the outputs will have 0 rows. If the the input sequences. If the value is 0, the outputs will have 0 rows. If the
value is negative, scan will run backwards (or if the flag go_backwards is value is negative, scan will run backwards (or if the flag go_backwards is
already set to true it will run forward in time). If n_steps is not provided, already set to true it will run forward in time). If n_steps is not provided,
or evaluetes to None, inf or nan, scan will figure out the maximal amount of steps it can or evaluetes to None, inf or nan, scan will figure out the maximal amount of
take and do that. steps it can run given the input sequences and do that.
:param truncate_gradient: :param truncate_gradient:
Number of steps to use in truncated BPTT. If you compute gradients Number of steps to use in truncated BPTT. If you compute gradients
through a scan op, they are computed using backpropagation through time. through a scan op, they are computed using backpropagation through time.
By providing a different value then -1, you choose to use truncated BPTT By providing a different value then -1, you choose to use truncated BPTT
instead of classical BPTT, where you only do ``truncate_gradient`` instead of classical BPTT, where you only do ``truncate_gradient``
number of steps. (NOT YET IMPLEMENTED) number of steps.
:param go_backwards: :param go_backwards:
Flag indicating if you should go backwards through the sequences Flag indicating if you should go backwards through the sequences ( if you
think as the sequences being indexed by time, this would mean go backwards
in time)
:param name: :param name:
The name of the theano function compiled by the Scan op. It will show in the The name of the theano function compiled by the Scan op. It will show in the
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论