Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
1ee77841
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 1 年 前同步成功
通知
2298
Star
20931
Fork
5422
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1423
列表
看板
标记
里程碑
合并请求
543
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1,423
Issue
1,423
列表
看板
标记
里程碑
合并请求
543
合并请求
543
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
1ee77841
编写于
3月 06, 2018
作者:
Q
qiaolongfei
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add get_program_cache_key function
上级
b63901f5
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
23 addition
and
7 deletion
+23
-7
python/paddle/fluid/executor.py
python/paddle/fluid/executor.py
+22
-6
python/paddle/fluid/tests/unittests/test_learning_rate_decay.py
.../paddle/fluid/tests/unittests/test_learning_rate_decay.py
+1
-1
未找到文件。
python/paddle/fluid/executor.py
浏览文件 @
1ee77841
...
...
@@ -163,6 +163,22 @@ def fetch_var(name, scope=None, return_numpy=True):
return
tensor
def
get_program_cache_key
(
feed
,
fetch_list
):
feed_var_names
=
feed
.
keys
()
def
to_name_str
(
var
):
if
isinstance
(
var
,
Variable
):
return
var
.
desc
.
name
()
elif
isinstance
(
var
,
str
):
return
var
else
:
raise
TypeError
(
str
(
var
)
+
" should be Variable or str"
)
fetch_var_names
=
map
(
to_name_str
,
fetch_list
)
return
str
(
feed_var_names
+
fetch_var_names
)
class
Executor
(
object
):
def
__init__
(
self
,
places
):
if
not
isinstance
(
places
,
list
)
and
not
isinstance
(
places
,
tuple
):
...
...
@@ -232,12 +248,13 @@ class Executor(object):
Python executor takes a program, add feed operators and fetch operators to this program according
to feed map and fetch_list. Feed map provides input data for the program. fetch_list provides
the variables that user want to get after program run. Note: the executor will run all
the variables
(or names)
that user want to get after program run. Note: the executor will run all
operators in the program but not only the operators dependent by the fetch_list
:param program: the program that need to run, if not provied, then default_main_program will be used.
:param feed: feed variable map, e.g. {"image": ImageData, "label": LableData}
:param fetch_list: a list of variable that user want to get, run will return them according to this list.
:param fetch_list: a list of variable or variable names that user want to get, run will return them according
to this list.
:param feed_var_name: the name for the input variable of feed Operator.
:param fetch_var_name: the name for the output variable of feed Operator.
:param scope: the scope used to run this program, you can switch it to different scope. default is global_scope
...
...
@@ -247,6 +264,8 @@ class Executor(object):
"""
if
feed
is
None
:
feed
=
{}
if
not
isinstance
(
feed
,
dict
):
raise
TypeError
(
"feed should be a map"
)
if
fetch_list
is
None
:
fetch_list
=
[]
...
...
@@ -260,10 +279,7 @@ class Executor(object):
scope
=
global_scope
()
program_cache
=
None
feed_var_names
=
feed
.
keys
()
fetch_var_names
=
[
var
.
desc
.
name
()
for
var
in
fetch_list
]
program_cache_key
=
str
(
feed_var_names
+
fetch_var_names
)
program_cache_key
=
get_program_cache_key
(
feed
,
fetch_list
)
if
use_program_cache
:
# find program cache by cache_key
...
...
python/paddle/fluid/tests/unittests/test_learning_rate_decay.py
浏览文件 @
1ee77841
...
...
@@ -89,7 +89,7 @@ class TestLearningRateDecay(unittest.TestCase):
exe
.
run
(
fluid
.
default_startup_program
())
for
step
in
range
(
10
):
lr_val
,
=
exe
.
run
(
fluid
.
default_main_program
(),
feed
=
[]
,
feed
=
{}
,
fetch_list
=
[
decayed_lr
])
python_decayed_lr
=
python_decay_fn
(
global_step
=
float
(
step
),
**
kwargs
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录