Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
cc51a643
提交
cc51a643
authored
5月 01, 2015
作者:
Frederic
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Better BadOptimization error (add max abs and rel diff values, and keep common ids in debugprint)
上级
87ad4106
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
22 行增加
和
6 行删除
+22
-6
debugmode.py
theano/compile/debugmode.py
+15
-4
printing.py
theano/printing.py
+7
-2
没有找到文件。
theano/compile/debugmode.py
浏览文件 @
cc51a643
...
@@ -290,9 +290,13 @@ class BadOptimization(DebugModeError):
...
@@ -290,9 +290,13 @@ class BadOptimization(DebugModeError):
print
>>
ssio
,
" Mean Abs Diff: "
,
numpy
.
mean
(
numpy
.
absolute
(
nv
-
print
>>
ssio
,
" Mean Abs Diff: "
,
numpy
.
mean
(
numpy
.
absolute
(
nv
-
ov
))
ov
))
print
>>
ssio
,
" Median Abs Diff: "
,
numpy
.
median
(
numpy
.
absolute
(
print
>>
ssio
,
" Median Abs Diff: "
,
numpy
.
median
(
numpy
.
absolute
(
nv
-
ov
))
nv
-
ov
))
print
>>
ssio
,
" Std Abs Diff: "
,
numpy
.
std
(
numpy
.
absolute
(
print
>>
ssio
,
" Std Abs Diff: "
,
numpy
.
std
(
numpy
.
absolute
(
nv
-
ov
))
nv
-
ov
))
arg_max_val
=
numpy
.
argmax
(
numpy
.
absolute
(
nv
-
ov
))
values_at_max
=
(
nv
.
flatten
()[
arg_max_val
],
ov
.
flatten
()[
arg_max_val
])
print
>>
ssio
,
" Value at Max Diff: "
,
values_at_max
# N.B. the maximum(..., 1e-8) protects against div by 0 when
# N.B. the maximum(..., 1e-8) protects against div by 0 when
# nv == ov == 0
# nv == ov == 0
...
@@ -304,6 +308,10 @@ class BadOptimization(DebugModeError):
...
@@ -304,6 +308,10 @@ class BadOptimization(DebugModeError):
print
>>
ssio
,
" Mean Rel Diff: "
,
numpy
.
mean
(
reldiff
)
print
>>
ssio
,
" Mean Rel Diff: "
,
numpy
.
mean
(
reldiff
)
print
>>
ssio
,
" Median Rel Diff: "
,
numpy
.
median
(
reldiff
)
print
>>
ssio
,
" Median Rel Diff: "
,
numpy
.
median
(
reldiff
)
print
>>
ssio
,
" Std Rel Diff: "
,
numpy
.
std
(
reldiff
)
print
>>
ssio
,
" Std Rel Diff: "
,
numpy
.
std
(
reldiff
)
arg_max_val
=
numpy
.
argmax
(
reldiff
)
values_at_max
=
(
nv
.
flatten
()[
arg_max_val
],
ov
.
flatten
()[
arg_max_val
])
print
>>
ssio
,
" Value at Max Diff: "
,
values_at_max
# only if all succeeds to we add anything to sio
# only if all succeeds to we add anything to sio
print
>>
sio
,
ssio
.
getvalue
()
print
>>
sio
,
ssio
.
getvalue
()
except
Exception
:
except
Exception
:
...
@@ -1559,10 +1567,13 @@ class _VariableEquivalenceTracker(object):
...
@@ -1559,10 +1567,13 @@ class _VariableEquivalenceTracker(object):
if
append_reason
:
if
append_reason
:
# N.B. compute the debugprint now, because future
# N.B. compute the debugprint now, because future
# optimizations will change the graph
# optimizations will change the graph
done
=
dict
()
self
.
reasons
[
new_r
]
.
append
((
reason
,
self
.
reasons
[
new_r
]
.
append
((
reason
,
r
,
r
,
debugprint
(
r
,
prefix
=
' '
,
depth
=
6
,
file
=
StringIO
())
.
getvalue
(),
debugprint
(
r
,
prefix
=
' '
,
depth
=
6
,
debugprint
(
new_r
,
prefix
=
' '
,
depth
=
6
,
file
=
StringIO
())
.
getvalue
()))
file
=
StringIO
(),
done
=
done
)
.
getvalue
(),
debugprint
(
new_r
,
prefix
=
' '
,
depth
=
6
,
file
=
StringIO
(),
done
=
done
)
.
getvalue
()))
self
.
replaced_by
[
r
]
.
append
((
reason
,
new_r
))
self
.
replaced_by
[
r
]
.
append
((
reason
,
new_r
))
if
r
in
self
.
equiv
:
if
r
in
self
.
equiv
:
...
...
theano/printing.py
浏览文件 @
cc51a643
...
@@ -34,7 +34,8 @@ VALID_ASSOC = set(['left', 'right', 'either'])
...
@@ -34,7 +34,8 @@ VALID_ASSOC = set(['left', 'right', 'either'])
def
debugprint
(
obj
,
depth
=-
1
,
print_type
=
False
,
def
debugprint
(
obj
,
depth
=-
1
,
print_type
=
False
,
file
=
None
,
ids
=
'CHAR'
,
stop_on_name
=
False
):
file
=
None
,
ids
=
'CHAR'
,
stop_on_name
=
False
,
done
=
None
):
"""Print a computation graph as text to stdout or a file.
"""Print a computation graph as text to stdout or a file.
:type obj: Variable, Apply, or Function instance
:type obj: Variable, Apply, or Function instance
...
@@ -53,6 +54,9 @@ def debugprint(obj, depth=-1, print_type=False,
...
@@ -53,6 +54,9 @@ def debugprint(obj, depth=-1, print_type=False,
"" - don't print an identifier
"" - don't print an identifier
:param stop_on_name: When True, if a node in the graph has a name,
:param stop_on_name: When True, if a node in the graph has a name,
we don't print anything below it.
we don't print anything below it.
:type done: None or dict
:param done: A dict where we store the ids of printed node.
Useful to have multiple call to debugprint share the ids for the same node.
:returns: string if `file` == 'str', else file arg
:returns: string if `file` == 'str', else file arg
...
@@ -80,7 +84,8 @@ def debugprint(obj, depth=-1, print_type=False,
...
@@ -80,7 +84,8 @@ def debugprint(obj, depth=-1, print_type=False,
_file
=
sys
.
stdout
_file
=
sys
.
stdout
else
:
else
:
_file
=
file
_file
=
file
done
=
dict
()
if
done
is
None
:
done
=
dict
()
results_to_print
=
[]
results_to_print
=
[]
profile_list
=
[]
profile_list
=
[]
order
=
[]
order
=
[]
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论