Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Crayon鑫
Paddle
提交
2087f771
P
Paddle
项目概览
Crayon鑫
/
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看板
提交
2087f771
编写于
10月 09, 2019
作者:
Z
Zhang Ting
提交者:
hong
10月 09, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
modified doc of crop_tensor, test=develop, test=document_fix (#20203)
上级
6bc4d488
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
57 addition
and
59 deletion
+57
-59
paddle/fluid/API.spec
paddle/fluid/API.spec
+1
-1
python/paddle/fluid/layers/nn.py
python/paddle/fluid/layers/nn.py
+56
-58
未找到文件。
paddle/fluid/API.spec
浏览文件 @
2087f771
...
...
@@ -223,7 +223,7 @@ paddle.fluid.layers.relu (ArgSpec(args=['x', 'name'], varargs=None, keywords=Non
paddle.fluid.layers.selu (ArgSpec(args=['x', 'scale', 'alpha', 'name'], varargs=None, keywords=None, defaults=(None, None, None)), ('document', 'f93c61f5b0bf933cd425a64dca2c4fdd'))
paddle.fluid.layers.log (ArgSpec(args=['x', 'name'], varargs=None, keywords=None, defaults=(None,)), ('document', '02f668664e3bfc4df6c00d7363467140'))
paddle.fluid.layers.crop (ArgSpec(args=['x', 'shape', 'offsets', 'name'], varargs=None, keywords=None, defaults=(None, None, None)), ('document', 'ba3621917d5beffd3d022b88fbf6dc46'))
paddle.fluid.layers.crop_tensor (ArgSpec(args=['x', 'shape', 'offsets', 'name'], varargs=None, keywords=None, defaults=(None, None, None)), ('document', '
cb855453e3506bf54c5c013616ffddfb
'))
paddle.fluid.layers.crop_tensor (ArgSpec(args=['x', 'shape', 'offsets', 'name'], varargs=None, keywords=None, defaults=(None, None, None)), ('document', '
d460aaf35afbbeb9beea4789aa6e4343
'))
paddle.fluid.layers.rank_loss (ArgSpec(args=['label', 'left', 'right', 'name'], varargs=None, keywords=None, defaults=(None,)), ('document', '8eb36596bb43d7a907d3397c7aedbdb3'))
paddle.fluid.layers.margin_rank_loss (ArgSpec(args=['label', 'left', 'right', 'margin', 'name'], varargs=None, keywords=None, defaults=(0.1, None)), ('document', '6fc86ed23b420c8a0f6c043563cf3937'))
paddle.fluid.layers.elu (ArgSpec(args=['x', 'alpha', 'name'], varargs=None, keywords=None, defaults=(1.0, None)), ('document', '9af1926c06711eacef9e82d7a9e4d308'))
...
...
python/paddle/fluid/layers/nn.py
浏览文件 @
2087f771
...
...
@@ -10267,59 +10267,57 @@ def crop_tensor(x, shape=None, offsets=None, name=None):
.. code-block:: text
* Case 1:
Given
X = [[0, 1, 2, 0, 0]
[0, 3, 4, 0, 0]
[0, 0, 0, 0, 0]],
and
shape = [2, 2],
offsets = [0, 1],
output is:
* Case 1 (input is a 2-D Tensor):
Input:
X.shape = [3. 5]
X.data = [[0, 1, 2, 0, 0],
[0, 3, 4, 0, 0],
[0, 0, 0, 0, 0]]
Parameters:
shape = [2, 2]
offsets = [0, 1]
Output:
Out = [[1, 2],
[3, 4]]
.
* Case 2:
Given
X
= [[[0, 1, 2, 3
]
[0, 5, 6, 7]
[0, 0, 0, 0]
],
[[0, 3, 4, 5]
[0, 6, 7, 8]
[0, 0, 0, 0]]].
and
shape = [2, 2, 3]
,
offsets = [0, 0, 1]
,
output is
:
Out = [[[1, 2, 3]
[3, 4]]
* Case 2
(input is a 3-D Tensor)
:
Input:
X
.shape = [2, 3, 4
]
X.data = [[[0, 1, 2, 3],
[0, 5, 6, 7
],
[0, 0, 0, 0]],
[[0, 3, 4, 5],
[0, 6, 7, 8],
[0, 0, 0, 0]]]
Parameters:
shape = [2, 2, 3]
offsets = [0, 0, 1]
Output
:
Out = [[[1, 2, 3]
,
[5, 6, 7]],
[[3, 4, 5]
[6, 7, 8]]].
Args:
x (Variable): The input tensor variable.
shape (Variable|list|tuple of integer): The output shape is specified
by `shape`. It can be a 1-D tensor Variable or a list/tuple. If a
1-D tensor Variable, it's rank must be the same as `x`. If a
list/tuple, it's length must be the same as the rank of `x`. Each
element of list can be an integer or a tensor Variable of shape: [1].
[[3, 4, 5],
[6, 7, 8]]]
Parameters:
x (Variable): 1-D to 6-D Tensor, the data type is float32 or float64.
shape (list|tuple|Variable): The output shape is specified
by `shape`. Its data type is int32. If a list/tuple, it's length must be
the same as the dimension size of `x`. If a Variable, it shoule be a 1-D Tensor.
When it is a list, each element can be an integer or a Tensor of shape: [1].
If Variable contained, it is suitable for the case that the shape may
be changed each iteration. Only the first element of list/tuple can be
set to -1, it means that the first dimension of the output is the same
set to -1, it means that the first dimension
's size
of the output is the same
as the input.
offsets (Variable|list|tuple of integer|None): Specifies the cropping
offsets at each dimension. It can be a 1-D tensor Variable or a list/tuple.
If a 1-D tensor Variable, it's rank must be the same as `x`. If a list/tuple,
it's length must be the same as the rank of `x`. Each element of list can be
an integer or a tensor Variable of shape: [1]. If Variable contained, it is
suitable for the case that the offsets may be changed each iteration. If None,
the offsets are 0 at each dimension.
name(str|None): A name for this layer(optional). If set None, the layer
will be named automatically.
offsets (list|tuple|Variable, optional): Specifies the cropping
offsets at each dimension. Its data type is int32. If a list/tuple, it's length
must be the same as the dimension size of `x`. If a Variable, it shoule be a 1-D
Tensor. When it is a list, each element can be an integer or a Tensor of shape: [1].
If Variable contained, it is suitable for the case that the offsets may be changed
each iteration. Default: None, the offsets are 0 at each dimension.
name(str, optional): The default value is None. Normally there is no need for user to set
this property. For more information, please refer to :ref:`api_guide_Name` .
Returns:
Variable: The cropped
tensor variable
.
Variable: The cropped
Tensor has same data type with `x`
.
Raises:
ValueError: If shape is not a list, tuple or Variable.
...
...
@@ -10330,11 +10328,11 @@ def crop_tensor(x, shape=None, offsets=None, name=None):
.. code-block:: python
import paddle.fluid as fluid
x = fluid.
layers.data(name="x", shape=[
3, 5], dtype="float32")
x = fluid.
data(name="x", shape=[None,
3, 5], dtype="float32")
# x.shape = [-1, 3, 5], where -1 indicates batch size, and it will get the exact value in runtime.
# shape is a 1-D
tensor variable
crop_shape = fluid.
layers.data(name="crop_shape", shape=[3], dtype="int32", append_batch_size=False
)
# shape is a 1-D
Tensor
crop_shape = fluid.
data(name="crop_shape", shape=[3], dtype="int32"
)
crop0 = fluid.layers.crop_tensor(x, shape=crop_shape)
# crop0.shape = [-1, -1, -1], it means crop0.shape[0] = x.shape[0] in runtime.
...
...
@@ -10342,19 +10340,19 @@ def crop_tensor(x, shape=None, offsets=None, name=None):
crop1 = fluid.layers.crop_tensor(x, shape=[-1, 2, 3])
# crop1.shape = [-1, 2, 3]
# or shape is a list in which each element is a constant or
v
ariable
y = fluid.
layers.
data(name="y", shape=[3, 8, 8], dtype="float32")
dim1 = fluid.
layers.data(name="dim1", shape=[1], dtype="int32", append_batch_size=False
)
crop2 = fluid.layers.crop_tensor(y, shape=[
-1,
3, dim1, 4])
# crop2.shape = [
-1,
3, -1, 4]
# or shape is a list in which each element is a constant or
V
ariable
y = fluid.data(name="y", shape=[3, 8, 8], dtype="float32")
dim1 = fluid.
data(name="dim1", shape=[1], dtype="int32"
)
crop2 = fluid.layers.crop_tensor(y, shape=[3, dim1, 4])
# crop2.shape = [3, -1, 4]
# offsets is a 1-D
tensor variable
crop_offsets = fluid.
layers.data(name="crop_offsets", shape=[3], dtype="int32", append_batch_size=False
)
# offsets is a 1-D
Tensor
crop_offsets = fluid.
data(name="crop_offsets", shape=[3], dtype="int32"
)
crop3 = fluid.layers.crop_tensor(x, shape=[-1, 2, 3], offsets=crop_offsets)
# crop3.shape = [-1, 2, 3]
# offsets is a list in which each element is a constant or
v
ariable
offsets_var = fluid.
layers.data(name="dim1", shape=[1], dtype="int32", append_batch_size=False
)
# offsets is a list in which each element is a constant or
V
ariable
offsets_var = fluid.
data(name="dim1", shape=[1], dtype="int32"
)
crop4 = fluid.layers.crop_tensor(x, shape=[-1, 2, 3], offsets=[0, 1, offsets_var])
# crop4.shape = [-1, 2, 3]
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录