Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
e7cb39cb
提交
e7cb39cb
authored
10月 31, 2014
作者:
Frederic
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
pep8
上级
76d02f64
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
32 行增加
和
28 行删除
+32
-28
printing.py
theano/printing.py
+32
-28
没有找到文件。
theano/printing.py
浏览文件 @
e7cb39cb
...
...
@@ -107,8 +107,9 @@ def debugprint(obj, depth=-1, print_type=False,
scan_ops
=
[]
for
r
in
results_to_print
:
#Add the parent scan op to the list as well
if
hasattr
(
r
.
owner
,
'op'
)
and
isinstance
(
r
.
owner
.
op
,
theano
.
scan_module
.
scan_op
.
Scan
):
# Add the parent scan op to the list as well
if
(
hasattr
(
r
.
owner
,
'op'
)
and
isinstance
(
r
.
owner
.
op
,
theano
.
scan_module
.
scan_op
.
Scan
)):
scan_ops
.
append
(
r
)
debugmode
.
debugprint
(
r
,
depth
=
depth
,
done
=
done
,
print_type
=
print_type
,
...
...
@@ -122,7 +123,8 @@ def debugprint(obj, depth=-1, print_type=False,
for
s
in
scan_ops
:
print
>>
file
,
""
debugmode
.
debugprint
(
s
,
depth
=
depth
,
done
=
done
,
print_type
=
print_type
,
debugmode
.
debugprint
(
s
,
depth
=
depth
,
done
=
done
,
print_type
=
print_type
,
file
=
_file
,
ids
=
ids
,
scan_ops
=
scan_ops
,
stop_on_name
=
stop_on_name
)
if
hasattr
(
s
.
owner
.
op
,
'fn'
):
...
...
@@ -135,10 +137,12 @@ def debugprint(obj, depth=-1, print_type=False,
if
isinstance
(
i
.
owner
.
op
,
theano
.
scan_module
.
scan_op
.
Scan
):
scan_ops
.
append
(
i
)
debugmode
.
debugprint
(
r
=
i
,
prefix
=
new_prefix
,
depth
=
depth
,
done
=
done
,
debugmode
.
debugprint
(
r
=
i
,
prefix
=
new_prefix
,
depth
=
depth
,
done
=
done
,
print_type
=
print_type
,
file
=
file
,
ids
=
ids
,
stop_on_name
=
stop_on_name
,
prefix_child
=
new_prefix_child
,
scan_ops
=
scan_ops
)
prefix_child
=
new_prefix_child
,
scan_ops
=
scan_ops
)
if
file
is
_file
:
return
file
...
...
@@ -269,10 +273,10 @@ class OperatorPrinter:
if
(
self
.
assoc
==
'left'
and
i
!=
0
or
self
.
assoc
==
'right'
and
i
!=
max_i
):
s
=
pprinter
.
process
(
input
,
pstate
.
clone
(
precedence
=
self
.
precedence
+
1e-6
))
precedence
=
self
.
precedence
+
1e-6
))
else
:
s
=
pprinter
.
process
(
input
,
pstate
.
clone
(
precedence
=
self
.
precedence
))
precedence
=
self
.
precedence
))
input_strings
.
append
(
s
)
if
len
(
input_strings
)
==
1
:
s
=
self
.
operator
+
input_strings
[
0
]
...
...
@@ -327,8 +331,8 @@ class FunctionPrinter:
idx
=
node
.
outputs
.
index
(
output
)
name
=
self
.
names
[
idx
]
return
"
%
s(
%
s)"
%
(
name
,
", "
.
join
(
[
pprinter
.
process
(
input
,
pstate
.
clone
(
precedence
=-
1000
))
for
input
in
node
.
inputs
]))
[
pprinter
.
process
(
input
,
pstate
.
clone
(
precedence
=-
1000
))
for
input
in
node
.
inputs
]))
class
MemberPrinter
:
...
...
@@ -374,8 +378,8 @@ class DefaultPrinter:
if
node
is
None
:
return
LeafPrinter
()
.
process
(
r
,
pstate
)
return
"
%
s(
%
s)"
%
(
str
(
node
.
op
),
", "
.
join
(
[
pprinter
.
process
(
input
,
pstate
.
clone
(
precedence
=-
1000
))
for
input
in
node
.
inputs
]))
[
pprinter
.
process
(
input
,
pstate
.
clone
(
precedence
=-
1000
))
for
input
in
node
.
inputs
]))
class
LeafPrinter
:
...
...
@@ -442,7 +446,7 @@ class PPrinter:
if
output
in
inv_updates
:
name
=
str
(
inv_updates
[
output
])
strings
.
append
((
i
+
1000
,
"
%
s <-
%
s"
%
(
name
,
pprinter
.
process
(
output
))))
name
,
pprinter
.
process
(
output
))))
i
+=
1
if
output
.
name
is
not
None
or
output
in
outputs
:
if
output
.
name
is
None
:
...
...
@@ -514,13 +518,13 @@ Print to the terminal a math-like expression.
# colors not used: orange, amber#FFBF00, purple, pink,
# used by default: green, blue, grey, red
default_colorCodes
=
{
'GpuFromHost'
:
'red'
,
'HostFromGpu'
:
'red'
,
'Scan'
:
'yellow'
,
'Shape'
:
'cyan'
,
'IfElse'
:
'magenta'
,
'Elemwise'
:
'#FFAABB'
,
# dark pink
'Subtensor'
:
'#FFAAFF'
,
# purple
'Alloc'
:
'#FFAA22'
}
# orange
'HostFromGpu'
:
'red'
,
'Scan'
:
'yellow'
,
'Shape'
:
'cyan'
,
'IfElse'
:
'magenta'
,
'Elemwise'
:
'#FFAABB'
,
# dark pink
'Subtensor'
:
'#FFAAFF'
,
# purple
'Alloc'
:
'#FFAA22'
}
# orange
def
pydotprint
(
fct
,
outfile
=
None
,
...
...
@@ -633,7 +637,7 @@ def pydotprint(fct, outfile=None,
topo
=
fct
.
toposort
()
if
not
pydot_imported
:
raise
RuntimeError
(
"Failed to import pydot. You must install pydot"
" for `pydotprint` to work."
)
" for `pydotprint` to work."
)
return
g
=
pd
.
Dot
()
...
...
@@ -696,8 +700,8 @@ def pydotprint(fct, outfile=None,
varstr
=
(
input_update
[
var
]
.
variable
.
name
+
" UPDATE "
+
str
(
var
.
type
))
else
:
#a var id is needed as otherwise var with the same type will be
#merged in the graph.
#
a var id is needed as otherwise var with the same type will be
#
merged in the graph.
varstr
=
str
(
var
.
type
)
if
(
varstr
in
all_strings
)
or
with_ids
:
idx
=
' id='
+
str
(
len
(
var_str
))
...
...
@@ -726,7 +730,7 @@ def pydotprint(fct, outfile=None,
prof_str
=
''
if
mode
:
time
=
mode
.
profile_stats
[
fct
]
.
apply_time
.
get
(
node
,
0
)
#second, % total time in profiler, %fct time in profiler
#
second, % total time in profiler, %fct time in profiler
if
mode
.
local_time
==
0
:
pt
=
0
else
:
...
...
@@ -738,7 +742,7 @@ def pydotprint(fct, outfile=None,
prof_str
=
' (
%.3
fs,
%.3
f
%%
,
%.3
f
%%
)'
%
(
time
,
pt
,
pf
)
elif
profile
:
time
=
profile
.
apply_time
.
get
(
node
,
0
)
#second, %fct time in profiler
#
second, %fct time in profiler
if
profile
.
fct_callcount
==
0
:
pf
=
0
else
:
...
...
@@ -788,7 +792,7 @@ def pydotprint(fct, outfile=None,
nw_node
=
pd
.
Node
(
astr
,
shape
=
apply_shape
)
elif
high_contrast
:
nw_node
=
pd
.
Node
(
astr
,
style
=
'filled'
,
fillcolor
=
use_color
,
shape
=
apply_shape
)
shape
=
apply_shape
)
else
:
nw_node
=
pd
.
Node
(
astr
,
color
=
use_color
,
shape
=
apply_shape
)
g
.
add_node
(
nw_node
)
...
...
@@ -819,7 +823,7 @@ def pydotprint(fct, outfile=None,
elif
var
.
name
or
not
compact
:
g
.
add_edge
(
pd
.
Edge
(
varstr
,
astr
,
label
=
label
))
else
:
#no name, so we don't make a var ellipse
#
no name, so we don't make a var ellipse
g
.
add_edge
(
pd
.
Edge
(
apply_name
(
var
.
owner
),
astr
,
label
=
label
))
for
id
,
var
in
enumerate
(
node
.
outputs
):
...
...
@@ -902,7 +906,7 @@ def pydotprint_variables(vars,
'''
warnings
.
warn
(
"pydotprint_variables() is deprecated."
" Use pydotprint() instead."
)
" Use pydotprint() instead."
)
if
colorCodes
is
None
:
colorCodes
=
default_colorCodes
...
...
@@ -986,7 +990,7 @@ def pydotprint_variables(vars,
g
.
add_node
(
pd
.
Node
(
varastr
))
elif
high_contrast
:
g
.
add_node
(
pd
.
Node
(
varastr
,
style
=
'filled'
,
fillcolor
=
'green'
))
fillcolor
=
'green'
))
else
:
g
.
add_node
(
pd
.
Node
(
varastr
,
color
=
'green'
))
else
:
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论