Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
b73195a3
提交
b73195a3
authored
8月 11, 2015
作者:
Iban Harlouchet
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fixed all Returns
上级
d25dac2b
隐藏空白字符变更
内嵌
并排
正在显示
16 个修改的文件
包含
136 行增加
和
75 行删除
+136
-75
basic.py
theano/tensor/basic.py
+10
-8
blas.py
theano/tensor/blas.py
+4
-1
elemwise_cgen.py
theano/tensor/elemwise_cgen.py
+2
-1
extra_ops.py
theano/tensor/extra_ops.py
+24
-16
nlinalg.py
theano/tensor/nlinalg.py
+9
-4
conv.py
theano/tensor/nnet/conv.py
+2
-1
neighbours.py
theano/tensor/nnet/neighbours.py
+26
-22
nnet.py
theano/tensor/nnet/nnet.py
+5
-3
sigm.py
theano/tensor/nnet/sigm.py
+10
-0
opt.py
theano/tensor/opt.py
+20
-8
raw_random.py
theano/tensor/raw_random.py
+1
-0
shared_randomstreams.py
theano/tensor/shared_randomstreams.py
+4
-1
sort.py
theano/tensor/sort.py
+3
-1
subtensor.py
theano/tensor/subtensor.py
+10
-7
type.py
theano/tensor/type.py
+3
-1
var.py
theano/tensor/var.py
+3
-1
没有找到文件。
theano/tensor/basic.py
浏览文件 @
b73195a3
...
@@ -2261,7 +2261,7 @@ class Nonzero(gof.Op):
...
@@ -2261,7 +2261,7 @@ class Nonzero(gof.Op):
Returns
Returns
-------
-------
result :
matrix
matrix
Matrix containing the indices of the non-zero elements of a.
Matrix containing the indices of the non-zero elements of a.
See Also
See Also
...
@@ -2323,7 +2323,7 @@ def nonzero(a, return_matrix=False):
...
@@ -2323,7 +2323,7 @@ def nonzero(a, return_matrix=False):
Returns
Returns
-------
-------
result :
tuple of vectors or matrix
tuple of vectors or matrix
See Also
See Also
--------
--------
...
@@ -2356,7 +2356,7 @@ def flatnonzero(a):
...
@@ -2356,7 +2356,7 @@ def flatnonzero(a):
Returns
Returns
-------
-------
res :
vector
vector
Output vector, containing the indices of the elements of `a.flatten()`
Output vector, containing the indices of the elements of `a.flatten()`
that are non-zero.
that are non-zero.
...
@@ -2396,7 +2396,7 @@ def nonzero_values(a):
...
@@ -2396,7 +2396,7 @@ def nonzero_values(a):
Returns
Returns
-------
-------
res :
vector
vector
Output vector, containing the non-zero elements of a.
Output vector, containing the non-zero elements of a.
See Also
See Also
...
@@ -2460,7 +2460,7 @@ def tri(N, M=None, k=0, dtype=None):
...
@@ -2460,7 +2460,7 @@ def tri(N, M=None, k=0, dtype=None):
Returns
Returns
-------
-------
tri :
Array of shape (N, M)
Array of shape (N, M)
Array with its lower triangle filled with ones and zero elsewhere;
Array with its lower triangle filled with ones and zero elsewhere;
in other words ``T[i,j] == 1`` for ``i <= j + k``, 0 otherwise.
in other words ``T[i,j] == 1`` for ``i <= j + k``, 0 otherwise.
...
@@ -2489,7 +2489,7 @@ def tril(m, k=0):
...
@@ -2489,7 +2489,7 @@ def tril(m, k=0):
Returns
Returns
-------
-------
tril :
array, shape (M, N)
array, shape (M, N)
Lower triangle of `m`, of same shape and data-type as `m`.
Lower triangle of `m`, of same shape and data-type as `m`.
See Also
See Also
...
@@ -2569,7 +2569,7 @@ def eye(n, m=None, k=0, dtype=None):
...
@@ -2569,7 +2569,7 @@ def eye(n, m=None, k=0, dtype=None):
Returns
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
An array where all elements are equal to zero, except for the `k`-th
diagonal, whose values are equal to one.
diagonal, whose values are equal to one.
...
@@ -3904,7 +3904,7 @@ def roll(x, shift, axis=None):
...
@@ -3904,7 +3904,7 @@ def roll(x, shift, axis=None):
Returns
Returns
-------
-------
res :
tensor
tensor
Output tensor, with the same shape as `x`.
Output tensor, with the same shape as `x`.
"""
"""
...
@@ -5520,6 +5520,7 @@ class Diagonal(Op):
...
@@ -5520,6 +5520,7 @@ class Diagonal(Op):
Returns
Returns
-------
-------
vector
A vector representing the diagonal elements.
A vector representing the diagonal elements.
"""
"""
...
@@ -5655,6 +5656,7 @@ def ptp(a, axis=None):
...
@@ -5655,6 +5656,7 @@ def ptp(a, axis=None):
Returns
Returns
-------
-------
array
A new array holding the result.
A new array holding the result.
"""
"""
...
...
theano/tensor/blas.py
浏览文件 @
b73195a3
...
@@ -1449,7 +1449,10 @@ def _factor_canonicalized(lst):
...
@@ -1449,7 +1449,10 @@ def _factor_canonicalized(lst):
def
_gemm_from_factored_list
(
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
=
[]
lst2
=
[]
# Remove the tuple that can't be cast correctly.
# Remove the tuple that can't be cast correctly.
# This can happen when we try to cast a complex to a real
# This can happen when we try to cast a complex to a real
...
...
theano/tensor/elemwise_cgen.py
浏览文件 @
b73195a3
...
@@ -5,8 +5,8 @@ import theano
...
@@ -5,8 +5,8 @@ import theano
def
make_declare
(
loop_orders
,
dtypes
,
sub
):
def
make_declare
(
loop_orders
,
dtypes
,
sub
):
"""
"""
Produce code to declare all necessary variables.
Produce code to declare all necessary variables.
"""
"""
decl
=
""
decl
=
""
for
i
,
(
loop_order
,
dtype
)
in
enumerate
(
zip
(
loop_orders
,
dtypes
)):
for
i
,
(
loop_order
,
dtype
)
in
enumerate
(
zip
(
loop_orders
,
dtypes
)):
var
=
sub
[
'lv
%
i'
%
i
]
# input name corresponding to ith loop variable
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,
...
@@ -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
Returns a list containing a C expression representing the
stride for each dimension of the ith variable, in the
stride for each dimension of the ith variable, in the
specified loop_order.
specified loop_order.
"""
"""
var
=
sub
[
"lv
%
i"
%
i
]
var
=
sub
[
"lv
%
i"
%
i
]
r
=
[]
r
=
[]
...
...
theano/tensor/extra_ops.py
浏览文件 @
b73195a3
...
@@ -539,8 +539,8 @@ def bincount(x, weights=None, minlength=None, assert_nonneg=False):
...
@@ -539,8 +539,8 @@ def bincount(x, weights=None, minlength=None, assert_nonneg=False):
def
squeeze
(
x
):
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
It returns the input array, but with the
broadcastable dimensions removed. This is
broadcastable dimensions removed. This is
...
@@ -565,26 +565,27 @@ def squeeze(x):
...
@@ -565,26 +565,27 @@ def squeeze(x):
def
compress
(
condition
,
x
,
axis
=
None
):
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
It returns the input tensor, but with selected slices along a given axis
retained. If no axis is provided, the tensor is flattened.
retained. If no axis is provided, the tensor is flattened.
Corresponds to numpy.compress
Corresponds to numpy.compress
.. versionadded:: 0.7
Parameters
Parameters
----------
----------
x
x
Input data, tensor variable.
Input data, tensor variable.
condition
condition
1 dimensional array of non-zero and zero values
1 dimensional array of non-zero and zero values
corresponding to indices of slices along a selected axis.
corresponding to indices of slices along a selected axis.
Returns
Returns
-------
-------
`x` with selected slices
object
`x` with selected slices.
.. versionadded:: 0.7
"""
"""
indices
=
theano
.
tensor
.
basic
.
flatnonzero
(
condition
)
indices
=
theano
.
tensor
.
basic
.
flatnonzero
(
condition
)
...
@@ -802,12 +803,15 @@ bartlett_ = Bartlett()
...
@@ -802,12 +803,15 @@ bartlett_ = Bartlett()
# I create a function only to have the doc show well.
# I create a function only to have the doc show well.
def
bartlett
(
M
):
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,
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
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
processing for tapering a signal, without generating too much ripple in
the frequency domain.
the frequency domain.
.. versionadded:: 0.6
Parameters
Parameters
----------
----------
M : integer scalar
M : integer scalar
...
@@ -821,8 +825,6 @@ def bartlett(M):
...
@@ -821,8 +825,6 @@ def bartlett(M):
(the value one appears only if the number of samples is odd), with
(the value one appears only if the number of samples is odd), with
the first and last samples equal to zero.
the first and last samples equal to zero.
.. versionadded:: 0.6
"""
"""
return
bartlett_
(
M
)
return
bartlett_
(
M
)
...
@@ -889,20 +891,24 @@ fill_diagonal_ = FillDiagonal()
...
@@ -889,20 +891,24 @@ fill_diagonal_ = FillDiagonal()
# I create a function only to have the doc show well.
# I create a function only to have the doc show well.
def
fill_diagonal
(
a
,
val
):
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.
elements of the main diagonal set to a specified scalar value.
.. versionadded:: 0.6
Parameters
Parameters
----------
----------
a
:
a
Rectangular array of at least two dimensions.
Rectangular array of at least two dimensions.
val
:
val
Scalar value to fill the diagonal whose type must be
Scalar value to fill the diagonal whose type must be
compatible with that of array 'a' (i.e. 'val' cannot be viewed
compatible with that of array 'a' (i.e. 'val' cannot be viewed
as an upcast of 'a').
as an upcast of 'a').
Returns
Returns
-------
-------
array
An array identical to 'a' except that its main diagonal
An array identical to 'a' except that its main diagonal
is filled with scalar 'val'. (For an array 'a' with a.ndim >=
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]
2, the main diagonal is the list of locations a[i, i, ..., i]
...
@@ -911,7 +917,7 @@ def fill_diagonal(a, val):
...
@@ -911,7 +917,7 @@ def fill_diagonal(a, val):
Support rectangular matrix and tensor with more than 2 dimensions
Support rectangular matrix and tensor with more than 2 dimensions
if the later have all dimensions are equals.
if the later have all dimensions are equals.
.. versionadded:: 0.6
"""
"""
return
fill_diagonal_
(
a
,
val
)
return
fill_diagonal_
(
a
,
val
)
...
@@ -1043,6 +1049,7 @@ def fill_diagonal_offset(a, val, offset):
...
@@ -1043,6 +1049,7 @@ def fill_diagonal_offset(a, val, offset):
Returns
Returns
-------
-------
array
An array identical to 'a' except that its offset diagonal
An array identical to 'a' except that its offset diagonal
is filled with scalar 'val'. The output is unwrapped.
is filled with scalar 'val'. The output is unwrapped.
...
@@ -1051,7 +1058,8 @@ def fill_diagonal_offset(a, val, offset):
...
@@ -1051,7 +1058,8 @@ def fill_diagonal_offset(a, val, offset):
def
to_one_hot
(
y
,
nb_class
,
dtype
=
None
):
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.
encoding of each element in y.
Parameters
Parameters
...
@@ -1069,7 +1077,7 @@ def to_one_hot(y, nb_class, dtype=None):
...
@@ -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
A matrix of shape (y.shape[0], nb_class), where each row ``i`` is
the one hot encoding of the corresponding ``y[i]`` value.
the one hot encoding of the corresponding ``y[i]`` value.
"""
"""
ret
=
theano
.
tensor
.
zeros
((
y
.
shape
[
0
],
nb_class
),
ret
=
theano
.
tensor
.
zeros
((
y
.
shape
[
0
],
nb_class
),
dtype
=
dtype
)
dtype
=
dtype
)
ret
=
theano
.
tensor
.
set_subtensor
(
ret
[
theano
.
tensor
.
arange
(
y
.
shape
[
0
]),
y
],
ret
=
theano
.
tensor
.
set_subtensor
(
ret
[
theano
.
tensor
.
arange
(
y
.
shape
[
0
]),
y
],
...
...
theano/tensor/nlinalg.py
浏览文件 @
b73195a3
...
@@ -255,14 +255,18 @@ def trace(X):
...
@@ -255,14 +255,18 @@ def trace(X):
"""
"""
Returns the sum of diagonal elements of matrix 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
()
return
extract_diag
(
X
)
.
sum
()
class
Det
(
Op
):
class
Det
(
Op
):
"""Matrix determinant
"""
Input should be a square matrix
Matrix determinant. Input should be a square matrix.
"""
"""
__props__
=
()
__props__
=
()
...
@@ -598,6 +602,7 @@ def qr(a, mode="full"):
...
@@ -598,6 +602,7 @@ def qr(a, mode="full"):
class
SVD
(
Op
):
class
SVD
(
Op
):
"""
"""
Parameters
Parameters
----------
----------
full_matrices : bool, optional
full_matrices : bool, optional
...
@@ -609,7 +614,7 @@ class SVD(Op):
...
@@ -609,7 +614,7 @@ class SVD(Op):
Whether or not to compute u and v in addition to s.
Whether or not to compute u and v in addition to s.
True by default.
True by default.
"""
"""
# See doc in the docstring of the function just after this class.
# See doc in the docstring of the function just after this class.
_numop
=
staticmethod
(
numpy
.
linalg
.
svd
)
_numop
=
staticmethod
(
numpy
.
linalg
.
svd
)
...
...
theano/tensor/nnet/conv.py
浏览文件 @
b73195a3
...
@@ -356,7 +356,8 @@ class ConvOp(OpenMPOp):
...
@@ -356,7 +356,8 @@ class ConvOp(OpenMPOp):
Returns
Returns
-------
-------
(rows,cols) of output image.
object
(rows,cols) of output image.
"""
"""
# The formula would be ceil((i + s * k - s * 1) / float(d)),
# The formula would be ceil((i + s * k - s * 1) / float(d)),
...
...
theano/tensor/nnet/neighbours.py
浏览文件 @
b73195a3
...
@@ -13,27 +13,29 @@ from theano.gradient import grad_undefined
...
@@ -13,27 +13,29 @@ from theano.gradient import grad_undefined
class
Images2Neibs
(
Op
):
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'
):
Returns
"""
-------
Parameters
object
----------
Reshapes the input as a 2D tensor where each row is an
mode : {'valid', 'ignore_borders', 'wrap_centered'}
pooling example.
'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
"""
-------
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'
]:
if
mode
not
in
[
'valid'
,
'wrap_centered'
,
'ignore_borders'
]:
raise
NotImplementedError
(
"Only the mode valid, ignore_borders"
raise
NotImplementedError
(
"Only the mode valid, ignore_borders"
" and wrap_centered have been"
" and wrap_centered have been"
...
@@ -456,16 +458,17 @@ def images2neibs(ten4, neib_shape, neib_step=None, mode='valid'):
...
@@ -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`
:math:`n * step
\
_size_i + neib
\
_shape_i` for some :math:`n`
mode : {'valid', 'ignore_borders', 'wrap_centered}
mode : {'valid', 'ignore_borders', 'wrap_centered}
``valid``
``valid``
Requires an input that is a multiple of the
Requires an input that is a multiple of the
pooling factor (in each direction).
pooling factor (in each direction).
``ignore_borders``
``ignore_borders``
Same as valid, but will ignore the borders if the shape(s) of
Same as valid, but will ignore the borders if the shape(s) of
the input is not a multiple of the pooling factor(s).
the input is not a multiple of the pooling factor(s).
``wrap_centered``
``wrap_centered``
?? TODO comment
?? TODO comment
Returns
Returns
-------
-------
object
Reshapes the input as a 2D tensor where each row is an
Reshapes the input as a 2D tensor where each row is an
pooling example. Pseudo-code of the output:
pooling example. Pseudo-code of the output:
...
@@ -531,6 +534,7 @@ def neibs2images(neibs, neib_shape, original_shape, mode='valid'):
...
@@ -531,6 +534,7 @@ def neibs2images(neibs, neib_shape, original_shape, mode='valid'):
Returns
Returns
-------
-------
object
Reconstructs the input of
Reconstructs the input of
:func:`images2neibs <theano.sandbox.neigbours.neibs2images>`,
:func:`images2neibs <theano.sandbox.neigbours.neibs2images>`,
a 4d tensor of shape `original_shape`.
a 4d tensor of shape `original_shape`.
...
...
theano/tensor/nnet/nnet.py
浏览文件 @
b73195a3
...
@@ -805,7 +805,7 @@ class CrossentropySoftmaxArgmax1HotWithBias(gof.Op):
...
@@ -805,7 +805,7 @@ class CrossentropySoftmaxArgmax1HotWithBias(gof.Op):
"""
"""
A special compound L{Op} for the output of neural-net classifiers.
A special compound L{Op} for the output of neural-net classifiers.
Attribute
s
Parameter
s
----------
----------
x : a matrix of floats (32 or 64)
x : a matrix of floats (32 or 64)
b : a [row] vector of floats (32 or 64), length is number of cols in x
b : a [row] vector of floats (32 or 64), length is number of cols in x
...
@@ -813,6 +813,7 @@ class CrossentropySoftmaxArgmax1HotWithBias(gof.Op):
...
@@ -813,6 +813,7 @@ class CrossentropySoftmaxArgmax1HotWithBias(gof.Op):
Returns
Returns
-------
-------
object
row-wise NLL, softmax(x+b), row-wise argmax of (x+b).
row-wise NLL, softmax(x+b), row-wise argmax of (x+b).
@precondition: every entry in y_idx is a valid (non-negative)
@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):
...
@@ -1240,6 +1241,7 @@ def crossentropy_softmax_max_and_argmax_1hot_with_bias(x, b, y_idx, **kwargs):
"""
"""
Returns
Returns
-------
-------
object
The cross-entropy, the softmax output, the max probability,
The cross-entropy, the softmax output, the max probability,
and the argmax index.
and the argmax index.
...
@@ -1931,7 +1933,7 @@ def categorical_crossentropy(coding_dist, true_dist):
...
@@ -1931,7 +1933,7 @@ def categorical_crossentropy(coding_dist, true_dist):
----------
----------
coding_dist : a dense matrix
coding_dist : a dense matrix
Each slice along axis represents one distribution.
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
In the case of a matrix argument, each slice along axis represents one
distribution. In the case of an integer vector argument, each element
distribution. In the case of an integer vector argument, each element
represents the position of the '1' in a 1-of-N encoding.
represents the position of the '1' in a 1-of-N encoding.
...
@@ -2091,7 +2093,7 @@ def relu(x, alpha=0):
...
@@ -2091,7 +2093,7 @@ def relu(x, alpha=0):
----------
----------
x : symbolic tensor
x : symbolic tensor
Tensor to compute the activation function for.
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
Slope for negative input, usually between 0 and 1. The default value
of 0 will lead to the standard rectifier, 1 will lead to
of 0 will lead to the standard rectifier, 1 will lead to
a linear activation function, and any value in between will give a
a linear activation function, and any value in between will give a
...
...
theano/tensor/nnet/sigm.py
浏览文件 @
b73195a3
...
@@ -383,6 +383,7 @@ logsigm_to_softplus = gof.PatternSub(
...
@@ -383,6 +383,7 @@ logsigm_to_softplus = gof.PatternSub(
def
_is_1
(
expr
):
def
_is_1
(
expr
):
"""
"""
Returns
Returns
-------
-------
bool
bool
...
@@ -417,8 +418,10 @@ opt.register_stabilize(log1pexp_to_softplus, name='log1pexp_to_softplus')
...
@@ -417,8 +418,10 @@ opt.register_stabilize(log1pexp_to_softplus, name='log1pexp_to_softplus')
def
is_1pexp
(
t
):
def
is_1pexp
(
t
):
"""
"""
Returns
Returns
-------
-------
object
If 't' is of the form (1+exp(x)), return (False, x).
If 't' is of the form (1+exp(x)), return (False, x).
Else return None.
Else return None.
...
@@ -471,6 +474,7 @@ def is_exp(var):
...
@@ -471,6 +474,7 @@ def is_exp(var):
Returns
Returns
-------
-------
tuple
A pair (b, x) with `b` a boolean set to True if `var` is of the
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`
form `-exp(x)` and False if `var` is of the form `exp(x)`. If `var`
cannot be cast into either form, then return `None`.
cannot be cast into either form, then return `None`.
...
@@ -496,6 +500,7 @@ def is_mul(var):
...
@@ -496,6 +500,7 @@ def is_mul(var):
Returns
Returns
-------
-------
object
A list [x, y, z, ...] if `var` is of the form `x * y * z * ...`,
A list [x, y, z, ...] if `var` is of the form `x * y * z * ...`,
or None if `var` cannot be cast into this form.
or None if `var` cannot be cast into this form.
...
@@ -538,6 +543,7 @@ def is_neg(var):
...
@@ -538,6 +543,7 @@ def is_neg(var):
Returns
Returns
-------
-------
object
`x` if `var` is of the form `-x`, or None otherwise.
`x` if `var` is of the form `-x`, or None otherwise.
"""
"""
...
@@ -627,6 +633,7 @@ def parse_mul_tree(root):
...
@@ -627,6 +633,7 @@ def parse_mul_tree(root):
Returns
Returns
-------
-------
object
A tree where each non-leaf node corresponds to a multiplication
A tree where each non-leaf node corresponds to a multiplication
in the computation of `root`, represented by the list of its inputs.
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
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):
...
@@ -688,6 +695,7 @@ def replace_leaf(arg, leaves, new_leaves, op, neg):
Returns
Returns
-------
-------
bool
True if a replacement occurred, or False otherwise.
True if a replacement occurred, or False otherwise.
"""
"""
...
@@ -712,6 +720,7 @@ def simplify_mul(tree):
...
@@ -712,6 +720,7 @@ def simplify_mul(tree):
Returns
Returns
-------
-------
object
A multiplication tree computing the same output as `tree` but without
A multiplication tree computing the same output as `tree` but without
useless multiplications by 1 nor -1 (identified by leaves of the form
useless multiplications by 1 nor -1 (identified by leaves of the form
[False, None] or [True, None] respectively). Useless multiplications
[False, None] or [True, None] respectively). Useless multiplications
...
@@ -757,6 +766,7 @@ def compute_mul(tree):
...
@@ -757,6 +766,7 @@ def compute_mul(tree):
Returns
Returns
-------
-------
object
A Variable that computes the multiplication represented by the tree.
A Variable that computes the multiplication represented by the tree.
"""
"""
...
...
theano/tensor/opt.py
浏览文件 @
b73195a3
...
@@ -156,6 +156,7 @@ def _fill_chain(new_out, orig_inputs):
...
@@ -156,6 +156,7 @@ def _fill_chain(new_out, orig_inputs):
def
encompasses_broadcastable
(
b1
,
b2
):
def
encompasses_broadcastable
(
b1
,
b2
):
"""
"""
Parameters
Parameters
----------
----------
b1
b1
...
@@ -165,8 +166,9 @@ def encompasses_broadcastable(b1, b2):
...
@@ -165,8 +166,9 @@ def encompasses_broadcastable(b1, b2):
Returns
Returns
-------
-------
True if the broadcastable patterns b1 and b2 are such that b2 is
bool
broadcasted to b1's shape and not the opposite.
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
):
if
len
(
b1
)
<
len
(
b2
):
...
@@ -1693,10 +1695,10 @@ class Assert(T.Op):
...
@@ -1693,10 +1695,10 @@ class Assert(T.Op):
Examples
Examples
--------
--------
T = theano.tensor
T = theano.tensor
x = T.vector('x')
x = T.vector('x')
assert_op = T.opt.Assert()
assert_op = T.opt.Assert()
func = theano.function([x], assert_op(x, x.size<2))
func = theano.function([x], assert_op(x, x.size<2))
"""
"""
...
@@ -3819,8 +3821,10 @@ class Canonizer(gof.LocalOptimizer):
...
@@ -3819,8 +3821,10 @@ class Canonizer(gof.LocalOptimizer):
@staticmethod
@staticmethod
def
get_constant
(
v
):
def
get_constant
(
v
):
"""
"""
Returns
Returns
-------
-------
object
A numeric constant if v is a Constant or, well, a
A numeric constant if v is a Constant or, well, a
numeric constant. If v is a plain Variable, returns None.
numeric constant. If v is a plain Variable, returns None.
...
@@ -5189,6 +5193,7 @@ def constant_folding(node):
...
@@ -5189,6 +5193,7 @@ def constant_folding(node):
def
_is_1
(
expr
):
def
_is_1
(
expr
):
"""
"""
Returns
Returns
-------
-------
bool
bool
...
@@ -5204,6 +5209,7 @@ def _is_1(expr):
...
@@ -5204,6 +5209,7 @@ def _is_1(expr):
def
_is_minus1
(
expr
):
def
_is_minus1
(
expr
):
"""
"""
Returns
Returns
-------
-------
bool
bool
...
@@ -5218,13 +5224,19 @@ def _is_minus1(expr):
...
@@ -5218,13 +5224,19 @@ def _is_minus1(expr):
def
get_clients
(
node
):
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
return
[
c
for
c
,
i
in
node
.
outputs
[
0
]
.
clients
if
c
!=
"output"
]
if
c
!=
"output"
]
def
get_clients2
(
node
):
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
=
[]
l
=
[]
for
c
,
i
in
node
.
outputs
[
0
]
.
clients
:
for
c
,
i
in
node
.
outputs
[
0
]
.
clients
:
if
c
!=
"output"
:
if
c
!=
"output"
:
...
...
theano/tensor/raw_random.py
浏览文件 @
b73195a3
...
@@ -843,6 +843,7 @@ def multinomial(random_state, size=None, n=1, pvals=[0.5, 0.5],
...
@@ -843,6 +843,7 @@ def multinomial(random_state, size=None, n=1, pvals=[0.5, 0.5],
Returns
Returns
-------
-------
tensor
Tensor of len(size)+1 dimensions, and shape[-1]==L, with
Tensor of len(size)+1 dimensions, and shape[-1]==L, with
the specified ``dtype``, with the experiment counts. See
the specified ``dtype``, with the experiment counts. See
examples to understand the shape of the return value, which is
examples to understand the shape of the return value, which is
...
...
theano/tensor/shared_randomstreams.py
浏览文件 @
b73195a3
...
@@ -21,7 +21,10 @@ class RandomStateSharedVariable(SharedVariable):
...
@@ -21,7 +21,10 @@ class RandomStateSharedVariable(SharedVariable):
@shared_constructor
@shared_constructor
def
randomstate_constructor
(
value
,
name
=
None
,
strict
=
False
,
def
randomstate_constructor
(
value
,
name
=
None
,
strict
=
False
,
allow_downcast
=
None
,
borrow
=
False
):
allow_downcast
=
None
,
borrow
=
False
):
"""SharedVariable Constructor for RandomState"""
"""
SharedVariable Constructor for RandomState.
"""
if
not
isinstance
(
value
,
numpy
.
random
.
RandomState
):
if
not
isinstance
(
value
,
numpy
.
random
.
RandomState
):
raise
TypeError
raise
TypeError
if
not
borrow
:
if
not
borrow
:
...
...
theano/tensor/sort.py
浏览文件 @
b73195a3
...
@@ -103,6 +103,7 @@ class SortOp(theano.Op):
...
@@ -103,6 +103,7 @@ class SortOp(theano.Op):
def
sort
(
a
,
axis
=-
1
,
kind
=
'quicksort'
,
order
=
None
):
def
sort
(
a
,
axis
=-
1
,
kind
=
'quicksort'
,
order
=
None
):
"""
"""
Parameters
Parameters
----------
----------
a : Tensor
a : Tensor
...
@@ -119,7 +120,8 @@ def sort(a, axis=-1, kind='quicksort', order=None):
...
@@ -119,7 +120,8 @@ def sort(a, axis=-1, kind='quicksort', order=None):
Returns
Returns
-------
-------
A sorted copy of an array.
array
A sorted copy of an array.
"""
"""
if
axis
is
None
:
if
axis
is
None
:
...
...
theano/tensor/subtensor.py
浏览文件 @
b73195a3
...
@@ -309,8 +309,9 @@ class Subtensor(Op):
...
@@ -309,8 +309,9 @@ class Subtensor(Op):
Returns
Returns
-------
-------
idxs, with the slices flattened out into a list.
list
If cond is true for an entry, does not flatten it.
idxs, with the slices flattened out into a list.
If cond is true for an entry, does not flatten it.
"""
"""
ret
=
[]
ret
=
[]
...
@@ -1484,7 +1485,8 @@ class IncSubtensor(Op):
...
@@ -1484,7 +1485,8 @@ class IncSubtensor(Op):
Returns
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
Base class uses PyArrayObject *, subclasses may override for
different types of arrays.
different types of arrays.
...
@@ -1547,8 +1549,8 @@ class IncSubtensor(Op):
...
@@ -1547,8 +1549,8 @@ class IncSubtensor(Op):
Returns
Returns
-------
-------
Returns a C code expression to copy source into view, and
object
return
0 on success.
C code expression to copy source into view, and
0 on success.
"""
"""
return
"""PyArray_CopyInto(
%(view)
s,
%(source)
s)"""
%
locals
()
return
"""PyArray_CopyInto(
%(view)
s,
%(source)
s)"""
%
locals
()
...
@@ -1911,12 +1913,13 @@ class AdvancedIncSubtensor1(Op):
...
@@ -1911,12 +1913,13 @@ class AdvancedIncSubtensor1(Op):
"""
"""
Parameters
Parameters
----------
----------
x: string
x
: string
Gives the name of a C variable pointing to an array.
Gives the name of a C variable pointing to an array.
Returns
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
Base class uses PyArrayObject *, subclasses may override for
different types of arrays.
different types of arrays.
...
...
theano/tensor/type.py
浏览文件 @
b73195a3
...
@@ -657,7 +657,8 @@ class TensorType(Type):
...
@@ -657,7 +657,8 @@ class TensorType(Type):
Returns
Returns
-------
-------
Python object that ``self.get_size()`` understands.
object
Python object that ``self.get_size()`` understands.
"""
"""
return
obj
.
shape
return
obj
.
shape
...
@@ -673,6 +674,7 @@ class TensorType(Type):
...
@@ -673,6 +674,7 @@ class TensorType(Type):
Returns
Returns
-------
-------
int
The number of bytes taken by the object described by ``shape_info``.
The number of bytes taken by the object described by ``shape_info``.
"""
"""
...
...
theano/tensor/var.py
浏览文件 @
b73195a3
...
@@ -255,9 +255,11 @@ class _tensor_py_operators:
...
@@ -255,9 +255,11 @@ class _tensor_py_operators:
def
transpose
(
self
,
*
axes
):
def
transpose
(
self
,
*
axes
):
"""
"""
Returns
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
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
assumed to be the entire axes tuple, and passed intact to
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论