Documentation: tensor logical elementwise rework.

上级 328e24e5
...@@ -290,6 +290,23 @@ Comparisons ...@@ -290,6 +290,23 @@ Comparisons
Theano has no boolean dtype. Instead, all boolean tensors are represented Theano has no boolean dtype. Instead, all boolean tensors are represented
in ``'int8'``. in ``'int8'``.
.. note::
The six usual equality and inequality operators share the same interface.
:Parameter: *a* - symbolic Tensor (or compatible)
:Parameter: *b* - symbolic Tensor (or compatible)
:Return type: symbolic Tensor
:Returns: a symbolic tensor representing the application of the logical
elementwise operator.
Here is an example with the less-than operator.
.. code-block:: python
import theano.tensor as T
x,y = T.dmatrices('x','y')
z = T.le(x,y)
.. function:: lt(a, b) .. function:: lt(a, b)
Returns a symbolic ``'int8'`` tensor representing the result of logical less-than (a<b). Returns a symbolic ``'int8'`` tensor representing the result of logical less-than (a<b).
...@@ -304,65 +321,38 @@ Comparisons ...@@ -304,65 +321,38 @@ Comparisons
.. function:: le(a, b) .. function:: le(a, b)
Returns a variable representing the result of logical less than or Returns a variable representing the result of logical less than or equal (a<=b).
equal (a<=b).
:Parameter: *a* - symbolic Tensor (or compatible)
:Parameter: *b* - symbolic Tensor (or compatible)
:Return type: symbolic Tensor
:Returns: a symbolic tensor representing the application of logical
elementwise less than or equal.
.. code-block:: python
import theano.tensor as T Also available using syntax ``a <= b``
x,y = T.dmatrices('x','y')
z = T.le(x,y)
.. function:: ge(a, b) .. function:: ge(a, b)
Returns a variable representing the result of logical greater or equal than (a>=b). Returns a variable representing the result of logical greater or equal than (a>=b).
:Parameter: *a* - symbolic Tensor (or compatible)
:Parameter: *b* - symbolic Tensor (or compatible)
:Return type: symbolic Tensor
:Returns: a symbolic tensor representing the application of logical
elementwise greater than or equal.
.. code-block:: python
import theano.tensor as T Also available using syntax ``a >= b``
x,y = T.dmatrices('x','y')
z = T.ge(x,y)
.. function:: eq(a, b) .. function:: eq(a, b)
Returns a variable representing the result of logical equality (a==b). Returns a variable representing the result of logical equality (a==b).
:Parameter: *a* - symbolic Tensor (or compatible)
:Parameter: *b* - symbolic Tensor (or compatible)
:Return type: symbolic Tensor
:Returns: a symbolic tensor representing the application of logical
elementwise equality.
.. code-block:: python
import theano.tensor as T
x,y = T.dmatrices('x','y')
z = T.eq(x,y)
.. function:: neq(a, b) .. function:: neq(a, b)
Returns a variable representing the result of logical inequality Returns a variable representing the result of logical inequality (a!=b).
(a!=b).
:Parameter: *a* - symbolic Tensor (or compatible) .. function:: switch(cond, ift, iff)
:Parameter: *b* - symbolic Tensor (or compatible) Returns a variable representing a switch between ift (iftrue) and iff (iffalse)
based on the condition cond.
:Parameter: *cond* - symbolic Tensor (or compatible)
:Parameter: *ift* - symbolic Tensor (or compatible)
:Parameter: *iff* - symbolic Tensor (or compatible)
:Return type: symbolic Tensor :Return type: symbolic Tensor
:Returns: a symbolic tensor representing the application of logical
elementwise inequality.
.. code-block:: python .. code-block:: python
import theano.tensor as T
a,b = T.dmatrices('a','b')
x,y = T.dmatrices('x','y')
z = T.switch(T.lt(a,b), x, y)
import theano.tensor as T
x,y = T.dmatrices('x','y')
z = T.neq(x,y)
Mathematical Mathematical
------------ ------------
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论