Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
机器未来
Paddle
提交
361bd296
P
Paddle
项目概览
机器未来
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
361bd296
编写于
1月 29, 2018
作者:
F
fengjiayi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update
上级
33ae1331
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
40 addition
and
11 deletion
+40
-11
python/paddle/v2/fluid/framework.py
python/paddle/v2/fluid/framework.py
+40
-11
未找到文件。
python/paddle/v2/fluid/framework.py
浏览文件 @
361bd296
...
@@ -240,20 +240,30 @@ class Variable(object):
...
@@ -240,20 +240,30 @@ class Variable(object):
def
__str__
(
self
):
def
__str__
(
self
):
return
self
.
to_string
(
True
)
return
self
.
to_string
(
True
)
def
to_string
(
self
,
throw_on_error
):
def
to_string
(
self
,
throw_on_error
,
with_details
=
False
):
"""
"""
Get debug string.
Get debug string.
Args:
Args:
throw_on_error(bool): True if raise an exception when self is not
throw_on_error(bool): True if raise an exception when self is not
intialized.
intialized.
with_details(bool): more details about variables and parameters
(e.g. trainable, optimize_attr, ...) will be printed when with_details is True
Returns(str): The debug string.
Returns(str): The debug string.
"""
"""
assert
isinstance
(
throw_on_error
,
bool
)
and
isinstance
(
with_details
,
bool
)
protostr
=
self
.
desc
.
serialize_to_string
()
protostr
=
self
.
desc
.
serialize_to_string
()
proto
=
framework_pb2
.
VarDesc
.
FromString
(
str
(
protostr
))
proto
=
framework_pb2
.
VarDesc
.
FromString
(
str
(
protostr
))
return
_debug_string_
(
proto
,
throw_on_error
)
res_str
=
_debug_string_
(
proto
,
throw_on_error
)
if
with_details
:
additional_attr
=
(
"error_clip"
,
"stop_gradient"
)
for
attr_name
in
additional_attr
:
res_str
+=
"%s: %s
\n
"
%
(
attr_name
,
str
(
getattr
(
self
,
attr_name
)))
return
res_str
__repr__
=
__str__
__repr__
=
__str__
...
@@ -636,7 +646,8 @@ class Block(object):
...
@@ -636,7 +646,8 @@ class Block(object):
Args:
Args:
throw_on_error(bool): raise exception when self is not initialized
throw_on_error(bool): raise exception when self is not initialized
when throw_on_error is True
when throw_on_error is True
with_details(bool): more details about paramters(e.g. trainable, optimize_attr, ...) will be printed when with_details is True
with_details(bool): more details about variables and parameters
(e.g. trainable, optimize_attr, ...) will be printed when with_details is True
Returns(str): The debug string.
Returns(str): The debug string.
...
@@ -649,7 +660,7 @@ class Block(object):
...
@@ -649,7 +660,7 @@ class Block(object):
self
.
idx
,
self
.
parent_idx
)
self
.
idx
,
self
.
parent_idx
)
for
var
in
self
.
vars
.
itervalues
():
for
var
in
self
.
vars
.
itervalues
():
res_str
+=
"
\n
vars {
\n
%s }"
%
re_add_indent
.
sub
(
res_str
+=
"
\n
vars {
\n
%s }"
%
re_add_indent
.
sub
(
r
"\n \1"
,
var
.
to_string
(
throw_on_error
))
r
"\n \1"
,
var
.
to_string
(
throw_on_error
,
with_details
))
for
op
in
self
.
ops
:
for
op
in
self
.
ops
:
res_str
+=
"
\n
ops {
\n
%s }"
%
re_add_indent
.
sub
(
res_str
+=
"
\n
ops {
\n
%s }"
%
re_add_indent
.
sub
(
r
"\n \1"
,
op
.
to_string
(
throw_on_error
))
r
"\n \1"
,
op
.
to_string
(
throw_on_error
))
...
@@ -828,7 +839,8 @@ class Program(object):
...
@@ -828,7 +839,8 @@ class Program(object):
Args:
Args:
throw_on_error(bool): raise exception when self is not initialized
throw_on_error(bool): raise exception when self is not initialized
when throw_on_error is True
when throw_on_error is True
with_details(bool): more details about paramters(e.g. trainable, optimize_attr, ...) will be printed when with_details is True
with_details(bool): more details about variables and parameters
(e.g. trainable, optimize_attr, ...) will be printed when with_details is True
Returns(str): The debug string.
Returns(str): The debug string.
...
@@ -997,12 +1009,29 @@ class Parameter(Variable):
...
@@ -997,12 +1009,29 @@ class Parameter(Variable):
def
__str__
(
self
):
def
__str__
(
self
):
return
self
.
to_string
(
True
)
return
self
.
to_string
(
True
)
def
to_string
(
self
,
throw_on_error
):
def
to_string
(
self
,
throw_on_error
,
with_details
=
False
):
res_str
=
Variable
.
to_string
(
self
,
throw_on_error
)
"""
To debug string.
Args:
throw_on_error(bool): raise exception when self is not initialized
when throw_on_error is True
with_details(bool): more details about variables and parameters
(e.g. trainable, optimize_attr, ...) will be printed when with_details is True
Returns(str): The debug string.
"""
assert
isinstance
(
throw_on_error
,
bool
)
and
isinstance
(
with_details
,
bool
)
if
with_details
:
res_str
=
Variable
.
to_string
(
self
,
throw_on_error
,
True
)
additional_attr
=
(
"trainable"
,
"optimize_attr"
,
"regularizer"
,
additional_attr
=
(
"trainable"
,
"optimize_attr"
,
"regularizer"
,
"gradient_clip_attr"
)
"gradient_clip_attr"
)
for
attr_name
in
additional_attr
:
for
attr_name
in
additional_attr
:
res_str
+=
"%s: %s
\n
"
%
(
attr_name
,
str
(
getattr
(
self
,
attr_name
)))
res_str
+=
"%s: %s
\n
"
%
(
attr_name
,
str
(
getattr
(
self
,
attr_name
)))
else
:
res_str
=
Variable
.
to_string
(
self
,
throw_on_error
,
False
)
return
res_str
return
res_str
__repr__
=
__str__
__repr__
=
__str__
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录