Skip to content

Commit d1a8498

Browse files
committed
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into update-api-reference-1
2 parents a4ee0d0 + ea03a22 commit d1a8498

File tree

2 files changed

+56
-53
lines changed

2 files changed

+56
-53
lines changed

paddle/fluid/operators/slice_op.cc

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -95,23 +95,26 @@ of that dimension. If the value passed to start or end is larger than
9595
the n (the number of elements in this dimension), it represents n.
9696
For slicing to the end of a dimension with unknown size, it is recommended
9797
to pass in INT_MAX. If axes are omitted, they are set to [0, ..., ndim-1].
98-
99-
Example 1:
100-
Given:
101-
data = [ [1, 2, 3, 4], [5, 6, 7, 8], ]
102-
axes = [0, 1]
103-
starts = [1, 0]
104-
ends = [2, 3]
105-
Then:
106-
result = [ [5, 6, 7], ]
107-
108-
Example 2:
109-
Given:
110-
data = [ [1, 2, 3, 4], [5, 6, 7, 8], ]
111-
starts = [0, 1]
112-
ends = [-1, 1000]
113-
Then:
114-
result = [ [2, 3, 4], ]
98+
Following examples will explain how slice works:
99+
100+
.. code-block:: text
101+
102+
Cast1:
103+
Given:
104+
data = [ [1, 2, 3, 4], [5, 6, 7, 8], ]
105+
axes = [0, 1]
106+
starts = [1, 0]
107+
ends = [2, 3]
108+
Then:
109+
result = [ [5, 6, 7], ]
110+
111+
Cast2:
112+
Given:
113+
data = [ [1, 2, 3, 4], [5, 6, 7, 8], ]
114+
starts = [0, 1]
115+
ends = [-1, 1000]
116+
Then:
117+
result = [ [2, 3, 4], ]
115118
)DOC");
116119
}
117120
};

