Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
15ba1e41
提交
15ba1e41
authored
8月 06, 2015
作者:
Iban Harlouchet
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
numpydoc for theano/tensor/var.py
上级
ab2c91ce
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
76 行增加
和
50 行删除
+76
-50
var.py
theano/tensor/var.py
+76
-50
没有找到文件。
theano/tensor/var.py
浏览文件 @
15ba1e41
...
...
@@ -22,8 +22,9 @@ def equal_slices(s1, s2):
class
AsTensorError
(
TypeError
):
"""Raised when as_tensor_variable isn't able to create a
TensorVariable.
"""
Raised when as_tensor_variable isn't able to create a TensorVariable.
"""
pass
...
...
@@ -254,8 +255,9 @@ class _tensor_py_operators:
def
transpose
(
self
,
*
axes
):
"""
Return `tensor.transpose(self, axes)`
or `tensor.transpose(self, axes[0])`
Returns
-------
`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
...
...
@@ -298,16 +300,18 @@ class _tensor_py_operators:
def
reshape
(
self
,
shape
,
ndim
=
None
):
"""Return a reshaped view/copy of this variable.
:param shape: something that can be converted to a symbolic vector of
integers
:param ndim: the length of the shape. Passing None here means for
theano to try and guess the length of `shape`.
Parameters
----------
shape
Something that can be converted to a symbolic vector of integers.
ndim
The length of the shape. Passing None here means for
Theano to try and guess the length of `shape`.
* warning-- t
his has a different signature than numpy's
ndarray.reshape!
i
n numpy you do not need to wrap the shape arguments
in a tuple, in theano you do need to
.. warning:: T
his has a different signature than numpy's
ndarray.reshape!
I
n numpy you do not need to wrap the shape arguments
in a tuple, in theano you do need to.
"""
...
...
@@ -323,21 +327,29 @@ class _tensor_py_operators:
Reorder the dimensions of this variable, optionally inserting
broadcasted dimensions.
:param pattern: list/tuple of int mixed with 'x' for broadcastable
dimensions
Parameters
----------
pattern
List/tuple of int mixed with 'x' for broadcastable dimensions.
Examples
--------
For example, to create a 3D view of a [2D] matrix, call
``dimshuffle([0,'x',1])``. This will create a 3D view such that the
middle dimension is an implicit broadcasted dimension. To do the same
thing on the transpose of that matrix, call
``dimshuffle([1, 'x', 0])``.
thing on the transpose of that matrix, call ``dimshuffle([1, 'x', 0])``.
Notes
-----
This function supports the pattern passed as a tuple, or as a
variable-length argument (e.g. ``a.dimshuffle(pattern)`` is equivalent
to ``a.dimshuffle(*pattern)`` where ``pattern`` is a list/tuple of ints
mixed with 'x' characters).
For more information, see `DimShuffle`.
See Also
--------
DimShuffle
"""
if
(
len
(
pattern
)
==
1
)
and
(
isinstance
(
pattern
[
0
],
(
list
,
tuple
))):
pattern
=
pattern
[
0
]
...
...
@@ -524,13 +536,17 @@ class _tensor_py_operators:
"""The rank of this tensor."""
broadcastable
=
property
(
lambda
self
:
self
.
type
.
broadcastable
)
"""The broadcastable signature of this tensor.
"""
The broadcastable signature of this tensor.
See Also
--------
broadcasting
See :doc:`broadcasting` for details.
"""
dtype
=
property
(
lambda
self
:
self
.
type
.
dtype
)
"""
The dtype of this tensor.
"""
"""
The dtype of this tensor.
"""
# extra pseudo-operator symbols
def
__dot__
(
left
,
right
):
...
...
@@ -542,13 +558,13 @@ class _tensor_py_operators:
dot
=
__dot__
def
sum
(
self
,
axis
=
None
,
dtype
=
None
,
keepdims
=
False
,
acc_dtype
=
None
):
"""See `theano.tensor.sum`"""
"""See `theano.tensor.sum`
.
"""
return
theano
.
tensor
.
basic
.
sum
(
self
,
axis
=
axis
,
dtype
=
dtype
,
keepdims
=
keepdims
,
acc_dtype
=
acc_dtype
)
def
prod
(
self
,
axis
=
None
,
dtype
=
None
,
keepdims
=
False
,
acc_dtype
=
None
):
"""See `theano.tensor.prod`"""
"""See `theano.tensor.prod`
.
"""
return
theano
.
tensor
.
basic
.
prod
(
self
,
axis
=
axis
,
dtype
=
dtype
,
keepdims
=
keepdims
,
acc_dtype
=
acc_dtype
)
...
...
@@ -564,49 +580,49 @@ class _tensor_py_operators:
theano
.
tensor
.
basic
.
abs_
(
self
),
L
)
.
sum
(
axis
=
axis
),
1.0
/
L
)
def
mean
(
self
,
axis
=
None
,
dtype
=
None
,
keepdims
=
False
,
acc_dtype
=
None
):
"""See `theano.tensor.mean`"""
"""See `theano.tensor.mean`
.
"""
return
theano
.
tensor
.
basic
.
mean
(
self
,
axis
=
axis
,
dtype
=
dtype
,
keepdims
=
keepdims
,
acc_dtype
=
acc_dtype
)
def
var
(
self
,
axis
=
None
,
keepdims
=
False
):
"""See `theano.tensor.var`"""
"""See `theano.tensor.var`
.
"""
return
theano
.
tensor
.
basic
.
var
(
self
,
axis
,
keepdims
=
keepdims
)
def
std
(
self
,
axis
=
None
,
keepdims
=
False
):
"""See `theano.tensor.std`"""
"""See `theano.tensor.std`
.
"""
return
theano
.
tensor
.
basic
.
std
(
self
,
axis
,
keepdims
=
keepdims
)
def
min
(
self
,
axis
=
None
,
keepdims
=
False
):
"""See `theano.tensor.min`"""
"""See `theano.tensor.min`
.
"""
return
theano
.
tensor
.
basic
.
min
(
self
,
axis
,
keepdims
=
keepdims
)
def
max
(
self
,
axis
=
None
,
keepdims
=
False
):
"""See `theano.tensor.max`"""
"""See `theano.tensor.max`
.
"""
return
theano
.
tensor
.
basic
.
max
(
self
,
axis
,
keepdims
=
keepdims
)
def
argmin
(
self
,
axis
=
None
,
keepdims
=
False
):
"""See `theano.tensor.argmin`"""
"""See `theano.tensor.argmin`
.
"""
return
theano
.
tensor
.
basic
.
argmin
(
self
,
axis
,
keepdims
=
keepdims
)
def
argmax
(
self
,
axis
=
None
,
keepdims
=
False
):
"""See `theano.tensor.argmax`"""
"""See `theano.tensor.argmax`
.
"""
return
theano
.
tensor
.
basic
.
argmax
(
self
,
axis
,
keepdims
=
keepdims
)
def
nonzero
(
self
,
return_matrix
=
False
):
"""See `theano.tensor.nonzero`"""
"""See `theano.tensor.nonzero`
.
"""
return
theano
.
tensor
.
basic
.
nonzero
(
self
,
return_matrix
=
return_matrix
)
def
nonzero_values
(
self
):
"""See `theano.tensor.nonzero_values`"""
"""See `theano.tensor.nonzero_values`
.
"""
return
theano
.
tensor
.
basic
.
nonzero_values
(
self
)
def
sort
(
self
,
axis
=-
1
,
kind
=
'quicksort'
,
order
=
None
):
"""See `theano.tensor.sort`"""
"""See `theano.tensor.sort`
.
"""
return
theano
.
tensor
.
sort
(
self
,
axis
,
kind
,
order
)
def
argsort
(
self
,
axis
=-
1
,
kind
=
'quicksort'
,
order
=
None
):
"""See `theano.tensor.argsort`"""
"""See `theano.tensor.argsort`
.
"""
return
theano
.
tensor
.
argsort
(
self
,
axis
,
kind
,
order
)
def
clip
(
self
,
a_min
,
a_max
):
...
...
@@ -614,17 +630,17 @@ class _tensor_py_operators:
return
theano
.
tensor
.
basic
.
clip
(
self
,
a_min
,
a_max
)
def
conj
(
self
):
"""See `theano.tensor.conj`"""
"""See `theano.tensor.conj`
.
"""
return
theano
.
tensor
.
basic
.
conj
(
self
)
conjugate
=
conj
def
repeat
(
self
,
repeats
,
axis
=
None
):
"""See `theano.tensor.repeat`"""
"""See `theano.tensor.repeat`
.
"""
return
theano
.
tensor
.
extra_ops
.
repeat
(
self
,
repeats
,
axis
)
def
round
(
self
,
mode
=
"half_away_from_zero"
):
"""See `theano.tensor.round`"""
"""See `theano.tensor.round`
.
"""
return
theano
.
tensor
.
basic
.
round
(
self
,
mode
)
def
trace
(
self
):
...
...
@@ -646,12 +662,13 @@ class _tensor_py_operators:
return
theano
.
tensor
.
extra_ops
.
cumprod
(
self
,
axis
)
def
ptp
(
self
,
axis
=
None
):
"""
see 'theano.tensor.ptp'
"""
"""
See 'theano.tensor.ptp'.
"""
return
theano
.
tensor
.
ptp
(
self
,
axis
)
def
swapaxes
(
self
,
axis1
,
axis2
):
"""Return 'tensor.swapaxes(self, axis1, axis2)
"""
Return 'tensor.swapaxes(self, axis1, axis2).
If a matrix is provided with the right axes, its transpose
will be returned.
...
...
@@ -660,32 +677,38 @@ class _tensor_py_operators:
return
theano
.
tensor
.
basic
.
swapaxes
(
self
,
axis1
,
axis2
)
def
fill
(
self
,
value
):
"""Fill inputted tensor with the assigned value"""
"""Fill inputted tensor with the assigned value
.
"""
return
theano
.
tensor
.
basic
.
fill
(
self
,
value
)
def
choose
(
self
,
a
,
choices
,
out
=
None
,
mode
=
'raise'
):
"""Construct an array from an index array and a set of arrays to choose from."""
"""
Construct an array from an index array and a set of arrays to choose
from.
"""
return
theano
.
tensor
.
basic
.
choose
(
self
,
a
,
choices
,
out
=
None
,
mode
=
'raise'
)
def
squeeze
(
self
):
"""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 always `x` itself or a view into `x`.
It returns the input array, but with the
broadcastable dimensions removed. This is
always `x` itself or a view into `x`.
"""
return
theano
.
tensor
.
extra_ops
.
squeeze
(
self
)
def
compress
(
self
,
a
,
axis
=
None
):
"""Return selected slices only
"""
"""Return selected slices only."""
return
theano
.
tensor
.
extra_ops
.
compress
(
self
,
a
,
axis
=
axis
)
class
TensorVariable
(
_tensor_py_operators
,
Variable
):
"""Subclass to add the tensor operators to the basic `Variable` class."""
"""
Subclass to add the tensor operators to the basic `Variable` class.
"""
def
__init__
(
self
,
type
,
owner
=
None
,
index
=
None
,
name
=
None
):
super
(
TensorVariable
,
self
)
.
__init__
(
type
,
owner
=
owner
,
...
...
@@ -721,9 +744,11 @@ TensorType.Variable = TensorVariable
class
TensorConstantSignature
(
tuple
):
"""A Signature object for comparing TensorConstant instances
"""
A Signature object for comparing TensorConstant instances.
An instance is a pair: (Type instance, ndarray).
"""
def
__eq__
(
self
,
other
):
if
type
(
self
)
!=
type
(
other
):
...
...
@@ -814,6 +839,7 @@ class TensorConstant(_tensor_py_operators, Constant):
"""Subclass to add the tensor operators to the basic `Constant` class.
To create a TensorConstant, use the `constant` function in this module.
"""
def
__init__
(
self
,
type
,
data
,
name
=
None
):
Constant
.
__init__
(
self
,
type
,
data
,
name
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论