Skip to content

Commit ea03a22

Browse files
author
chengduo
authored
Merge pull request #11513 from chengduoZH/refine_conv3d_doc
Fix conv3d/conv3d_trans/slice/mean_iou Doc
2 parents 3a25f21 + 7b82353 commit ea03a22

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'
@@ -2152,32 +2147,36 @@ def conv2d_transpose(input,
21522147
represent height and width, respectively. The details of convolution transpose
21532148
layer, please refer to the following explanation and references
21542149
`therein <http://www.matthewzeiler.com/wp-content/uploads/2017/07/cvpr2010.pdf>`_.
2150+
If bias attribution and activation type are provided, bias is added to
2151+
the output of the convolution, and the corresponding activation function
2152+
is applied to the final result.
21552153
21562154
For each input :math:`X`, the equation is:
21572155
21582156
.. math::
21592157
2160-
Out = W \\ast X
2158+
Out = \sigma (W \\ast X + b)
21612159
2162-
In the above equation:
2160+
Where:
21632161
21642162
* :math:`X`: Input value, a tensor with NCHW format.
21652163
* :math:`W`: Filter value, a tensor with MCHW format.
2166-
* :math:`\\ast` : Convolution transpose operation.
2167-
* :math:`Out`: Output value, the shape of :math:`Out` and :math:`X` may be
2168-
different.
2164+
* :math:`\\ast`: Convolution operation.
2165+
* :math:`b`: Bias value, a 2-D tensor with shape [M, 1].
2166+
* :math:`\\sigma`: Activation function.
2167+
* :math:`Out`: Output value, the shape of :math:`Out` and :math:`X` may be different.
21692168
21702169
Example:
21712170
21722171
- Input:
21732172
2174-
Input shape: $(N, C_{in}, H_{in}, W_{in})$
2173+
Input shape: :math:`(N, C_{in}, H_{in}, W_{in})`
21752174
2176-
Filter shape: $(C_{in}, C_{out}, H_f, W_f)$
2175+
Filter shape: :math:`(C_{in}, C_{out}, H_f, W_f)`
21772176
21782177
- Output:
21792178
2180-
Output shape: $(N, C_{out}, H_{out}, W_{out})$
2179+
Output shape: :math:`(N, C_{out}, H_{out}, W_{out})`
21812180
21822181
Where
21832182
@@ -2231,10 +2230,8 @@ def conv2d_transpose(input,
22312230
Examples:
22322231
.. code-block:: python
22332232
2234-
data = fluid.layers.data(
2235-
name='data', shape=[3, 32, 32], dtype='float32')
2236-
conv2d_transpose = fluid.layers.conv2d_transpose(
2237-
input=data, num_filters=2, filter_size=3)
2233+
data = fluid.layers.data(name='data', shape=[3, 32, 32], dtype='float32')
2234+
conv2d_transpose = fluid.layers.conv2d_transpose(input=data, num_filters=2, filter_size=3)
22382235
"""
22392236
helper = LayerHelper("conv2d_transpose", **locals())
22402237
if not isinstance(input, Variable):
@@ -2314,32 +2311,36 @@ def conv3d_transpose(input,
23142311
two elements. These two elements represent height and width, respectively.
23152312
The details of convolution transpose layer, please refer to the following
23162313
explanation and references `therein <http://www.matthewzeiler.com/wp-content/uploads/2017/07/cvpr2010.pdf>`_.
2314+
If bias attribution and activation type are provided, bias is added to
2315+
the output of the convolution, and the corresponding activation function
2316+
is applied to the final result.
23172317
23182318
For each input :math:`X`, the equation is:
23192319
23202320
.. math::
23212321
2322-
Out = W \\ast X
2322+
Out = \sigma (W \\ast X + b)
23232323
23242324
In the above equation:
23252325
23262326
* :math:`X`: Input value, a tensor with NCDHW format.
23272327
* :math:`W`: Filter value, a tensor with MCDHW format.
2328-
* :math:`\\ast` : Convolution transpose operation.
2329-
* :math:`Out`: Output value, the shape of :math:`Out` and :math:`X` may be
2330-
different.
2328+
* :math:`\\ast`: Convolution operation.
2329+
* :math:`b`: Bias value, a 2-D tensor with shape [M, 1].
2330+
* :math:`\\sigma`: Activation function.
2331+
* :math:`Out`: Output value, the shape of :math:`Out` and :math:`X` may be different.
23312332
23322333
Example:
23332334
23342335
- Input:
23352336
2336-
Input shape: $(N, C_{in}, D_{in}, H_{in}, W_{in})$
2337+
Input shape: :math:`(N, C_{in}, D_{in}, H_{in}, W_{in})`
23372338
2338-
Filter shape: $(C_{in}, C_{out}, D_f, H_f, W_f)$
2339+
Filter shape: :math:`(C_{in}, C_{out}, D_f, H_f, W_f)`
23392340
23402341
- Output:
23412342
2342-
Output shape: $(N, C_{out}, D_{out}, H_{out}, W_{out})$
2343+
Output shape: :math:`(N, C_{out}, D_{out}, H_{out}, W_{out})`
23432344
23442345
Where
23452346
@@ -2394,10 +2395,8 @@ def conv3d_transpose(input,
23942395
Examples:
23952396
.. code-block:: python
23962397
2397-
data = fluid.layers.data(
2398-
name='data', shape=[3, 12, 32, 32], dtype='float32')
2399-
conv2d_transpose = fluid.layers.conv3d_transpose(
2400-
input=data, num_filters=2, filter_size=3)
2398+
data = fluid.layers.data(name='data', shape=[3, 12, 32, 32], dtype='float32')
2399+
conv3d_transpose = fluid.layers.conv3d_transpose(input=data, num_filters=2, filter_size=3)
24012400
"""
24022401
l_type = "conv3d_transpose"
24032402
helper = LayerHelper(l_type, **locals())
@@ -4745,17 +4744,18 @@ def mean_iou(input, label, num_classes):
47454744
IOU is defined as follows:
47464745
47474746
.. math::
4748-
4749-
IOU = true_positive / (true_positive + false_positive + false_negative).
4747+
4748+
IOU = \\frac{true\_positiv}{(true\_positive + false\_positive + false\_negative)}.
47504749
47514750
The predictions are accumulated in a confusion matrix and mean-IOU
47524751
is then calculated from it.
47534752
47544753
47554754
Args:
47564755
input (Variable): A Tensor of prediction results for semantic labels with type int32 or int64.
4757-
label (Variable): A Tensor of ground truth labels with type int32 or int64.
4756+
label (Variable): A Tensor of ground truth labels with type int32 or int64.
47584757
Its shape should be the same as input.
4758+
num_classes (int): The possible number of labels.
47594759
47604760
Returns:
47614761
mean_iou (Variable): A Tensor representing the mean intersection-over-union with shape [1].

0 commit comments

Comments
 (0)