提交 f22d3165 authored 作者: Brandon T. Willard's avatar Brandon T. Willard 提交者: Brandon T. Willard

Fix Sphinx documentation syntax errors, broken links, etc.

上级 b0a07a40
差异被折叠。
......@@ -321,7 +321,7 @@ class FunctionGraph(MetaObject):
This will also import the `variable`'s `Apply` node.
Parameters:
Parameters
----------
variable : aesara.graph.basic.Variable
The variable to be imported.
......@@ -361,7 +361,7 @@ class FunctionGraph(MetaObject):
) -> None:
"""Recursively import everything between an `Apply` node and the `FunctionGraph`'s outputs.
Parameters:
Parameters
----------
apply_node : aesara.graph.basic.Apply
The node to be imported.
......@@ -492,7 +492,7 @@ class FunctionGraph(MetaObject):
This is the main interface to manipulate the subgraph in `FunctionGraph`.
For every node that uses `var` as input, makes it use `new_var` instead.
Parameters:
Parameters
----------
var : aesara.graph.basic.Variable
The variable to be replaced.
......@@ -772,20 +772,21 @@ class FunctionGraph(MetaObject):
def clone_get_equiv(
self, check_integrity: bool = True, attach_feature: bool = True
) -> Union["FunctionGraph", Dict[Variable, Variable]]:
"""Clone the graph and get a dict that maps old nodes to new ones
Parameters:
check_integrity: bool
Whether to check integrity. Default is True.
attach_feature: bool
Whether to attach feature of origin graph to cloned graph.
Default is True.
Returns:
e: FunctionGraph
Cloned fgraph. Every node in cloned graph is cloned.
equiv: dict
A dict that map old node to new node.
"""Clone the graph and return a ``dict`` that maps old nodes to new nodes.
Parameters
----------
check_integrity
Whether to check integrity.
attach_feature
Whether to attach feature of origin graph to cloned graph.
Returns
-------
e
Cloned fgraph. Every node in cloned graph is cloned.
equiv
A ``dict`` that maps old nodes to the new nodes.
"""
equiv = clone_get_equiv(self.inputs, self.outputs)
......
......@@ -56,7 +56,7 @@ ThunkType = Callable[[PerformMethodType, StorageMapType, ComputeMapType, Apply],
def compute_test_value(node: Apply):
"""Computes the test value of a node.
r"""Computes the test value of a node.
Parameters
----------
......@@ -66,7 +66,7 @@ def compute_test_value(node: Apply):
Returns
-------
None
The `tag.test_value`s are updated in each `Variable` in `node.outputs`.
The `tag.test_value`\s are updated in each `Variable` in `node.outputs`.
"""
# Gather the test values for each input of the node
......@@ -140,13 +140,11 @@ class Op(MetaObject):
A `Op` instance has several responsibilities:
- construct `Apply` nodes via `Op.make_node` method,
- perform the numeric calculation of the modeled operation via
the `Op.perform` method,
- and (optionally) build the gradient-calculating sub-graphs via the
`Op.grad` method.
* construct `Apply` nodes via :meth:`Op.make_node` method,
* perform the numeric calculation of the modeled operation via the
:meth:`Op.perform` method,
* and (optionally) build the gradient-calculating sub-graphs via the
:meth:`Op.grad` method.
To see how `Op`, `Type`, `Variable`, and `Apply` fit together see the
page on :doc:`graph`.
......@@ -173,8 +171,12 @@ class Op(MetaObject):
Examples
========
.. code-block:: python
view_map = {0: [1]} # first output is a view of second input
view_map = {1: [0]} # second output is a view of first input
"""
destroy_map: Dict[int, List[int]] = {}
......@@ -184,6 +186,9 @@ class Op(MetaObject):
Examples
========
.. code-block:: python
destroy_map = {0: [1]} # first output operates in-place on second input
destroy_map = {1: [0]} # second output operates in-place on first input
......@@ -223,17 +228,17 @@ class Op(MetaObject):
return Apply(self, inputs, [o() for o in self.otypes])
def __call__(self, *inputs: Any, **kwargs) -> Union[Variable, List[Variable]]:
"""Construct an `Apply` node using `self.make_node` and return its outputs.
r"""Construct an `Apply` node using `self.make_node` and return its outputs.
This method is just a wrapper around `Op.make_node`.
It is called by code such as:
.. python::
.. code-block:: python
x = tensor.matrix()
x = aesara.tensor.matrix()
y = aesara.tensor.exp(x)
y = tensor.exp(x)
`tensor.exp` is an Op instance, so `tensor.exp(x)` calls
`tensor.exp.__call__` (i.e. this method) and returns its single output
......@@ -250,19 +255,19 @@ class Op(MetaObject):
The `Op`'s inputs.
kwargs
Additional keyword arguments to be forwarded to
`make_node()` *except* for optional argument `return_list` (which
defaults to `False`). If `return_list` is `True`, then the returned
value is always a `list`. Otherwise it is either a single `Variable`
when the output of `make_node()` contains a single element, or this
:meth:`Op.make_node` *except* for optional argument ``return_list`` (which
defaults to ``False``). If ``return_list`` is ``True``, then the returned
value is always a ``list``. Otherwise it is either a single `Variable`
when the output of :meth:`Op.make_node` contains a single element, or this
output (unchanged) when it contains multiple elements.
Returns
-------
outputs : list of Variable or Variable
Either a list of output `Variable`s, or a single `Variable`.
Either a list of output `Variable`\s, or a single `Variable`.
This is determined by the number of outputs produced by the
`Op`, the value of the keyword `return_list`, and the value of
the `Op.default_output` property.
`Op`, the value of the keyword ``return_list``, and the value of
the :attr:`Op.default_output` property.
"""
return_list = kwargs.pop("return_list", False)
......@@ -346,28 +351,24 @@ class Op(MetaObject):
def R_op(
self, inputs: List[Variable], eval_points: Union[Variable, List[Variable]]
) -> List[Variable]:
"""Construct a graph for the R-operator.
This method is primarily used by `Rop`
r"""Construct a graph for the R-operator.
Suppose the op outputs
This method is primarily used by `Rop`.
[ f_1(inputs), ..., f_n(inputs) ]
Suppose the `Op` outputs ``[ f_1(inputs), ..., f_n(inputs) ]``.
Parameters
----------
inputs : a Variable or list of Variables
inputs
The `Op` inputs.
eval_points
A Variable or list of Variables with the same length as inputs.
Each element of eval_points specifies the value of the corresponding
input at the point where the R op is to be evaluated.
A `Variable` or list of `Variable`\s with the same length as inputs.
Each element of `eval_points` specifies the value of the corresponding
input at the point where the R-operator is to be evaluated.
Returns
-------
list of n elements
rval[i] should be Rop(f=f_i(inputs),
wrt=inputs,
eval_points=eval_points)
``rval[i]`` should be ``Rop(f=f_i(inputs), wrt=inputs, eval_points=eval_points)``.
"""
raise NotImplementedError()
......@@ -682,14 +683,20 @@ def get_test_value(v: Variable) -> Any:
def missing_test_message(msg: Text) -> None:
"""
Displays msg, a message saying that some test_value is missing,
in the appropriate form based on config.compute_test_value:
"""Display a message saying that some test_value is missing.
This uses the appropriate form based on ``config.compute_test_value``:
off:
The interactive debugger is off, so we do nothing.
ignore:
The interactive debugger is set to ignore missing inputs, so do
nothing.
warn:
Display `msg` as a warning.
off: The interactive debugger is off, so we do nothing.
ignore: The interactive debugger is set to ignore missing inputs,
so do nothing.
warn: Display msg as a warning.
Raises
------
......@@ -707,28 +714,33 @@ def missing_test_message(msg: Text) -> None:
def get_test_values(*args: Variable) -> Union[Any, List[Any]]:
"""Get test values for multiple `Variable`s.
r"""Get test values for multiple `Variable`\s.
Intended use:
.. code-block:: python
for val_1, ..., val_n in get_debug_values(var_1, ..., var_n):
if some condition on val_1, ..., val_n is not met:
missing_test_message("condition was not met")
Given a list of variables, get_debug_values does one of three things:
1. If the interactive debugger is off, returns an empty list
2. If the interactive debugger is on, and all variables have
debug values, returns a list containing a single element.
This single element is either:
a) if there is only one variable, the element is its
value
b) otherwise, a tuple containing debug values of all
the variables.
3. If the interactive debugger is on, and some variable does
not have a debug value, issue a missing_test_message about
the variable, and, if still in control of execution, return
an empty list.
Given a list of variables, `get_debug_values` does one of three things:
1. If the interactive debugger is off, returns an empty list
2. If the interactive debugger is on, and all variables have
debug values, returns a list containing a single element.
This single element is either:
a) if there is only one variable, the element is its
value
b) otherwise, a tuple containing debug values of all
the variables.
3. If the interactive debugger is on, and some variable does
not have a debug value, issue a `missing_test_message` about
the variable, and, if still in control of execution, return
an empty list.
"""
......@@ -754,10 +766,10 @@ def get_test_values(*args: Variable) -> Union[Any, List[Any]]:
ops_with_inner_function: Dict[Op, Text] = {}
"""
Registry of Ops that have an inner compiled Aesara function.
r"""
Registry of `Op`\s that have an inner compiled Aesara function.
The keys are Op classes (not instances), and values are the name of the
The keys are `Op` classes (not instances), and values are the name of the
attribute that contains the function. For instance, if the function is
self.fn, the value will be 'fn'.
......
......@@ -75,9 +75,10 @@ class GlobalOptimizer(abc.ABC):
def optimize(self, fgraph, *args, **kwargs):
"""
This is meant as a shortcut to:
opt.add_requirements(fgraph)
opt.apply(fgraph)
This is meant as a shortcut for the following::
opt.add_requirements(fgraph)
opt.apply(fgraph)
"""
self.add_requirements(fgraph)
......@@ -93,13 +94,13 @@ class GlobalOptimizer(abc.ABC):
return self.optimize(fgraph)
def add_requirements(self, fgraph):
"""
"""Add features to `fgraph` that are required to apply the optimization.
Add features to the fgraph that are required to apply the optimization.
For example:
fgraph.attach_feature(History())
fgraph.attach_feature(MyFeature())
etc.
For example::
fgraph.attach_feature(History())
fgraph.attach_feature(MyFeature())
# etc.
"""
......@@ -1478,8 +1479,9 @@ class OpSub(LocalOptimizer):
Examples
--------
OpSub(add, sub) ==>
add(div(x, y), add(y, x)) -> sub(div(x, y), sub(y, x))
OpSub(add, sub) ==>
add(div(x, y), add(y, x)) -> sub(div(x, y), sub(y, x))
"""
......@@ -1554,20 +1556,20 @@ class PatternSub(LocalOptimizer):
Replaces all occurrences of the input pattern by the output pattern:
input_pattern ::= (op, <sub_pattern1>, <sub_pattern2>, ...)
input_pattern ::= dict(pattern = <input_pattern>,
constraint = <constraint>)
sub_pattern ::= input_pattern
sub_pattern ::= string
sub_pattern ::= a Constant instance
sub_pattern ::= int
sub_pattern ::= float
constraint ::= lambda fgraph, expr: additional matching condition
output_pattern ::= (op, <output_pattern1>, <output_pattern2>, ...)
output_pattern ::= string
output_pattern ::= int
output_pattern ::= float
input_pattern ::= (op, <sub_pattern1>, <sub_pattern2>, ...)
input_pattern ::= dict(pattern = <input_pattern>,
constraint = <constraint>)
sub_pattern ::= input_pattern
sub_pattern ::= string
sub_pattern ::= a Constant instance
sub_pattern ::= int
sub_pattern ::= float
constraint ::= lambda fgraph, expr: additional matching condition
output_pattern ::= (op, <output_pattern1>, <output_pattern2>, ...)
output_pattern ::= string
output_pattern ::= int
output_pattern ::= float
Each string in the input pattern is a variable that will be set to
whatever expression is found in its place. If the same string is
......@@ -1619,13 +1621,15 @@ class PatternSub(LocalOptimizer):
Examples
--------
PatternSub((add, 'x', 'y'), (add, 'y', 'x'))
PatternSub((multiply, 'x', 'x'), (square, 'x'))
PatternSub((subtract, (add, 'x', 'y'), 'y'), 'x')
PatternSub((power, 'x', Constant(double, 2.0)), (square, 'x'))
PatternSub((boggle, {'pattern': 'x',
'constraint': lambda expr: expr.type == scrabble}),
(scrabble, 'x'))
PatternSub((add, 'x', 'y'), (add, 'y', 'x'))
PatternSub((multiply, 'x', 'x'), (square, 'x'))
PatternSub((subtract, (add, 'x', 'y'), 'y'), 'x')
PatternSub((power, 'x', Constant(double, 2.0)), (square, 'x'))
PatternSub((boggle, {'pattern': 'x',
'constraint': lambda expr: expr.type == scrabble}),
(scrabble, 'x'))
"""
def __init__(
......@@ -1868,18 +1872,17 @@ class NavigatorOptimizer(GlobalOptimizer):
- 'auto': let the local_opt set this parameter via its 'reentrant'
attribute.
failure_callback
A function that takes (exception, navigator, [(old, new),
(old,new),...]) and we call it if there's an exception.
A function with the signature ``(exception, navigator, [(old, new),
(old,new),...])`` that is called when there's an exception.
If the trouble is from local_opt.transform(), the new variables
will be 'None'.
If the exception is raised in ``local_opt.transform``, the ``new`` variables
will be ``None``.
If the trouble is from validation (the new types don't match for
example) then the new variables will be the ones created by
transform().
If the exception is raised during validation (e.g. the new types don't
match) then the new variables will be the ones created by ``self.transform``.
If this parameter is None, then exceptions are not caught here
(raised normally).
If this parameter is ``None``, then exceptions are not caught here and
are raised normally.
"""
......@@ -3078,33 +3081,35 @@ def inherit_stack_trace(from_var):
def check_stack_trace(f_or_fgraph, ops_to_check="last", bug_print="raise"):
"""
r"""
This function checks if the outputs of specific ops of a compiled graph
have a stack.
Parameters
----------
f_or_fgraph: aesara.compile.function.types.Function or
aesara.graph.fg.FunctionGraph
f_or_fgraph : Function or FunctionGraph
The compiled function or the function graph to be analysed.
ops_to_check: it can be of four different types:
- classes or instances inheriting from aesara.graph.op.Op
- tuple/list of classes or instances inheriting from aesara.graph.op.Op
- string
- function returning a boolean and taking as input an instance of
aesara.graph.op.Op.
- if ops_to_check is a string, it should be either 'last' or 'all'.
'last' will check only the last op of the graph while 'all' will
check all the ops of the graph.
- if ops_to_check is an op or a tuple/list of ops, the function will
ops_to_check
This value can be of four different types:
- classes or instances inheriting from `Op`
- tuple/list of classes or instances inheriting from `Op`
- string
- function returning a boolean and taking as input an instance of `Op`
- if `ops_to_check` is a string, it should be either ``'last'`` or ``'all'``.
``'last'`` will check only the last `Op` of the graph while ``'all'`` will
check all the `Op`\s of the graph.
- if `ops_to_check` is an `Op` or a tuple/list of `Op`\s, the function will
check that all the outputs of their occurrences in the graph have a
stack trace.
- if ops_to_check is a function, it should take as input a
aesara.graph.op.Op and return a boolean indicating if the input op should
- if `ops_to_check` is a function, it should take as input a
`Op` and return a boolean indicating if the input `Op` should
be checked or not.
bug_print: string belonging to {'raise', 'warn', 'ignore'}
bug_print
This value is a string belonging to ``{'raise', 'warn', 'ignore'}``.
You can specify the behaviour of the function when the specified
ops_to_check are not in the graph of f_or_fgraph: it can either raise
`ops_to_check` are not in the graph of `f_or_fgraph`: it can either raise
an exception, write a warning or simply ignore it.
Returns
......
......@@ -97,13 +97,13 @@ class Type(MetaObject):
def filter_variable(
self, other: Union[Variable, D], allow_convert: bool = True
) -> Variable:
"""Convert a symbolic variable into this `Type`, if compatible.
r"""Convert a symbolic variable into this `Type`, if compatible.
For the moment, the only `Type`s compatible with one another are
For the moment, the only `Type`\s compatible with one another are
`TensorType` and `GpuArrayType`, provided they have the same number of
dimensions, same broadcasting pattern, and same dtype.
If `Type`s are not compatible, a ``TypeError`` should be raised.
If `Type`\s are not compatible, a ``TypeError`` should be raised.
"""
if not isinstance(other, Variable):
......
......@@ -655,7 +655,7 @@ class JITLinker(PerformLinker):
def create_jitable_thunk(
self, compute_map, order, input_storage, output_storage, storage_map
):
"""Create a thunk for each output of the `Linker`s `FunctionGraph`.
r"""Create a thunk for each output of the `Linker`\s `FunctionGraph`.
This is differs from the other thunk-making function in that it only
produces thunks for the `FunctionGraph` output nodes.
......
......@@ -20,6 +20,8 @@ class CLinkerObject:
Examples
--------
.. code-block:: python
def c_headers(self, **kwargs):
return ['<iostream>', '<math.h>', '/full/path/to/header.h']
......@@ -39,6 +41,8 @@ class CLinkerObject:
Examples
--------
.. code-block:: python
def c_header_dirs(self, **kwargs):
return ['/usr/local/include', '/opt/weirdpath/src/include']
......@@ -58,6 +62,8 @@ class CLinkerObject:
Examples
--------
.. code-block:: python
def c_libraries(self, **kwargs):
return ['gsl', 'gslcblas', 'm', 'fftw3', 'g2c'].
......@@ -76,6 +82,8 @@ class CLinkerObject:
Examples
--------
.. code-block:: python
def c_lib_dirs(self, **kwargs):
return ['/usr/local/lib', '/opt/weirdpath/build/libs'].
......@@ -107,6 +115,8 @@ class CLinkerObject:
Examples
--------
.. code-block:: python
def c_compile_args(self, **kwargs):
return ['-ffast-math']
......@@ -173,8 +183,8 @@ class CLinkerOp(CLinkerObject):
Parameters
----------
node : Apply instance
The node for which we are compiling the current c_code.
The same Op may be used in more than one node.
The node for which we are compiling the current C code.
The same ``Op`` may be used in more than one node.
name : str
A name that is automatically assigned and guaranteed to be
unique.
......@@ -183,13 +193,13 @@ class CLinkerOp(CLinkerObject):
string is the name of a C variable pointing to that input.
The type of the variable depends on the declared type of
the input. There is a corresponding python variable that
can be accessed by prepending "py_" to the name in the
can be accessed by prepending ``"py_"`` to the name in the
list.
outputs : list of strings
Each string is the name of a C variable where the Op should
store its output. The type depends on the declared type of
the output. There is a corresponding python variable that
can be accessed by prepending "py_" to the name in the
the output. There is a corresponding Python variable that
can be accessed by prepending ``"py_"`` to the name in the
list. In some cases the outputs will be preallocated and
the value of the variable may be pre-filled. The value for
an unallocated output is type-dependent.
......@@ -246,13 +256,13 @@ class CLinkerOp(CLinkerObject):
string is the name of a C variable pointing to that input.
The type of the variable depends on the declared type of
the input. There is a corresponding python variable that
can be accessed by prepending "py_" to the name in the
can be accessed by prepending ``"py_"`` to the name in the
list.
outputs : list of str
Each string is the name of a C variable corresponding to
one of the outputs of the Op. The type depends on the
declared type of the output. There is a corresponding
python variable that can be accessed by prepending "py_" to
python variable that can be accessed by prepending ``"py_"`` to
the name in the list.
sub : dict of str
extra symbols defined in `CLinker` sub symbols (such as 'fail').
......@@ -287,7 +297,8 @@ class CLinkerOp(CLinkerObject):
Parameters
----------
node : an Apply instance in the graph being compiled
node
An `Apply` instance in the graph being compiled
name : str
A string or number that serves to uniquely identify this node.
Symbol names defined by this support code should include the name,
......@@ -366,12 +377,13 @@ class CLinkerType(CLinkerObject):
Parameters
----------
name: str
name : str
The name of the ``PyObject *`` pointer that will
the value for this Type
sub: dict string -> string
a dictionary of special codes. Most importantly
sub['fail']. See CLinker for more info on `sub` and ``fail``.
sub
A dictionary of special codes. Most importantly
``sub['fail']``. See `CLinker` for more info on ``sub`` and
``fail``.
Notes
-----
......@@ -388,6 +400,7 @@ class CLinkerType(CLinkerObject):
Examples
--------
.. code-block: python
def c_declare(self, name, sub, check_input=True):
......@@ -410,6 +423,7 @@ class CLinkerType(CLinkerObject):
Examples
--------
.. code-block: python
def c_init(self, name, sub):
......@@ -421,15 +435,15 @@ class CLinkerType(CLinkerObject):
def c_extract(
self, name: Text, sub: Dict[Text, Text], check_input: bool = True, **kwargs
) -> Text:
"""Return C code to extract a ``PyObject *`` instance.
r"""Return C code to extract a ``PyObject *`` instance.
The code returned from this function must be templated using
``%(name)s``, representing the name that the caller wants to
call this `Variable`. The Python object ``self.data`` is in a
variable called ``"py_%(name)s"`` and this code must set the
variables declared by c_declare to something representative
of ``py_%(name)``s. If the data is improper, set an appropriate
exception and insert ``"%(fail)s"``.
variables declared by :meth:`CLinkerType.c_declare` to something
representative of ``py_%(name)``\s. If the data is improper, set an
appropriate exception and insert ``"%(fail)s"``.
TODO: Point out that template filling (via sub) is now performed
by this function. --jpt
......@@ -446,6 +460,7 @@ class CLinkerType(CLinkerObject):
Examples
--------
.. code-block: python
def c_extract(self, name, sub, check_input=True, **kwargs):
......
......@@ -89,7 +89,7 @@ incsubtensor_ops = (IncSubtensor, AdvancedIncSubtensor1)
@singledispatch
def jax_typify(data, dtype=None, **kwargs):
"""Convert instances of Aesara `Type`s to JAX types."""
r"""Convert instances of Aesara `Type`\s to JAX types."""
if dtype is None:
return data
else:
......
"""
`Op`s that have their python implementations taken from SciPy.
r"""
`Op`\s that have their python implementations taken from SciPy.
As SciPy is not always available, we treat them separately.
"""
......
......@@ -25,9 +25,9 @@ of using ``scan`` over `for` loops in python (among others) are:
* it allows the number of iterations to be part of the symbolic graph
* it allows computing gradients through the for loop
* there exist a bunch of optimizations that help re-write your loop
such that less memory is used and that it runs faster
such that less memory is used and that it runs faster
* it ensures that data is not copied from host to gpu and gpu to
host at each step
host at each step
The Scan Op should typically be used by calling any of the following
functions: ``scan()``, ``map()``, ``reduce()``, ``foldl()``,
......
......@@ -4048,15 +4048,15 @@ class SamplingDot(Op):
sampling_dot = SamplingDot()
"""
Operand for calculating the dot product dot(`x`, `y`.T) = `z` when you
Operand for calculating the dot product ``dot(x, y.T) = z`` when you
only want to calculate a subset of `z`.
It is equivalent to `p` o (`x` . `y`.T) where o is the element-wise
It is equivalent to ``p o (x . y.T)`` where ``o`` is the element-wise
product, `x` and `y` operands of the dot product and `p` is a matrix that
contains 1 when the corresponding element of `z` should be calculated
and 0 when it shouldn't. Note that SamplingDot has a different interface
than `dot` because SamplingDot requires `x` to be a `m`x`k` matrix while
`y` is a `n`x`k` matrix instead of the usual `k`x`n` matrix.
than `dot` because SamplingDot requires `x` to be a ``m x k`` matrix while
`y` is a ``n x k`` matrix instead of the usual ``k x n`` matrix.
Notes
-----
......@@ -4079,7 +4079,7 @@ p
Returns
-------
sparse matrix
A dense matrix containing the dot product of `x` by `y`.T only
A dense matrix containing the dot product of `x` by ``y.T`` only
where `p` is 1.
"""
......@@ -4333,22 +4333,26 @@ class ConstructSparseFromList(Op):
def make_node(self, x, values, ilist):
"""
This creates a sparse matrix with the same shape as `x`. Its
values are the rows of `values` moved. It operates similar to
the following pseudo-code:
.. code-block:: python
output = csc_matrix.zeros_like(x, dtype=values.dtype)
for in_idx, out_idx in enumerate(ilist):
output[out_idx] = values[in_idx]
Parameters
----------
x
A dense matrix that specify the output shape.
A dense matrix that specifies the output shape.
values
A dense matrix with the values to use for output.
ilist
A dense vector with the same length as the number of rows of values.
It specify where in the output to put the corresponding rows.
This create a sparse matrix with the same shape as `x`. Its
values are the rows of `values` moved. Pseudo-code::
output = csc_matrix.zeros_like(x, dtype=values.dtype)
for in_idx, out_idx in enumerate(ilist):
output[out_idx] = values[in_idx]
It specifies where in the output to put the corresponding rows.
"""
x_ = aet.as_tensor_variable(x)
......
......@@ -1804,16 +1804,18 @@ register_specialize(local_structured_add_s_v, "cxx_only")
class SamplingDotCSR(_NoPythonCOp):
"""
Operand optimized for calculating the dot product dot(`x`, `y`.T) = `z`
when you only want to calculate a subset of `z`.
It is equivalent to `p` o (`x` . `y`.T) where o is the element-wise
product, `x` and `y` operands of the dot product and `p` is a matrix
that contains 1 when the corresponding element of `z` should be
calculated and 0 when it shouldn't. Note that SamplingDot has a different
interface than `dot` because SamplingDot requires `x` to be a `m`x`k`
matrix while `y` is a `n`x`k` matrix instead of the usual `k`x`n` matrix.
r"""
Operand optimized for calculating the dot product :math:`x y^\top = z`
when you only want to calculate a subset of :math:`z`.
It is equivalent to :math:`p \circ (x \cdot y^\top)` where :math:`\circ` is
the element-wise product, :math:`x` and :math:`y` operands of the dot
product, and :math:`p` is a matrix that contains 1 when the corresponding
element of :math:`z` should be calculated and 0 when it shouldn't. Note
that `SamplingDot` has a different interface than ``dot`` because
`SamplingDot` requires :math:`x` to be a :math:`m \times k` matrix while
:math:`y` is a :math:`n \times k` matrix instead of the usual :math:``k
\times n` matrix.
Parameters
----------
......@@ -1832,8 +1834,8 @@ class SamplingDotCSR(_NoPythonCOp):
Returns
-------
A dense matrix containing the dot product of `x` by `y`.T only
where `p` is 1.
A dense matrix containing the dot product of :math:`x` by :math:`y^\top` only
where :math:`p` is 1.
Notes
-----
......
"""`Op` classes for working with ``numpy.ndarrays`` symbolically.
r"""`Op` classes for working with ``numpy.ndarrays`` symbolically.
This module primarily defines `Op`s for the creation, conversion, and
This module primarily defines `Op`\s for the creation, conversion, and
manipulation of tensors.
"""
......@@ -2203,8 +2203,8 @@ def patternbroadcast(x, broadcastable):
class Join(COp):
"""
Concatenate multiple `TensorVariable`s along some axis.
r"""
Concatenate multiple `TensorVariable`\s along some axis.
The axis must be given as first argument. All tensors must have the same
shape along all dimensions other than this axis.
......@@ -2533,8 +2533,8 @@ pprint.assign(Join, printing.FunctionPrinter("join"))
def join(axis, *tensors_list):
"""
Convenience function to concatenate `TensorType`s along the given axis.
r"""
Convenience function to concatenate `TensorType`\s along the given axis.
This function will not add the op in the graph when it is not useful.
For example, in the case that the list of tensors to be concatenated
......
......@@ -4382,15 +4382,15 @@ register_specialize(topo_constant_folding, "fast_compile", final_opt=True)
def local_elemwise_fusion_op(op_class, max_input_fct=lambda node: 32, maker=None):
"""Create a recursive function that fuses `Elemwise` `Op`s.
r"""Create a recursive function that fuses `Elemwise` `Op`\s.
The basic idea is that we loop through an `Elemwise` node's inputs, find
other `Elemwise` nodes, determine the scalars input types for all of the
`Elemwise` `Op`s, construct a new scalar `Op` using the scalar input types
`Elemwise` `Op`\s, construct a new scalar `Op` using the scalar input types
and each `Elemwise`'s scalar `Op`, and use the composite scalar `Op` in a
new "fused" `Elemwise`.
It's parameterized in order to work for `Elemwise` and `GpuElemwise` `Op`s.
It's parameterized in order to work for `Elemwise` and `GpuElemwise` `Op`\s.
Parameters
----------
......@@ -4401,14 +4401,14 @@ def local_elemwise_fusion_op(op_class, max_input_fct=lambda node: 32, maker=None
can take (useful for `GpuElemwise`). The GPU kernel currently has a
limit of 256 bytes for the size of all parameters passed to it. As
currently we pass a lot of information only by parameter, we must limit how
many `Op`s we fuse together to avoid busting that 256 limit.
many `Op`\s we fuse together to avoid busting that 256 limit.
On the CPU we limit to 32 input variables since that is the maximum
NumPy support.
maker: callable
A function with the signature `(node, *args)` that constructs an
`op_class` instance (e.g. `op_class(*args)`).
A function with the signature ``(node, *args)`` that constructs an
`op_class` instance (e.g. ``op_class(*args)``).
"""
if maker is None:
......@@ -4417,9 +4417,9 @@ def local_elemwise_fusion_op(op_class, max_input_fct=lambda node: 32, maker=None
return op_class(scalar_op)
def local_fuse(fgraph, node):
"""Fuse `Elemwise` `Op`s in a node.
r"""Fuse `Elemwise` `Op`\s in a node.
As part of specialization, we fuse two consecutive elemwise `Op`s of the
As part of specialization, we fuse two consecutive `Elemwise` `Op`\s of the
same shape.
For mixed dtype, we let the `Composite` `Op` do the cast. It lets the C
......
......@@ -254,8 +254,9 @@ def searchsorted(x, v, side="left", sorter=None):
Notes
-----
* Binary search is used to find the required insertion points.
* This Op is working **only on CPU** currently.
* Binary search is used to find the required insertion points.
* This Op is working **only on CPU** currently.
Examples
--------
......@@ -778,7 +779,7 @@ def repeat(x, repeats, axis=None):
axis to repeat values. By default, use the flattened input
array, and return a flat output array.
The number of repetitions for each element is `repeat`.
The number of repetitions for each element is `repeats`.
`repeats` is broadcasted to fit the length of the given `axis`.
Parameters
......@@ -1305,9 +1306,10 @@ def unique(
Returns the sorted unique elements of an array. There are three optional
outputs in addition to the unique elements:
* the indices of the input array that give the unique values
* the indices of the unique array that reconstruct the input array
* the number of times each unique value comes up in the input array
* the indices of the input array that give the unique values
* the indices of the unique array that reconstruct the input array
* the number of times each unique value comes up in the input array
"""
return Unique(return_index, return_inverse, return_counts, axis)(ar)
......@@ -1473,7 +1475,7 @@ def broadcast_shape(*arrays, **kwargs):
Parameters
----------
*arrays: `TensorVariable`s
*arrays: TensorVariable
The tensor variables, or their shapes (as tuples),
for which the broadcast shape is computed.
arrays_are_shapes: bool (Optional)
......
......@@ -3278,6 +3278,9 @@ def parse_mul_tree(root):
Examples
--------
.. code-block:: python
x * y -> [False, [[False, x], [False, y]]]
-(x * y) -> [True, [[False, x], [False, y]]]
-x * y -> [False, [[True, x], [False, y]]]
......
......@@ -112,9 +112,9 @@ def indices_from_subtensor(
def as_index_constant(a):
"""Convert Python literals to Aesara constants--when possible--in Subtensor arguments.
r"""Convert Python literals to Aesara constants--when possible--in Subtensor arguments.
This will leave `Variable`s untouched.
This will leave `Variable`\s untouched.
"""
if a is None:
return a
......@@ -351,10 +351,10 @@ def is_basic_idx(idx):
def basic_shape(shape, indices):
"""Computes the shape resulting from basic NumPy indexing.
r"""Computes the shape resulting from basic NumPy indexing.
Basic indices are either `slice`s or `None`s.
`Ellipsis` are not supported here; convert them to `slice`s first.
Basic indices are either ``slice``\s or ``None``\s. ``Ellipsis`` are not
supported here; convert them to ``slice``\s first.
Parameters
----------
......
......@@ -31,9 +31,6 @@ some of them might be outdated though:
* :ref:`sandbox_elemwise` -- Description of element wise operations.
* :ref:`sandbox_maxgotcha` -- Describes the difference between ``numpy.max``
and Python max (something to consider when using max).
* :ref:`sandbox_randnb` -- Description of how Aesara deals with random
numbers.
......
......@@ -79,7 +79,6 @@ make sure there are no broader problems.
To run the test suite with the default options, see
:ref:`test_aesara`.
For more detail, see :ref:`metadocumentation_nightly_build`.
Setting up your Editor for PEP8
-------------------------------
......
......@@ -565,7 +565,7 @@ default, it will recompile the c code for each process.
Shape and Shape_i
=================
We have 2 generic `Op`s, `Shape` and `Shape_i`, that return the shape of any
We have 2 generic `Op`\s, `Shape` and `Shape_i`, that return the shape of any
Aesara `Variable` that has a shape attribute (`Shape_i` returns only one of
the elements of the shape).
......
......@@ -435,7 +435,7 @@ wrong but DebugMode will not detect this.
TODO: jpt: I don't understand the following sentence.
`Op`s and `Type`s should usually be considered immutable -- you should
`Op`\s and `Type`\s should usually be considered immutable -- you should
definitely not make a change that would have an impact on ``__eq__``,
``__hash__``, or the mathematical value that would be computed by ``perform``
or ``c_code``.
......@@ -969,7 +969,7 @@ In addition to these macros, the ``init_code_struct``, ``code``, and
happy.
* ``PARAMS`` : Name of the params variable for this node. (only
for `Op`s which have params, which is discussed elsewhere)
for `Op`\s which have params, which is discussed elsewhere)
Finally the tag ``code`` and ``code_cleanup`` have macros to
pass the inputs and output names. These are name ``INPUT_{i}`` and
......
......@@ -45,7 +45,6 @@ with Aesara itself.
ctype
cop
using_params
extending_aesara_gpu
optimization
tips
unittest
......
......@@ -5,11 +5,11 @@
Views and inplace operations
============================
Aesara allows the definition of ``Op``s which return a :term:`view` on one
Aesara allows the definition of ``Op``\s which return a :term:`view` on one
of their inputs or operate :term:`inplace` on one or several
inputs. This allows more efficient operations on NumPy's ``ndarray``
data type than would be possible otherwise.
However, in order to work correctly, these ``Op``s need to
However, in order to work correctly, these ``Op``\s need to
implement an additional interface.
Aesara recognizes views and inplace operations specially. It ensures
......@@ -206,7 +206,7 @@ input(s)'s memory). From there, go to the previous section.
Inplace optimization and DebugMode
==================================
It is recommended that during the graph construction, all ``Op``s are not inplace.
It is recommended that during the graph construction, all ``Op``\s are not inplace.
Then an optimization replaces them with inplace ones. Currently ``DebugMode`` checks
all optimizations that were tried even if they got rejected. One reason an inplace
optimization can get rejected is when there is another ``Op`` that is already being applied
......@@ -218,6 +218,6 @@ checking a rejected inplace optimization, since it will lead to wrong results.
In order to be able to use ``DebugMode`` in more situations, your inplace
optimization can pre-check whether it will get rejected by using the
``aesara.graph.destroyhandler.fast_inplace_check()`` function, that will tell
which ``Op``s can be performed inplace. You may then skip the optimization if it is
which ``Op``\s can be performed inplace. You may then skip the optimization if it is
incompatible with this check. Note however that this check does not cover all
cases where an optimization may be rejected (it will not detect cycles).
......@@ -49,9 +49,9 @@ define the following methods.
.. function:: make_node(*inputs)
This method is responsible for creating output Variables of a
suitable symbolic `Type` to serve as the outputs of this Op's
application. The Variables found in ``*inputs`` must be operated on
This method is responsible for creating output :class:`Variable`\s of a
suitable symbolic `Type` to serve as the outputs of this :Class:`Op`'s
application. The :class:`Variable`\s found in ``*inputs`` must be operated on
using Aesara's symbolic language to compute the symbolic output
Variables. This method should put these outputs into an Apply
instance, and return the Apply instance.
......
......@@ -91,11 +91,11 @@ A local optimization is an object which defines the following methods:
.. method:: transform(fgraph, node)
This method takes a :ref:`FunctionGraph` and an :ref:`Apply` node and
This method takes a :class:`FunctionGraph` and an :ref:`Apply` node and
returns either ``False`` to signify that no changes are to be done or a
list of `Variable`s which matches the length of the node's ``outputs``
list. When the `LocalOptimizer` is applied by a `Navigator`, the outputs
of the node passed as argument to the `LocalOptimizer` will be replaced by
list of :class:`Variable`\s which matches the length of the node's ``outputs``
list. When the :class:`LocalOptimizer` is applied by a :class:`NavigatorOptimizer`, the outputs
of the node passed as argument to the :class:`LocalOptimizer` will be replaced by
the list returned.
......@@ -423,8 +423,8 @@ optdb is a SequenceDB, so, at the top level, Aesara applies a sequence
of global optimizations to the computation graphs.
OptimizationQuery
-----
:class:`OptimizationQuery`
--------------------------
A OptimizationQuery is built by the following call:
......
......@@ -75,7 +75,7 @@ produce a ``thunk``, which is a function with no arguments that
returns nothing. Along with the thunk, one list of input containers (a
`aesara.link.basic.Container` is a sort of object that wraps another and does
type casting) and one list of output containers are produced,
corresponding to the input and output `Variable`s as well as the updates
corresponding to the input and output :class:`Variable`\s as well as the updates
defined for the inputs when applicable. To perform the computations,
the inputs must be placed in the input containers, the thunk must be
called, and the outputs must be retrieved from the output containers
......
......@@ -38,7 +38,7 @@ Use Aesara's high order Ops when applicable
Aesara provides some generic Op classes which allow you to generate a
lot of Ops at a lesser effort. For instance, Elemwise can be used to
make :term:`elementwise` operations easily whereas DimShuffle can be
make :term:`elemwise` operations easily whereas DimShuffle can be
used to make transpose-like transformations. These higher order Ops
are mostly Tensor-related, as this is Aesara's specialty.
......
......@@ -102,7 +102,7 @@ Example:
Creating an Op Unit Test
=======================
========================
A few tools have been developed to help automate the development of
unit tests for Aesara Ops.
......
......@@ -39,7 +39,7 @@ Glossary
See also: :class:`graph.basic.Constant`
Elemwise (i.e. element-wise)
Elemwise
An element-wise operation ``f`` on two tensor variables ``M`` and ``N``
is one such that:
......
......@@ -55,12 +55,11 @@ Roughly in order of what you'll want to check out:
* :ref:`extending` -- Learn to add a Type, Op, or graph optimization.
* :ref:`dev_start_guide` -- How to contribute code to Aesara.
* :ref:`internal` -- How to maintain Aesara and more...
* :ref:`release` -- How our release should work.
* :ref:`acknowledgement` -- What we took from other projects.
* `Related Projects`_ -- link to other projects that implement new functionalities on top of Aesara
.. _aesara_community:
.. _aesara-community:
Community
=========
......@@ -88,7 +87,6 @@ Community
links
internal/index
acknowledgement
LICENSE
.. _Theano: https://github.com/Theano/Theano
......
......@@ -40,8 +40,6 @@ support rapid development of efficient machine learning algorithms. Theano was
named after the `Greek mathematician`_, who may have been Pythagoras' wife.
Aesara is an alleged daughter of Pythagoras and Theano.
Aesara is released under a BSD license (:ref:`link <license>`).
Sneak peek
==========
......
......@@ -204,7 +204,7 @@ import ``aesara`` and print the config variable, as in:
collection allows Aesara to reuse buffers for intermediate results between
function calls. This speeds up Aesara by spending less time reallocating
space during function evaluation and can provide significant speed-ups for
functions with many fast ``Op``s, but it also increases Aesara's memory
functions with many fast :class:`Op`\s, but it also increases Aesara's memory
usage.
.. note:: If :attr:`config.gpuarray__preallocate` is the default value
......@@ -226,7 +226,7 @@ import ``aesara`` and print the config variable, as in:
Default: ``False``
Allow garbage collection inside of ``Scan`` ``Op``s.
Allow garbage collection inside of :class:`Scan` :class:`Op`\s.
If :attr:`config.allow_gc` is ``True``, but :attr:`config.scan__allow_gc` is
``False``, then Aesara will perform garbage collection during the inner
......@@ -272,7 +272,7 @@ import ``aesara`` and print the config variable, as in:
Default: ``False``
Enable or disable parallel computation on the CPU with OpenMP.
It is the default value used by ``Op``s that support OpenMP.
It is the default value used by :class:`Op`\s that support OpenMP.
It is best to specify this setting in ``.aesararc`` or in the environment
variable ``AESARA_FLAGS``.
......@@ -281,7 +281,7 @@ import ``aesara`` and print the config variable, as in:
Positive int value, default: 200000.
This specifies the minimum size of a vector for which OpenMP will be used by
``Elemwise`` ``Op``s, when OpenMP is enabled.
:class:`Elemwise` :class:`Op`\s, when OpenMP is enabled.
.. attribute:: cast_policy
......@@ -382,7 +382,7 @@ import ``aesara`` and print the config variable, as in:
Positive int value, default: 20.
The number of ``Op``s to print in the profiler output.
The number of :class:`Op`\s to print in the profiler output.
.. attribute:: config.profiling__min_memory_size
......@@ -664,7 +664,7 @@ import ``aesara`` and print the config variable, as in:
.. attribute:: config.conv__assert_shape
If ``True``, ``AbstractConv*`` ``Op``s will verify that user-provided shapes
If ``True``, ``AbstractConv*`` :class:`Op`\s will verify that user-provided shapes
match the run-time shapes. This is a debugging option, and may slow down
compilation.
......@@ -823,7 +823,7 @@ import ``aesara`` and print the config variable, as in:
.. attribute:: compile
This section contains attributes which influence the compilation of
C code for ``Op``s. Due to historical reasons many attributes outside
C code for :class:`Op`\s. Due to historical reasons many attributes outside
of this section also have an influence over compilation, most
notably ``cxx``.
......@@ -972,7 +972,7 @@ import ``aesara`` and print the config variable, as in:
If ``True``, will print a warning when compiling one or more ``Op`` with C
code that can't be cached because there is no ``c_code_cache_version()``
function associated to at least one of those ``Op``s.
function associated to at least one of those :class:`Op`\s.
.. attribute:: config.cmodule__remove_gxx_opt
......
.. _libdoc_graph_op:
================================================
==============================================================
:mod:`graph` -- Objects and functions for computational graphs
================================================
==============================================================
.. automodule:: aesara.graph.op
:platform: Unix, Windows
......
.. _libdoc_graph_params_type:
============================================================
:mod:`aesara.graph.params_type` -- Wrapper class for op params
============================================================
=======================================================================
:mod:`aesara.graph.params_type` -- Wrapper class for :class:`Op` params
=======================================================================
---------
Reference
......
......@@ -27,7 +27,6 @@ Types and Ops that you can use to build and compile expression graphs.
sparse/sandbox
tensor/index
typed_list
tests
There are also some top-level imports that you might find more convenient:
......
......@@ -682,4 +682,5 @@ reference
.. autofunction:: aesara.foldl
.. autofunction:: aesara.foldr
.. autofunction:: aesara.scan
:noindex:
.. autofunction:: aesara.scan.scan_checkpoints
.. ../../../../aesara/sparse/sandbox/sp.py
.. ../../../../aesara/sparse/sandbox/truedot.py
.. ../../../../aesara/sparse/basic/truedot.py
.. _libdoc_sparse_sandbox:
......@@ -19,5 +19,3 @@ API
:members:
.. automodule:: aesara.sparse.sandbox.sp2
:members:
.. automodule:: aesara.sparse.sandbox.truedot
:members:
......@@ -465,7 +465,7 @@ TensorVariable
you'll want to call.
.. autoclass:: var._tensor_py_operators
.. autoclass:: aesara.tensor.var._tensor_py_operators
:members:
This mix-in class adds convenient attributes, methods, and support
......@@ -478,16 +478,19 @@ TensorVariable
values that might be associated with this variable.
.. attribute:: ndim
:noindex:
The number of dimensions of this tensor. Aliased to
:attr:`TensorType.ndim`.
.. attribute:: dtype
:noindex:
The numeric type of this tensor. Aliased to
:attr:`TensorType.dtype`.
.. method:: reshape(shape, ndim=None)
:noindex:
Returns a view of this tensor that has been reshaped as in
numpy.reshape. If the shape is a Variable argument, then you might
......@@ -498,6 +501,7 @@ TensorVariable
See :func:`reshape`.
.. method:: dimshuffle(*pattern)
:noindex:
Returns a view of this tensor with permuted dimensions. Typically the
pattern will include the integers 0, 1, ... ndim-1, and any number of
......@@ -549,13 +553,19 @@ TensorVariable
.. method:: copy() Return a new symbolic variable that is a copy of the variable. Does not copy the tag.
.. method:: norm(L, axis=None)
.. method:: nonzero(self, return_matrix=False)
:noindex:
.. method:: nonzero_values(self)
:noindex:
.. method:: sort(self, axis=-1, kind='quicksort', order=None)
:noindex:
.. method:: argsort(self, axis=-1, kind='quicksort', order=None)
:noindex:
.. method:: clip(self, a_min, a_max) with a_min <= a_max
.. method:: conf()
.. method:: repeat(repeats, axis=None)
:noindex:
.. method:: round(mode="half_away_from_zero")
:noindex:
.. method:: trace()
.. method:: get_scalar_constant_value()
.. method:: zeros_like(model, dtype=None)
......@@ -577,6 +587,7 @@ dimensions, see :meth:`_tensor_py_operators.dimshuffle`.
Returns an lvector representing the shape of `x`.
.. function:: reshape(x, newshape, ndim=None)
:noindex:
:type x: any TensorVariable (or compatible)
:param x: variable to be reshaped
......@@ -810,6 +821,7 @@ Creating Tensor
(2, 2, 2, 3, 2)
.. function:: stack(*tensors)
:noindex:
.. warning::
......@@ -1175,7 +1187,7 @@ Bitwise
>>> ~a # aet.invert(a) bitwise invert (alias aet.bitwise_not)
Inplace
-------------
-------
In-place operators are *not* supported. Aesara's graph-optimizations
will determine which intermediate values to use for in-place
......@@ -1183,10 +1195,10 @@ computations. If you would like to update the value of a
:term:`shared variable`, consider using the ``updates`` argument to
:func:`Aesara.function`.
.. _libdoc_tensor_elementwise:
.. _libdoc_tensor_elemwise:
Elementwise
===========
:class:`Elemwise`
=================
Casting
-------
......@@ -1220,7 +1232,7 @@ Casting
Comparisons
------------
-----------
The six usual equality and inequality operators share the same interface.
:Parameter: *a* - symbolic Tensor (or compatible)
......@@ -1456,6 +1468,7 @@ Mathematical
Returns a variable representing the floor of a (for example floor(2.9) is 2).
.. function:: round(a, mode="half_away_from_zero")
:noindex:
Returns a variable representing the rounding of a in the same dtype as a. Implemented rounding mode are half_away_from_zero and half_to_even.
......
......@@ -25,7 +25,8 @@ They are grouped into the following sections:
elemwise
extra_ops
io
opt
basic_opt
slinalg
nlinalg
fft
math_opt
.. _libdoc_tensor_nnet_bn:
.. _libdoc_tensor_nnet_batchnorm:
================================
:mod:`bn` -- Batch Normalization
================================
=======================================
:mod:`batchnorm` -- Batch Normalization
=======================================
.. module:: tensor.nnet.bn
.. module:: tensor.nnet.batchnorm
:platform: Unix, Windows
:synopsis: Batch Normalization
.. moduleauthor:: LISA
.. autofunction:: aesara.tensor.nnet.bn.batch_normalization_train
.. autofunction:: aesara.tensor.nnet.bn.batch_normalization_test
.. autofunction:: aesara.tensor.nnet.batchnorm.batch_normalization_train
.. autofunction:: aesara.tensor.nnet.batchnorm.batch_normalization_test
.. seealso:: cuDNN batch normalization: :class:`aesara.gpuarray.dnn.dnn_batch_normalization_train`, :class:`aesara.gpuarray.dnn.dnn_batch_normalization_test>`.
.. autofunction:: aesara.tensor.nnet.bn.batch_normalization
.. autofunction:: aesara.tensor.nnet.batchnorm.batch_normalization
......@@ -17,8 +17,8 @@ and ops which are particular to neural networks and deep learning.
:maxdepth: 1
conv
nnet
basic
neighbours
bn
batchnorm
blocksparse
ctc
.. _libdoc_tensor_random:
.. _libdoc_tensor_random_basic:
=============================================
:mod:`random` -- Low-level random numbers
:mod:`basic` -- Low-level random numbers
=============================================
.. module:: aesara.tensor.random
......@@ -17,9 +17,9 @@ Reference
.. class:: RandomStream()
A helper class that tracks changes in a shared ``numpy.random.RandomState``
and behaves like ``numpy.random.RandomState`` by managing access
to `RandomVariable`s. For example:
A helper class that tracks changes in a shared :class:`numpy.random.RandomState`
and behaves like :class:`numpy.random.RandomState` by managing access
to :class:`RandomVariable`\s. For example:
.. testcode:: constructors
......
......@@ -7,11 +7,8 @@
Low-level random numbers
------------------------
.. module:: aesara.tensor.random
:synopsis: symbolic random variables
The `aesara.tensor.random` module provides random-number drawing functionality
that closely resembles the `numpy.random` module.
The :mod:`aesara.tensor.random` module provides random-number drawing functionality
that closely resembles the :mod:`numpy.random` module.
.. toctree::
:maxdepth: 2
......
......@@ -16,7 +16,7 @@
present in convolutional neural networks (where filters are 3D and pool
over several input channels).
.. module:: conv
.. module:: aesara.tensor.signal.conv
:platform: Unix, Windows
:synopsis: ops for performing convolutions
.. moduleauthor:: LISA
......
.. _libdoc_tests:
=====================
:mod:`tests` -- Tests
=====================
.. automodule:: tests.breakpoint
:members:
......@@ -33,9 +33,7 @@ you compute the gradient, **WRITEME**.
Gradients for a particular variable can be one of four kinds:
1) forgot to implement it
You will get an exception of the following form.
.. code-block:: python
You will get an exception of the following form::
aesara.graph.utils.MethodNotDefined: ('grad', <class 'pylearn.algorithms.sandbox.cost.LogFactorial'>, 'LogFactorial')
......
......@@ -30,8 +30,8 @@ the logistic curve, which is given by:
A plot of the logistic function, with x on the x-axis and s(x) on the
y-axis.
You want to compute the function :ref:`elementwise
<libdoc_tensor_elementwise>` on matrices of doubles, which means that
You want to compute the function :ref:`element-wise
<libdoc_tensor_elemwise>` on matrices of doubles, which means that
you want to apply this function to each individual element of the
matrix.
......@@ -75,7 +75,7 @@ Computing More than one Thing at the Same Time
==============================================
Aesara supports functions with multiple outputs. For example, we can
compute the :ref:`elementwise <libdoc_tensor_elementwise>` difference, absolute difference, and
compute the :ref:`element-wise <libdoc_tensor_elemwise>` difference, absolute difference, and
squared difference between two matrices *a* and *b* at the same time:
.. If you modify this code, also change :
......@@ -373,7 +373,7 @@ Here's a brief example. The setup code is:
Here, 'rv_u' represents a random stream of 2x2 matrices of draws from a uniform
distribution. Likewise, 'rv_n' represents a random stream of 2x2 matrices of
draws from a normal distribution. The distributions that are implemented are
defined as :class:`RandomVariable`s
defined as :class:`RandomVariable`\s
in :ref:`basic<libdoc_tensor_random_basic>`. They only work on CPU.
See `Other Implementations`_ for GPU version.
......
......@@ -1065,7 +1065,7 @@ class TestFusion:
self.do(self.mode, self._shared, shp)
def test_fusion_35_inputs(self):
"""Make sure we don't fuse too many `Op`s and go past the 31 function arguments limit."""
r"""Make sure we don't fuse too many `Op`\s and go past the 31 function arguments limit."""
inpts = vectors(["i%i" % i for i in range(35)])
# Make an elemwise graph looking like:
......@@ -1228,7 +1228,7 @@ class TestFusion:
@pytest.mark.skipif(not config.cxx, reason="No cxx compiler")
def test_no_c_code(self):
"""Make sure we avoid fusions for `Op`s without C code implementations."""
r"""Make sure we avoid fusions for `Op`\s without C code implementations."""
# This custom `Op` has no `c_code` method
class NoCCodeOp(aes.basic.UnaryScalarOp):
......
......@@ -68,7 +68,7 @@ def test_filter_float_subclass():
def test_filter_memmap():
"""Make sure `TensorType.filter` can handle NumPy `memmap`s subclasses."""
r"""Make sure `TensorType.filter` can handle NumPy `memmap`\s subclasses."""
data = np.arange(12, dtype=config.floatX)
data.resize((3, 4))
filename = path.join(mkdtemp(), "newfile.dat")
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论