Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
0fdd1c3d
提交
0fdd1c3d
authored
2月 22, 2012
作者:
Frederic
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Added __str__ to many sparse Op. Removed __ne__ as they do the same as the default implementation.
上级
b8ecaae2
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
55 行增加
和
14 行删除
+55
-14
basic.py
theano/sparse/basic.py
+55
-14
没有找到文件。
theano/sparse/basic.py
浏览文件 @
0fdd1c3d
...
...
@@ -525,12 +525,14 @@ class CSMProperties(gof.Op):
def
__eq__
(
self
,
other
):
return
type
(
self
)
==
type
(
other
)
and
_kmap_eq
(
self
.
kmap
,
other
.
kmap
)
def
__ne__
(
self
,
other
):
return
not
(
self
==
other
)
def
__hash__
(
self
):
return
8234
^
hash
(
type
(
self
))
^
_kmap_hash
(
self
.
kmap
)
def
__str__
(
self
):
return
"
%
s{
%
s}"
%
(
self
.
__class__
.
__name__
,
self
.
kmap
)
def
make_node
(
self
,
csm
):
csm
=
as_sparse_variable
(
csm
)
data
=
tensor
.
TensorType
(
dtype
=
csm
.
type
.
dtype
,
...
...
@@ -700,12 +702,14 @@ class CSMGrad(gof.op.Op):
def
__eq__
(
self
,
other
):
return
type
(
self
)
==
type
(
other
)
and
_kmap_eq
(
self
.
kmap
,
other
.
kmap
)
def
__ne__
(
self
,
other
):
return
not
(
self
==
other
)
def
__hash__
(
self
):
return
82345
^
hash
(
type
(
self
))
^
_kmap_hash
(
self
.
kmap
)
def
__str__
(
self
):
return
"
%
s{
%
s}"
%
(
self
.
__class__
.
__name__
,
self
.
kmap
)
def
make_node
(
self
,
data
,
gout_data
,
gout_indices
):
g_data
=
gout_data
.
type
()
return
gof
.
Apply
(
self
,
[
data
,
gout_data
,
gout_indices
],
[
g_data
])
...
...
@@ -761,6 +765,11 @@ class DenseFromSparse(gof.op.Op):
def
__hash__
(
self
):
return
hash
(
type
(
self
))
^
hash
(
self
.
sparse_grad
)
def
__str__
(
self
):
return
"
%
s{structured_grad=
%
s}"
%
(
self
.
__class__
.
__name__
,
self
.
sparse_grad
)
def
make_node
(
self
,
x
):
x
=
as_sparse_variable
(
x
)
return
gof
.
Apply
(
self
,
...
...
@@ -801,12 +810,14 @@ class SparseFromDense(gof.op.Op):
def
__eq__
(
self
,
other
):
return
type
(
self
)
==
type
(
other
)
and
self
.
format
==
other
.
format
def
__ne__
(
self
,
other
):
return
not
(
self
==
other
)
def
__hash__
(
self
):
return
982374
^
hash
(
self
.
format
)
^
hash
(
DenseFromSparse
)
def
__str__
(
self
):
return
"
%
s{
%
s}"
%
(
self
.
__class__
.
__name__
,
self
.
format
)
def
make_node
(
self
,
x
):
x
=
tensor
.
as_tensor_variable
(
x
)
if
x
.
ndim
>
2
:
...
...
@@ -1005,6 +1016,9 @@ class Transpose(gof.op.Op):
def
__hash__
(
self
):
return
hash
(
type
(
self
))
def
__str__
(
self
):
return
"Sparse"
+
self
.
__class__
.
__name__
def
make_node
(
self
,
x
):
x
=
as_sparse_variable
(
x
)
return
gof
.
Apply
(
self
,
...
...
@@ -1034,6 +1048,9 @@ class Neg(gof.op.Op):
def
__hash__
(
self
):
return
hash
(
type
(
self
))
def
__str__
(
self
):
return
"Sparse"
+
self
.
__class__
.
__name__
def
make_node
(
self
,
x
):
x
=
as_sparse_variable
(
x
)
return
gof
.
Apply
(
self
,
[
x
],
[
x
.
type
()])
...
...
@@ -1060,6 +1077,9 @@ class AddSS(gof.op.Op):
def
__hash__
(
self
):
return
hash
(
type
(
self
))
def
__str__
(
self
):
return
self
.
__class__
.
__name__
def
make_node
(
self
,
x
,
y
):
x
,
y
=
map
(
as_sparse_variable
,
[
x
,
y
])
if
x
.
type
.
dtype
!=
y
.
type
.
dtype
:
...
...
@@ -1096,6 +1116,9 @@ class AddSD(gof.op.Op):
def
__hash__
(
self
):
return
hash
(
type
(
self
))
def
__str__
(
self
):
return
self
.
__class__
.
__name__
def
make_node
(
self
,
x
,
y
):
x
,
y
=
as_sparse_variable
(
x
),
tensor
.
as_tensor_variable
(
y
)
if
x
.
type
.
dtype
!=
y
.
type
.
dtype
:
...
...
@@ -1161,6 +1184,9 @@ class MulSS(gof.op.Op):
def
__hash__
(
self
):
return
hash
(
type
(
self
))
def
__str__
(
self
):
return
self
.
__class__
.
__name__
def
make_node
(
self
,
x
,
y
):
x
,
y
=
as_sparse_variable
(
x
),
as_sparse_variable
(
y
)
if
x
.
type
!=
y
.
type
:
...
...
@@ -1195,6 +1221,9 @@ class MulSD(gof.op.Op):
def
__hash__
(
self
):
return
hash
(
type
(
self
))
def
__str__
(
self
):
return
self
.
__class__
.
__name__
def
make_node
(
self
,
x
,
y
):
x
,
y
=
as_sparse_variable
(
x
),
tensor
.
as_tensor_variable
(
y
)
...
...
@@ -1304,6 +1333,9 @@ class StructuredDot(gof.Op):
def
__hash__
(
self
):
return
hash
(
type
(
self
))
def
__str__
(
self
):
return
self
.
__class__
.
__name__
def
make_node
(
self
,
a
,
b
):
if
not
_is_sparse_variable
(
a
):
raise
TypeError
(
'First argument must be of type SparseVariable '
...
...
@@ -1405,6 +1437,9 @@ class StructuredDotCSC(gof.Op):
def
__hash__
(
self
):
return
hash
(
type
(
self
))
def
__str__
(
self
):
return
self
.
__class__
.
__name__
def
make_node
(
self
,
a_val
,
a_ind
,
a_ptr
,
a_nrows
,
b
):
dtype_out
=
scalar
.
upcast
(
a_val
.
type
.
dtype
,
b
.
type
.
dtype
)
r
=
gof
.
Apply
(
self
,
[
a_val
,
a_ind
,
a_ptr
,
a_nrows
,
b
],
...
...
@@ -1577,6 +1612,9 @@ class StructuredDotCSR(gof.Op):
def
__hash__
(
self
):
return
hash
(
type
(
self
))
def
__str__
(
self
):
return
self
.
__class__
.
__name__
def
make_node
(
self
,
a_val
,
a_ind
,
a_ptr
,
b
):
self
.
dtype_out
=
scalar
.
upcast
(
a_val
.
type
.
dtype
,
b
.
type
.
dtype
)
r
=
gof
.
Apply
(
self
,
[
a_val
,
a_ind
,
a_ptr
,
b
],
...
...
@@ -1759,6 +1797,9 @@ class StructuredDotGradCSC(gof.Op):
def
__hash__
(
self
):
return
hash
(
type
(
self
))
def
__str__
(
self
):
return
self
.
__class__
.
__name__
def
make_node
(
self
,
a_indices
,
a_indptr
,
b
,
g_ab
):
return
gof
.
Apply
(
self
,
[
a_indices
,
a_indptr
,
b
,
g_ab
],
[
tensor
.
tensor
(
g_ab
.
dtype
,
(
False
,))])
...
...
@@ -1878,6 +1919,9 @@ class StructuredDotGradCSR(gof.Op):
def
__hash__
(
self
):
return
hash
(
type
(
self
))
def
__str__
(
self
):
return
self
.
__class__
.
__name__
def
make_node
(
self
,
a_indices
,
a_indptr
,
b
,
g_ab
):
return
gof
.
Apply
(
self
,
[
a_indices
,
a_indptr
,
b
,
g_ab
],
[
tensor
.
tensor
(
b
.
dtype
,
(
False
,))])
...
...
@@ -2005,8 +2049,8 @@ class Dot(gof.op.Op):
def
__hash__
(
self
):
return
hash
(
type
(
self
))
def
__
ne__
(
self
,
other
):
return
not
(
self
==
other
)
def
__
str__
(
self
):
return
"Sparse"
+
self
.
__class__
.
__name__
def
infer_shape
(
self
,
node
,
shapes
):
xshp
,
yshp
=
shapes
...
...
@@ -2100,9 +2144,6 @@ class Usmm(gof.op.Op):
def
__hash__
(
self
):
return
hash
(
type
(
self
))
def
__ne__
(
self
,
other
):
return
not
(
self
==
other
)
def
__str__
(
self
):
return
'Usmm{no_inplace}'
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论