Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
aaa3ee65
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看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
aaa3ee65
编写于
10月 08, 2020
作者:
W
wanghuancoder
提交者:
GitHub
10月 08, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
modify doc for unique_name.guard unique_name.generate unique_name.switch, test=develop (#27605)
上级
7ca66f1e
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
19 addition
and
20 deletion
+19
-20
python/paddle/fluid/unique_name.py
python/paddle/fluid/unique_name.py
+19
-20
未找到文件。
python/paddle/fluid/unique_name.py
浏览文件 @
aaa3ee65
...
@@ -97,9 +97,9 @@ def generate(key):
...
@@ -97,9 +97,9 @@ def generate(key):
.. code-block:: python
.. code-block:: python
import paddle
.fluid as fluid
import paddle
name1 =
fluid
.unique_name.generate('fc')
name1 =
paddle.utils
.unique_name.generate('fc')
name2 =
fluid
.unique_name.generate('fc')
name2 =
paddle.utils
.unique_name.generate('fc')
print(name1, name2) # fc_0, fc_1
print(name1, name2) # fc_0, fc_1
"""
"""
return
generator
(
key
)
return
generator
(
key
)
...
@@ -154,19 +154,18 @@ def switch(new_generator=None, new_para_name_checker=None):
...
@@ -154,19 +154,18 @@ def switch(new_generator=None, new_para_name_checker=None):
.. code-block:: python
.. code-block:: python
import paddle
.fluid as fluid
import paddle
name1 =
fluid
.unique_name.generate('fc')
name1 =
paddle.utils
.unique_name.generate('fc')
name2 =
fluid
.unique_name.generate('fc')
name2 =
paddle.utils
.unique_name.generate('fc')
print(name1, name2) # fc_0, fc_1
print(name1, name2) # fc_0, fc_1
pre_generator, pre_dygraph_name_checker =
fluid
.unique_name.switch() # switch to a new anonymous namespace.
pre_generator, pre_dygraph_name_checker =
paddle.utils
.unique_name.switch() # switch to a new anonymous namespace.
name2 =
fluid
.unique_name.generate('fc')
name2 =
paddle.utils
.unique_name.generate('fc')
print(name2) # fc_0
print(name2) # fc_0
fluid
.unique_name.switch(pre_generator, pre_dygraph_name_checker) # switch back to pre_generator.
paddle.utils
.unique_name.switch(pre_generator, pre_dygraph_name_checker) # switch back to pre_generator.
name3 =
fluid
.unique_name.generate('fc')
name3 =
paddle.utils
.unique_name.generate('fc')
print(name3) # fc_2, since pre_generator has generated fc_0, fc_1.
print(name3) # fc_2, since pre_generator has generated fc_0, fc_1.
"""
"""
global
generator
global
generator
old_generator
=
generator
old_generator
=
generator
...
@@ -204,17 +203,17 @@ def guard(new_generator=None):
...
@@ -204,17 +203,17 @@ def guard(new_generator=None):
.. code-block:: python
.. code-block:: python
import paddle
.fluid as fluid
import paddle
with
fluid
.unique_name.guard():
with
paddle.utils
.unique_name.guard():
name_1 = fluid
.unique_name.generate('fc')
name_1 = paddle.utils
.unique_name.generate('fc')
with
fluid
.unique_name.guard():
with
paddle.utils
.unique_name.guard():
name_2 = fluid
.unique_name.generate('fc')
name_2 = paddle.utils
.unique_name.generate('fc')
print(name_1, name_2) # fc_0, fc_0
print(name_1, name_2) # fc_0, fc_0
with
fluid
.unique_name.guard('A'):
with
paddle.utils
.unique_name.guard('A'):
name_1 = fluid
.unique_name.generate('fc')
name_1 = paddle.utils
.unique_name.generate('fc')
with
fluid
.unique_name.guard('B'):
with
paddle.utils
.unique_name.guard('B'):
name_2 = fluid.unique_name.generate('fc')
name_2 = paddle.utils.unique_name.generate('fc')
print(name_1, name_2) # Afc_0, Bfc_0
print(name_1, name_2) # Afc_0, Bfc_0
"""
"""
if
isinstance
(
new_generator
,
six
.
string_types
):
if
isinstance
(
new_generator
,
six
.
string_types
):
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录