提交 2abad4b7 authored 作者: Arnaud Bergeron's avatar Arnaud Bergeron

More fixes to doc syntax.

上级 627d9bf7
......@@ -750,8 +750,10 @@ Creating Tensor
.. function:: stack(*tensors)
.. warning:: The interface stack(*tensors) is deprecated!
Use stack(tensors, axis=0) instead.
.. warning::
The interface `stack(*tensors)` is deprecated! Use
`stack(tensors, axis=0)` instead.
Stack tensors in sequence vertically (row wise).
......@@ -1773,6 +1775,7 @@ Gradient / Differentiation
.. automodule:: theano.gradient
:members: grad
:noindex:
See the :ref:`gradient <libdoc_gradient>` page for complete documentation
of the gradient module.
......@@ -181,7 +181,7 @@ of error can thus be identified with much more precision and much earlier in
the compilation pipeline. For example, running the above code yields the
following error message, which properly identifies *line 24* as the culprit.
.. code-block:: node
.. code-block:: none
Traceback (most recent call last):
File "test2.py", line 24, in <module>
......
......@@ -878,7 +878,7 @@ pre-defined macros. These section tags have no macros: ``init_code``,
discussed below.
* ``APPLY_SPECIFIC(str)`` which will automatically append a name
unique to the :ref:`Apply node that applies the Op at the end
unique to the :ref:`Apply` node that applies the Op at the end
of the provided ``str``. The use of this macro is discussed
futher below.
......
......@@ -371,58 +371,51 @@ def grad(cost, wrt, consider_constant=None,
see :mod:`gradient`. For information on how to implement the gradient of
a certain Op, see :func:`grad`.
:type cost: Scalar (0-dimensional) tensor variable.
May optionally be None if known_grads is provided.
:param cost: a scalar with respect to which we are differentiating
Parameters
----------
cost : scalar (0-dimensional) tensor variable or None
Value with respect to which we are differentiating. May be
`None` if known_grads is provided.
wrt : variable or list of variables
term[s] for which we want gradients
consider_constant : list of variables
expressions not to backpropagate through
disconnected_inputs : {'ignore', 'warn', 'raise'}
Defines the behaviour if some of the variables in `wrt` are
not part of the computational graph computing `cost` (or if
all links are non-differentiable). The possible values are:
:type wrt: Tensor variable or list of variables.
:param wrt: term[s] for which we want gradients
:type consider_constant: list of variables
:param consider_constant: a list of expressions not to backpropagate
through
:type disconnected_inputs: string
:param disconnected_inputs: Defines the behaviour if some of the variables
in ``wrt`` are not part of the computational graph computing ``cost``
(or if all links are non-differentiable). The possible values are:
- 'ignore': considers that the gradient on these parameters is zero.
- 'warn': consider the gradient zero, and print a warning.
- 'raise': raise DisconnectedInputError.
:type add_names: bool
:param add_names: If True, variables generated by grad will be named
(d<cost.name>/d<wrt.name>) provided that both cost and wrt have
names
:type known_grads: dict
:param known_grads: If not None, a dictionary mapping variables to their
gradients. This is useful in the case where you know the
gradient on some variables but do not know the original
cost.
:type return_disconnected: string
:param return_disconnected:
add_names : bool
If True, variables generated by grad will be named
(d<cost.name>/d<wrt.name>) provided that both cost and wrt
have names
known_grads : dict, optional
A dictionary mapping variables to their gradients. This is
useful in the case where you know the gradient on some
variables but do not know the original cost.
return_disconnected : {'zero', 'None', 'Disconnected'}
- 'zero' : If wrt[i] is disconnected, return value i will be
wrt[i].zeros_like()
- 'None' : If wrt[i] is disconnected, return value i will be
None
- 'Disconnected' : returns variables of type DisconnectedType
null_gradients : {'raise', 'return'}
Defines the behaviour if some of the variables in `wrt` have a
null gradient. The possibles values are:
:type null_gradients: string
:param null_gradients: Defines the behaviour if some of the variables in
``wrt`` have a null gradient. The possibles values are :
- 'raise' : raise a NullTypeGradError exception
- 'return' : return the null gradients
:rtype: variable or list/tuple of Variables (matching `wrt`)
:return: symbolic expression of gradient of `cost` with respect to each
of the `wrt` terms.
If an element of `wrt` is not differentiable with respect
to the output, then a zero variable is returned.
It returns an object of same type as `wrt`: a list/tuple
or Variable in all cases.
Returns
-------
variable or list/tuple of variables (matches `wrt`)
symbolic expression of gradient of `cost` with respect to each
of the `wrt` terms. If an element of `wrt` is not
differentiable with respect to the output, then a zero
variable is returned.
"""
t0 = time.time()
......
......@@ -126,14 +126,17 @@ class CudaNdarraySharedVariable(_operators, SharedVariable):
* The destination on the GPU must be c_contiguous.
* The source is on the CPU.
* The old value must have the same dtype as the new value (which is
a given for now, since only float32 is supported).
* The old value must have the same dtype as the new value
(which is a given for now, since only float32 is
supported).
* The old and new value must have the same shape.
* The old value is being completely replaced by the new value (not
partially modified, e.g. by replacing some subtensor of it).
* You change the value of the shared variable via set_value, not via
the .value accessors. You should not use the .value accessors
anyway, since they will soon be deprecated and removed.
* The old value is being completely replaced by the new
value (not partially modified, e.g. by replacing some
subtensor of it).
* You change the value of the shared variable via
set_value, not via the .value accessors. You should not
use the .value accessors anyway, since they will soon be
deprecated and removed.
It is also worth mentioning that, for efficient transfer to the GPU,
Theano will make the new data ``c_contiguous``. This can require an
......
......@@ -14,22 +14,20 @@ from theano.gradient import grad_undefined
class Images2Neibs(Op):
"""
Reshapes the input as a 2D tensor where each row is an pooling
example.
Parameters
----------
mode : {'valid', 'ignore_borders', 'wrap_centered'}
'valid': Requires an input that is a multiple of the
pooling factor (in each direction).
'ignore_borders': Same as valid, but will ignore the borders
if the shape(s) of the input is not a multiple of the pooling
factor(s).
'wrap_centered' : ?? TODO comment
Returns
-------
object
Reshapes the input as a 2D tensor where each row is an
pooling example.
- 'valid' :
Requires an input that is a multiple of the pooling factor
(in each direction).
- 'ignore_borders' :
Same as valid, but will ignore the borders if the shape(s)
of the input is not a multiple of the pooling factor(s).
- 'wrap_centered' :
?? TODO comment
"""
......@@ -429,7 +427,7 @@ class Images2Neibs(Op):
def images2neibs(ten4, neib_shape, neib_step=None, mode='valid'):
"""
Function :func:`images2neibs <theano.sandbox.neighbours.images2neibs>`
Function :func:`images2neibs <theano.tensor.nnet.neighbours.images2neibs>`
allows to apply a sliding window operation to a tensor containing
images or other two-dimensional objects.
The sliding window operation loops over points in input data and stores
......@@ -455,9 +453,6 @@ def images2neibs(ten4, neib_shape, neib_step=None, mode='valid'):
By default it is equal to `neib_shape` in other words, the patches are
disjoint. When the step is greater than `neib_shape`, some elements are
omitted. When None, this is the same as neib_shape (patch are disjoint).
.. note:: Currently the step size should be chosen in the way that the
corresponding dimension :math:`i` (width or height) is equal to
:math:`n * step\_size_i + neib\_shape_i` for some :math:`n`
mode : {'valid', 'ignore_borders', 'wrap_centered'}
``valid``
Requires an input that is a multiple of the
......@@ -489,6 +484,13 @@ def images2neibs(ten4, neib_shape, neib_step=None, mode='valid'):
these for loops, they're just the easiest way to describe the
output pattern.
Notes
-----
.. note::
Currently the step size should be chosen in the way that the
corresponding dimension :math:`i` (width or height) is equal
to :math:`n * step\_size_i + neib\_shape_i` for some :math:`n`.
Examples
--------
......@@ -524,7 +526,7 @@ def neibs2images(neibs, neib_shape, original_shape, mode='valid'):
Parameters
----------
neibs: matrix
neibs : 2d tensor
Like the one obtained by
:func:`images2neibs <theano.sandbox.neigbours.neibs2images>`.
neib_shape
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论