Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
b8775273
提交
b8775273
authored
7月 16, 2015
作者:
Iban Harlouchet
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
__props__ for theano/tensor/basic.py
上级
f4edcc59
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
26 行增加
和
101 行删除
+26
-101
basic.py
theano/tensor/basic.py
+26
-101
没有找到文件。
theano/tensor/basic.py
浏览文件 @
b8775273
...
@@ -1001,6 +1001,9 @@ _scal_elemwise = _scal_elemwise_with_nfunc(None, None, None)
...
@@ -1001,6 +1001,9 @@ _scal_elemwise = _scal_elemwise_with_nfunc(None, None, None)
#########################
#########################
class
TensorFromScalar
(
Op
):
class
TensorFromScalar
(
Op
):
__props__
=
()
def
make_node
(
self
,
s
):
def
make_node
(
self
,
s
):
assert
isinstance
(
s
.
type
,
scal
.
Scalar
)
assert
isinstance
(
s
.
type
,
scal
.
Scalar
)
return
Apply
(
self
,
return
Apply
(
self
,
...
@@ -1032,18 +1035,12 @@ class TensorFromScalar(Op):
...
@@ -1032,18 +1035,12 @@ class TensorFromScalar(Op):
raise
NotImplementedError
(
"grad not implemented for complex dtypes"
)
raise
NotImplementedError
(
"grad not implemented for complex dtypes"
)
def
__str__
(
self
):
return
self
.
__class__
.
__name__
tensor_from_scalar
=
TensorFromScalar
()
tensor_from_scalar
=
TensorFromScalar
()
class
ScalarFromTensor
(
Op
):
class
ScalarFromTensor
(
Op
):
def
__eq__
(
self
,
other
):
return
type
(
self
)
==
type
(
other
)
def
__hash__
(
self
):
__props__
=
()
return
hash
(
type
(
self
))
def
make_node
(
self
,
t
):
def
make_node
(
self
,
t
):
assert
isinstance
(
t
.
type
,
TensorType
)
assert
isinstance
(
t
.
type
,
TensorType
)
...
@@ -1071,9 +1068,6 @@ class ScalarFromTensor(Op):
...
@@ -1071,9 +1068,6 @@ class ScalarFromTensor(Op):
return
[
None
]
return
[
None
]
return
self
.
make_node
(
*
eval_points
)
.
outputs
return
self
.
make_node
(
*
eval_points
)
.
outputs
def
__str__
(
self
):
return
self
.
__class__
.
__name__
def
c_code
(
self
,
node
,
name
,
inputs
,
outputs
,
sub
):
def
c_code
(
self
,
node
,
name
,
inputs
,
outputs
,
sub
):
x
,
=
inputs
x
,
=
inputs
z
,
=
outputs
z
,
=
outputs
...
@@ -1196,12 +1190,7 @@ class MaxAndArgmax(Op):
...
@@ -1196,12 +1190,7 @@ class MaxAndArgmax(Op):
nin
=
2
# tensor, axis
nin
=
2
# tensor, axis
nout
=
2
# max val, max idx
nout
=
2
# max val, max idx
E_axis
=
'invalid axis'
E_axis
=
'invalid axis'
__props__
=
()
def
__eq__
(
self
,
other
):
return
type
(
self
)
==
type
(
other
)
def
__hash__
(
self
):
return
hash
(
type
(
self
))
def
make_node
(
self
,
x
,
axis
=
None
):
def
make_node
(
self
,
x
,
axis
=
None
):
x
=
_as_tensor_variable
(
x
)
x
=
_as_tensor_variable
(
x
)
...
@@ -1423,10 +1412,6 @@ class MaxAndArgmax(Op):
...
@@ -1423,10 +1412,6 @@ class MaxAndArgmax(Op):
g_x
=
eq
(
xmax_pad
,
x
)
*
g_max_pad
g_x
=
eq
(
xmax_pad
,
x
)
*
g_max_pad
return
g_x
,
axis_grad
return
g_x
,
axis_grad
def
__str__
(
self
):
return
self
.
__class__
.
__name__
_max_and_argmax
=
MaxAndArgmax
()
_max_and_argmax
=
MaxAndArgmax
()
...
@@ -2329,6 +2314,9 @@ def nonzero_values(a):
...
@@ -2329,6 +2314,9 @@ def nonzero_values(a):
class
Tri
(
gof
.
Op
):
class
Tri
(
gof
.
Op
):
__props__
=
(
"dtype"
,)
def
__init__
(
self
,
dtype
=
None
):
def
__init__
(
self
,
dtype
=
None
):
if
dtype
is
None
:
if
dtype
is
None
:
dtype
=
config
.
floatX
dtype
=
config
.
floatX
...
@@ -2355,12 +2343,6 @@ class Tri(gof.Op):
...
@@ -2355,12 +2343,6 @@ class Tri(gof.Op):
def
grad
(
self
,
inp
,
grads
):
def
grad
(
self
,
inp
,
grads
):
return
[
grad_undefined
(
self
,
i
,
inp
[
i
])
for
i
in
xrange
(
3
)]
return
[
grad_undefined
(
self
,
i
,
inp
[
i
])
for
i
in
xrange
(
3
)]
def
__eq__
(
self
,
other
):
return
type
(
self
)
==
type
(
other
)
and
self
.
dtype
==
other
.
dtype
def
__hash__
(
self
):
return
hash
(
self
.
dtype
)
^
hash
(
type
(
self
))
def
tri
(
N
,
M
=
None
,
k
=
0
,
dtype
=
None
):
def
tri
(
N
,
M
=
None
,
k
=
0
,
dtype
=
None
):
"""
"""
...
@@ -2437,6 +2419,9 @@ def triu(m, k=0):
...
@@ -2437,6 +2419,9 @@ def triu(m, k=0):
class
Eye
(
gof
.
Op
):
class
Eye
(
gof
.
Op
):
__props__
=
(
"dtype"
,
)
def
__init__
(
self
,
dtype
=
None
):
def
__init__
(
self
,
dtype
=
None
):
if
dtype
is
None
:
if
dtype
is
None
:
dtype
=
config
.
floatX
dtype
=
config
.
floatX
...
@@ -2989,6 +2974,7 @@ class Default(gof.Op):
...
@@ -2989,6 +2974,7 @@ class Default(gof.Op):
have exactly the same type.
have exactly the same type.
"""
"""
view_map
=
{
0
:
[
0
]}
view_map
=
{
0
:
[
0
]}
__props__
=
()
def
make_node
(
self
,
x
,
default
):
def
make_node
(
self
,
x
,
default
):
x
,
default
=
as_tensor_variable
(
x
),
as_tensor_variable
(
default
)
x
,
default
=
as_tensor_variable
(
x
),
as_tensor_variable
(
default
)
...
@@ -3282,20 +3268,14 @@ class Split(Op):
...
@@ -3282,20 +3268,14 @@ class Split(Op):
"""A Split instance will have this many outputs, and require that
"""A Split instance will have this many outputs, and require that
the splits argument to `perform` have exactly this many elements.
the splits argument to `perform` have exactly this many elements.
"""
"""
__props__
=
(
"len_splits"
,)
def
__init__
(
self
,
len_splits
):
def
__init__
(
self
,
len_splits
):
self
.
len_splits
=
int
(
len_splits
)
self
.
len_splits
=
int
(
len_splits
)
def
__eq__
(
self
,
other
):
return
(
type
(
self
)
==
type
(
other
)
and
self
.
len_splits
==
other
.
len_splits
)
def
__str__
(
self
):
def
__str__
(
self
):
return
self
.
__class__
.
__name__
+
"{
%
s}"
%
self
.
len_splits
return
self
.
__class__
.
__name__
+
"{
%
s}"
%
self
.
len_splits
def
__hash__
(
self
):
return
hash
(
Split
)
^
self
.
len_splits
def
make_node
(
self
,
x
,
axis
,
splits
):
def
make_node
(
self
,
x
,
axis
,
splits
):
"""WRITEME"""
"""WRITEME"""
x
=
as_tensor_variable
(
x
)
x
=
as_tensor_variable
(
x
)
...
@@ -3509,15 +3489,7 @@ class Join(Op):
...
@@ -3509,15 +3489,7 @@ class Join(Op):
join(0, x, u) # WRONG: joined tensors must have the same rank
join(0, x, u) # WRONG: joined tensors must have the same rank
"""
"""
check_input
=
False
check_input
=
False
__props__
=
()
def
__eq__
(
self
,
other
):
return
type
(
self
)
==
type
(
other
)
def
__hash__
(
self
):
return
hash
(
type
(
self
))
def
__str__
(
self
):
return
'
%
s'
%
(
self
.
__class__
.
__name__
)
def
make_node
(
self
,
*
axis_and_tensors
):
def
make_node
(
self
,
*
axis_and_tensors
):
"""
"""
...
@@ -3971,19 +3943,13 @@ class Reshape(Op):
...
@@ -3971,19 +3943,13 @@ class Reshape(Op):
_f16_ok
=
True
_f16_ok
=
True
check_input
=
False
check_input
=
False
__props__
=
(
"ndim"
,)
# name does not participate because it doesn't affect computations
def
__init__
(
self
,
ndim
,
name
=
None
):
def
__init__
(
self
,
ndim
,
name
=
None
):
self
.
ndim
=
ndim
self
.
ndim
=
ndim
self
.
name
=
name
self
.
name
=
name
def
__eq__
(
self
,
other
):
# .name does not participate because it doesn't affect computations
return
(
type
(
other
)
is
type
(
self
))
and
(
other
.
ndim
==
self
.
ndim
)
def
__hash__
(
self
):
# .name does not participate because it doesn't affect computations
return
hash
(
type
(
self
))
^
hash
(
self
.
ndim
)
def
__str__
(
self
):
def
__str__
(
self
):
return
'
%
s{
%
s}'
%
(
self
.
__class__
.
__name__
,
self
.
ndim
)
return
'
%
s{
%
s}'
%
(
self
.
__class__
.
__name__
,
self
.
ndim
)
...
@@ -4172,16 +4138,11 @@ class Flatten(Op):
...
@@ -4172,16 +4138,11 @@ class Flatten(Op):
view_map
=
{
0
:
[
0
]}
view_map
=
{
0
:
[
0
]}
check_input
=
False
check_input
=
False
__props__
=
(
"outdim"
,)
def
__init__
(
self
,
outdim
=
1
):
def
__init__
(
self
,
outdim
=
1
):
self
.
outdim
=
int
(
outdim
)
self
.
outdim
=
int
(
outdim
)
def
__eq__
(
self
,
other
):
return
type
(
self
)
==
type
(
other
)
and
self
.
outdim
==
other
.
outdim
def
__hash__
(
self
):
return
hashtype
(
self
)
^
hash
(
self
.
outdim
)
def
__str__
(
self
):
def
__str__
(
self
):
return
'
%
s{
%
s}'
%
(
self
.
__class__
.
__name__
,
self
.
outdim
)
return
'
%
s{
%
s}'
%
(
self
.
__class__
.
__name__
,
self
.
outdim
)
...
@@ -4356,15 +4317,11 @@ class Tile(Op):
...
@@ -4356,15 +4317,11 @@ class Tile(Op):
:see: `numpy.tile
:see: `numpy.tile
<http://docs.scipy.org/doc/numpy/reference/generated/numpy.tile.html>`_
<http://docs.scipy.org/doc/numpy/reference/generated/numpy.tile.html>`_
"""
"""
__props__
=
(
"ndim"
,)
def
__init__
(
self
,
ndim
):
def
__init__
(
self
,
ndim
):
self
.
ndim
=
ndim
self
.
ndim
=
ndim
def
__eq__
(
self
,
other
):
return
(
type
(
other
)
is
Tile
)
and
(
other
.
ndim
==
self
.
ndim
)
def
__hash__
(
self
):
return
hash
(
Tile
)
^
hash
(
self
.
ndim
)
def
__str__
(
self
):
def
__str__
(
self
):
return
self
.
__class__
.
__name__
+
"{ndim=
%
d}"
%
self
.
ndim
return
self
.
__class__
.
__name__
+
"{ndim=
%
d}"
%
self
.
ndim
...
@@ -4465,19 +4422,11 @@ class ARange(Op):
...
@@ -4465,19 +4422,11 @@ class ARange(Op):
Parameters and behaviour are the same as numpy.arange().
Parameters and behaviour are the same as numpy.arange().
"""
"""
__props__
=
(
"dtype"
,)
def
__init__
(
self
,
dtype
):
def
__init__
(
self
,
dtype
):
self
.
dtype
=
dtype
self
.
dtype
=
dtype
def
__eq__
(
self
,
other
):
return
type
(
self
)
==
type
(
other
)
and
self
.
dtype
==
other
.
dtype
def
__hash__
(
self
):
return
hash
(
self
.
dtype
)
def
__str__
(
self
):
return
self
.
__class__
.
__name__
def
make_node
(
self
,
start
,
stop
,
step
):
def
make_node
(
self
,
start
,
stop
,
step
):
start
,
stop
,
step
=
map
(
as_tensor_variable
,
(
start
,
stop
,
step
))
start
,
stop
,
step
=
map
(
as_tensor_variable
,
(
start
,
stop
,
step
))
assert
start
.
ndim
==
0
assert
start
.
ndim
==
0
...
@@ -4633,6 +4582,8 @@ class _nd_grid(object):
...
@@ -4633,6 +4582,8 @@ class _nd_grid(object):
>>> b[1].eval()
>>> b[1].eval()
array([[0, 1, 2, 3]], dtype=int8)
array([[0, 1, 2, 3]], dtype=int8)
"""
"""
__props__
=
(
"sparse"
,)
def
__init__
(
self
,
sparse
=
False
):
def
__init__
(
self
,
sparse
=
False
):
self
.
sparse
=
sparse
self
.
sparse
=
sparse
...
@@ -4693,6 +4644,7 @@ class PermuteRowElements(Op):
...
@@ -4693,6 +4644,7 @@ class PermuteRowElements(Op):
If the "inverse" argument is True, the Op will perform the inverse
If the "inverse" argument is True, the Op will perform the inverse
permutation instead.
permutation instead.
"""
"""
__props__
=
()
def
make_node
(
self
,
x
,
y
,
inverse
):
def
make_node
(
self
,
x
,
y
,
inverse
):
x
=
as_tensor_variable
(
x
)
x
=
as_tensor_variable
(
x
)
...
@@ -4900,12 +4852,7 @@ class Dot(Op):
...
@@ -4900,12 +4852,7 @@ class Dot(Op):
tensor.blas)
tensor.blas)
"""
"""
__props__
=
()
def
__eq__
(
self
,
other
):
return
type
(
self
)
==
type
(
other
)
def
__hash__
(
self
):
return
hash
(
type
(
self
))
# the rationale for Dot22 is related to getting GEMM Ops into the
# the rationale for Dot22 is related to getting GEMM Ops into the
# graph. See Dot22 in tensor.blas for details.
# graph. See Dot22 in tensor.blas for details.
...
@@ -5076,9 +5023,6 @@ class Dot(Op):
...
@@ -5076,9 +5023,6 @@ class Dot(Op):
return
[
xshp
[:
-
1
]
+
yshp
[
-
1
:]]
return
[
xshp
[:
-
1
]
+
yshp
[
-
1
:]]
raise
NotImplementedError
()
raise
NotImplementedError
()
def
__str__
(
self
):
return
"dot"
_dot
=
Dot
()
_dot
=
Dot
()
pprint
.
assign
(
_dot
,
printing
.
OperatorPrinter
(
printing
.
special
[
'middle_dot'
],
pprint
.
assign
(
_dot
,
printing
.
OperatorPrinter
(
printing
.
special
[
'middle_dot'
],
-
1
,
'left'
))
-
1
,
'left'
))
...
@@ -5369,6 +5313,7 @@ class Diagonal(Op):
...
@@ -5369,6 +5313,7 @@ class Diagonal(Op):
:return: A vector representing the diagonal elements.
:return: A vector representing the diagonal elements.
"""
"""
__props__
=
(
"offset"
,
"axis1"
,
"axis2"
)
def
__init__
(
self
,
offset
=
0
,
axis1
=
0
,
axis2
=
1
):
def
__init__
(
self
,
offset
=
0
,
axis1
=
0
,
axis2
=
1
):
if
numpy_diagonal_return_view
:
if
numpy_diagonal_return_view
:
...
@@ -5377,16 +5322,6 @@ class Diagonal(Op):
...
@@ -5377,16 +5322,6 @@ class Diagonal(Op):
self
.
axis1
=
axis1
self
.
axis1
=
axis1
self
.
axis2
=
axis2
self
.
axis2
=
axis2
def
__eq__
(
self
,
other
):
return
(
type
(
self
)
==
type
(
other
)
and
self
.
offset
==
other
.
offset
and
self
.
axis1
==
other
.
axis1
and
self
.
axis2
==
other
.
axis2
)
def
__hash__
(
self
):
return
(
hash
(
type
(
self
))
^
hash
(
self
.
offset
)
^
hash
(
self
.
axis1
)
^
hash
(
self
.
axis2
))
def
make_node
(
self
,
x
):
def
make_node
(
self
,
x
):
x
=
as_tensor_variable
(
x
)
x
=
as_tensor_variable
(
x
)
assert
x
.
ndim
>=
2
assert
x
.
ndim
>=
2
...
@@ -5420,9 +5355,6 @@ class Diagonal(Op):
...
@@ -5420,9 +5355,6 @@ class Diagonal(Op):
out_shape
.
append
(
diag_size
)
out_shape
.
append
(
diag_size
)
return
[
tuple
(
out_shape
)]
return
[
tuple
(
out_shape
)]
def
__str__
(
self
):
return
self
.
__class__
.
__name__
def
diagonal
(
a
,
offset
=
0
,
axis1
=
0
,
axis2
=
1
):
def
diagonal
(
a
,
offset
=
0
,
axis1
=
0
,
axis2
=
1
):
if
(
offset
,
axis1
,
axis2
)
==
(
0
,
0
,
1
):
if
(
offset
,
axis1
,
axis2
)
==
(
0
,
0
,
1
):
...
@@ -5432,11 +5364,7 @@ def diagonal(a, offset=0, axis1=0, axis2=1):
...
@@ -5432,11 +5364,7 @@ def diagonal(a, offset=0, axis1=0, axis2=1):
class
Diag
(
Op
):
class
Diag
(
Op
):
def
__eq__
(
self
,
other
):
__props__
=
()
return
type
(
self
)
==
type
(
other
)
def
__hash__
(
self
):
return
hash
(
type
(
self
))
def
make_node
(
self
,
diag
):
def
make_node
(
self
,
diag
):
diag
=
as_tensor_variable
(
diag
)
diag
=
as_tensor_variable
(
diag
)
...
@@ -5456,9 +5384,6 @@ class Diag(Op):
...
@@ -5456,9 +5384,6 @@ class Diag(Op):
def
infer_shape
(
self
,
nodes
,
shapes
):
def
infer_shape
(
self
,
nodes
,
shapes
):
return
[(
shapes
[
0
][
0
],)
*
2
]
return
[(
shapes
[
0
][
0
],)
*
2
]
def
__str__
(
self
):
return
self
.
__class__
.
__name__
def
diag
(
v
,
k
=
0
):
def
diag
(
v
,
k
=
0
):
if
v
.
ndim
==
1
:
if
v
.
ndim
==
1
:
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论