Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
bc355bfe
提交
bc355bfe
authored
12月 18, 2017
作者:
Frederic Bastien
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Make tests less verbose
上级
f636d83a
显示空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
22 行增加
和
4 行删除
+22
-4
test_monitormode.py
theano/compile/tests/test_monitormode.py
+18
-0
test_elemwise.py
theano/gpuarray/tests/test_elemwise.py
+0
-1
test_basic.py
theano/tensor/tests/test_basic.py
+2
-2
test_opt.py
theano/tensor/tests/test_opt.py
+2
-1
没有找到文件。
theano/compile/tests/test_monitormode.py
浏览文件 @
bc355bfe
from
__future__
import
absolute_import
,
print_function
,
division
from
__future__
import
absolute_import
,
print_function
,
division
import
sys
import
numpy
as
np
import
numpy
as
np
from
six.moves
import
StringIO
import
theano
import
theano
...
@@ -23,7 +26,12 @@ def test_detect_nan():
...
@@ -23,7 +26,12 @@ def test_detect_nan():
f
=
theano
.
function
([
x
],
[
theano
.
tensor
.
log
(
x
)
*
x
],
f
=
theano
.
function
([
x
],
[
theano
.
tensor
.
log
(
x
)
*
x
],
mode
=
theano
.
compile
.
MonitorMode
(
mode
=
theano
.
compile
.
MonitorMode
(
post_func
=
detect_nan
))
post_func
=
detect_nan
))
try
:
old_stdout
=
sys
.
stdout
sys
.
stdout
=
StringIO
()
f
(
0
)
# log(0) * 0 = -inf * 0 = NaN
f
(
0
)
# log(0) * 0 = -inf * 0 = NaN
finally
:
sys
.
stdout
=
old_stdout
assert
nan_detected
[
0
]
assert
nan_detected
[
0
]
...
@@ -49,7 +57,12 @@ def test_optimizer():
...
@@ -49,7 +57,12 @@ def test_optimizer():
mode
=
mode
)
mode
=
mode
)
# Test that the fusion wasn't done
# Test that the fusion wasn't done
assert
len
(
f
.
maker
.
fgraph
.
apply_nodes
)
==
2
assert
len
(
f
.
maker
.
fgraph
.
apply_nodes
)
==
2
try
:
old_stdout
=
sys
.
stdout
sys
.
stdout
=
StringIO
()
f
(
0
)
# log(0) * 0 = -inf * 0 = NaN
f
(
0
)
# log(0) * 0 = -inf * 0 = NaN
finally
:
sys
.
stdout
=
old_stdout
# Test that we still detect the nan
# Test that we still detect the nan
assert
nan_detected
[
0
]
assert
nan_detected
[
0
]
...
@@ -83,7 +96,12 @@ def test_not_inplace():
...
@@ -83,7 +96,12 @@ def test_not_inplace():
# Test that the fusion wasn't done
# Test that the fusion wasn't done
assert
len
(
f
.
maker
.
fgraph
.
apply_nodes
)
==
5
assert
len
(
f
.
maker
.
fgraph
.
apply_nodes
)
==
5
assert
not
f
.
maker
.
fgraph
.
toposort
()[
-
1
]
.
op
.
destroy_map
assert
not
f
.
maker
.
fgraph
.
toposort
()[
-
1
]
.
op
.
destroy_map
try
:
old_stdout
=
sys
.
stdout
sys
.
stdout
=
StringIO
()
f
([
0
,
0
])
# log(0) * 0 = -inf * 0 = NaN
f
([
0
,
0
])
# log(0) * 0 = -inf * 0 = NaN
finally
:
sys
.
stdout
=
old_stdout
# Test that we still detect the nan
# Test that we still detect the nan
assert
nan_detected
[
0
]
assert
nan_detected
[
0
]
theano/gpuarray/tests/test_elemwise.py
浏览文件 @
bc355bfe
...
@@ -59,7 +59,6 @@ def test_elemwise_pow():
...
@@ -59,7 +59,6 @@ def test_elemwise_pow():
assert
exp
.
dtype
==
dtype_exp
assert
exp
.
dtype
==
dtype_exp
output
=
base
**
exp
output
=
base
**
exp
f
=
theano
.
function
([
base
],
output
,
mode
=
mode_with_gpu
)
f
=
theano
.
function
([
base
],
output
,
mode
=
mode_with_gpu
)
theano
.
printing
.
debugprint
(
f
)
# We don't transfer to the GPU when the output dtype is int*
# We don't transfer to the GPU when the output dtype is int*
n
=
len
([
n
for
n
in
f
.
maker
.
fgraph
.
apply_nodes
n
=
len
([
n
for
n
in
f
.
maker
.
fgraph
.
apply_nodes
if
isinstance
(
n
.
op
,
GpuElemwise
)])
if
isinstance
(
n
.
op
,
GpuElemwise
)])
...
...
theano/tensor/tests/test_basic.py
浏览文件 @
bc355bfe
...
@@ -820,7 +820,7 @@ def test_maximum_minimum_grad():
...
@@ -820,7 +820,7 @@ def test_maximum_minimum_grad():
for
op
in
[
tensor
.
maximum
,
tensor
.
minimum
]:
for
op
in
[
tensor
.
maximum
,
tensor
.
minimum
]:
o
=
op
(
x
,
y
)
o
=
op
(
x
,
y
)
g
=
theano
.
grad
(
o
.
sum
(),
[
x
,
y
])
g
=
theano
.
grad
(
o
.
sum
(),
[
x
,
y
])
theano
.
printing
.
debugprint
(
g
)
f
=
theano
.
function
([
x
,
y
],
g
)
f
=
theano
.
function
([
x
,
y
],
g
)
assert
np
.
allclose
(
f
([
1
],
[
1
]),
[[
1
],
[
0
]])
assert
np
.
allclose
(
f
([
1
],
[
1
]),
[[
1
],
[
0
]])
...
@@ -7789,7 +7789,7 @@ class TestSpecifyShape(unittest.TestCase):
...
@@ -7789,7 +7789,7 @@ class TestSpecifyShape(unittest.TestCase):
f
(
xval
)
f
(
xval
)
xval
=
np
.
random
.
rand
(
3
)
.
astype
(
floatX
)
xval
=
np
.
random
.
rand
(
3
)
.
astype
(
floatX
)
self
.
assertRaises
(
AssertionError
,
f
,
xval
)
self
.
assertRaises
(
AssertionError
,
f
,
xval
)
theano
.
printing
.
debugprint
(
f
)
assert
isinstance
([
n
for
n
in
f
.
maker
.
fgraph
.
toposort
()
assert
isinstance
([
n
for
n
in
f
.
maker
.
fgraph
.
toposort
()
if
isinstance
(
n
.
op
,
SpecifyShape
)][
0
]
.
inputs
[
0
]
.
type
,
if
isinstance
(
n
.
op
,
SpecifyShape
)][
0
]
.
inputs
[
0
]
.
type
,
self
.
input_type
)
self
.
input_type
)
...
...
theano/tensor/tests/test_opt.py
浏览文件 @
bc355bfe
...
@@ -1116,7 +1116,6 @@ class test_fusion(unittest.TestCase):
...
@@ -1116,7 +1116,6 @@ class test_fusion(unittest.TestCase):
nb_elemwise
,
answer
,
out_dtype
]
in
enumerate
(
cases
):
nb_elemwise
,
answer
,
out_dtype
]
in
enumerate
(
cases
):
if
isinstance
(
out_dtype
,
dict
):
if
isinstance
(
out_dtype
,
dict
):
out_dtype
=
out_dtype
[
config
.
cast_policy
]
out_dtype
=
out_dtype
[
config
.
cast_policy
]
print
(
"new cases"
,
id
)
if
shared_fn
is
None
:
if
shared_fn
is
None
:
f
=
compile
.
function
(
list
(
sym_inputs
),
g
,
mode
=
mode
)
f
=
compile
.
function
(
list
(
sym_inputs
),
g
,
mode
=
mode
)
...
@@ -1139,6 +1138,7 @@ class test_fusion(unittest.TestCase):
...
@@ -1139,6 +1138,7 @@ class test_fusion(unittest.TestCase):
atol
=
1e-6
atol
=
1e-6
if
not
np
.
allclose
(
out
,
answer
*
nb_repeat
,
atol
=
atol
):
if
not
np
.
allclose
(
out
,
answer
*
nb_repeat
,
atol
=
atol
):
fail1
.
append
(
id
)
fail1
.
append
(
id
)
print
(
"cases"
,
id
)
print
(
val_inputs
)
print
(
val_inputs
)
print
(
out
)
print
(
out
)
print
(
answer
*
nb_repeat
)
print
(
answer
*
nb_repeat
)
...
@@ -1163,6 +1163,7 @@ class test_fusion(unittest.TestCase):
...
@@ -1163,6 +1163,7 @@ class test_fusion(unittest.TestCase):
fail4
.
append
((
id
,
out_dtype
,
out
.
dtype
))
fail4
.
append
((
id
,
out_dtype
,
out
.
dtype
))
failed
=
len
(
fail1
+
fail2
+
fail3
+
fail4
)
failed
=
len
(
fail1
+
fail2
+
fail3
+
fail4
)
if
failed
>
0
:
print
(
"Executed"
,
len
(
cases
),
"cases"
,
"failed"
,
failed
)
print
(
"Executed"
,
len
(
cases
),
"cases"
,
"failed"
,
failed
)
if
failed
>
0
:
if
failed
>
0
:
raise
Exception
(
"Failed
%
d cases"
%
failed
,
fail1
,
raise
Exception
(
"Failed
%
d cases"
%
failed
,
fail1
,
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论