Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
机器未来
Paddle
提交
61222578
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看板
提交
61222578
编写于
6月 19, 2017
作者:
X
xuwei06
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Allow printer layer to print user provided message
For example: layer.printer(input=[x, y], format="x=%s y=%s")
上级
4d6cb5d0
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
35 addition
and
4 deletion
+35
-4
paddle/gserver/layers/PrintLayer.cpp
paddle/gserver/layers/PrintLayer.cpp
+25
-2
python/paddle/trainer/config_parser.py
python/paddle/trainer/config_parser.py
+7
-1
python/paddle/trainer_config_helpers/layers.py
python/paddle/trainer_config_helpers/layers.py
+2
-1
python/paddle/trainer_config_helpers/tests/configs/protostr/test_print_layer.protostr
..._helpers/tests/configs/protostr/test_print_layer.protostr
+1
-0
未找到文件。
paddle/gserver/layers/PrintLayer.cpp
浏览文件 @
61222578
...
...
@@ -22,10 +22,33 @@ public:
void
forward
(
PassType
passType
)
override
{
Layer
::
forward
(
passType
);
std
::
vector
<
std
::
string
>
vals
;
for
(
size_t
i
=
0
;
i
!=
inputLayers_
.
size
();
++
i
)
{
getInput
(
i
).
printValueString
(
LOG
(
INFO
),
"layer="
+
inputLayers_
[
i
]
->
getName
()
+
" "
);
std
::
ostringstream
s
;
getInput
(
i
).
printValueString
(
s
,
""
);
vals
.
push_back
(
s
.
str
());
}
size_t
pos
=
0
;
int
i
=
0
;
std
::
ostringstream
s
;
const
std
::
string
&
format
=
config_
.
user_arg
();
while
(
true
)
{
size_t
pos1
=
format
.
find
(
"%s"
,
pos
);
if
(
pos1
==
std
::
string
::
npos
)
break
;
if
(
i
>=
vals
.
size
())
{
break
;
}
s
<<
format
.
substr
(
pos
,
pos1
-
pos
)
<<
vals
[
i
];
pos
=
pos1
+
2
;
++
i
;
}
if
(
i
!=
inputLayers_
.
size
())
{
LOG
(
ERROR
)
<<
"Number of value in the format ("
<<
format
<<
") is not same as the number of inputs ("
<<
inputLayers_
.
size
()
<<
") at "
<<
getName
();
}
s
<<
format
.
substr
(
pos
);
LOG
(
INFO
)
<<
s
.
str
();
}
void
backward
(
const
UpdateCallback
&
callback
)
override
{}
...
...
python/paddle/trainer/config_parser.py
浏览文件 @
61222578
...
...
@@ -1628,8 +1628,14 @@ class SelectiveFCLayer(LayerBase):
@
config_layer
(
'print'
)
class
PrintLayer
(
LayerBase
):
def
__init__
(
self
,
name
,
inputs
):
def
__init__
(
self
,
name
,
inputs
,
format
=
None
):
super
(
PrintLayer
,
self
).
__init__
(
name
,
'print'
,
0
,
inputs
)
if
format
is
None
:
format
=
"
\n
"
.
join
([
"layer="
+
input
.
input_layer_name
+
" %s"
for
input
in
self
.
inputs
])
self
.
config
.
user_arg
=
format
@
config_layer
(
'priorbox'
)
...
...
python/paddle/trainer_config_helpers/layers.py
浏览文件 @
61222578
...
...
@@ -964,7 +964,7 @@ def fc_layer(input,
@
wrap_name_default
(
"print"
)
def
printer_layer
(
input
,
name
=
None
):
def
printer_layer
(
input
,
format
=
None
,
name
=
None
):
"""
Print the output value of input layers. This layer is useful for debugging.
...
...
@@ -982,6 +982,7 @@ def printer_layer(input, name=None):
Layer
(
name
=
name
,
format
=
format
,
type
=
LayerType
.
PRINT_LAYER
,
inputs
=
[
l
.
name
for
l
in
input
],
)
# this layer don't return anything, can not be input of other layer.
...
...
python/paddle/trainer_config_helpers/tests/configs/protostr/test_print_layer.protostr
浏览文件 @
61222578
...
...
@@ -12,6 +12,7 @@ layers {
inputs {
input_layer_name: "input"
}
user_arg: "layer=input %s"
}
input_layer_names: "input"
output_layer_names: "input"
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录