未验证 提交 c34812ac 编写于 作者: I Infinity_lee 提交者: GitHub

fix boardcasting superlink (#48434)

* fix boardcasting superlink

* Update bitwise_op.cc

* fix typo errors(from 48186)

* Update python/paddle/distribution/uniform.py
Co-authored-by: NLigoml <39876205+Ligoml@users.noreply.github.com>

* Update math.py

* Update math.py

* refix

* Update logic.py

* BaseTransform api doc; test=docs_preview

* Update python/paddle/vision/transforms/transforms.py

* for text block; test=docs_preview

* Update transforms.py
Co-authored-by: NLigoml <39876205+Ligoml@users.noreply.github.com>
上级 4a66e7cf
......@@ -48,7 +48,9 @@ It operates ``%s`` on Tensor ``X`` and ``Y`` .
%s
.. note::
``paddle.%s`` supports broadcasting. If you want know more about broadcasting, please refer to :ref:`user_guide_broadcasting`.
``paddle.%s`` supports broadcasting. If you want know more about broadcasting, please refer to please refer to `Introduction to Tensor`_ .
.. _Introduction to Tensor: ../../guides/beginner/tensor_en.html#chapter5-broadcasting-of-tensor.
)DOC",
comment.type,
comment.equation,
......
......@@ -49,7 +49,12 @@ class Uniform(distribution.Distribution):
* :math:`Z`: is the normalizing constant.
The parameters `low` and `high` must be shaped in a way that supports
:ref:`user_guide_broadcasting` (e.g., `high - low` is a valid operation).
`Boardcasting` (e.g., `high - low` is a valid operation).
Note:
If you want know more about broadcasting, please refer to `Introduction to Tensor`_ .
.. _Introduction to Tensor: ../../guides/beginner/tensor_en.html#chapter5-broadcasting-of-tensor
Args:
low(int|float|list|tuple|numpy.ndarray|Tensor): The lower boundary of
......
......@@ -2005,8 +2005,10 @@ def complex(real, imag, name=None):
Returns:
Tensor: The output tensor. The data type is 'complex64' or 'complex128', with the same precision as ``real`` and ``imag``.
**Note**:
``paddle.complex`` supports broadcasting. If you want know more about broadcasting, please refer to :ref:`user_guide_broadcasting` .
Note:
``paddle.complex`` supports broadcasting. If you want know more about broadcasting, please refer to `Introduction to Tensor`_ .
.. _Introduction to Tensor: ../../guides/beginner/tensor_en.html#chapter5-broadcasting-of-tensor
Examples:
.. code-block:: python
......
......@@ -96,7 +96,9 @@ def logical_and(x, y, out=None, name=None):
out = x \&\& y
Note:
``paddle.logical_and`` supports broadcasting. If you want know more about broadcasting, please refer to :ref:`user_guide_broadcasting`.
``paddle.logical_and`` supports broadcasting. If you want know more about broadcasting, please refer to `Introduction to Tensor`_ .
.. _Introduction to Tensor: ../../guides/beginner/tensor_en.html#chapter5-broadcasting-of-tensor
Args:
x (Tensor): the input tensor, it's data type should be one of bool, int8, int16, in32, in64, float32, float64.
......@@ -136,7 +138,9 @@ def logical_or(x, y, out=None, name=None):
out = x || y
Note:
``paddle.logical_or`` supports broadcasting. If you want know more about broadcasting, please refer to :ref:`user_guide_broadcasting`.
``paddle.logical_or`` supports broadcasting. If you want know more about broadcasting, please refer to `Introduction to Tensor`_ .
.. _Introduction to Tensor: ../../guides/beginner/tensor_en.html#chapter5-broadcasting-of-tensor
Args:
x (Tensor): the input tensor, it's data type should be one of bool, int8, int16, in32, in64, float32, float64.
......@@ -178,7 +182,9 @@ def logical_xor(x, y, out=None, name=None):
out = (x || y) \&\& !(x \&\& y)
Note:
``paddle.logical_xor`` supports broadcasting. If you want know more about broadcasting, please refer to :ref:`user_guide_broadcasting`.
``paddle.logical_xor`` supports broadcasting. If you want know more about broadcasting, please refer to `Introduction to Tensor`_ .
.. _Introduction to Tensor: ../../guides/beginner/tensor_en.html#chapter5-broadcasting-of-tensor
Args:
x (Tensor): the input tensor, it's data type should be one of bool, int8, int16, in32, in64, float32, float64.
......@@ -221,6 +227,11 @@ def logical_not(x, out=None, name=None):
out = !x
Note:
``paddle.logical_not`` supports broadcasting. If you want know more about broadcasting, please refer to `Introduction to Tensor`_ .
.. _Introduction to Tensor: ../../guides/beginner/tensor_en.html#chapter5-broadcasting-of-tensor
Args:
x(Tensor): Operand of logical_not operator. Must be a Tensor of type bool, int8, int16, in32, in64, float32, or float64.
out(Tensor): The ``Tensor`` that specifies the output of the operator, which can be any ``Tensor`` that has been created in the program. The default value is None, and a new ``Tensor` will be created to save the output.
......
......@@ -420,7 +420,9 @@ def pow(x, y, name=None):
out = x^{y}
Note:
``paddle.pow`` supports broadcasting. If you want know more about broadcasting, please refer to :ref:`user_guide_broadcasting` .
``paddle.pow`` supports broadcasting. If you want know more about broadcasting, please refer to `Introduction to Tensor`_ .
.. _Introduction to Tensor: ../../guides/beginner/tensor_en.html#chapter5-broadcasting-of-tensors
Args:
......@@ -679,7 +681,9 @@ def subtract(x, y, name=None):
out = x - y
Note:
``paddle.subtract`` supports broadcasting. If you want know more about broadcasting, please refer to :ref:`user_guide_broadcasting` .
``paddle.subtract`` supports broadcasting. If you want know more about broadcasting, please refer to `Introduction to Tensor`_ .
.. _Introduction to Tensor: ../../guides/beginner/tensor_en.html#chapter5-broadcasting-of-tensor
Args:
x (Tensor): the input tensor, it's data type should be float32, float64, int32, int64.
......@@ -773,7 +777,9 @@ def divide(x, y, name=None):
out = x / y
Note:
``paddle.divide`` supports broadcasting. If you want know more about broadcasting, please refer to :ref:`user_guide_broadcasting` .
``paddle.divide`` supports broadcasting. If you want know more about broadcasting, please refer to `Introduction to Tensor`_ .
.. _Introduction to Tensor: ../../guides/beginner/tensor_en.html#chapter5-broadcasting-of-tensor
Args:
x (Tensor): the input tensor, it's data type should be float32, float64, int32, int64.
......@@ -817,7 +823,10 @@ def floor_divide(x, y, name=None):
out = trunc(x / y)
Note:
``paddle.floor_divide`` supports broadcasting. If you want know more about broadcasting, please refer to :ref:`user_guide_broadcasting` .
``paddle.floor_divide`` supports broadcasting. If you want know more about broadcasting, please refer to `Introduction to Tensor`_ .
.. _Introduction to Tensor: ../../guides/beginner/tensor_en.html#chapter5-broadcasting-of-tensor
Also note that the name ``floor_divide`` can be misleading, as the quotinents are actually rounded toward zero, not toward negative infinite.
Args:
......@@ -859,7 +868,9 @@ def remainder(x, y, name=None):
out = x \% y
Note:
``paddle.remainder`` supports broadcasting. If you want know more about broadcasting, please refer to :ref:`user_guide_broadcasting` .
``paddle.remainder`` supports broadcasting. If you want know more about broadcasting, please refer to `Introduction to Tensor`_ .
.. _Introduction to Tensor: ../../guides/beginner/tensor_en.html#chapter5-broadcasting-of-tensor
Args:
x (Tensor): the input tensor, it's data type should be float16, float32, float64, int32, int64.
......@@ -924,7 +935,9 @@ def multiply(x, y, name=None):
out = x * y
Note:
``paddle.multiply`` supports broadcasting. If you would like to know more about broadcasting, please refer to :ref:`user_guide_broadcasting`.
``paddle.multiply`` supports broadcasting. If you would like to know more about broadcasting, please refer to `Introduction to Tensor`_ .
.. _Introduction to Tensor: ../../guides/beginner/tensor_en.html#chapter5-broadcasting-of-tensor
Args:
x (Tensor): the input tensor, its data type should be one of float32, float64, int32, int64, bool.
......@@ -980,7 +993,9 @@ def maximum(x, y, name=None):
out = max(x, y)
Note:
``paddle.maximum`` supports broadcasting. If you want know more about broadcasting, please refer to :ref:`user_guide_broadcasting` .
``paddle.maximum`` supports broadcasting. If you want know more about broadcasting, please refer to `Introduction to Tensor`_ .
.. _Introduction to Tensor: ../../guides/beginner/tensor_en.html#chapter5-broadcasting-of-tensor
Args:
x (Tensor): the input tensor, it's data type should be float32, float64, int32, int64.
......@@ -1046,7 +1061,9 @@ def minimum(x, y, name=None):
out = min(x, y)
Note:
``paddle.minimum`` supports broadcasting. If you want know more about broadcasting, please refer to :ref:`user_guide_broadcasting` .
``paddle.minimum`` supports broadcasting. If you want know more about broadcasting, please refer to `Introduction to Tensor`_ .
.. _Introduction to Tensor: ../../guides/beginner/tensor_en.html#chapter5-broadcasting-of-tensor
Args:
x (Tensor): the input tensor, it's data type should be float32, float64, int32, int64.
......@@ -1114,7 +1131,9 @@ def fmax(x, y, name=None):
out = fmax(x, y)
Note:
``paddle.fmax`` supports broadcasting. If you want know more about broadcasting, please refer to :ref:`user_guide_broadcasting` .
``paddle.fmax`` supports broadcasting. If you want know more about broadcasting, please refer to `Introduction to Tensor`_ .
.. _Introduction to Tensor: ../../guides/beginner/tensor_en.html#chapter5-broadcasting-of-tensor
Args:
x (Tensor): the input tensor, it's data type should be float16, float32, float64, int32, int64.
......@@ -1182,7 +1201,9 @@ def fmin(x, y, name=None):
out = fmin(x, y)
Note:
``paddle.fmin`` supports broadcasting. If you want know more about broadcasting, please refer to :ref:`user_guide_broadcasting` .
``paddle.fmin`` supports broadcasting. If you want know more about broadcasting, please refer to `Introduction to Tensor`_ .
.. _Introduction to Tensor: ../../guides/beginner/tensor_en.html#chapter5-broadcasting-of-tensor
Args:
x (Tensor): the input tensor, it's data type should be float16, float32, float64, int32, int64.
......@@ -3962,7 +3983,12 @@ def any(x, axis=None, keepdim=False, name=None):
def broadcast_shape(x_shape, y_shape):
"""
The function returns the shape of doing operation with broadcasting on tensors of x_shape and y_shape, please refer to :ref:`user_guide_broadcasting` for more details.
The function returns the shape of doing operation with broadcasting on tensors of x_shape and y_shape.
Note:
If you want know more about broadcasting, please refer to `Introduction to Tensor`_ .
.. _Introduction to Tensor: ../../guides/beginner/tensor_en.html#chapter5-broadcasting-of-tensor
Args:
x_shape (list[int]|tuple[int]): A shape of tensor.
......@@ -4991,7 +5017,9 @@ def heaviside(x, y, name=None):
\right.
Note:
``paddle.heaviside`` supports broadcasting. If you want know more about broadcasting, please refer to :ref:`user_guide_broadcasting`.
``paddle.heaviside`` supports broadcasting. If you want know more about broadcasting, please refer to `Introduction to Tensor`_ .
.. _Introduction to Tensor: ../../guides/beginner/tensor_en.html#chapter5-broadcasting-of-tensor
Args:
x (Tensor): The input tensor of Heaviside step function, it's data type should be float16, float32, float64, int32 or int64.
......
......@@ -23,8 +23,8 @@ _image_backend = 'pil'
def set_image_backend(backend):
"""
Specifies the backend used to load images in class ``paddle.vision.datasets.ImageFolder``
and ``paddle.vision.datasets.DatasetFolder`` . Now support backends are pillow and opencv.
Specifies the backend used to load images in class :ref:`api_paddle_datasets_ImageFolder`
and :ref:`api_paddle_datasets_DatasetFolder` . Now support backends are pillow and opencv.
If backend not set, will use 'pil' as default.
Args:
......@@ -117,7 +117,7 @@ def image_load(path, backend=None):
path (str): Path of the image.
backend (str, optional): The image decoding backend type. Options are
`cv2`, `pil`, `None`. If backend is None, the global _imread_backend
specified by ``paddle.vision.set_image_backend`` will be used. Default: None.
specified by :ref:`api_paddle_vision_set_image_backend` will be used. Default: None.
Returns:
PIL.Image or np.array: Loaded image.
......
......@@ -42,7 +42,18 @@ def _is_numpy_image(img):
def to_tensor(pic, data_format='CHW'):
"""Converts a ``PIL.Image`` or ``numpy.ndarray`` to paddle.Tensor.
See ``ToTensor`` for more details.
Converts a PIL.Image or numpy.ndarray (H x W x C) to a paddle.Tensor of shape (C x H x W).
If input is a grayscale image (H x W), it will be converted to an image of shape (H x W x 1).
And the shape of output tensor will be (1 x H x W).
If you want to keep the shape of output tensor as (H x W x C), you can set data_format = ``HWC`` .
Converts a PIL.Image or numpy.ndarray in the range [0, 255] to a paddle.Tensor in the
range [0.0, 1.0] if the PIL Image belongs to one of the modes (L, LA, P, I, F, RGB, YCbCr,
RGBA, CMYK, 1) or if the numpy.ndarray has dtype = np.uint8.
In the other cases, tensors are returned without scaling.
Args:
pic (PIL.Image|np.ndarray): Image to be converted to tensor.
......@@ -764,7 +775,7 @@ def rotate(
center (2-list|2-tuple, optional): Optional center of rotation.
Origin is the upper left corner.
Default is the center of the image.
fill (3-list|3-tuple or int): RGB pixel fill value for area outside the rotated image.
fill (3-list|3-tuple or int, optional): RGB pixel fill value for area outside the rotated image.
If int, it is used for all channels respectively. Default value is 0.
......
......@@ -136,6 +136,8 @@ class BaseTransform:
calling logic:
.. code-block:: text
if keys is None:
_get_params -> _apply_image()
else:
......@@ -153,14 +155,11 @@ class BaseTransform:
Current available strings & data type are describe below:
- "image": input image, with shape of (H, W, C)
- "coords": coordinates, with shape of (N, 2)
- "boxes": bounding boxes, with shape of (N, 4), "xyxy" format,
the 1st "xy" represents top left point of a box,
the 2nd "xy" represents right bottom point.
- "mask": map used for segmentation, with shape of (H, W, 1)
- "image": input image, with shape of (H, W, C)
- "coords": coordinates, with shape of (N, 2)
- "boxes": bounding boxes, with shape of (N, 4), "xyxy" format,the 1st "xy" represents
top left point of a box,the 2nd "xy" represents right bottom point.
- "mask": map used for segmentation, with shape of (H, W, 1)
You can also customize your data types only if you implement the corresponding
_apply_*() methods, otherwise ``NotImplementedError`` will be raised.
......@@ -433,9 +432,9 @@ class RandomResizedCrop(BaseTransform):
Args:
size (int|list|tuple): Target size of output image, with (height, width) shape.
scale (list|tuple): Scale range of the cropped image before resizing, relatively to the origin
image. Default: (0.08, 1.0)
ratio (list|tuple): Range of aspect ratio of the origin aspect ratio cropped. Default: (0.75, 1.33)
scale (list|tuple, optional): Scale range of the cropped image before resizing, relatively to the origin
image. Default: (0.08, 1.0).
ratio (list|tuple, optional): Range of aspect ratio of the origin aspect ratio cropped. Default: (0.75, 1.33)
interpolation (int|str, optional): Interpolation method. Default: 'bilinear'. when use pil backend,
support method are as following:
- "nearest": Image.NEAREST,
......@@ -778,7 +777,7 @@ class BrightnessTransform(BaseTransform):
Args:
value (float): How much to adjust the brightness. Can be any
non negative number. 0 gives the original image
non negative number. 0 gives the original image.
keys (list[str]|tuple[str], optional): Same as ``BaseTransform``. Default: None.
Shape:
......@@ -821,7 +820,7 @@ class ContrastTransform(BaseTransform):
Args:
value (float): How much to adjust the contrast. Can be any
non negative number. 0 gives the original image
non negative number. 0 gives the original image.
keys (list[str]|tuple[str], optional): Same as ``BaseTransform``. Default: None.
Shape:
......@@ -866,7 +865,7 @@ class SaturationTransform(BaseTransform):
Args:
value (float): How much to adjust the saturation. Can be any
non negative number. 0 gives the original image
non negative number. 0 gives the original image.
keys (list[str]|tuple[str], optional): Same as ``BaseTransform``. Default: None.
Shape:
......@@ -909,7 +908,7 @@ class HueTransform(BaseTransform):
Args:
value (float): How much to adjust the hue. Can be any number
between 0 and 0.5, 0 gives the original image
between 0 and 0.5, 0 gives the original image.
keys (list[str]|tuple[str], optional): Same as ``BaseTransform``. Default: None.
Shape:
......@@ -953,14 +952,14 @@ class ColorJitter(BaseTransform):
"""Randomly change the brightness, contrast, saturation and hue of an image.
Args:
brightness (float): How much to jitter brightness.
Chosen uniformly from [max(0, 1 - brightness), 1 + brightness]. Should be non negative numbers.
contrast (float): How much to jitter contrast.
Chosen uniformly from [max(0, 1 - contrast), 1 + contrast]. Should be non negative numbers.
saturation (float): How much to jitter saturation.
Chosen uniformly from [max(0, 1 - saturation), 1 + saturation]. Should be non negative numbers.
hue (float): How much to jitter hue.
Chosen uniformly from [-hue, hue]. Should have 0<= hue <= 0.5.
brightness (float, optional): How much to jitter brightness.
Chosen uniformly from [max(0, 1 - brightness), 1 + brightness]. Should be non negative numbers. Default: 0.
contrast (float, optional): How much to jitter contrast.
Chosen uniformly from [max(0, 1 - contrast), 1 + contrast]. Should be non negative numbers. Default: 0.
saturation (float, optional): How much to jitter saturation.
Chosen uniformly from [max(0, 1 - saturation), 1 + saturation]. Should be non negative numbers. Default: 0.
hue (float, optional): How much to jitter hue.
Chosen uniformly from [-hue, hue]. Should have 0<= hue <= 0.5. Default: 0.
keys (list[str]|tuple[str], optional): Same as ``BaseTransform``. Default: None.
Shape:
......@@ -1665,7 +1664,7 @@ class Grayscale(BaseTransform):
"""Converts image to grayscale.
Args:
num_output_channels (int): (1 or 3) number of channels desired for output image
num_output_channels (int, optional): (1 or 3) number of channels desired for output image. Default: 1.
keys (list[str]|tuple[str], optional): Same as ``BaseTransform``. Default: None.
Shape:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册