Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
726cce89
提交
726cce89
authored
7月 05, 2015
作者:
Christof Angermueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Update d3print to use GraphFormatter
上级
45363f3f
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
14 行增加
和
12 行删除
+14
-12
d3printing.py
theano/d3printing/d3printing.py
+9
-8
formatting.py
theano/d3printing/formatting.py
+4
-4
template.html
theano/d3printing/template.html
+1
-0
没有找到文件。
theano/d3printing/d3printing.py
浏览文件 @
726cce89
...
...
@@ -5,6 +5,8 @@
import
os.path
from
theano.printing
import
pydotprint
from
formatting
import
GraphFormatter
def
replace_patterns
(
x
,
replace
):
...
...
@@ -29,13 +31,13 @@ def d3dot(fct, node_colors=None, *args, **kwargs):
def
d3write
(
fct
,
path
,
*
args
,
**
kwargs
):
dot
=
d3dot
(
fct
,
*
args
,
**
kwargs
)
with
open
(
path
,
'w'
)
as
f
:
f
.
write
(
dot
)
# Convert theano graph to pydot graph and write to file
gf
=
GraphFormatter
(
*
args
,
**
kwargs
)
g
=
gf
.
to_pydot
(
fct
)
g
.
write_dot
(
path
)
def
d3print
(
fct
,
outfile
=
None
,
return_html
=
False
,
print_message
=
True
,
width
=
800
,
height
=
600
,
*
args
,
**
kwargs
):
"""Creates dynamic graph visualization using d3.js javascript library.
...
...
@@ -47,11 +49,10 @@ def d3print(fct, outfile=None, return_html=False, print_message=True,
:param *args, **kwargs: Parameters passed to pydotprint
"""
# Generate dot graph by pydotprint and write to file
dot_graph
=
d3dot
(
fct
,
*
args
,
**
kwargs
)
# Create dot file
dot_file
=
os
.
path
.
splitext
(
outfile
)[
0
]
+
'.dot'
with
open
(
dot_file
,
'w'
)
as
f
:
f
.
write
(
dot_graph
)
d3write
(
fct
,
dot_file
,
*
args
,
**
kwargs
)
# Read template HTML file and replace variables
template_file
=
os
.
path
.
join
(
os
.
path
.
dirname
(
os
.
path
.
realpath
(
__file__
)),
...
...
theano/d3printing/formatting.py
浏览文件 @
726cce89
...
...
@@ -59,9 +59,9 @@ class GraphFormatter(object):
'Elemwise'
:
'#FFAABB'
,
# dark pink
'Subtensor'
:
'#FFAAFF'
,
# purple
'Alloc'
:
'#FFAA22'
}
# orange
self
.
node_colors
=
{
'input'
:
'green'
,
'output'
:
'blue'
,
'unused'
:
'grey'
self
.
node_colors
=
{
'input'
:
'
lime
green'
,
'output'
:
'
dodger
blue'
,
'unused'
:
'
light
grey'
}
self
.
max_label_size
=
70
...
...
@@ -168,7 +168,7 @@ class GraphFormatter(object):
nw_node
=
pd
.
Node
(
astr
,
shape
=
apply_shape
)
elif
self
.
high_contrast
:
nw_node
=
pd
.
Node
(
astr
,
style
=
'filled'
,
fillcolor
=
use_color
,
shape
=
apply_shape
)
shape
=
apply_shape
,
type
=
'colored'
)
else
:
nw_node
=
pd
.
Node
(
astr
,
color
=
use_color
,
shape
=
apply_shape
)
g
.
add_node
(
nw_node
)
...
...
theano/d3printing/template.html
浏览文件 @
726cce89
...
...
@@ -146,6 +146,7 @@
var
posMax
=
[
0
,
0
];
for
(
var
nodeId
in
dotGraph
.
_nodes
)
{
var
node
=
dotGraph
.
_nodes
[
nodeId
];
node
.
value
.
label
=
node
.
id
;
node
.
value
.
pos
=
node
.
value
.
pos
.
split
(
','
).
map
(
function
(
d
)
{
return
parseInt
(
d
);});
node
.
value
.
width
=
parseInt
(
node
.
value
.
width
);
node
.
value
.
height
=
parseInt
(
node
.
value
.
height
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论