Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
e331b68f
提交
e331b68f
authored
1月 25, 2017
作者:
Benjamin Scellier
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
file theano/compile/tests/test_debugmode.py
上级
f8d377f3
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
18 行增加
和
18 行删除
+18
-18
test_debugmode.py
theano/compile/tests/test_debugmode.py
+18
-18
没有找到文件。
theano/compile/tests/test_debugmode.py
浏览文件 @
e331b68f
...
...
@@ -2,7 +2,7 @@ from __future__ import absolute_import, print_function, division
from
nose.plugins.skip
import
SkipTest
import
unittest
import
numpy
import
numpy
as
np
from
theano
import
config
from
theano
import
gof
...
...
@@ -316,7 +316,7 @@ def test_just_c_code():
x
=
theano
.
tensor
.
dvector
()
f
=
theano
.
function
([
x
],
wb2
(
x
),
mode
=
debugmode
.
DebugMode
(
check_py_code
=
False
))
assert
n
umpy
.
all
(
f
([
1
,
2
])
==
[
2
,
4
])
assert
n
p
.
all
(
f
([
1
,
2
])
==
[
2
,
4
])
def
test_baddestroymap
():
...
...
@@ -349,7 +349,7 @@ def test_baddestroymap_c():
f
=
theano
.
function
([
x
],
wb2i
(
x
),
mode
=
debugmode
.
DebugMode
(
check_py_code
=
False
))
try
:
assert
n
umpy
.
all
(
f
([
1
,
2
])
==
[
2
,
4
])
assert
n
p
.
all
(
f
([
1
,
2
])
==
[
2
,
4
])
assert
False
# failed to raise error
except
debugmode
.
BadDestroyMap
:
pass
...
...
@@ -445,8 +445,8 @@ class Test_ViewMap(unittest.TestCase):
r0
,
r1
=
f
([
1
,
2
,
3
,
4
],
[
5
,
6
,
7
,
8
])
assert
n
umpy
.
all
(
r0
==
[
1
,
2
,
3
,
4
])
assert
n
umpy
.
all
(
r1
==
[
2
,
3
,
4
])
assert
n
p
.
all
(
r0
==
[
1
,
2
,
3
,
4
])
assert
n
p
.
all
(
r1
==
[
2
,
3
,
4
])
def
test_aliased_outputs_ok_output
(
self
):
# here aliased outputs is ok because they are both outputs of the
...
...
@@ -470,8 +470,8 @@ class Test_ViewMap(unittest.TestCase):
r0
,
r1
=
f
([
1
,
2
,
3
,
4
],
[
5
,
6
,
7
,
8
])
assert
n
umpy
.
all
(
r0
==
[
2
,
4
,
6
,
8
])
assert
n
umpy
.
all
(
r1
==
[
4
,
6
,
8
])
assert
n
p
.
all
(
r0
==
[
2
,
4
,
6
,
8
])
assert
n
p
.
all
(
r1
==
[
4
,
6
,
8
])
def
test_aliased_outputs_ok_shadow
(
self
):
# here the alias between outputs is ok because one of them is not used
...
...
@@ -496,7 +496,7 @@ class Test_ViewMap(unittest.TestCase):
r0
=
f
([
1
,
2
,
3
,
4
],
[
5
,
6
,
7
,
8
])
assert
n
umpy
.
all
(
r0
==
[
2
,
4
,
6
,
8
])
assert
n
p
.
all
(
r0
==
[
2
,
4
,
6
,
8
])
def
test_aliased_outputs_bad
(
self
):
# here the alias between outputs is not ok because destroying one
...
...
@@ -555,30 +555,30 @@ class Test_check_isfinite(unittest.TestCase):
g
=
theano
.
function
([
x
],
theano
.
tensor
.
log
(
x
),
mode
=
'DEBUG_MODE'
)
# this should work
f
(
n
umpy
.
log
([
3
,
4
,
5
])
.
astype
(
config
.
floatX
))
f
(
n
p
.
log
([
3
,
4
,
5
])
.
astype
(
config
.
floatX
))
# if TensorType.filter_checks_isfinite were true, these would raise
# ValueError
# if not, DebugMode will check internally, and raise InvalidValueError
# passing an invalid value as an input should trigger ValueError
self
.
assertRaises
(
debugmode
.
InvalidValueError
,
f
,
n
umpy
.
log
([
3
,
-
4
,
5
])
.
astype
(
config
.
floatX
))
n
p
.
log
([
3
,
-
4
,
5
])
.
astype
(
config
.
floatX
))
self
.
assertRaises
(
debugmode
.
InvalidValueError
,
f
,
(
n
umpy
.
asarray
([
0
,
1.0
,
0
])
/
0
)
.
astype
(
config
.
floatX
))
(
n
p
.
asarray
([
0
,
1.0
,
0
])
/
0
)
.
astype
(
config
.
floatX
))
self
.
assertRaises
(
debugmode
.
InvalidValueError
,
f
,
(
n
umpy
.
asarray
([
1.0
,
1.0
,
1.0
])
/
0
)
.
astype
(
config
.
floatX
))
(
n
p
.
asarray
([
1.0
,
1.0
,
1.0
])
/
0
)
.
astype
(
config
.
floatX
))
# generating an invalid value internally should trigger
# InvalidValueError
self
.
assertRaises
(
debugmode
.
InvalidValueError
,
g
,
n
umpy
.
asarray
([
3
,
-
4
,
5
],
dtype
=
config
.
floatX
))
n
p
.
asarray
([
3
,
-
4
,
5
],
dtype
=
config
.
floatX
))
# this should disable the exception
theano
.
tensor
.
TensorType
.
filter_checks_isfinite
=
False
theano
.
compile
.
mode
.
predefined_modes
[
'DEBUG_MODE'
]
.
check_isfinite
=
False
# insert several Inf
f
(
n
umpy
.
asarray
(
numpy
.
asarray
([
1.0
,
1.0
,
1.0
])
/
0
,
f
(
n
p
.
asarray
(
np
.
asarray
([
1.0
,
1.0
,
1.0
])
/
0
,
dtype
=
config
.
floatX
))
def
test_check_isfinite_disabled
(
self
):
...
...
@@ -587,10 +587,10 @@ class Test_check_isfinite(unittest.TestCase):
mode
=
debugmode
.
DebugMode
(
check_isfinite
=
False
))
# nan should go through
f
(
n
umpy
.
log
([
3
,
-
4
,
5
]))
f
(
n
p
.
log
([
3
,
-
4
,
5
]))
# inf should go through
infs
=
n
umpy
.
asarray
([
1.0
,
1.
,
1.
])
/
0
infs
=
n
p
.
asarray
([
1.0
,
1.
,
1.
])
/
0
# print infs
f
(
infs
)
return
...
...
@@ -721,14 +721,14 @@ class VecAsRowAndCol(gof.Op):
class
Test_preallocated_output
(
unittest
.
TestCase
):
def
setUp
(
self
):
self
.
rng
=
n
umpy
.
random
.
RandomState
(
seed
=
utt
.
fetch_seed
())
self
.
rng
=
n
p
.
random
.
RandomState
(
seed
=
utt
.
fetch_seed
())
def
test_f_contiguous
(
self
):
a
=
theano
.
tensor
.
fmatrix
(
'a'
)
b
=
theano
.
tensor
.
fmatrix
(
'b'
)
z
=
BrokenCImplementationAdd
()(
a
,
b
)
# In this test, we do not want z to be an output of the graph.
out
=
theano
.
tensor
.
dot
(
z
,
n
umpy
.
eye
(
7
))
out
=
theano
.
tensor
.
dot
(
z
,
n
p
.
eye
(
7
))
a_val
=
self
.
rng
.
randn
(
7
,
7
)
.
astype
(
'float32'
)
b_val
=
self
.
rng
.
randn
(
7
,
7
)
.
astype
(
'float32'
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论