Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
692aa8be
提交
692aa8be
authored
1月 27, 2011
作者:
Frederic Bastien
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
white space/indentation fix.
上级
32367dec
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
11 行增加
和
16 行删除
+11
-16
printing.py
theano/printing.py
+11
-16
没有找到文件。
theano/printing.py
浏览文件 @
692aa8be
...
@@ -71,16 +71,16 @@ def _print_fn(op, xin):
...
@@ -71,16 +71,16 @@ def _print_fn(op, xin):
for
attr
in
op
.
attrs
:
for
attr
in
op
.
attrs
:
temp
=
getattr
(
xin
,
attr
)
temp
=
getattr
(
xin
,
attr
)
if
callable
(
temp
):
if
callable
(
temp
):
pmsg
=
temp
()
pmsg
=
temp
()
else
:
else
:
pmsg
=
temp
pmsg
=
temp
print
op
.
message
,
attr
,
'='
,
pmsg
print
op
.
message
,
attr
,
'='
,
pmsg
class
Print
(
Op
):
class
Print
(
Op
):
"""This identity-like Op has the side effect of printing a message followed by its inputs
"""This identity-like Op has the side effect of printing a message followed by its inputs
when it runs. Default behaviour is to print the __str__ representation. Optionally, one
when it runs. Default behaviour is to print the __str__ representation. Optionally, one
can pass a list of the input member functions to execute, or attributes to print.
can pass a list of the input member functions to execute, or attributes to print.
@type message: String
@type message: String
@param message: string to prepend to the output
@param message: string to prepend to the output
@type attrs: list of Strings
@type attrs: list of Strings
...
@@ -122,7 +122,7 @@ class Print(Op):
...
@@ -122,7 +122,7 @@ class Print(Op):
return
(
1
,)
return
(
1
,)
class
PrinterState
(
gof
.
utils
.
scratchpad
):
class
PrinterState
(
gof
.
utils
.
scratchpad
):
def
__init__
(
self
,
props
=
{},
**
more_props
):
def
__init__
(
self
,
props
=
{},
**
more_props
):
if
isinstance
(
props
,
gof
.
utils
.
scratchpad
):
if
isinstance
(
props
,
gof
.
utils
.
scratchpad
):
self
.
__update__
(
props
)
self
.
__update__
(
props
)
...
@@ -311,9 +311,9 @@ class PPrinter:
...
@@ -311,9 +311,9 @@ class PPrinter:
i
+=
1
i
+=
1
if
output
.
name
is
not
None
or
output
in
outputs
:
if
output
.
name
is
not
None
or
output
in
outputs
:
if
output
.
name
is
None
:
if
output
.
name
is
None
:
name
=
'out[
%
i]'
%
outputs
.
index
(
output
)
name
=
'out[
%
i]'
%
outputs
.
index
(
output
)
else
:
else
:
name
=
output
.
name
name
=
output
.
name
#backport
#backport
#name = 'out[%i]' % outputs.index(output) if output.name is None else output.name
#name = 'out[%i]' % outputs.index(output) if output.name is None else output.name
current
=
output
current
=
output
...
@@ -401,14 +401,14 @@ def pydotprint(fct, outfile=os.path.join(config.compiledir,'theano.pydotprint.pn
...
@@ -401,14 +401,14 @@ def pydotprint(fct, outfile=os.path.join(config.compiledir,'theano.pydotprint.pn
except
:
except
:
print
"failed to import pydot. Yous must install pydot for this function to work."
print
"failed to import pydot. Yous must install pydot for this function to work."
return
return
g
=
pd
.
Dot
()
g
=
pd
.
Dot
()
var_str
=
{}
var_str
=
{}
all_strings
=
set
()
all_strings
=
set
()
def
var_name
(
var
):
def
var_name
(
var
):
if
var
in
var_str
:
if
var
in
var_str
:
return
var_str
[
var
]
return
var_str
[
var
]
if
var
.
name
is
not
None
:
if
var
.
name
is
not
None
:
varstr
=
'name='
+
var
.
name
+
" "
+
str
(
var
.
type
)
varstr
=
'name='
+
var
.
name
+
" "
+
str
(
var
.
type
)
elif
isinstance
(
var
,
gof
.
Constant
):
elif
isinstance
(
var
,
gof
.
Constant
):
...
@@ -483,8 +483,8 @@ def pydotprint(fct, outfile=os.path.join(config.compiledir,'theano.pydotprint.pn
...
@@ -483,8 +483,8 @@ def pydotprint(fct, outfile=os.path.join(config.compiledir,'theano.pydotprint.pn
else
:
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
))
g
.
add_edge
(
pd
.
Edge
(
apply_name
(
var
.
owner
),
astr
,
label
=
label
))
for
id
,
var
in
enumerate
(
node
.
outputs
):
for
id
,
var
in
enumerate
(
node
.
outputs
):
varstr
=
var_name
(
var
)
varstr
=
var_name
(
var
)
out
=
any
([
x
[
0
]
==
'output'
for
x
in
var
.
clients
])
out
=
any
([
x
[
0
]
==
'output'
for
x
in
var
.
clients
])
...
@@ -589,8 +589,3 @@ def pydot_var(vars, outfile=os.path.join(config.compiledir,'theano.pydotprint.pn
...
@@ -589,8 +589,3 @@ def pydot_var(vars, outfile=os.path.join(config.compiledir,'theano.pydotprint.pn
g
.
write_png
(
outfile
,
prog
=
'dot'
)
g
.
write_png
(
outfile
,
prog
=
'dot'
)
print
'The output file is available at'
,
outfile
print
'The output file is available at'
,
outfile
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论