提交 8e6888c5 authored 作者: Frederic's avatar Frederic

small doc update

上级 1ea4c65e
...@@ -657,9 +657,9 @@ dimensions, see :meth:`_tensor_py_operators.dimshuffle`. ...@@ -657,9 +657,9 @@ dimensions, see :meth:`_tensor_py_operators.dimshuffle`.
This function can create a tensor from a shaped list of scalars This function can create a tensor from a shaped list of scalars
>>> from theano.tensor import stacklists, scalar, matrix >>> from theano.tensor import stacklists, scalars, matrices
>>> from theano import function >>> from theano import function
>>> a,b,c,d = map(scalar, 'abcd') >>> a,b,c,d = scalars('abcd')
>>> X = stacklists([[a, b], [c, d]]) >>> X = stacklists([[a, b], [c, d]])
>>> f = function([a, b, c, d], X) >>> f = function([a, b, c, d], X)
>>> f(1, 2, 3, 4) >>> f(1, 2, 3, 4)
...@@ -669,7 +669,7 @@ dimensions, see :meth:`_tensor_py_operators.dimshuffle`. ...@@ -669,7 +669,7 @@ dimensions, see :meth:`_tensor_py_operators.dimshuffle`.
a 2 by 2 grid. a 2 by 2 grid.
>>> from numpy import ones >>> from numpy import ones
>>> a,b,c,d, = [tensor.matrix(a) for a in 'abcd'] >>> a,b,c,d, = matrices('abcd')
>>> X = stacklists([[a, b], [c, d]]) >>> X = stacklists([[a, b], [c, d]])
>>> f = function([a, b, c, d], X) >>> f = function([a, b, c, d], X)
>>> x = ones((4, 4), 'float32') >>> x = ones((4, 4), 'float32')
......
...@@ -8234,13 +8234,15 @@ def diag(v, k=0): ...@@ -8234,13 +8234,15 @@ def diag(v, k=0):
else: else:
raise ValueError("Input must be 1- or 2-d.") raise ValueError("Input must be 1- or 2-d.")
def stacklists(arg): def stacklists(arg):
""" Recursivly stack lists of tensors to maintain similar structure """ Recursivly stack lists of tensors to maintain similar structure
This function can create a tensor from a shaped list of scalars This function can create a tensor from a shaped list of scalars
>>> from theano.tensor import stacklists, scalar, matrix
>>> from theano.tensor import stacklists, scalars, matrices
>>> from theano import function >>> from theano import function
>>> a,b,c,d = map(scalar, 'abcd') >>> a,b,c,d = scalars('abcd')
>>> X = stacklists([[a, b], [c, d]]) >>> X = stacklists([[a, b], [c, d]])
>>> f = function([a, b, c, d], X) >>> f = function([a, b, c, d], X)
>>> f(1, 2, 3, 4) >>> f(1, 2, 3, 4)
...@@ -8249,8 +8251,9 @@ def stacklists(arg): ...@@ -8249,8 +8251,9 @@ def stacklists(arg):
We can also stack arbitrarily shaped tensors. Here we stack matrices into We can also stack arbitrarily shaped tensors. Here we stack matrices into
a 2 by 2 grid. a 2 by 2 grid.
>>> from numpy import ones >>> from numpy import ones
>>> a,b,c,d, = [tensor.matrix(a) for a in 'abcd'] >>> a,b,c,d, = matrices('abcd')
>>> X = stacklists([[a, b], [c, d]]) >>> X = stacklists([[a, b], [c, d]])
>>> f = function([a, b, c, d], X) >>> f = function([a, b, c, d], X)
>>> x = ones((4, 4), 'float32') >>> x = ones((4, 4), 'float32')
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论