Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
机器未来
Paddle
提交
fbdf7791
P
Paddle
项目概览
机器未来
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
fbdf7791
编写于
4月 11, 2020
作者:
L
liym27
提交者:
GitHub
4月 11, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix example code of api data/switch_case to keep cn-doc and en-doc consistent (#23670)
上级
d265b16a
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
9 addition
and
10 deletion
+9
-10
python/paddle/fluid/data.py
python/paddle/fluid/data.py
+7
-7
python/paddle/fluid/layers/control_flow.py
python/paddle/fluid/layers/control_flow.py
+2
-3
未找到文件。
python/paddle/fluid/data.py
浏览文件 @
fbdf7791
...
@@ -40,7 +40,7 @@ def data(name, shape, dtype='float32', lod_level=0):
...
@@ -40,7 +40,7 @@ def data(name, shape, dtype='float32', lod_level=0):
`paddle.fluid.data` checks the shape and the dtype of data fed by
`paddle.fluid.data` checks the shape and the dtype of data fed by
Executor or ParallelExecutor during run time.
Executor or ParallelExecutor during run time.
To feed variable size inputs, users can set -1 on the variable
To feed variable size inputs, users can set
None or
-1 on the variable
dimension when using :code:`paddle.fluid.data`, or feed variable size
dimension when using :code:`paddle.fluid.data`, or feed variable size
inputs directly to :code:`paddle.fluid.layers.data` and PaddlePaddle
inputs directly to :code:`paddle.fluid.layers.data` and PaddlePaddle
will fit the size accordingly.
will fit the size accordingly.
...
@@ -54,14 +54,14 @@ def data(name, shape, dtype='float32', lod_level=0):
...
@@ -54,14 +54,14 @@ def data(name, shape, dtype='float32', lod_level=0):
name (str): The name/alias of the variable, see :ref:`api_guide_Name`
name (str): The name/alias of the variable, see :ref:`api_guide_Name`
for more details.
for more details.
shape (list|tuple): List|Tuple of integers declaring the shape. You can
shape (list|tuple): List|Tuple of integers declaring the shape. You can
set "None" at a dimension to indicate the dimension can be of any
set "None"
or -1
at a dimension to indicate the dimension can be of any
size. For example, it is useful to set changeable batch size as "None"
size. For example, it is useful to set changeable batch size as "None"
or -1.
dtype (np.dtype|VarType|str, optional): The type of the data. Supported
dtype (np.dtype|VarType|str, optional): The type of the data. Supported
dtype: bool, float16, float32, float64, int8, int16, int32, int64,
dtype: bool, float16, float32, float64, int8, int16, int32, int64,
uint8. Default: float32
uint8. Default: float32
.
lod_level (int, optional): The LoD level of the LoDTensor. Usually users
lod_level (int, optional): The LoD level of the LoDTensor. Usually users
don't have to set this value. For more details about when and how to
don't have to set this value. For more details about when and how to
use LoD level, see :ref:`user_guide_lod_tensor` . Default: 0
use LoD level, see :ref:`user_guide_lod_tensor` . Default: 0
.
Returns:
Returns:
Variable: The global variable that gives access to the data.
Variable: The global variable that gives access to the data.
...
@@ -76,10 +76,10 @@ def data(name, shape, dtype='float32', lod_level=0):
...
@@ -76,10 +76,10 @@ def data(name, shape, dtype='float32', lod_level=0):
# User can only feed data of the same shape to x
# User can only feed data of the same shape to x
x = fluid.data(name='x', shape=[3, 2, 1], dtype='float32')
x = fluid.data(name='x', shape=[3, 2, 1], dtype='float32')
# Creates a variable with changeable batch size.
# Creates a variable with changeable batch size
-1
.
# Users can feed data of any batch size into y,
# Users can feed data of any batch size into y,
# but size of each data sample has to be [2, 1]
# but size of each data sample has to be [2, 1]
y = fluid.data(name='y', shape=[
None
, 2, 1], dtype='float32')
y = fluid.data(name='y', shape=[
-1
, 2, 1], dtype='float32')
z = x + y
z = x + y
...
...
python/paddle/fluid/layers/control_flow.py
浏览文件 @
fbdf7791
...
@@ -2332,7 +2332,7 @@ class Switch(object):
...
@@ -2332,7 +2332,7 @@ class Switch(object):
Case and default functions can only be used inside the scope of Switch, as shown below:
Case and default functions can only be used inside the scope of Switch, as shown below:
.. code-block:: python
.. code-block:: python
'''
'''
with fluid.layers.Switch() as switch:
with fluid.layers.Switch() as switch:
with switch.case(cond1):
with switch.case(cond1):
...
@@ -3372,8 +3372,7 @@ def switch_case(branch_index, branch_fns, default=None, name=None):
...
@@ -3372,8 +3372,7 @@ def switch_case(branch_index, branch_fns, default=None, name=None):
branch_fns=[(0, fn_1), (4, fn_2), (7, fn_3)])
branch_fns=[(0, fn_1), (4, fn_2), (7, fn_3)])
exe = fluid.Executor(fluid.CPUPlace())
exe = fluid.Executor(fluid.CPUPlace())
res_1, res_2, res_3 = exe.run(main_program,
res_1, res_2, res_3 = exe.run(main_program, fetch_list=[out_1, out_2, out_3])
fetch_list=[out_1, out_2, out_3])
print(res_1) # [[1. 1.]]
print(res_1) # [[1. 1.]]
print(res_2) # [[2 2] [2 2]]
print(res_2) # [[2 2] [2 2]]
print(res_3) # [3 3 3]
print(res_3) # [3 3 3]
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录