fix bug of interpolate doc
This commit is contained in:
parent
d92fd418e3
commit
27904bced1
|
@ -18,6 +18,18 @@ mindspore.ops.interpolate
|
|||
- **scales** (tuple[float], 可选) - 输入shape每个维度resize的系数。 `scales` 中的数全是正数。 `scales` 的长度跟 `x` 的shape长度相同。 `scales` 和 `sizes` 同时只能指定一个。
|
||||
- **sizes** (tuple[int], 可选) - 输入shape指定轴的新维度。 `sizes` 中的数全是正数。 `scales` 和 `sizes` 同时只能指定一个。当 `mode` 是"linear"时, `sizes` 为1个int元素 :math:`(new\_width,)` 的tuple。当 `mode` 是"bilinear"时, `sizes` 为2个int元素 :math:`(new\_height, new\_width)` 的tuple。
|
||||
- **coordinate_transformation_mode** (str) - 指定进行坐标变换的方式,默认值是"align_corners", 还可选"half_pixel"和"asymmetric"。
|
||||
假如我们需要将输入Tensor的x轴进行resize。我们记 `new_i` 为resize之后的Tenosr沿x轴的第i个坐标; 记 `old_i` 为输入Tensor沿x轴的对应坐标;
|
||||
记 `new_length` 是resize之后的Tensor沿着x轴的长度, 记 `old_length` 是输入Tensor沿x轴的长度。我们可以通过下面的公式计算出来 `old_i` :
|
||||
|
||||
.. code-block::
|
||||
|
||||
old_i = new_length != 1 ? new_i * (old_length - 1) / (new_length - 1) : 0 # if set to 'align_corners'
|
||||
|
||||
old_i = new_length > 1 ? (new_x + 0.5) * old_length / new_length - 0.5 : 0 # if set to 'half_pixel'
|
||||
|
||||
old_i = new_length != 0 ? new_i * old_length / new_length : 0 # if set to 'asymmetric'
|
||||
|
||||
|
||||
- **mode** (str) - 所使用的插值方式。 目前支持"linear"和"bilinear"插值方式。默认值: "linear"。
|
||||
|
||||
|
||||
|
@ -28,11 +40,12 @@ mindspore.ops.interpolate
|
|||
**异常:**
|
||||
|
||||
- **TypeError** - `x` 不是Tensor。
|
||||
- **TypeError** - `x` 的数据类型不支持。
|
||||
- **TypeError** - `scales` 不是float类型的tuple。
|
||||
- **ValueError** - `scales` 中的数不全是正数。
|
||||
- **TypeError** - `sizes` 不是int64类型的tuple。
|
||||
- **ValueError** - `sizes` 中的数不全是正数。
|
||||
- **TypeError** - `coordinate_transformation_mode` 不是string。
|
||||
- **TypeError** - `coordinate_transformation_mode` 不在支持的列表中。
|
||||
- **ValueError** - `coordinate_transformation_mode` 不在支持的列表中。
|
||||
- **TypeError** - `mode` 不是string类型。
|
||||
- **TypeError** - `mode` 不在支持的列表中。
|
||||
- **ValueError** - `mode` 不在支持的列表中。
|
|
@ -716,6 +716,19 @@ def interpolate(x, roi=None, scales=None, sizes=None, coordinate_transformation_
|
|||
is "linear". It is 2 int elements :math:`(new\_height, new\_width)` when `mode` is "bilinear".
|
||||
coordinate_transformation_mode (string): Default is 'align_corners'. Describes how to transform the coordinate
|
||||
in the resized tensor to the coordinate in the original tensor. Other optional: 'half_pixel', 'asymmetric'.
|
||||
For example, we want to resize the original tensor along axis x. Let's denote `new_i` as the i-th coordinate
|
||||
of the resized tensor along axis x, `old_i` as the coordinate of the original tensor along axis x,
|
||||
`new_length` as the length of the resized tensor along axis x, `old_length` as the length of the original
|
||||
tensor along axis x. We compute the `old_i` via the following formula:
|
||||
|
||||
.. code-block::
|
||||
|
||||
old_i = new_length != 1 ? new_i * (old_length - 1) / (new_length - 1) : 0 # if set to 'align_corners'
|
||||
|
||||
old_i = new_length > 1 ? (new_x + 0.5) * old_length / new_length - 0.5 : 0 # if set to 'half_pixel'
|
||||
|
||||
old_i = new_length != 0 ? new_i * old_length / new_length : 0 # if set to 'asymmetric'
|
||||
|
||||
mode (string): The method used to interpolate: 'linear' | 'bilinear'. Default is 'linear'.
|
||||
|
||||
Returns:
|
||||
|
@ -726,14 +739,15 @@ def interpolate(x, roi=None, scales=None, sizes=None, coordinate_transformation_
|
|||
|
||||
Raises:
|
||||
TypeError: If `x` is not a Tensor.
|
||||
TypeError: If the data type of `x` is not supported.
|
||||
TypeError: If `scales` is not a float tuple.
|
||||
ValueError: If not all numbers in `scales` are positive.
|
||||
TypeError: If `sizes` is not a int tuple.
|
||||
TypeError: If `sizes` is not an int tuple.
|
||||
ValueError: If not all numbers in `sizes` are positive.
|
||||
TypeError: If `coordinate_transformation_mode` is not a string.
|
||||
TypeError: If `coordinate_transformation_mode` is not in the support list.
|
||||
ValueError: If `coordinate_transformation_mode` is not in the support list.
|
||||
TypeError: If `mode` is not a string.
|
||||
TypeError: If `mode` is not in the support list.
|
||||
ValueError: If `mode` is not in the support list.
|
||||
|
||||
Examples:
|
||||
>>> x = Tensor([[[1, 2, 3], [4, 5, 6]]], mindspore.float32)
|
||||
|
|
Loading…
Reference in New Issue