Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
f9b45b04
提交
f9b45b04
authored
8月 14, 2013
作者:
Frederic
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove comment that is wrong. The remove0 op don't sort the indices.
I updated the test to check that. Other place where we talk about remove0 was telling that it just remove 0.
上级
70def42c
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
40 行增加
和
31 行删除
+40
-31
basic.py
theano/sparse/basic.py
+1
-2
test_basic.py
theano/sparse/tests/test_basic.py
+39
-29
没有找到文件。
theano/sparse/basic.py
浏览文件 @
f9b45b04
...
@@ -2357,8 +2357,7 @@ def vstack(blocks, format=None, dtype=None):
...
@@ -2357,8 +2357,7 @@ def vstack(blocks, format=None, dtype=None):
class
Remove0
(
gof
.
Op
):
class
Remove0
(
gof
.
Op
):
"""Remove explicit zeros from a sparse matrix, and
"""Remove explicit zeros from a sparse matrix.
resort indices.
:param x: Sparse matrix.
:param x: Sparse matrix.
...
...
theano/sparse/tests/test_basic.py
浏览文件 @
f9b45b04
...
@@ -1865,35 +1865,45 @@ class Remove0Tester(utt.InferShapeTester):
...
@@ -1865,35 +1865,45 @@ class Remove0Tester(utt.InferShapeTester):
(
'csr'
,
scipy
.
sparse
.
csr_matrix
),
]
(
'csr'
,
scipy
.
sparse
.
csr_matrix
),
]
for
format
,
matrix_class
in
configs
:
for
format
,
matrix_class
in
configs
:
(
x
,),
(
mat
,)
=
sparse_random_inputs
(
format
,
(
3
,
4
),
for
zero
,
unsor
in
[(
True
,
True
),
(
True
,
False
),
out_dtype
=
config
.
floatX
,
(
False
,
True
),
(
False
,
False
)]:
explicit_zero
=
True
)
(
x
,),
(
mat
,)
=
sparse_random_inputs
(
format
,
(
6
,
8
),
assert
0
in
mat
.
data
out_dtype
=
config
.
floatX
,
explicit_zero
=
zero
,
# the In thingy has to be there because theano has as rule not
unsorted_indices
=
unsor
)
# to optimize inputs
assert
0
in
mat
.
data
or
not
zero
f
=
theano
.
function
([
theano
.
In
(
x
,
borrow
=
True
,
mutable
=
True
)],
assert
not
mat
.
has_sorted_indices
or
not
unsor
Remove0
()(
x
))
# the In thingy has to be there because theano has as rule not
# assert optimization local_inplace_remove0 is applied in
# to optimize inputs
# modes with optimization
f
=
theano
.
function
([
theano
.
In
(
x
,
borrow
=
True
,
mutable
=
True
)],
if
theano
.
config
.
mode
not
in
[
'FAST_COMPILE'
]:
Remove0
()(
x
))
# list of apply nodes in the optimized graph.
nodes
=
f
.
maker
.
fgraph
.
toposort
()
# assert optimization local_inplace_remove0 is applied in
# Check there isn't any Remove0 instance not inplace.
# modes with optimization
assert
not
any
([
isinstance
(
node
.
op
,
Remove0
)
and
if
theano
.
config
.
mode
not
in
[
'FAST_COMPILE'
]:
not
node
.
op
.
inplace
for
node
in
nodes
]),
(
# list of apply nodes in the optimized graph.
'Inplace optimization should have been applied'
)
nodes
=
f
.
maker
.
fgraph
.
toposort
()
# Check there is at least one Remove0 inplace.
# Check there isn't any Remove0 instance not inplace.
assert
any
([
isinstance
(
node
.
op
,
Remove0
)
and
node
.
op
.
inplace
assert
not
any
([
isinstance
(
node
.
op
,
Remove0
)
and
for
node
in
nodes
])
not
node
.
op
.
inplace
for
node
in
nodes
]),
(
# checking
'Inplace optimization should have been applied'
)
# makes sense to change its name
# Check there is at least one Remove0 inplace.
target
=
mat
assert
any
([
isinstance
(
node
.
op
,
Remove0
)
and
node
.
op
.
inplace
result
=
f
(
mat
)
for
node
in
nodes
])
mat
.
eliminate_zeros
()
# checking
msg
=
'Matrices sizes differ. Have zeros been removed ?'
# makes sense to change its name
assert
result
.
size
==
target
.
size
,
msg
target
=
mat
result
=
f
(
mat
)
mat
.
eliminate_zeros
()
msg
=
'Matrices sizes differ. Have zeros been removed ?'
assert
result
.
size
==
target
.
size
,
msg
if
unsor
:
assert
not
result
.
has_sorted_indices
assert
not
target
.
has_sorted_indices
else
:
assert
result
.
has_sorted_indices
assert
target
.
has_sorted_indices
def
test_infer_shape
(
self
):
def
test_infer_shape
(
self
):
mat
=
(
numpy
.
arange
(
12
)
+
1
)
.
reshape
((
4
,
3
))
mat
=
(
numpy
.
arange
(
12
)
+
1
)
.
reshape
((
4
,
3
))
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论