Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PARL
提交
5054efed
P
PARL
项目概览
PaddlePaddle
/
PARL
通知
67
Star
3
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
18
列表
看板
标记
里程碑
合并请求
3
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PARL
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
18
Issue
18
列表
看板
标记
里程碑
合并请求
3
合并请求
3
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
5054efed
编写于
12月 23, 2019
作者:
L
LI Yunxiang
提交者:
Bo Zhou
12月 23, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix compiled_program restore (#192)
上级
cb4b3852
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
25 addition
and
4 deletion
+25
-4
parl/core/fluid/agent.py
parl/core/fluid/agent.py
+2
-0
parl/core/fluid/plutils/compiler.py
parl/core/fluid/plutils/compiler.py
+7
-4
parl/core/fluid/tests/agent_base_test_.py
parl/core/fluid/tests/agent_base_test_.py
+16
-0
未找到文件。
parl/core/fluid/agent.py
浏览文件 @
5054efed
...
...
@@ -212,6 +212,8 @@ class Agent(AgentBase):
if
program
is
None
:
program
=
self
.
learn_program
if
type
(
program
)
is
fluid
.
compiler
.
CompiledProgram
:
program
=
program
.
_init_program
dirname
=
'/'
.
join
(
save_path
.
split
(
'/'
)[:
-
1
])
filename
=
save_path
.
split
(
'/'
)[
-
1
]
fluid
.
io
.
load_params
(
...
...
parl/core/fluid/plutils/compiler.py
浏览文件 @
5054efed
...
...
@@ -40,7 +40,10 @@ def compile(program, loss=None):
build_strategy
=
fluid
.
BuildStrategy
()
build_strategy
.
reduce_strategy
=
fluid
.
BuildStrategy
.
ReduceStrategy
.
Reduce
return
fluid
.
compiler
.
CompiledProgram
(
program
).
with_data_parallel
(
loss_name
=
loss_name
,
exec_strategy
=
exec_strategy
,
build_strategy
=
build_strategy
)
compiled_program
=
fluid
.
compiler
.
CompiledProgram
(
program
).
with_data_parallel
(
loss_name
=
loss_name
,
exec_strategy
=
exec_strategy
,
build_strategy
=
build_strategy
)
compiled_program
.
_init_program
=
program
return
compiled_program
parl/core/fluid/tests/agent_base_test_.py
浏览文件 @
5054efed
...
...
@@ -116,6 +116,22 @@ class AgentBaseTest(unittest.TestCase):
current_output
=
another_agent
.
predict
(
obs
)
np
.
testing
.
assert_equal
(
current_output
,
previous_output
)
def
test_compiled_restore
(
self
):
agent
=
TestAgent
(
self
.
algorithm
)
agent
.
learn_program
=
parl
.
compile
(
agent
.
learn_program
)
obs
=
np
.
random
.
random
([
3
,
10
]).
astype
(
'float32'
)
previous_output
=
agent
.
predict
(
obs
)
save_path1
=
'./model.ckpt'
agent
.
save
(
save_path1
)
agent
.
restore
(
save_path1
)
# a new agent instance
another_agent
=
TestAgent
(
self
.
algorithm
)
another_agent
.
learn_program
=
parl
.
compile
(
another_agent
.
learn_program
)
another_agent
.
restore
(
save_path1
)
current_output
=
another_agent
.
predict
(
obs
)
np
.
testing
.
assert_equal
(
current_output
,
previous_output
)
if
__name__
==
'__main__'
:
unittest
.
main
()
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录