python/paddle/fluid/layers/nn.py

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1373,10 +1373,8 @@ def conv2d(input,
13731373
Examples:
13741374
.. code-block:: python
13751375
1376-
data = fluid.layers.data(
1377-
name='data', shape=[3, 32, 32], dtype='float32')
1378-
conv2d = fluid.layers.conv2d(
1379-
input=data, num_filters=2, filter_size=3, act="relu")
1376+
data = fluid.layers.data(name='data', shape=[3, 32, 32], dtype='float32')
1377+
conv2d = fluid.layers.conv2d(input=data, num_filters=2, filter_size=3, act="relu")
13801378
"""
13811379

13821380
num_channels = input.shape[1]
@@ -1478,8 +1476,7 @@ def conv3d(input,
14781476
* :math:`\\ast`: Convolution operation.
14791477
* :math:`b`: Bias value, a 2-D tensor with shape [M, 1].
14801478
* :math:`\\sigma`: Activation function.
1481-
* :math:`Out`: Output value, the shape of :math:`Out` and :math:`X` may be
1482-
different.
1479+
* :math:`Out`: Output value, the shape of :math:`Out` and :math:`X` may be different.
14831480
14841481
Example:
14851482
@@ -1541,10 +1538,8 @@ def conv3d(input,
15411538
Examples:
15421539
.. code-block:: python
15431540
1544-
data = fluid.layers.data(
1545-
name='data', shape=[3, 12, 32, 32], dtype='float32')
1546-
conv2d = fluid.layers.conv3d(
1547-
input=data, num_filters=2, filter_size=3, act="relu")
1541+
data = fluid.layers.data(name='data', shape=[3, 12, 32, 32], dtype='float32')
1542+
conv3d = fluid.layers.conv3d(input=data, num_filters=2, filter_size=3, act="relu")
15481543
"""
15491544

15501545
l_type = 'conv3d'
@@ -2182,32 +2177,36 @@ def conv2d_transpose(input,
21822177
represent height and width, respectively. The details of convolution transpose
21832178
layer, please refer to the following explanation and references
21842179
`therein <http://www.matthewzeiler.com/wp-content/uploads/2017/07/cvpr2010.pdf>`_.
2180+
If bias attribution and activation type are provided, bias is added to
2181+
the output of the convolution, and the corresponding activation function
2182+
is applied to the final result.
21852183
21862184
For each input :math:`X`, the equation is:
21872185
21882186
.. math::
21892187
2190-
Out = W \\ast X
2188+
Out = \sigma (W \\ast X + b)
21912189
2192-
In the above equation:
2190+
Where:
21932191
21942192
* :math:`X`: Input value, a tensor with NCHW format.
21952193
* :math:`W`: Filter value, a tensor with MCHW format.
2196-
* :math:`\\ast` : Convolution transpose operation.
2197-
* :math:`Out`: Output value, the shape of :math:`Out` and :math:`X` may be
2198-
different.
2194+
* :math:`\\ast`: Convolution operation.
2195+
* :math:`b`: Bias value, a 2-D tensor with shape [M, 1].
2196+
* :math:`\\sigma`: Activation function.
2197+
* :math:`Out`: Output value, the shape of :math:`Out` and :math:`X` may be different.
21992198
22002199
Example:
22012200
22022201
- Input:
22032202
2204-
Input shape: $(N, C_{in}, H_{in}, W_{in})$
2203+
Input shape: :math:`(N, C_{in}, H_{in}, W_{in})`
22052204
2206-
Filter shape: $(C_{in}, C_{out}, H_f, W_f)$
2205+
Filter shape: :math:`(C_{in}, C_{out}, H_f, W_f)`
22072206
22082207
- Output:
22092208
2210-
Output shape: $(N, C_{out}, H_{out}, W_{out})$
2209+
Output shape: :math:`(N, C_{out}, H_{out}, W_{out})`
22112210
22122211
Where
22132212
@@ -2261,10 +2260,8 @@ def conv2d_transpose(input,
22612260
Examples:
22622261
.. code-block:: python
22632262
2264-
data = fluid.layers.data(
2265-
name='data', shape=[3, 32, 32], dtype='float32')
2266-
conv2d_transpose = fluid.layers.conv2d_transpose(
2267-
input=data, num_filters=2, filter_size=3)
2263+
data = fluid.layers.data(name='data', shape=[3, 32, 32], dtype='float32')
2264+
conv2d_transpose = fluid.layers.conv2d_transpose(input=data, num_filters=2, filter_size=3)
22682265
"""
22692266
helper = LayerHelper("conv2d_transpose", **locals())
22702267
if not isinstance(input, Variable):
@@ -2344,32 +2341,36 @@ def conv3d_transpose(input,
23442341
two elements. These two elements represent height and width, respectively.
23452342
The details of convolution transpose layer, please refer to the following
23462343
explanation and references `therein <http://www.matthewzeiler.com/wp-content/uploads/2017/07/cvpr2010.pdf>`_.
2344+
If bias attribution and activation type are provided, bias is added to
2345+
the output of the convolution, and the corresponding activation function
2346+
is applied to the final result.
23472347
23482348
For each input :math:`X`, the equation is:
23492349
23502350
.. math::
23512351
2352-
Out = W \\ast X
2352+
Out = \sigma (W \\ast X + b)
23532353
23542354
In the above equation:
23552355
23562356
* :math:`X`: Input value, a tensor with NCDHW format.
23572357
* :math:`W`: Filter value, a tensor with MCDHW format.
2358-
* :math:`\\ast` : Convolution transpose operation.
2359-
* :math:`Out`: Output value, the shape of :math:`Out` and :math:`X` may be
2360-
different.
2358+
* :math:`\\ast`: Convolution operation.
2359+
* :math:`b`: Bias value, a 2-D tensor with shape [M, 1].
2360+
* :math:`\\sigma`: Activation function.
2361+
* :math:`Out`: Output value, the shape of :math:`Out` and :math:`X` may be different.
23612362
23622363
Example:
23632364
23642365
- Input:
23652366
2366-
Input shape: $(N, C_{in}, D_{in}, H_{in}, W_{in})$
2367+
Input shape: :math:`(N, C_{in}, D_{in}, H_{in}, W_{in})`
23672368
2368-
Filter shape: $(C_{in}, C_{out}, D_f, H_f, W_f)$
2369+
Filter shape: :math:`(C_{in}, C_{out}, D_f, H_f, W_f)`
23692370
23702371
- Output:
23712372
2372-
Output shape: $(N, C_{out}, D_{out}, H_{out}, W_{out})$
2373+
Output shape: :math:`(N, C_{out}, D_{out}, H_{out}, W_{out})`
23732374
23742375
Where
23752376
@@ -2424,10 +2425,8 @@ def conv3d_transpose(input,
24242425
Examples:
24252426
.. code-block:: python
24262427
2427-
data = fluid.layers.data(
2428-
name='data', shape=[3, 12, 32, 32], dtype='float32')
2429-
conv2d_transpose = fluid.layers.conv3d_transpose(
2430-
input=data, num_filters=2, filter_size=3)
2428+
data = fluid.layers.data(name='data', shape=[3, 12, 32, 32], dtype='float32')
2429+
conv3d_transpose = fluid.layers.conv3d_transpose(input=data, num_filters=2, filter_size=3)
24312430
"""
24322431
l_type = "conv3d_transpose"
24332432
helper = LayerHelper(l_type, **locals())
@@ -4778,17 +4777,18 @@ def mean_iou(input, label, num_classes):
47784777
IOU is defined as follows:
47794778
47804779
.. math::
4781-
4782-
IOU = true_positive / (true_positive + false_positive + false_negative).
4780+
4781+
IOU = \\frac{true\_positiv}{(true\_positive + false\_positive + false\_negative)}.
47834782
47844783
The predictions are accumulated in a confusion matrix and mean-IOU
47854784
is then calculated from it.
47864785
47874786
47884787
Args:
47894788
input (Variable): A Tensor of prediction results for semantic labels with type int32 or int64.
4790-
label (Variable): A Tensor of ground truth labels with type int32 or int64.
4789+
label (Variable): A Tensor of ground truth labels with type int32 or int64.
47914790
Its shape should be the same as input.
4791+
num_classes (int): The possible number of labels.
47924792
47934793
Returns:
47944794
mean_iou (Variable): A Tensor representing the mean intersection-over-union with shape [1].

0 commit comments

Comments
 (0)