fix some op docs

This commit is contained in:
xcnick 2021-03-14 19:49:54 +08:00
parent 2cef6a1143
commit 3ae92a5e43
3 changed files with 50 additions and 22 deletions

View File

@ -354,8 +354,7 @@ class SoftmaxCrossEntropyWithLogits(_Loss):
`labels` is int32 or int64. If `sparse` is False, the type of `labels` is the same as the type of `logits`.
Outputs:
Tensor, a tensor of the same shape as logits with the component-wise
logistic losses.
Tensor, a tensor of the same shape and type as logits with the component-wise logistic losses.
Raises:
TypeError: If `sparse` is not a bool.

View File

@ -619,8 +619,11 @@ class Squeeze(PrimitiveWithInfer):
"""
Returns a tensor with the same type but dimensions of 1 are removed based on `axis`.
If `axis` is specified, it will remove the dimensions of size 1 in the given `axis`.
It `axis` is None, it will remove all the dimensions of size 1.
Note:
The dimension index starts at 0 and must be in the range `[-input.ndim, input.ndim`.
The dimension index starts at 0 and must be in the range `[-input.ndim, input.ndim]`.
Args:
axis (Union[int, tuple(int)]): Specifies the dimension indexes of shape to be removed, which will remove
@ -1005,6 +1008,9 @@ class Split(PrimitiveWithCheck):
"""
Splits the input tensor into output_num of tensors along the given axis and output numbers.
The `input_x` tensor will be split into equally sized sub-tensors.
This requires that `input_x.shape(axis)` is divisible by `output_num`.
Args:
axis (int): Index of the split position. Default: 0.
output_num (int): The number of output tensors. Must be positive int. Default: 1.
@ -1866,8 +1872,9 @@ class Tile(PrimitiveWithInfer):
r"""
Replicates a tensor with given multiples times.
Creates a new tensor by replicating input multiples times. The dimension of
output tensor is the larger of the input tensor dimension and the length of `multiples`.
Creates a new tensor by replicating `input_x` `multiples` times. The i'th dimension of
output tensor has `input_x.shape(i) * multiples[i]` elements, and the values of `input_x`
are replicated `multiples[i]` times along the i'th dimension.
Inputs:
- **input_x** (Tensor) - 1-D or higher Tensor. Set the shape of input tensor as
@ -1880,7 +1887,6 @@ class Tile(PrimitiveWithInfer):
Outputs:
Tensor, has the same data type as the `input_x`.
- If the length of `multiples` is the same as the length of shape of `input_x`,
then the shape of their corresponding positions can be multiplied, and
the shape of Outputs is :math:`(x_1*y_1, x_2*y_2, ..., x_S*y_R)`.
@ -2581,13 +2587,22 @@ class Slice(PrimitiveWithInfer):
"""
Slices a tensor in the specified shape.
Slice the tensor 'input_x` in shape of `size` and starting at the location specified by `begin`,
The slice `begin` represents the offset in each dimension of `input_x`,
The slice `size` represents the size of the output tensor.
Note that `begin` is zero-based and `size` is one-based.
If `size[i]` is -1, all remaining elements in dimension i are included in the slice.
This is equivalent to setting :math:`size[i] = input_x.shape(i) - begin[i]`
Inputs:
- **x** (Tensor): The target tensor.
- **input_x** (Tensor): The target tensor.
- **begin** (tuple, list): The beginning of the slice. Only constant value is allowed.
- **size** (tuple, list): The size of the slice. Only constant value is allowed.
Outputs:
Tensor, the shape is : input `size`, the data type is the same as input `x`.
Tensor, the shape is : input `size`, the data type is the same as `input_x`.
Raises:
TypeError: If `begin` or `size` is neither tuple nor list.
@ -2745,6 +2760,14 @@ class Select(PrimitiveWithInfer):
selected from :math:`x` (if true) or :math:`y` (if false) based on the value of each
element.
It can be defined as:
.. math::
out_i = \begin{cases}
x_i, & \text{if } condition_i \\
y_i, & \text{otherwise}
\end{cases}
If condition is a vector, then :math:`x` and :math:`y` are higher-dimensional matrices, then it
chooses to copy that row (external dimensions) from :math:`x` and :math:`y`. If condition has
the same shape as :math:`x` and :math:`y`, you can choose to copy these elements from :math:`x`
@ -2888,19 +2911,21 @@ class StridedSlice(PrimitiveWithInfer):
before reaching the maximum location. Only constant value is allowed.
Outputs:
Tensor.
The output is explained by following example.
Tensor, The output is explained by following example.
- In the 0th dimension, begin is 1, end is 2, and strides is 1,
because :math:`1+1=2\geq2`, the interval is :math:`[1,2)`.
Thus, return the element with :math:`index = 1` in 0th dimension, i.e., [[3, 3, 3], [4, 4, 4]].
- In the 1st dimension, similarly, the interval is :math:`[0,1)`.
Based on the return value of the 0th dimension, return the element with :math:`index = 0`,
i.e., [3, 3, 3].
- In the 2nd dimension, similarly, the interval is :math:`[0,3)`.
Based on the return value of the 1st dimension, return the element with :math:`index = 0,1,2`,
i.e., [3, 3, 3].
- Finally, the output is [3, 3, 3].
In the 0th dimension, begin is 1, end is 2, and strides is 1,
because :math:`1+1=2\geq2`, the interval is :math:`[1,2)`.
Thus, return the element with :math:`index = 1` in 0th dimension, i.e., [[3, 3, 3], [4, 4, 4]].
In the 1st dimension, similarly, the interval is :math:`[0,1)`.
Based on the return value of the 0th dimension, return the element with :math:`index = 0`,
i.e., [3, 3, 3].
In the 2nd dimension, similarly, the interval is :math:`[0,3)`.
Based on the return value of the 1st dimension, return the element with :math:`index = 0,1,2`,
i.e., [3, 3, 3].
Finally, the output is [3, 3, 3].
Raises:
TypeError: If `begin_mask`, `end_mask`, `ellipsis_mask`, `new_axis_mask` or `shrink_axis_mask` is not an int.

View File

@ -246,6 +246,7 @@ class Softplus(PrimitiveWithInfer):
Softplus activation function.
Softplus is a smooth approximation to the ReLU function.
It can be used to constrain the output of a machine to always be positive.
The function is shown as follows:
.. math::
@ -2018,7 +2019,7 @@ class AvgPool(_Pool):
Average pooling operation.
Applies a 2D average pooling over an input Tensor which can be regarded as a composition of 2D input planes.
Typically the input is of shape :math:`(N_{in}, C_{in}, H_{in}, W_{in})`, AvgPool2d outputs
Typically the input is of shape :math:`(N_{in}, C_{in}, H_{in}, W_{in})`, AvgPool outputs
regional average in the :math:`(H_{in}, W_{in})`-dimension. Given kernel size
:math:`ks = (h_{ker}, w_{ker})` and stride :math:`s = (s_0, s_1)`, the operation is as follows.
@ -3928,7 +3929,10 @@ class LSTM(PrimitiveWithInfer):
class SigmoidCrossEntropyWithLogits(PrimitiveWithInfer):
r"""
Uses the given logits to compute sigmoid cross entropy.
Uses the given logits to compute sigmoid cross entropy between the target and the output.
Measures the distribution error in discrete classification tasks where each class is independent
and not mutually exclusive using cross entropy loss.
Sets input logits as `X`, input label as `Y`, output as `loss`. Then,