提交 f74350f4 authored 作者: James Bergstra's avatar James Bergstra

Added rst docs for tensor.cast(), clip(), real(), imag(), and angle()

上级 5f41cd2f
...@@ -659,6 +659,34 @@ Elementwise ...@@ -659,6 +659,34 @@ Elementwise
Casting Casting
------- -------
.. function:: cast(x, dtype)
Cast any tensor `x` to a Tensor of the same shape, but with a different
numerical type `dtype`.
This is not a reinterpret cast, but a coersion cast, similar to
``numpy.asarray(x, dtype=dtype)``.
.. code-block:: python
import theano.tensor as T
x_as_float = T.matrix()
x_as_int = T.cast(x, 'int32')
Attempting to casting a complex value to a real value is ambiguous and
will raise an exception. Use `real()`, `imag()`, `abs()`, or `angle()`.
.. function:: real(x)
Return the real (not imaginary) components of Tensor x.
For non-complex `x` this function returns x.
.. function:: imag(x)
Return the imaginary components of Tensor x.
For non-complex `x` this function returns zeros_like(x).
Comparisons Comparisons
------------ ------------
...@@ -733,6 +761,13 @@ Condition ...@@ -733,6 +761,13 @@ Condition
x,y = T.dmatrices('x','y') x,y = T.dmatrices('x','y')
z = T.switch(T.lt(a,b), x, y) z = T.switch(T.lt(a,b), x, y)
.. function:: clip(x, min, max)
Return a variable representing x, but with all elements greater than
`max` clipped to `max` and all elements less than `min` clipped to `min.
Normal broadcasting rules apply to each of `x`, `min`, and `max`.
Bit-wise Bit-wise
-------- --------
...@@ -783,6 +818,10 @@ Mathematical ...@@ -783,6 +818,10 @@ Mathematical
.. note:: Can also be accessed with ``abs(a)``. .. note:: Can also be accessed with ``abs(a)``.
.. function:: angle(a)
Returns a variable representing angular component of complex-valued Tensor `a`.
.. function:: exp(a) .. function:: exp(a)
Returns a variable representing the exponential of a, ie e^a. Returns a variable representing the exponential of a, ie e^a.
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论