From b1deaf74673584a646bfb990855400b40fbcedf3 Mon Sep 17 00:00:00 2001 From: yuchen202 <103028470+yuchen202@users.noreply.github.com> Date: Mon, 18 Sep 2023 11:31:02 +0800 Subject: [PATCH 1/3] 0918API --- python/paddle/nn/layer/conv.py | 6 +++++- python/paddle/static/input.py | 1 + python/paddle/tensor/manipulation.py | 6 +----- python/paddle/tensor/math.py | 7 +------ python/paddle/tensor/random.py | 2 +- python/paddle/vision/models/resnet.py | 2 +- 6 files changed, 10 insertions(+), 14 deletions(-) diff --git a/python/paddle/nn/layer/conv.py b/python/paddle/nn/layer/conv.py index e0ab183f51bcb3..fe019b176e2e8a 100644 --- a/python/paddle/nn/layer/conv.py +++ b/python/paddle/nn/layer/conv.py @@ -759,7 +759,11 @@ class Conv2DTranspose(_ConvNd): * :math:`\ast`: Convolution operation. * :math:`b`: Bias value, a 1-D ``Tensor`` with shape [M]. * :math:`\sigma`: Activation function. - * :math:`Out`: Output value, the shape of :math:`Out` and :math:`X` may be different. + * :math:`Out`: Output value, a 4-D ``Tensor`` with NCHW or NHWC format, the shape of :math:`Out` and :math:`X` may be different. + + ::note: + If output_size is None, :math:`H_{out}` = :math:`H^\prime_{out}` , :math:`W_{out}` = :math:`W^\prime_{out}`. Otherwise, the specified output_size_height (the height of the output feature layer) :math:`H_{out}` should be between:math:`H^\prime_{out}` and :math:`H^\prime_{out} + strides[0]` (excluding :math:`H^\prime_{out} + strides[0]` ). + The specified output_size_width :math:`W_{out}` should be between :math:`W^\prime_{out}` and :math:`W^\prime_{out} + strides[1]` (excluding :math:`W^\prime_{out} + strides[1]`). Parameters: in_channels(int): The number of channels in the input image. diff --git a/python/paddle/static/input.py b/python/paddle/static/input.py index 44554ea090c2c1..5bc8bfb8e2ab49 100644 --- a/python/paddle/static/input.py +++ b/python/paddle/static/input.py @@ -162,6 +162,7 @@ class InputSpec: uint8. Default: float32. name (str): The name/alias of the variable, see :ref:`api_guide_Name` for more details. + stop_gradient ():留空,坐等孙师傅指导。 Examples: .. code-block:: python diff --git a/python/paddle/tensor/manipulation.py b/python/paddle/tensor/manipulation.py index 62de7b884275b7..57047e7c15c6b7 100644 --- a/python/paddle/tensor/manipulation.py +++ b/python/paddle/tensor/manipulation.py @@ -2900,11 +2900,7 @@ def scatter(x, index, updates, overwrite=True, name=None): x (Tensor): The input N-D Tensor with ndim>=1. Data type can be float32, float64. index (Tensor): The index is a 1-D or 0-D Tensor. Data type can be int32, int64. The length of index cannot exceed updates's length, and the value in index cannot exceed input's length. updates (Tensor): Update input with updates parameter based on index. When the index is a 1-D tensor, the updates shape should be the same as input, and dim value with dim > 1 should be the same as input. When the index is a 0-D tensor, the updates should be a (N-1)-D tensor, the ith dim of the updates should be queal with the (i+1)th dim of the input. - overwrite (bool, optional): The mode that updating the output when there are same indices. - - If True, use the overwrite mode to update the output of the same index, - if False, use the accumulate mode to update the output of the same index. Default value is True. - + overwrite (bool, optional): The mode that updating the output when there are same indices.If True, use the overwrite mode to update the output of the same index,if False, use the accumulate mode to update the output of the same index. Default value is True. name(str, optional): The default value is None. Normally there is no need for user to set this property. For more information, please refer to :ref:`api_guide_Name` . Returns: diff --git a/python/paddle/tensor/math.py b/python/paddle/tensor/math.py index eae8eff6e506bb..c409e46c6378e1 100644 --- a/python/paddle/tensor/math.py +++ b/python/paddle/tensor/math.py @@ -643,16 +643,11 @@ def add(x, y, name=None): $X$ the tensor of any dimension. $Y$ the tensor whose dimensions must be less than or equal to the dimensions of $X$. - There are two cases for this operator: + This operator is used in the following cases: 1. The shape of $Y$ is the same with $X$. 2. The shape of $Y$ is a continuous subsequence of $X$. - For case 2: - - 1. Broadcast $Y$ to match the shape of $X$, where axis is the start dimension index for broadcasting $Y$ onto $X$. - 2. If $axis$ is -1 (default), $axis$=rank($X$)-rank($Y$). - 3. The trailing dimensions of size 1 for $Y$ will be ignored for the consideration of subsequence, such as shape($Y$) = (2, 1) => (2). For example: diff --git a/python/paddle/tensor/random.py b/python/paddle/tensor/random.py index bbfc533c5fc925..f3d82a492f6aa3 100644 --- a/python/paddle/tensor/random.py +++ b/python/paddle/tensor/random.py @@ -1078,7 +1078,7 @@ def rand(shape, dtype=None, name=None): If ``shape`` is an Tensor, it should be an 1-D Tensor which represents a list. dtype (str|np.dtype, optional): The data type of the output Tensor. Supported data types: float32, float64. - Default is None, use global default dtype (see ``get_default_dtype`` + Default is None, use global default dtype (see :ref:`get_default_dtype` for details). name (str, optional): The default value is None. Normally there is no need for user to set this property. For more information, please diff --git a/python/paddle/vision/models/resnet.py b/python/paddle/vision/models/resnet.py index d91cd66f04f5dd..cb270154dd8492 100644 --- a/python/paddle/vision/models/resnet.py +++ b/python/paddle/vision/models/resnet.py @@ -438,7 +438,7 @@ def resnet50(pretrained=False, **kwargs): Args: pretrained (bool, optional): Whether to load pre-trained weights. If True, returns a model pre-trained on ImageNet. Default: False. - **kwargs (optional): Additional keyword arguments. For details, please refer to :ref:`ResNet `. + **kwargs (optional): Additional keyword arguments. For details, please refer to :ref:`ResNet `. Returns: :ref:`api_paddle_nn_Layer`. An instance of ResNet 50-layer model. From dbd8d910b58c5c817c289e91bc93768dbd42368f Mon Sep 17 00:00:00 2001 From: yuchen202 <103028470+yuchen202@users.noreply.github.com> Date: Thu, 21 Sep 2023 23:10:07 +0800 Subject: [PATCH 2/3] Apply suggestions from code review Co-authored-by: zachary sun <70642955+sunzhongkai588@users.noreply.github.com> --- python/paddle/nn/layer/conv.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/python/paddle/nn/layer/conv.py b/python/paddle/nn/layer/conv.py index fe019b176e2e8a..26a18e91e847cb 100644 --- a/python/paddle/nn/layer/conv.py +++ b/python/paddle/nn/layer/conv.py @@ -759,10 +759,10 @@ class Conv2DTranspose(_ConvNd): * :math:`\ast`: Convolution operation. * :math:`b`: Bias value, a 1-D ``Tensor`` with shape [M]. * :math:`\sigma`: Activation function. - * :math:`Out`: Output value, a 4-D ``Tensor`` with NCHW or NHWC format, the shape of :math:`Out` and :math:`X` may be different. + * :math:`Out`: Output value, a 4-D ``Tensor`` with NCHW or NHWC format, the shape of :math:`Out` and :math:`X` could be different. ::note: - If output_size is None, :math:`H_{out}` = :math:`H^\prime_{out}` , :math:`W_{out}` = :math:`W^\prime_{out}`. Otherwise, the specified output_size_height (the height of the output feature layer) :math:`H_{out}` should be between:math:`H^\prime_{out}` and :math:`H^\prime_{out} + strides[0]` (excluding :math:`H^\prime_{out} + strides[0]` ). + If output_size is None, :math:`H_{out}` = :math:`H^\prime_{out}` , :math:`W_{out}` = :math:`W^\prime_{out}`. Otherwise, the specified output_size_height (the height of the output feature layer) :math:`H_{out}` should be between :math:`H^\prime_{out}` and :math:`H^\prime_{out} + strides[0]` (excluding :math:`H^\prime_{out} + strides[0]` ). The specified output_size_width :math:`W_{out}` should be between :math:`W^\prime_{out}` and :math:`W^\prime_{out} + strides[1]` (excluding :math:`W^\prime_{out} + strides[1]`). Parameters: From 83f2bcda680945957f0db894587d9b31b3f7efab Mon Sep 17 00:00:00 2001 From: yuchen202 <103028470+yuchen202@users.noreply.github.com> Date: Sat, 23 Sep 2023 23:36:34 +0800 Subject: [PATCH 3/3] =?UTF-8?q?0923=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- python/paddle/nn/layer/conv.py | 7 +++---- python/paddle/static/input.py | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/python/paddle/nn/layer/conv.py b/python/paddle/nn/layer/conv.py index 26a18e91e847cb..5b6d295458cfaa 100644 --- a/python/paddle/nn/layer/conv.py +++ b/python/paddle/nn/layer/conv.py @@ -759,11 +759,10 @@ class Conv2DTranspose(_ConvNd): * :math:`\ast`: Convolution operation. * :math:`b`: Bias value, a 1-D ``Tensor`` with shape [M]. * :math:`\sigma`: Activation function. - * :math:`Out`: Output value, a 4-D ``Tensor`` with NCHW or NHWC format, the shape of :math:`Out` and :math:`X` could be different. + * :math:`Out`: Output value, a 4-D ``Tensor`` with NCHW or NHWC format, the shape of :math:`Out` and :math:`X` may be different. - ::note: - If output_size is None, :math:`H_{out}` = :math:`H^\prime_{out}` , :math:`W_{out}` = :math:`W^\prime_{out}`. Otherwise, the specified output_size_height (the height of the output feature layer) :math:`H_{out}` should be between :math:`H^\prime_{out}` and :math:`H^\prime_{out} + strides[0]` (excluding :math:`H^\prime_{out} + strides[0]` ). - The specified output_size_width :math:`W_{out}` should be between :math:`W^\prime_{out}` and :math:`W^\prime_{out} + strides[1]` (excluding :math:`W^\prime_{out} + strides[1]`). + Note: + If output_size is None, :math:`H_{out}` = :math:`H^\prime_{out}` , :math:`W_{out}` = :math:`W^\prime_{out}`. Otherwise, the specified output_size_height (the height of the output feature layer) :math:`H_{out}` should be between :math:`H^\prime_{out}` and :math:`H^\prime_{out} + strides[0]` (excluding :math:`H^\prime_{out} + strides[0]` ). Parameters: in_channels(int): The number of channels in the input image. diff --git a/python/paddle/static/input.py b/python/paddle/static/input.py index 5bc8bfb8e2ab49..59048de5478113 100644 --- a/python/paddle/static/input.py +++ b/python/paddle/static/input.py @@ -162,7 +162,7 @@ class InputSpec: uint8. Default: float32. name (str): The name/alias of the variable, see :ref:`api_guide_Name` for more details. - stop_gradient ():留空,坐等孙师傅指导。 + stop_gradient (bool, optional): A boolean that mentions whether gradient should flow. Default is False, means don't stop calculate gradients. Examples: .. code-block:: python