diff --git a/python/paddle/nn/functional/common.py b/python/paddle/nn/functional/common.py index 83c216483e1bd8e3abc43d253da3d0f53d54fbca..a139740662f071972fcf9b2be59a0997950ecef3 100644 --- a/python/paddle/nn/functional/common.py +++ b/python/paddle/nn/functional/common.py @@ -1445,35 +1445,35 @@ def alpha_dropout(x, p=0.5, training=True, name=None): return x -def pad(x, pad, mode='constant', value=0, data_format="NCHW", name=None): +def pad(x, pad, mode='constant', value=0.0, data_format="NCHW", name=None): """ - Pad tensor according to 'pad' and 'mode'. - If mode is 'constant' and length of pad is twice as length of x dimension, + Pad tensor according to ``'pad'`` and ``'mode'``. + If mode is ``'constant'`` and length of pad is twice as length of x dimension, then the padding will be started from the first dimension and moved back onto x - according to 'pad' and 'value'. - If mode is 'reflect', pad[0] and pad[1] must be no greater + according to ``'pad'`` and ``'value'``. + If mode is ``'reflect'``, pad[0] and pad[1] must be no greater than width-1. The height and depth dimension has the same condition. Parameters: x (Tensor): The input tensor with data type float32/double/int32/int64_t. pad (Tensor|list[int]|tuple[int]): The padding size with data type int. - If mode is 'constant' and length of pad is twice as length of x dimension, then x will + If mode is ``'constant'`` and length of pad is twice as length of x dimension, then x will be padded from the first dimension to the last dimension. Else: 1. If input dimension is 3, then the pad has the form (pad_left, pad_right). 2. If the input dimension is 4, then the pad has the form (pad_left, pad_right, pad_top, pad_bottom). 3. If the input dimension is 5, then the pad has the form (pad_left, pad_right, pad_top, pad_bottom, pad_front, pad_back). - mode (str, optional): Four modes: 'constant' (default), 'reflect', 'replicate', 'circular'. Default is 'constant' + mode (str, optional): Four modes: ``'constant'`` (default), ``'reflect'``, ``'replicate'``, ``'circular'``. Default is ``'constant'``. - 'constant' mode, uses a constant value to pad the input tensor. - 'reflect' mode, uses reflection of the input boundaries to pad the input tensor. - 'replicate' mode, uses input boundaries to pad the input tensor. - 'circular' mode, uses circular input to pad the input tensor. - value (float, optional): The value to fill the padded areas in 'constant' mode . Default is :math:`0.0`, - data_format (str, optional): An string from: "NCL", "NLC", NHWC", "NCHW", "NCDHW", "NDHWC". Specify the data format of - the input data. Default is "NCHW", - name (str, optional): For details, please refer to :ref:`api_guide_Name`. Generally, no setting is required. Default: None. + value (float, optional): The value to fill the padded areas in 'constant' mode . Default is :math:`0.0`. + data_format (str, optional): An string from: ``'NCL'``, ``'NLC'``, ``'NHWC'``, ``'NCHW'``, ``'NCDHW'``, ``'NDHWC'``. Specify the data format of + the input data. Default: ``'NCHW'``. + name (str, optional): For details, please refer to :ref:`api_guide_Name`. Generally, no setting is required. Default: ``'None'``. Returns: Tensor, a Tensor padded according to pad and mode and data type is same as input. diff --git a/python/paddle/nn/functional/loss.py b/python/paddle/nn/functional/loss.py index 1e34e9c9bebe041bacf691683825483776dee0f8..f894c7bfcbfed2241e198bb006e6b89c42e93f56 100755 --- a/python/paddle/nn/functional/loss.py +++ b/python/paddle/nn/functional/loss.py @@ -1419,7 +1419,8 @@ def nll_loss( ): """ This api returns negative log likelihood. - See more detail in :ref:`api_nn_loss_NLLLoss` . + See more detail in :ref:`NLLLoss ` . + Parameters: input (Tensor): Input tensor, the shape is :math:`[N, C]`, `C` is the number of classes. diff --git a/python/paddle/nn/functional/vision.py b/python/paddle/nn/functional/vision.py index a246a8eb76bfe3c1374b1493f6fb19586db49c41..cc4464ebeec6eb907fd61a3803dc6fa91474e50b 100644 --- a/python/paddle/nn/functional/vision.py +++ b/python/paddle/nn/functional/vision.py @@ -348,14 +348,14 @@ def grid_sample( def pixel_shuffle(x, upscale_factor, data_format="NCHW", name=None): """ This API implements pixel shuffle operation. - See more details in :ref:`api_nn_vision_PixelShuffle` . + See more details in :ref:`PixelSuffle ` . Parameters: x(Tensor): 4-D tensor, the data type should be float32 or float64. upscale_factor(int): factor to increase spatial resolution. - data_format (str, optional): The data format of the input and output data. An optional string from: "NCHW", "NHWC". The default is "NCHW". When it is "NCHW", the data is stored in the order of: [batch_size, input_channels, input_height, input_width]. - name (str, optional): The default value is None. Normally there is no need for user to set this property. + data_format (str, optional): The data format of the input and output data. An optional string from: ``'NCHW'``, ``'NHWC'``. When it is ``'NCHW'``, the data is stored in the order of: [batch_size, input_channels, input_height, input_width]. Default: ``'NCHW'``. + name (str, optional): Name for the operation (optional, default is None). For more information, please refer to :ref:`api_guide_Name`. Returns: Out(tensor): Reshaped tensor according to the new dimension. @@ -402,12 +402,12 @@ def pixel_shuffle(x, upscale_factor, data_format="NCHW", name=None): def pixel_unshuffle(x, downscale_factor, data_format="NCHW", name=None): """ This API implements pixel unshuffle operation. - See more details in :ref:`api_nn_vision_PixelUnshuffle` . + See more details in :ref:`PixelUnSuffle ` . Parameters: x (Tensor): 4-D tensor, the data type should be float32 or float64. downscale_factor (int): Factor to decrease spatial resolution. - data_format (str, optional): The data format of the input and output data. An optional string of NCHW or NHWC. The default is NCHW. When it is NCHW, the data is stored in the order of [batch_size, input_channels, input_height, input_width]. + data_format (str, optional): The data format of the input and output data. An optional string of ``'NCHW'`` or ``'NHWC'``. When it is ``'NCHW'``, the data is stored in the order of [batch_size, input_channels, input_height, input_width]. Default: ``'NCHW'``. name (str, optional): Name for the operation (optional, default 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/nn/layer/common.py b/python/paddle/nn/layer/common.py index 3dd0eb3ccce290c550e94f4acd9642b1db7c3146..a4994e3366ea179db3924de5ba817949c4945261 100644 --- a/python/paddle/nn/layer/common.py +++ b/python/paddle/nn/layer/common.py @@ -1012,24 +1012,24 @@ class AlphaDropout(Layer): class Pad1D(Layer): """ This interface is used to construct a callable object of the ``Pad1D`` class. - Pad tensor according to 'pad', 'mode' and 'value'. - If mode is 'reflect', pad[0] and pad[1] must be no greater than width-1. + Pad tensor according to ``pad``, ``mode`` and ``value``. + If mode is ``reflect``, pad[0] and pad[1] must be no greater than width-1. Parameters: - padding (Tensor|list[int]|int): The padding size with data type int. If is int, use the + padding (Tensor|list[int]|int): The padding size with data type ``'int'``. If is ``'int'``, use the same padding in both dimensions. Else [len(padding)/2] dimensions of input will be padded. The pad has the form (pad_left, pad_right). - mode (str, optional): Four modes: 'constant' (default), 'reflect', 'replicate', 'circular'. Default is 'constant'. + mode (str, optional): Four modes: ``'constant'`` (default), ``'reflect'``, ``'replicate'``, ``'circular'``. Default: ``'constant'``. - 'constant' mode, uses a constant value to pad the input tensor. - 'reflect' mode, uses reflection of the input boundaries to pad the input tensor. - 'replicate' mode, uses input boundaries to pad the input tensor. - 'circular' mode, uses circular input to pad the input tensor. - value (float, optional): The value to fill the padded areas. Default is :math:`0.0`。 - data_format (str, optional): An string from: "NCL", "NLC". Specify the data format of the input data. - Default is "NCL" - name (str, optional): For details, please refer to :ref:`api_guide_Name`. Generally, no setting is required. Default: None. + value (float, optional): The value to fill the padded areas. Default is :math:`0.0`. + data_format (str, optional): An string from: ``'NCL'``, ``'NLC'``. Specify the data format of the input data. + Default: ``'NCL'``. + name (str, optional): For details, please refer to :ref:`api_guide_Name`. Generally, no setting is required. Default: ``'None'``. Returns: None @@ -1081,25 +1081,25 @@ class Pad1D(Layer): class Pad2D(Layer): """ This interface is used to construct a callable object of the ``Pad2D`` class. - Pad tensor according to 'pad', 'mode' and 'value'. - If mode is 'reflect', pad[0] and pad[1] must be no greater + Pad tensor according to ``pad``, ``mode`` and ``value``. + If mode is ``'reflect'``, pad[0] and pad[1] must be no greater than width-1. The height dimension has the same condition. Parameters: - padding (Tensor|list[int]|int): The padding size with data type int. If is int, use the + padding (Tensor|list[int]|int): The padding size with data type ``'int'``. If is ``'int'``, use the same padding in all dimensions. Else [len(padding)/2] dimensions of input will be padded. The pad has the form (pad_left, pad_right, pad_top, pad_bottom). - mode (str, optional): Four modes: 'constant' (default), 'reflect', 'replicate', 'circular'. Default is 'constant'. + mode (str, optional): Four modes: ``'constant'`` (default), ``'reflect'``, ``'replicate'``, ``'circular'``. Default: ``'constant'``. - 'constant' mode, uses a constant value to pad the input tensor. - 'reflect' mode, uses reflection of the input boundaries to pad the input tensor. - 'replicate' mode, uses input boundaries to pad the input tensor. - 'circular' mode, uses circular input to pad the input tensor. - value (float, optional): The value to fill the padded areas. Default is :math:`0.0`。 - data_format (str, optional): An string from: "NCHW", "NHWC". Specify the data format of the input data. - Default is "NCHW"。 - name (str, optional): For details, please refer to :ref:`api_guide_Name`. Generally, no setting is required. Default: None. + value (float, optional): The value to fill the padded areas. Default is :math:`0.0`. + data_format (str, optional): An string from: ``'NCHW'``, ``'NHWC'``. Specify the data format of the input data. + Default: ``'NCHW'``. + name (str, optional): For details, please refer to :ref:`api_guide_Name`. Generally, no setting is required. Default: ``'None'``. Returns: None @@ -1223,25 +1223,25 @@ class ZeroPad2D(Layer): class Pad3D(Layer): """ This interface is used to construct a callable object of the ``Pad3D`` class. - Pad tensor according to 'pad', 'mode' and 'value'. - If mode is 'reflect', pad[0] and pad[1] must be no greater + Pad tensor according to ``'pad'``, ``'mode'`` and ``'value'``. + If mode is ``'reflect'``, pad[0] and pad[1] must be no greater than width-1. The height and depth dimension has the same condition. Parameters: - padding (Tensor|list[int]|int): The padding size with data type int. If is int, use the + padding (Tensor|list[int]|int): The padding size with data type ``'int'``. If is ``'int'``, use the same padding in all dimensions. Else [len(padding)/2] dimensions of input will be padded. The pad has the form (pad_left, pad_right, pad_top, pad_bottom, pad_front, pad_back). - mode (str, optional): Four modes: 'constant' (default), 'reflect', 'replicate', 'circular'. Default is 'constant'. + mode (str, optional): Four modes: ``'constant'`` (default), ``'reflect'``, ``'replicate'``, ``'circular'``. Default: ``'constant'``. - 'constant' mode, uses a constant value to pad the input tensor. - 'reflect' mode, uses reflection of the input boundaries to pad the input tensor. - 'replicate' mode, uses input boundaries to pad the input tensor. - 'circular' mode, uses circular input to pad the input tensor. - value (float, optional): The value to fill the padded areas. Default is :math:`0.0`。 - data_format (str, optional): An string from: "NCDHW", "NDHWC". Specify the data format of the input data. - Default is "NCDHW"。 - name (str, optional): For details, please refer to :ref:`api_guide_Name`. Generally, no setting is required. Default: None. + value (float, optional): The value to fill the padded areas. Default is :math:`0.0`. + data_format (str, optional): An string from: ``'NCDHW'``, ``'NDHWC'``. Specify the data format of the input data. + Default: ``'NCDHW'``。 + name (str, optional): For details, please refer to :ref:`api_guide_Name`. Generally, no setting is required. Default: ``'None'``. Returns: None diff --git a/python/paddle/nn/layer/loss.py b/python/paddle/nn/layer/loss.py index f9e9a4ec152b701e4a31d25bd1634540049ff7f7..b7408d93dd050753e3a18f61b31cbdae220aa9dc 100644 --- a/python/paddle/nn/layer/loss.py +++ b/python/paddle/nn/layer/loss.py @@ -817,12 +817,12 @@ class NLLLoss(Layer): ignore_index (int, optional): Specifies a target value that is ignored and does not contribute to the input gradient. reduction (str, optional): Indicate how to average the loss, - the candicates are ``'none'`` | ``'mean'`` | ``'sum'``. + the candicates are ``'none'`` | ``'mean'`` | ``'sum'``. Default is ``'mean'``. If `reduction` is ``'mean'``, the reduced mean loss is returned; if `reduction` is ``'sum'``, the reduced sum loss is returned; if `reduction` is ``'none'``, no reduction will be apllied. Default is ``'mean'``. - name (str, optional): For details, please refer to :ref:`api_guide_Name`. Generally, no setting is required. Default: None. + name (str, optional): For details, please refer to :ref:`api_guide_Name`. Generally, no setting is required. Default is ``'None'``. Shape: - input (Tensor): Input tensor, the shape is :math:`[N, C]`, `C` is the number of classes. diff --git a/python/paddle/nn/layer/vision.py b/python/paddle/nn/layer/vision.py index 8058aeadf871a83f93ea8c80c08853fa9cfd0b9b..b0ebff15196b0cad74739167a120ede1284b87aa 100644 --- a/python/paddle/nn/layer/vision.py +++ b/python/paddle/nn/layer/vision.py @@ -22,11 +22,9 @@ __all__ = [] class PixelShuffle(Layer): """ - PixelShuffle Layer - Rearranges elements in a tensor of shape :math:`[N, C, H, W]` - to a tensor of shape :math:`[N, C/upscale_factor^2, H*upscale_factor, W \times upscale_factor]`, - or from shape :math:`[N, H, W, C]` to :math:`[N, H \times upscale_factor, W \times upscale_factor, C/upscale_factor^2]`. + to a tensor of shape :math:`[N, C/upscale_factor^2, H*upscale_factor, W*upscale_factor]`, + or from shape :math:`[N, H, W, C]` to :math:`[N, H*upscale_factor, W*upscale_factor, C/upscale_factor^2]`. This is useful for implementing efficient sub-pixel convolution with a stride of 1/upscale_factor. Please refer to the paper: `Real-Time Single Image and Video Super-Resolution @@ -36,12 +34,12 @@ class PixelShuffle(Layer): Parameters: upscale_factor(int): factor to increase spatial resolution. - data_format (str, optional): The data format of the input and output data. An optional string from: "NCHW", "NHWC". The default is "NCHW". When it is "NCHW", the data is stored in the order of: [batch_size, input_channels, input_height, input_width]. + data_format (str, optional): The data format of the input and output data. An optional string from: `'NCHW'``, ``'NHWC'``. When it is ``'NCHW'``, the data is stored in the order of: [batch_size, input_channels, input_height, input_width]. Default: ``'NCHW'``. name (str, optional): Name for the operation (optional, default is None). For more information, please refer to :ref:`api_guide_Name`. Shape: - x: 4-D tensor with shape of :math:`(N, C, H, W)` or :math:`(N, H, W, C)`. - - out: 4-D tensor with shape of :math:`(N, C/upscale_factor^2, H \times upscale_factor, W \times upscale_factor)` or :math:`(N, H \times upscale_factor, W \times upscale_factor, C/upscale_factor^2)`. + - out: 4-D tensor with shape of :math:`(N, C/upscale_factor^2, H*upscale_factor, W*upscale_factor)` or :math:`(N, H*upscale_factor, W*upscale_factor, C/upscale_factor^2)`. Examples: @@ -100,7 +98,7 @@ class PixelUnshuffle(Layer): Parameters: downscale_factor (int): Factor to decrease spatial resolution. - data_format (str, optional): The data format of the input and output data. An optional string of NCHW or NHWC. The default is NCHW. When it is NCHW, the data is stored in the order of [batch_size, input_channels, input_height, input_width]. + data_format (str, optional): The data format of the input and output data. An optional string of ``'NCHW'`` or ``'NHWC'``. When it is ``'NCHW'``, the data is stored in the order of [batch_size, input_channels, input_height, input_width]. Default: ``'NCHW'``. name (str, optional): Name for the operation (optional, default is None). Normally there is no need for user to set this property. For more information, please refer to :ref:`api_guide_Name`. Shape: