Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
0cffdb28
提交
0cffdb28
authored
2月 28, 2012
作者:
Frederic
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Added debugprint the parameter stop_on_name.
上级
9c407da9
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
33 行增加
和
7 行删除
+33
-7
debugmode.py
theano/compile/debugmode.py
+9
-5
printing.py
theano/printing.py
+5
-2
test_printing.py
theano/tests/test_printing.py
+19
-0
没有找到文件。
theano/compile/debugmode.py
浏览文件 @
0cffdb28
...
...
@@ -502,7 +502,7 @@ def char_from_number(number):
def
debugprint
(
r
,
prefix
=
''
,
depth
=-
1
,
done
=
None
,
print_type
=
False
,
file
=
sys
.
stdout
,
print_destroy_map
=
False
,
print_view_map
=
False
,
order
=
[],
ids
=
'CHAR'
):
order
=
[],
ids
=
'CHAR'
,
stop_on_name
=
False
):
"""Print the graph leading to `r` to given depth.
:param r: Variable instance
...
...
@@ -520,6 +520,8 @@ def debugprint(r, prefix='', depth=-1, done=None, print_type=False,
int - print integer character
CHAR - print capital character
"" - don't print an identifier
:param stop_on_name: When True, if a node in the graph have a name,
we don't print anything below it.
"""
if
depth
==
0
:
...
...
@@ -594,10 +596,12 @@ def debugprint(r, prefix='', depth=-1, done=None, print_type=False,
view_map_str
,
o
)
if
not
already_printed
:
for
i
in
a
.
inputs
:
debugprint
(
i
,
prefix
+
' |'
,
depth
=
depth
-
1
,
done
=
done
,
print_type
=
print_type
,
file
=
file
,
order
=
order
,
ids
=
ids
)
if
(
not
stop_on_name
or
not
(
hasattr
(
r
,
'name'
)
and
r
.
name
is
not
None
)):
for
i
in
a
.
inputs
:
debugprint
(
i
,
prefix
+
' |'
,
depth
=
depth
-
1
,
done
=
done
,
print_type
=
print_type
,
file
=
file
,
order
=
order
,
ids
=
ids
,
stop_on_name
=
stop_on_name
)
else
:
#this is an input variable
id_str
=
get_id_str
(
r
)
...
...
theano/printing.py
浏览文件 @
0cffdb28
...
...
@@ -29,7 +29,7 @@ _logger = logging.getLogger("theano.printing")
def
debugprint
(
obj
,
depth
=-
1
,
print_type
=
False
,
file
=
None
,
ids
=
'CHAR'
):
file
=
None
,
ids
=
'CHAR'
,
stop_on_name
=
False
):
"""Print a computation graph to file
:type obj: Variable, Apply, or Function instance
...
...
@@ -46,6 +46,8 @@ def debugprint(obj, depth=-1, print_type=False,
CHAR - print capital character
CHAR - print capital character
"" - don't print an identifier
:param stop_on_name: When True, if a node in the graph have a name,
we don't print anything below it.
:returns: string if `file` == 'str', else file arg
...
...
@@ -90,7 +92,8 @@ def debugprint(obj, depth=-1, print_type=False,
raise
TypeError
(
"debugprint cannot print an object of this type"
,
obj
)
for
r
in
results_to_print
:
debugmode
.
debugprint
(
r
,
depth
=
depth
,
done
=
done
,
print_type
=
print_type
,
file
=
_file
,
order
=
order
,
ids
=
ids
)
file
=
_file
,
order
=
order
,
ids
=
ids
,
stop_on_name
=
stop_on_name
)
if
file
is
_file
:
return
file
elif
file
==
'str'
:
...
...
theano/tests/test_printing.py
浏览文件 @
0cffdb28
...
...
@@ -143,6 +143,25 @@ def test_debugprint():
assert
s
==
reference
# test ids=CHAR, stop_on_name=True
s
=
StringIO
.
StringIO
()
debugprint
(
G
,
file
=
s
,
ids
=
'CHAR'
,
stop_on_name
=
True
)
s
=
s
.
getvalue
()
# The additional white space are needed!
reference
=
"""Elemwise{add,no_inplace} [@A] ''
|Elemwise{add,no_inplace} [@B] 'C'
|Elemwise{add,no_inplace} [@C] ''
| |D [@D]
| |E [@E]
"""
if
s
!=
reference
:
print
'--'
+
s
+
'--'
print
'--'
+
reference
+
'--'
assert
s
==
reference
# test ids=
s
=
StringIO
.
StringIO
()
debugprint
(
G
,
file
=
s
,
ids
=
''
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论