Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleSlim
提交
69d18ea3
P
PaddleSlim
项目概览
PaddlePaddle
/
PaddleSlim
1 年多 前同步成功
通知
51
Star
1434
Fork
344
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
53
列表
看板
标记
里程碑
合并请求
16
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleSlim
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
53
Issue
53
列表
看板
标记
里程碑
合并请求
16
合并请求
16
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
69d18ea3
编写于
11月 04, 2019
作者:
B
baiyfbupt
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix train logit
上级
593094fd
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
19 addition
and
25 deletion
+19
-25
paddleslim/dist/mp_distiller.py
paddleslim/dist/mp_distiller.py
+19
-25
未找到文件。
paddleslim/dist/mp_distiller.py
浏览文件 @
69d18ea3
...
...
@@ -67,8 +67,7 @@ class Knowledge(object):
assert
(
len
(
self
.
path
)
==
4
and
isinstance
(
self
.
path
[
0
],
str
)
and
isinstance
(
self
.
path
[
1
],
str
)
and
isinstance
(
self
.
path
[
2
],
str
)
and
isinstance
(
self
.
path
[
3
],
str
)
isinstance
(
self
.
path
[
2
],
str
)
and
isinstance
(
self
.
path
[
3
],
str
)
),
"path should contains four str, ['local hadoop home', 'fs.default.name', 'hadoop.job.ugi', 'FS path']"
hadoop_home
=
self
.
path
[
0
]
...
...
@@ -104,8 +103,8 @@ class Knowledge(object):
np
.
save
(
file_path
,
data
)
self
.
file_cnt
+=
1
self
.
client
.
upload
(
self
.
path
[
3
],
file_path
)
logger
.
info
(
'{}.npy pushed to HDFS/AFS: {}'
.
format
(
file_name
,
self
.
path
[
3
]))
logger
.
info
(
'{}.npy pushed to HDFS/AFS: {}'
.
format
(
file_name
,
self
.
path
[
3
]))
elif
self
.
write_type
==
'LocalFS'
:
file_name
=
'knowledge_'
+
str
(
self
.
file_cnt
)
...
...
@@ -116,6 +115,7 @@ class Knowledge(object):
else
:
self
.
knowledge_queue
.
put
(
data
)
logger
.
info
(
'{} pushed to Queue'
.
format
(
file_name
))
def
run
(
self
,
teacher_program
,
exe
,
place
,
scope
,
reader
,
inputs
,
outputs
,
call_back
):
...
...
@@ -151,42 +151,36 @@ class Knowledge(object):
compiled_teacher_program
=
fluid
.
compiler
.
CompiledProgram
(
teacher_program
)
self
.
file_cnt
=
0
if
isinstance
(
reader
,
Variable
)
or
(
isinstance
(
reader
,
DataLoaderBase
)
and
(
not
reader
.
iterable
)):
if
isinstance
(
reader
,
Variable
)
or
(
isinstance
(
reader
,
DataLoaderBase
)
and
(
not
reader
.
iterable
)):
reader
.
start
()
try
:
batch_id
=
0
while
True
:
logits
=
exe
.
run
(
compiled_teacher_program
,
scope
=
scope
,
fetch_list
=
outputs
,
feed
=
None
)
logits
=
exe
.
run
(
compiled_teacher_program
,
scope
=
scope
,
fetch_list
=
outputs
,
feed
=
None
)
knowledge
=
dict
()
for
index
,
array
in
enumerate
(
logits
):
knowledge
[
self
.
items
[
index
]]
=
array
if
batch_id
%
1
==
0
:
logger
.
info
(
'infer finish iter {}'
.
format
(
batch_id
))
self
.
_write
(
knowledge
)
except
EOFException
:
reader
.
reset
()
else
:
feeder
=
fluid
.
DataFeeder
(
feed_list
=
inputs
,
place
=
place
,
program
=
teacher_program
)
if
not
isinstance
(
reader
,
DataLoaderBase
):
feeder
=
fluid
.
DataFeeder
(
feed_list
=
inputs
,
place
=
place
,
program
=
teacher_program
)
for
batch_id
,
data
in
enumerate
(
reader
()):
feed
=
feeder
.
feed
(
data
)
logits
=
exe
.
run
(
compiled_teacher_program
,
scope
=
scope
,
fetch_list
=
outputs
,
feed
=
feed
)
if
not
isinstance
(
reader
,
DataLoaderBase
):
data
=
feeder
.
feed
(
data
)
logits
=
exe
.
run
(
compiled_teacher_program
,
scope
=
scope
,
fetch_list
=
outputs
,
feed
=
data
)
knowledge
=
dict
()
for
index
,
array
in
enumerate
(
logits
):
knowledge
[
self
.
items
[
index
]]
=
array
if
batch_id
%
1
==
0
:
logger
.
info
(
'infer finish iter {}'
.
format
(
batch_id
))
self
.
_write
(
knowledge
)
return
True
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录