Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
f0dedb92
提交
f0dedb92
authored
2月 10, 2011
作者:
Frederic Bastien
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
make sparse test run in the default mode, the a hardcoded one.
上级
9b3c4363
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
9 行增加
和
26 行删除
+9
-26
test_basic.py
theano/sparse/tests/test_basic.py
+9
-26
没有找到文件。
theano/sparse/tests/test_basic.py
浏览文件 @
f0dedb92
...
@@ -324,7 +324,7 @@ class test_structureddot(unittest.TestCase):
...
@@ -324,7 +324,7 @@ class test_structureddot(unittest.TestCase):
images
=
tensor
.
Tensor
(
dtype
=
'float32'
,
broadcastable
=
[
False
,
False
])(
'images'
)
images
=
tensor
.
Tensor
(
dtype
=
'float32'
,
broadcastable
=
[
False
,
False
])(
'images'
)
cscmat
=
CSC
(
kerns
,
spmat
.
indices
[:
spmat
.
size
],
spmat
.
indptr
,
spmat
.
shape
)
cscmat
=
CSC
(
kerns
,
spmat
.
indices
[:
spmat
.
size
],
spmat
.
indptr
,
spmat
.
shape
)
f
=
theano
.
function
([
kerns
,
images
],
structured_dot
(
cscmat
,
images
.
T
)
,
mode
=
'FAST_RUN'
)
f
=
theano
.
function
([
kerns
,
images
],
structured_dot
(
cscmat
,
images
.
T
))
sdcscpresent
=
False
sdcscpresent
=
False
for
node
in
f
.
maker
.
env
.
toposort
():
for
node
in
f
.
maker
.
env
.
toposort
():
...
@@ -373,18 +373,7 @@ class test_structureddot(unittest.TestCase):
...
@@ -373,18 +373,7 @@ class test_structureddot(unittest.TestCase):
a
=
SparseType
(
'csc'
,
dtype
=
sparse_dtype
)()
a
=
SparseType
(
'csc'
,
dtype
=
sparse_dtype
)()
b
=
tensor
.
matrix
(
dtype
=
dense_dtype
)
b
=
tensor
.
matrix
(
dtype
=
dense_dtype
)
d
=
theano
.
dot
(
a
,
b
)
d
=
theano
.
dot
(
a
,
b
)
#f = theano.function([a,b], theano.Out(d, borrow=True), mode='PROFILE_MODE')
f
=
theano
.
function
([
a
,
b
],
theano
.
Out
(
d
,
borrow
=
True
))
f
=
theano
.
function
([
a
,
b
],
theano
.
Out
(
d
,
borrow
=
True
),
mode
=
'FAST_RUN'
)
# technically we could be using DEBUG MODE to verify internal problems.
# in fact, if this test fails for correctness, then it would be good to use DEBUG_MODE
# to figure out where thigns go wrong.
# however, comparing FAST_RUN with scipy is a quick way of ensuring all's well that
# ends well, and also lets us ensure that our speed optimizations are working.
print
f
.
maker
.
mode
#print f.maker.env.toposort()
for
M
,
N
,
K
,
nnz
in
[(
4
,
3
,
2
,
3
),
for
M
,
N
,
K
,
nnz
in
[(
4
,
3
,
2
,
3
),
(
40
,
30
,
20
,
3
),
(
40
,
30
,
20
,
3
),
...
@@ -417,7 +406,8 @@ class test_structureddot(unittest.TestCase):
...
@@ -417,7 +406,8 @@ class test_structureddot(unittest.TestCase):
overhead_tol
=
0.003
# seconds overall
overhead_tol
=
0.003
# seconds overall
overhead_rtol
=
1.2
# times as long
overhead_rtol
=
1.2
# times as long
self
.
failUnless
(
numpy
.
allclose
(
theano_result
,
scipy_result
))
self
.
failUnless
(
numpy
.
allclose
(
theano_result
,
scipy_result
))
self
.
failIf
(
theano_time
>
overhead_rtol
*
scipy_time
+
overhead_tol
)
if
not
theano
.
config
.
mode
in
[
"DebugMode"
,
"DEBUG_MODE"
]:
self
.
failIf
(
theano_time
>
overhead_rtol
*
scipy_time
+
overhead_tol
)
def
test_csr_correct_output_faster_than_scipy
(
self
):
def
test_csr_correct_output_faster_than_scipy
(
self
):
...
@@ -429,15 +419,7 @@ class test_structureddot(unittest.TestCase):
...
@@ -429,15 +419,7 @@ class test_structureddot(unittest.TestCase):
a
=
SparseType
(
'csr'
,
dtype
=
sparse_dtype
)()
a
=
SparseType
(
'csr'
,
dtype
=
sparse_dtype
)()
b
=
tensor
.
matrix
(
dtype
=
dense_dtype
)
b
=
tensor
.
matrix
(
dtype
=
dense_dtype
)
d
=
theano
.
dot
(
a
,
b
)
d
=
theano
.
dot
(
a
,
b
)
f
=
theano
.
function
([
a
,
b
],
d
,
mode
=
'FAST_RUN'
)
f
=
theano
.
function
([
a
,
b
],
d
)
# technically we could be using DEBUG MODE to verify internal problems.
# in fact, if this test fails for correctness, then it would be good to use DEBUG_MODE
# to figure out where thigns go wrong.
# however, comparing FAST_RUN with scipy is a quick way of ensuring all's well that
# ends well, and also lets us ensure that our speed optimizations are working.
print
f
.
maker
.
env
.
toposort
()
for
M
,
N
,
K
,
nnz
in
[(
4
,
3
,
2
,
3
),
for
M
,
N
,
K
,
nnz
in
[(
4
,
3
,
2
,
3
),
(
40
,
30
,
20
,
3
),
(
40
,
30
,
20
,
3
),
...
@@ -461,13 +443,14 @@ class test_structureddot(unittest.TestCase):
...
@@ -461,13 +443,14 @@ class test_structureddot(unittest.TestCase):
overhead_tol
=
0.002
# seconds
overhead_tol
=
0.002
# seconds
overhead_rtol
=
1.1
# times as long
overhead_rtol
=
1.1
# times as long
self
.
failUnless
(
numpy
.
allclose
(
theano_result
,
scipy_result
))
self
.
failUnless
(
numpy
.
allclose
(
theano_result
,
scipy_result
))
self
.
failIf
(
theano_time
>
overhead_rtol
*
scipy_time
+
overhead_tol
)
if
not
theano
.
config
.
mode
in
[
"DebugMode"
,
"DEBUG_MODE"
]:
self
.
failIf
(
theano_time
>
overhead_rtol
*
scipy_time
+
overhead_tol
)
def
test_shape_i
():
def
test_shape_i
():
sparse_dtype
=
'float32'
sparse_dtype
=
'float32'
a
=
SparseType
(
'csr'
,
dtype
=
sparse_dtype
)()
a
=
SparseType
(
'csr'
,
dtype
=
sparse_dtype
)()
f
=
theano
.
function
([
a
],
a
.
shape
[
1
]
,
mode
=
'FAST_RUN'
)
f
=
theano
.
function
([
a
],
a
.
shape
[
1
])
assert
f
(
sp
.
csr_matrix
(
random_lil
((
100
,
10
),
sparse_dtype
,
3
)))
==
10
assert
f
(
sp
.
csr_matrix
(
random_lil
((
100
,
10
),
sparse_dtype
,
3
)))
==
10
def
test_shape
():
def
test_shape
():
...
@@ -476,7 +459,7 @@ def test_shape():
...
@@ -476,7 +459,7 @@ def test_shape():
sparse_dtype
=
'float32'
sparse_dtype
=
'float32'
a
=
SparseType
(
'csr'
,
dtype
=
sparse_dtype
)()
a
=
SparseType
(
'csr'
,
dtype
=
sparse_dtype
)()
f
=
theano
.
function
([
a
],
a
.
shape
,
mode
=
'FAST_RUN'
)
f
=
theano
.
function
([
a
],
a
.
shape
)
assert
numpy
.
all
(
f
(
sp
.
csr_matrix
(
random_lil
((
100
,
10
),
sparse_dtype
,
3
)))
==
(
100
,
10
))
assert
numpy
.
all
(
f
(
sp
.
csr_matrix
(
random_lil
((
100
,
10
),
sparse_dtype
,
3
)))
==
(
100
,
10
))
if
theano
.
config
.
mode
!=
'FAST_COMPILE'
:
if
theano
.
config
.
mode
!=
'FAST_COMPILE'
:
topo
=
f
.
maker
.
env
.
toposort
()
topo
=
f
.
maker
.
env
.
toposort
()
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论