提交 b73195a3 authored 作者: Iban Harlouchet's avatar Iban Harlouchet

Fixed all Returns

上级 d25dac2b
......@@ -2261,7 +2261,7 @@ class Nonzero(gof.Op):
Returns
-------
result : matrix
matrix
Matrix containing the indices of the non-zero elements of a.
See Also
......@@ -2323,7 +2323,7 @@ def nonzero(a, return_matrix=False):
Returns
-------
result : tuple of vectors or matrix
tuple of vectors or matrix
See Also
--------
......@@ -2356,7 +2356,7 @@ def flatnonzero(a):
Returns
-------
res : vector
vector
Output vector, containing the indices of the elements of `a.flatten()`
that are non-zero.
......@@ -2396,7 +2396,7 @@ def nonzero_values(a):
Returns
-------
res : vector
vector
Output vector, containing the non-zero elements of a.
See Also
......@@ -2460,7 +2460,7 @@ def tri(N, M=None, k=0, dtype=None):
Returns
-------
tri : Array of shape (N, M)
Array of shape (N, M)
Array with its lower triangle filled with ones and zero elsewhere;
in other words ``T[i,j] == 1`` for ``i <= j + k``, 0 otherwise.
......@@ -2489,7 +2489,7 @@ def tril(m, k=0):
Returns
-------
tril : array, shape (M, N)
array, shape (M, N)
Lower triangle of `m`, of same shape and data-type as `m`.
See Also
......@@ -2569,7 +2569,7 @@ def eye(n, m=None, k=0, dtype=None):
Returns
-------
I : ndarray of shape (N,M)
ndarray of shape (N,M)
An array where all elements are equal to zero, except for the `k`-th
diagonal, whose values are equal to one.
......@@ -3904,7 +3904,7 @@ def roll(x, shift, axis=None):
Returns
-------
res : tensor
tensor
Output tensor, with the same shape as `x`.
"""
......@@ -5520,6 +5520,7 @@ class Diagonal(Op):
Returns
-------
vector
A vector representing the diagonal elements.
"""
......@@ -5655,6 +5656,7 @@ def ptp(a, axis=None):
Returns
-------
array
A new array holding the result.
"""
......
......@@ -1449,7 +1449,10 @@ def _factor_canonicalized(lst):
def _gemm_from_factored_list(lst):
"""Returns None, or a list to replace node.outputs."""
"""
Returns None, or a list to replace node.outputs.
"""
lst2 = []
# Remove the tuple that can't be cast correctly.
# This can happen when we try to cast a complex to a real
......
......@@ -5,8 +5,8 @@ import theano
def make_declare(loop_orders, dtypes, sub):
"""
Produce code to declare all necessary variables.
"""
"""
decl = ""
for i, (loop_order, dtype) in enumerate(zip(loop_orders, dtypes)):
var = sub['lv%i' % i] # input name corresponding to ith loop variable
......@@ -342,6 +342,7 @@ def make_reordered_loop(init_loop_orders, olv_index, dtypes, inner_task, sub,
Returns a list containing a C expression representing the
stride for each dimension of the ith variable, in the
specified loop_order.
"""
var = sub["lv%i" % i]
r = []
......
......@@ -539,8 +539,8 @@ def bincount(x, weights=None, minlength=None, assert_nonneg=False):
def squeeze(x):
"""Remove broadcastable dimensions from
the shape of an array.
"""
Remove broadcastable dimensions from the shape of an array.
It returns the input array, but with the
broadcastable dimensions removed. This is
......@@ -565,26 +565,27 @@ def squeeze(x):
def compress(condition, x, axis=None):
"""Return selected slices of an array along given axis.
"""
Return selected slices of an array along given axis.
It returns the input tensor, but with selected slices along a given axis
retained. If no axis is provided, the tensor is flattened.
Corresponds to numpy.compress
.. versionadded:: 0.7
Parameters
----------
x
Input data, tensor variable.
condition
1 dimensional array of non-zero and zero values
corresponding to indices of slices along a selected axis.
Returns
-------
`x` with selected slices
.. versionadded:: 0.7
object
`x` with selected slices.
"""
indices = theano.tensor.basic.flatnonzero(condition)
......@@ -802,12 +803,15 @@ bartlett_ = Bartlett()
# I create a function only to have the doc show well.
def bartlett(M):
"""An instance of this class returns the Bartlett spectral window in the
"""
An instance of this class returns the Bartlett spectral window in the
time-domain. The Bartlett window is very similar to a triangular window,
except that the end points are at zero. It is often used in signal
processing for tapering a signal, without generating too much ripple in
the frequency domain.
.. versionadded:: 0.6
Parameters
----------
M : integer scalar
......@@ -821,8 +825,6 @@ def bartlett(M):
(the value one appears only if the number of samples is odd), with
the first and last samples equal to zero.
.. versionadded:: 0.6
"""
return bartlett_(M)
......@@ -889,20 +891,24 @@ fill_diagonal_ = FillDiagonal()
# I create a function only to have the doc show well.
def fill_diagonal(a, val):
""" Returns a copy of an array with all
"""
Returns a copy of an array with all
elements of the main diagonal set to a specified scalar value.
.. versionadded:: 0.6
Parameters
----------
a :
a
Rectangular array of at least two dimensions.
val :
val
Scalar value to fill the diagonal whose type must be
compatible with that of array 'a' (i.e. 'val' cannot be viewed
as an upcast of 'a').
Returns
-------
array
An array identical to 'a' except that its main diagonal
is filled with scalar 'val'. (For an array 'a' with a.ndim >=
2, the main diagonal is the list of locations a[i, i, ..., i]
......@@ -911,7 +917,7 @@ def fill_diagonal(a, val):
Support rectangular matrix and tensor with more than 2 dimensions
if the later have all dimensions are equals.
.. versionadded:: 0.6
"""
return fill_diagonal_(a, val)
......@@ -1043,6 +1049,7 @@ def fill_diagonal_offset(a, val, offset):
Returns
-------
array
An array identical to 'a' except that its offset diagonal
is filled with scalar 'val'. The output is unwrapped.
......@@ -1051,7 +1058,8 @@ def fill_diagonal_offset(a, val, offset):
def to_one_hot(y, nb_class, dtype=None):
"""Return a matrix where each row correspond to the one hot
"""
Return a matrix where each row correspond to the one hot
encoding of each element in y.
Parameters
......@@ -1069,7 +1077,7 @@ def to_one_hot(y, nb_class, dtype=None):
A matrix of shape (y.shape[0], nb_class), where each row ``i`` is
the one hot encoding of the corresponding ``y[i]`` value.
"""
"""
ret = theano.tensor.zeros((y.shape[0], nb_class),
dtype=dtype)
ret = theano.tensor.set_subtensor(ret[theano.tensor.arange(y.shape[0]), y],
......
......@@ -255,14 +255,18 @@ def trace(X):
"""
Returns the sum of diagonal elements of matrix X.
:note: work on GPU since 0.6rc4.
Notes
-----
Works on GPU since 0.6rc4.
"""
return extract_diag(X).sum()
class Det(Op):
"""Matrix determinant
Input should be a square matrix
"""
Matrix determinant. Input should be a square matrix.
"""
__props__ = ()
......@@ -598,6 +602,7 @@ def qr(a, mode="full"):
class SVD(Op):
"""
Parameters
----------
full_matrices : bool, optional
......@@ -609,7 +614,7 @@ class SVD(Op):
Whether or not to compute u and v in addition to s.
True by default.
"""
"""
# See doc in the docstring of the function just after this class.
_numop = staticmethod(numpy.linalg.svd)
......
......@@ -356,7 +356,8 @@ class ConvOp(OpenMPOp):
Returns
-------
(rows,cols) of output image.
object
(rows,cols) of output image.
"""
# The formula would be ceil((i + s * k - s * 1) / float(d)),
......
......@@ -13,27 +13,29 @@ from theano.gradient import grad_undefined
class Images2Neibs(Op):
"""
__props__ = ("mode",)
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
def __init__(self, mode='valid'):
"""
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.
Returns
-------
Reshapes the input as a 2D tensor where each row is an
pooling example.
"""
"""
__props__ = ("mode",)
def __init__(self, mode='valid'):
if mode not in ['valid', 'wrap_centered', 'ignore_borders']:
raise NotImplementedError("Only the mode valid, ignore_borders"
" and wrap_centered have been"
......@@ -456,16 +458,17 @@ def images2neibs(ten4, neib_shape, neib_step=None, mode='valid'):
: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
pooling factor (in each direction).
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).
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
?? TODO comment
Returns
-------
object
Reshapes the input as a 2D tensor where each row is an
pooling example. Pseudo-code of the output:
......@@ -531,6 +534,7 @@ def neibs2images(neibs, neib_shape, original_shape, mode='valid'):
Returns
-------
object
Reconstructs the input of
:func:`images2neibs <theano.sandbox.neigbours.neibs2images>`,
a 4d tensor of shape `original_shape`.
......
......@@ -805,7 +805,7 @@ class CrossentropySoftmaxArgmax1HotWithBias(gof.Op):
"""
A special compound L{Op} for the output of neural-net classifiers.
Attributes
Parameters
----------
x : a matrix of floats (32 or 64)
b : a [row] vector of floats (32 or 64), length is number of cols in x
......@@ -813,6 +813,7 @@ class CrossentropySoftmaxArgmax1HotWithBias(gof.Op):
Returns
-------
object
row-wise NLL, softmax(x+b), row-wise argmax of (x+b).
@precondition: every entry in y_idx is a valid (non-negative)
......@@ -1240,6 +1241,7 @@ def crossentropy_softmax_max_and_argmax_1hot_with_bias(x, b, y_idx, **kwargs):
"""
Returns
-------
object
The cross-entropy, the softmax output, the max probability,
and the argmax index.
......@@ -1931,7 +1933,7 @@ def categorical_crossentropy(coding_dist, true_dist):
----------
coding_dist : a dense matrix
Each slice along axis represents one distribution.
true_dist: a dense matrix or sparse matrix or integer vector
true_dist : a dense matrix or sparse matrix or integer vector
In the case of a matrix argument, each slice along axis represents one
distribution. In the case of an integer vector argument, each element
represents the position of the '1' in a 1-of-N encoding.
......@@ -2091,7 +2093,7 @@ def relu(x, alpha=0):
----------
x : symbolic tensor
Tensor to compute the activation function for.
alpha: scalar or tensor, optional
alpha : scalar or tensor, optional
Slope for negative input, usually between 0 and 1. The default value
of 0 will lead to the standard rectifier, 1 will lead to
a linear activation function, and any value in between will give a
......
......@@ -383,6 +383,7 @@ logsigm_to_softplus = gof.PatternSub(
def _is_1(expr):
"""
Returns
-------
bool
......@@ -417,8 +418,10 @@ opt.register_stabilize(log1pexp_to_softplus, name='log1pexp_to_softplus')
def is_1pexp(t):
"""
Returns
-------
object
If 't' is of the form (1+exp(x)), return (False, x).
Else return None.
......@@ -471,6 +474,7 @@ def is_exp(var):
Returns
-------
tuple
A pair (b, x) with `b` a boolean set to True if `var` is of the
form `-exp(x)` and False if `var` is of the form `exp(x)`. If `var`
cannot be cast into either form, then return `None`.
......@@ -496,6 +500,7 @@ def is_mul(var):
Returns
-------
object
A list [x, y, z, ...] if `var` is of the form `x * y * z * ...`,
or None if `var` cannot be cast into this form.
......@@ -538,6 +543,7 @@ def is_neg(var):
Returns
-------
object
`x` if `var` is of the form `-x`, or None otherwise.
"""
......@@ -627,6 +633,7 @@ def parse_mul_tree(root):
Returns
-------
object
A tree where each non-leaf node corresponds to a multiplication
in the computation of `root`, represented by the list of its inputs.
Each input is a pair [n, x] with `n` a boolean value indicating whether
......@@ -688,6 +695,7 @@ def replace_leaf(arg, leaves, new_leaves, op, neg):
Returns
-------
bool
True if a replacement occurred, or False otherwise.
"""
......@@ -712,6 +720,7 @@ def simplify_mul(tree):
Returns
-------
object
A multiplication tree computing the same output as `tree` but without
useless multiplications by 1 nor -1 (identified by leaves of the form
[False, None] or [True, None] respectively). Useless multiplications
......@@ -757,6 +766,7 @@ def compute_mul(tree):
Returns
-------
object
A Variable that computes the multiplication represented by the tree.
"""
......
......@@ -156,6 +156,7 @@ def _fill_chain(new_out, orig_inputs):
def encompasses_broadcastable(b1, b2):
"""
Parameters
----------
b1
......@@ -165,8 +166,9 @@ def encompasses_broadcastable(b1, b2):
Returns
-------
True if the broadcastable patterns b1 and b2 are such that b2 is
broadcasted to b1's shape and not the opposite.
bool
True if the broadcastable patterns b1 and b2 are such that b2 is
broadcasted to b1's shape and not the opposite.
"""
if len(b1) < len(b2):
......@@ -1693,10 +1695,10 @@ class Assert(T.Op):
Examples
--------
T = theano.tensor
x = T.vector('x')
assert_op = T.opt.Assert()
func = theano.function([x], assert_op(x, x.size<2))
T = theano.tensor
x = T.vector('x')
assert_op = T.opt.Assert()
func = theano.function([x], assert_op(x, x.size<2))
"""
......@@ -3819,8 +3821,10 @@ class Canonizer(gof.LocalOptimizer):
@staticmethod
def get_constant(v):
"""
Returns
-------
object
A numeric constant if v is a Constant or, well, a
numeric constant. If v is a plain Variable, returns None.
......@@ -5189,6 +5193,7 @@ def constant_folding(node):
def _is_1(expr):
"""
Returns
-------
bool
......@@ -5204,6 +5209,7 @@ def _is_1(expr):
def _is_minus1(expr):
"""
Returns
-------
bool
......@@ -5218,13 +5224,19 @@ def _is_minus1(expr):
def get_clients(node):
"""Used by erf/erfc opt to track less frequent op."""
"""
Used by erf/erfc opt to track less frequent op.
"""
return [c for c, i in node.outputs[0].clients
if c != "output"]
def get_clients2(node):
"""Used by erf/erfc opt to track less frequent op."""
"""
Used by erf/erfc opt to track less frequent op.
"""
l = []
for c, i in node.outputs[0].clients:
if c != "output":
......
......@@ -843,6 +843,7 @@ def multinomial(random_state, size=None, n=1, pvals=[0.5, 0.5],
Returns
-------
tensor
Tensor of len(size)+1 dimensions, and shape[-1]==L, with
the specified ``dtype``, with the experiment counts. See
examples to understand the shape of the return value, which is
......
......@@ -21,7 +21,10 @@ class RandomStateSharedVariable(SharedVariable):
@shared_constructor
def randomstate_constructor(value, name=None, strict=False,
allow_downcast=None, borrow=False):
"""SharedVariable Constructor for RandomState"""
"""
SharedVariable Constructor for RandomState.
"""
if not isinstance(value, numpy.random.RandomState):
raise TypeError
if not borrow:
......
......@@ -103,6 +103,7 @@ class SortOp(theano.Op):
def sort(a, axis=-1, kind='quicksort', order=None):
"""
Parameters
----------
a : Tensor
......@@ -119,7 +120,8 @@ def sort(a, axis=-1, kind='quicksort', order=None):
Returns
-------
A sorted copy of an array.
array
A sorted copy of an array.
"""
if axis is None:
......
......@@ -309,8 +309,9 @@ class Subtensor(Op):
Returns
-------
idxs, with the slices flattened out into a list.
If cond is true for an entry, does not flatten it.
list
idxs, with the slices flattened out into a list.
If cond is true for an entry, does not flatten it.
"""
ret = []
......@@ -1484,7 +1485,8 @@ class IncSubtensor(Op):
Returns
-------
C code expression to make a copy of x.
object
C code expression to make a copy of x.
Base class uses PyArrayObject *, subclasses may override for
different types of arrays.
......@@ -1547,8 +1549,8 @@ class IncSubtensor(Op):
Returns
-------
Returns a C code expression to copy source into view, and
return 0 on success.
object
C code expression to copy source into view, and 0 on success.
"""
return """PyArray_CopyInto(%(view)s, %(source)s)""" % locals()
......@@ -1911,12 +1913,13 @@ class AdvancedIncSubtensor1(Op):
"""
Parameters
----------
x: string
x : string
Gives the name of a C variable pointing to an array.
Returns
-------
C code expression to make a copy of x.
object
C code expression to make a copy of x.
Base class uses PyArrayObject *, subclasses may override for
different types of arrays.
......
......@@ -657,7 +657,8 @@ class TensorType(Type):
Returns
-------
Python object that ``self.get_size()`` understands.
object
Python object that ``self.get_size()`` understands.
"""
return obj.shape
......@@ -673,6 +674,7 @@ class TensorType(Type):
Returns
-------
int
The number of bytes taken by the object described by ``shape_info``.
"""
......
......@@ -255,9 +255,11 @@ class _tensor_py_operators:
def transpose(self, *axes):
"""
Returns
-------
`tensor.transpose(self, axes)` or `tensor.transpose(self, axes[0])`.
object
`tensor.transpose(self, axes)` or `tensor.transpose(self, axes[0])`.
If only one `axes` argument is provided and it is iterable, then it is
assumed to be the entire axes tuple, and passed intact to
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论