Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
67a6297a
P
Paddle
项目概览
BaiXuePrincess
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
67a6297a
编写于
5月 28, 2019
作者:
T
Tao Luo
提交者:
GitHub
5月 28, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update unique_name notes and examples (#17671)
test=develop
上级
f34830e2
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
71 addition
and
3 deletion
+71
-3
paddle/fluid/API.spec
paddle/fluid/API.spec
+3
-3
python/paddle/fluid/unique_name.py
python/paddle/fluid/unique_name.py
+68
-0
未找到文件。
paddle/fluid/API.spec
浏览文件 @
67a6297a
...
...
@@ -556,9 +556,9 @@ paddle.fluid.profiler.reset_profiler (ArgSpec(args=[], varargs=None, keywords=No
paddle.fluid.profiler.profiler (ArgSpec(args=['state', 'sorted_key', 'profile_path'], varargs=None, keywords=None, defaults=(None, '/tmp/profile')), ('document', 'd8db46bf9a579bec476d09dea80eb23d'))
paddle.fluid.profiler.start_profiler (ArgSpec(args=['state'], varargs=None, keywords=None, defaults=None), ('document', '88da8fb6dbebaee2f7520188a09574f9'))
paddle.fluid.profiler.stop_profiler (ArgSpec(args=['sorted_key', 'profile_path'], varargs=None, keywords=None, defaults=(None, '/tmp/profile')), ('document', 'a7500e39dd033f1e64f562e909333a8a'))
paddle.fluid.unique_name.generate (ArgSpec(args=['key'], varargs=None, keywords=None, defaults=None), ('document', '
6adf97f83acf6453d4a6a4b1070f3754
'))
paddle.fluid.unique_name.switch (ArgSpec(args=['new_generator'], varargs=None, keywords=None, defaults=(None,)), ('document', '6
adf97f83acf6453d4a6a4b1070f3754
'))
paddle.fluid.unique_name.guard (ArgSpec(args=['new_generator'], varargs=None, keywords=None, defaults=(None,)), ('document', '
6adf97f83acf6453d4a6a4b1070f375
4'))
paddle.fluid.unique_name.generate (ArgSpec(args=['key'], varargs=None, keywords=None, defaults=None), ('document', '
4d68cde4c4df8f1b8018620b4dc19b42
'))
paddle.fluid.unique_name.switch (ArgSpec(args=['new_generator'], varargs=None, keywords=None, defaults=(None,)), ('document', '6
95a6e91afbcdbafac69a069038811be
'))
paddle.fluid.unique_name.guard (ArgSpec(args=['new_generator'], varargs=None, keywords=None, defaults=(None,)), ('document', '
ead717d6d440a1eb11971695cd1727f
4'))
paddle.fluid.recordio_writer.convert_reader_to_recordio_file (ArgSpec(args=['filename', 'reader_creator', 'feeder', 'compressor', 'max_num_records', 'feed_order'], varargs=None, keywords=None, defaults=(Compressor.Snappy, 1000, None)), ('document', '65c7523e86f0c50bb729b01667f36310'))
paddle.fluid.recordio_writer.convert_reader_to_recordio_files (ArgSpec(args=['filename', 'batch_per_file', 'reader_creator', 'feeder', 'compressor', 'max_num_records', 'feed_order'], varargs=None, keywords=None, defaults=(Compressor.Snappy, 1000, None)), ('document', 'bc643f0f5f1b9db57ff0d8a57d379bd7'))
paddle.fluid.Scope Scope() -> paddle.fluid.core._Scope
...
...
python/paddle/fluid/unique_name.py
浏览文件 @
67a6297a
...
...
@@ -55,6 +55,25 @@ generator = UniqueNameGenerator()
def
generate
(
key
):
"""
Generate unique name with prefix key.
Args:
key(str): The generated name prefix. All generated name will be
started with this prefix.
Returns:
str: A unique string with the prefix key.
Examples:
.. code-block:: python
import paddle.fluid as fluid
name1 = fluid.unique_name.generate('fc')
name2 = fluid.unique_name.generate('fc')
# The result is fc_0, fc_1
print name1, name2
"""
return
generator
(
key
)
...
...
@@ -82,6 +101,29 @@ def generate_with_ignorable_key(key):
def
switch
(
new_generator
=
None
):
"""
Switch the Global namespace to a new namespace.
Args:
new_generator(None|UniqueNameGenerator): A new UniqueNameGenerator.
Returns:
UniqueNameGenerator: The previous UniqueNameGenerator.
Examples:
.. code-block:: python
import paddle.fluid as fluid
name1 = fluid.unique_name.generate('fc')
name2 = fluid.unique_name.generate('fc')
# The result is fc_0, fc_1
print name1, name2
fluid.unique_name.switch()
name2 = fluid.unique_name.generate('fc')
# The result is fc_0
print name2
"""
global
generator
old
=
generator
if
new_generator
is
None
:
...
...
@@ -93,6 +135,32 @@ def switch(new_generator=None):
@
signature_safe_contextmanager
def
guard
(
new_generator
=
None
):
"""
Change the global namespace with `with` statement.
Args:
new_generator(None|str|bytes): New name of global namespace.
Note that str in Python2 was spilted into str and bytes in Python3,
so here are two types. Default is None.
Examples:
.. code-block:: python
import paddle.fluid as fluid
with fluid.unique_name.guard():
name_1 = fluid.unique_name.generate('fc')
with fluid.unique_name.guard():
name_2 = fluid.unique_name.generate('fc')
# The result is fc_0, fc_0
print name_1, name_2
with fluid.unique_name.guard('A'):
name_1 = fluid.unique_name.generate('fc')
with fluid.unique_name.guard('B'):
name_2 = fluid.unique_name.generate('fc')
# The result is Afc_0, Bfc_0
print name_1, name_2
"""
if
isinstance
(
new_generator
,
six
.
string_types
):
new_generator
=
UniqueNameGenerator
(
new_generator
)
elif
isinstance
(
new_generator
,
six
.
binary_type
):
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录