Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
9d2ae407
提交
9d2ae407
authored
9月 12, 2009
作者:
James Bergstra
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
minor improvements to DebugMode
上级
5332d39d
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
55 行增加
和
10 行删除
+55
-10
debugmode.py
theano/compile/debugmode.py
+55
-10
没有找到文件。
theano/compile/debugmode.py
浏览文件 @
9d2ae407
...
...
@@ -128,20 +128,44 @@ class BadOptimization(DebugModeError):
def
str_diagnostic
(
self
):
"""Return a pretty multiline string representating the cause of the exception"""
sio
=
StringIO
()
val_str_len_limit
=
800
print
>>
sio
,
"BadOptimization Error"
,
super
(
BadOptimization
,
self
)
.
__str__
()
print
>>
sio
,
" Variable: id"
,
id
(
self
.
new_r
),
self
.
new_r
print
>>
sio
,
" Op"
,
self
.
new_r
.
owner
print
>>
sio
,
" Value Type:"
,
type
(
self
.
new_r_val
)
try
:
ssio
=
StringIO
()
print
>>
ssio
,
" Old Value shape, dtype, strides:"
,
print
>>
ssio
,
self
.
old_r_val
.
shape
,
print
>>
ssio
,
self
.
old_r_val
.
dtype
,
print
>>
ssio
,
self
.
old_r_val
.
strides
# only if all succeeds to we add anything to sio
print
>>
sio
,
ssio
.
getvalue
()
except
:
pass
str_old_r_val
=
str
(
self
.
old_r_val
)
if
len
(
str_old_r_val
)
>
80
:
print
>>
sio
,
" Old Value: "
,
str
(
self
.
old_r_val
)[:
80
],
'...'
if
len
(
str_old_r_val
)
>
val_str_len_limit
:
print
>>
sio
,
" Old Value: "
,
str
(
self
.
old_r_val
)[:
val_str_len_limit
],
'...'
else
:
print
>>
sio
,
" Old Value: "
,
str
(
self
.
old_r_val
)
try
:
ssio
=
StringIO
()
print
>>
ssio
,
" New Value shape, dtype, strides:"
,
print
>>
ssio
,
self
.
new_r_val
.
shape
,
print
>>
ssio
,
self
.
new_r_val
.
dtype
,
print
>>
ssio
,
self
.
new_r_val
.
strides
# only if all succeeds to we add anything to sio
print
>>
sio
,
ssio
.
getvalue
()
except
:
pass
str_new_r_val
=
str
(
self
.
new_r_val
)
if
len
(
str_new_r_val
)
>
80
:
print
>>
sio
,
" New Value: "
,
str
(
self
.
new_r_val
)[:
80
],
'...'
if
len
(
str_new_r_val
)
>
val_str_len_limit
:
print
>>
sio
,
" New Value: "
,
str
(
self
.
new_r_val
)[:
val_str_len_limit
],
'...'
else
:
print
>>
sio
,
" New Value: "
,
str
(
self
.
new_r_val
)
print
>>
sio
,
" Reason: "
,
str
(
self
.
reason
)
print
>>
sio
,
" Old Graph:"
print
>>
sio
,
self
.
old_graph
...
...
@@ -177,7 +201,7 @@ class BadDestroyMap(DebugModeError):
print
>>
sio
,
" value min (new-old):"
,
(
npy_new_val
-
npy_old_val
)
.
min
()
print
>>
sio
,
" value max (new-old):"
,
(
npy_new_val
-
npy_old_val
)
.
max
()
print
>>
sio
,
""
print
>>
sio
,
" Hint: this can also be caused by a deficient values_eq_approx() or __eq__() implementation
that compares node input values
"
print
>>
sio
,
" Hint: this can also be caused by a deficient values_eq_approx() or __eq__() implementation
[which compared input values]
"
return
sio
.
getvalue
()
except
Exception
,
e
:
return
str
(
e
)
...
...
@@ -220,24 +244,45 @@ class StochasticOrder(DebugModeError):
class
InvalidValueError
(
DebugModeError
):
"""Exception: some Op an output value that is inconsistent with the Type of that output"""
def
__init__
(
self
,
r
,
v
,
client_node
=
None
):
def
__init__
(
self
,
r
,
v
,
client_node
=
None
,
hint
=
'none'
):
super
(
InvalidValueError
,
self
)
.
__init__
()
self
.
r
=
r
self
.
v
=
v
self
.
client_node
=
client_node
self
.
hint
=
hint
def
__str__
(
self
):
r
,
v
=
self
.
r
,
self
.
v
type_r
=
type
(
r
)
type_r
=
r
.
type
type_v
=
type
(
v
)
v_val
=
str
(
v
)[
0
:
100
]
v_dtype
=
'N/A'
v_shape
=
'N/A'
v_min
=
'N/A'
v_max
=
'N/A'
v_isfinite
=
'N/A'
try
:
v_shape
=
v
.
shape
v_dtype
=
v
.
dtype
v_min
=
v
.
min
()
v_max
=
v
.
max
()
v_isfinite
=
numpy
.
all
(
numpy
.
isfinite
(
v
))
except
:
pass
client_node
=
self
.
client_node
hint
=
self
.
hint
return
"""InvalidValueError
type(variable) =
%(type_r)
s
variable =
%(r)
s
type(value) =
%(type_v)
s
dtype(value) =
%(v_dtype)
s
shape(value) =
%(v_shape)
s
value =
%(v_val)
s
min(value) =
%(v_min)
s
max(value) =
%(v_max)
s
isfinite =
%(v_isfinite)
s
client_node =
%(client_node)
s
hint =
%(hint)
s
"""
%
locals
()
########################
...
...
@@ -930,7 +975,7 @@ class _Linker(gof.link.LocalLinker):
# check output values for type-correctness
for
r
in
node
.
outputs
:
if
not
r
.
type
.
is_valid_value
(
storage_map
[
r
][
0
]):
raise
InvalidValueError
(
r
,
storage_map
[
r
][
0
])
raise
InvalidValueError
(
r
,
storage_map
[
r
][
0
]
,
hint
=
'perform output'
)
#if r in r_vals:
_check_inputs
(
node
,
storage_map
,
r_vals
,
dr_vals
,
active_order_set
,
...
...
@@ -963,7 +1008,7 @@ class _Linker(gof.link.LocalLinker):
for
r
in
node
.
outputs
:
# check output values for type-correctness
if
not
r
.
type
.
is_valid_value
(
storage_map
[
r
][
0
]):
raise
InvalidValueError
(
r
,
storage_map
[
r
][
0
])
raise
InvalidValueError
(
r
,
storage_map
[
r
][
0
]
,
hint
=
'c output'
)
if
thunk_py
:
assert
r
in
r_vals
#because we put it in during the thunk_py branch
...
...
@@ -1140,7 +1185,7 @@ class _Maker(FunctionMaker): #inheritance buys a few helper functions
print
>>
infolog
,
"-----------------------------------------------------"
for
j
in
xrange
(
max
(
len
(
li
),
len
(
l0
))):
if
j
>=
len
(
li
)
or
j
>=
len
(
l0
)
or
li
[
j
]
!=
l0
[
j
]:
print
>>
infolog
,
"* "
,
j
,
print
>>
infolog
,
"* "
,
j
if
j
<
len
(
li
):
msg
=
str
(
li
[
j
])
else
:
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论