Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleHub
提交
a5da11b6
P
PaddleHub
项目概览
PaddlePaddle
/
PaddleHub
大约 1 年 前同步成功
通知
282
Star
12117
Fork
2091
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
200
列表
看板
标记
里程碑
合并请求
4
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleHub
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
200
Issue
200
列表
看板
标记
里程碑
合并请求
4
合并请求
4
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
a5da11b6
编写于
2月 13, 2019
作者:
W
wuzewu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add logger class
上级
d481f83a
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
87 addition
and
11 deletion
+87
-11
paddle_hub/logger.py
paddle_hub/logger.py
+84
-6
paddle_hub/module.py
paddle_hub/module.py
+3
-5
未找到文件。
paddle_hub/logger.py
浏览文件 @
a5da11b6
...
...
@@ -17,9 +17,87 @@ from __future__ import division
from
__future__
import
print_function
import
logging
log_level
=
logging
.
DEBUG
logging
.
basicConfig
(
format
=
'[%(asctime)-15s] [%(levelname)8s] - %(message)s (%(filename)s:%(lineno)s)'
)
logger
=
logging
.
getLogger
(
'paddle-hub'
)
logger
.
setLevel
(
log_level
)
class
Logger
:
PLACEHOLDER
=
'%'
NOLOG
=
"NOLOG"
def
__init__
(
self
,
name
=
None
):
logging
.
basicConfig
(
format
=
'[%(asctime)-15s] [%(levelname)8s] - %(message)s'
)
if
not
name
:
name
=
"paddle-hub"
self
.
logger
=
logging
.
getLogger
(
name
)
self
.
logLevel
=
"DEBUG"
self
.
logger
.
setLevel
(
self
.
_get_logging_level
())
def
_is_no_log
(
self
):
return
self
.
getLevel
()
==
Logger
.
NOLOG
def
_get_logging_level
(
self
):
return
eval
(
"logging.%s"
%
self
.
logLevel
)
def
setLevel
(
self
,
logLevel
):
self
.
logLevel
=
logLevel
.
upper
()
if
not
self
.
_is_no_log
():
_logging_level
=
eval
(
"logging.%s"
%
self
.
logLevel
)
self
.
logger
.
setLevel
(
_logging_level
)
def
getLevel
(
self
):
return
self
.
logLevel
def
__call__
(
self
,
type
,
msg
):
def
_get_log_arr
(
msg
):
ph
=
Logger
.
PLACEHOLDER
lrspace
=
2
lc
=
rc
=
" "
*
lrspace
tbspace
=
1
msgarr
=
str
(
msg
).
split
(
"
\n
"
)
if
len
(
msgarr
)
==
1
:
return
msgarr
maxlen
=
-
1
for
text
in
msgarr
:
if
len
(
text
)
>
maxlen
:
maxlen
=
len
(
text
)
result
=
[
" "
,
ph
*
(
maxlen
+
2
+
lrspace
*
2
)]
tbline
=
"%s%s%s"
%
(
ph
,
" "
*
(
maxlen
+
lrspace
*
2
),
ph
)
for
index
in
range
(
tbspace
):
result
.
append
(
tbline
)
for
text
in
msgarr
:
text
=
"%s%s%s%s%s%s"
%
(
ph
,
lc
,
text
,
rc
,
" "
*
(
maxlen
-
len
(
text
)),
ph
)
result
.
append
(
text
)
for
index
in
range
(
tbspace
):
result
.
append
(
tbline
)
result
.
append
(
ph
*
(
maxlen
+
2
+
lrspace
*
2
))
return
result
if
self
.
_is_no_log
():
return
func
=
eval
(
"self.logger.%s"
%
type
)
for
msg
in
_get_log_arr
(
msg
):
func
(
msg
)
def
debug
(
self
,
msg
):
self
(
"debug"
,
msg
)
def
info
(
self
,
msg
):
self
(
"info"
,
msg
)
def
error
(
self
,
msg
):
self
(
"error"
,
msg
)
def
warning
(
self
,
msg
):
self
(
"warning"
,
msg
)
def
critical
(
self
,
msg
):
self
(
"critical"
,
msg
)
logger
=
Logger
()
paddle_hub/module.py
浏览文件 @
a5da11b6
...
...
@@ -173,10 +173,8 @@ class Module(object):
# remove feed fetch operator and variable
ModuleUtils
.
remove_feed_fetch_op
(
self
.
inference_program
)
# print("inference_program")
# print(self.inference_program)
print
(
"**feed_target_names**
\n
{}"
.
format
(
self
.
feed_target_names
))
print
(
"**fetch_targets**
\n
{}"
.
format
(
self
.
fetch_targets
))
logger
.
info
(
"**feed_target_names**
\n
{}"
.
format
(
self
.
feed_target_names
))
logger
.
info
(
"**fetch_targets**
\n
{}"
.
format
(
self
.
fetch_targets
))
self
.
_process_parameter
()
program
=
self
.
get_inference_program
().
clone
()
...
...
@@ -519,7 +517,7 @@ class ModuleUtils(object):
def
remove_feed_fetch_op
(
program
):
""" remove feed and fetch operator and variable for fine-tuning
"""
print
(
"remove feed fetch op"
)
logger
.
info
(
"remove feed fetch op"
)
block
=
program
.
global_block
()
need_to_remove_op_index
=
[]
for
i
,
op
in
enumerate
(
block
.
ops
):
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录