From 8ef0f2b81409ebc93464b1da44defd560d0d9653 Mon Sep 17 00:00:00 2001 From: LoneRanger <836253168@qq.com> Date: Thu, 15 Dec 2022 20:55:56 +0800 Subject: [PATCH 01/16] =?UTF-8?q?=E4=BF=AE=E6=94=B9linspace=E5=8F=82?= =?UTF-8?q?=E6=95=B0"stop"=E7=9A=84=E4=BB=8B=E7=BB=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- python/paddle/tensor/creation.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/python/paddle/tensor/creation.py b/python/paddle/tensor/creation.py index 98587f5874791..5773654e21850 100644 --- a/python/paddle/tensor/creation.py +++ b/python/paddle/tensor/creation.py @@ -272,12 +272,12 @@ def create_tensor(dtype, name=None, persistable=False): def linspace(start, stop, num, dtype=None, name=None): r""" - Return fixed number of evenly spaced values within a given interval. + Return fixed number of evenly spaced values within a given interval. Note: no gradient calculation is performed. Args: start(int|float|Tensor): The input :attr:`start` is start of range. It is a int, float, \ or a 0-D Tensor with data type int32, int64, float32 or float64. - stop(int|float|Tensor): The input :attr:`stop` is start variable of range. It is a int, float, \ + stop(int|float|Tensor): The input :attr:`stop` is end variable of range. It is a int, float, \ or a 0-D Tensor with data type int32, int64, float32 or float64. num(int|Tensor): The input :attr:`num` is given num of the sequence. It is an int, \ or a 0-D Tensor with data type int32. From 813769393ffc1fd68b752f820af4392bd18d8363 Mon Sep 17 00:00:00 2001 From: LoneRanger <836253168@qq.com> Date: Thu, 15 Dec 2022 23:16:53 +0800 Subject: [PATCH 02/16] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E4=BA=86conv2d=5Ftrans?= =?UTF-8?q?pose=E8=8B=B1=E6=96=87=E6=96=87=E6=A1=A3=E4=B8=AD=201.=E5=85=AC?= =?UTF-8?q?=E5=BC=8F=E5=BC=82=E5=B8=B8=202.=E5=8F=82=E6=95=B0=E8=AF=B4?= =?UTF-8?q?=E6=98=8E=E5=BC=82=E5=B8=B8=203.padding=3DSAME=E5=92=8CVALID?= =?UTF-8?q?=E7=9A=84=E5=85=AC=E5=BC=8F=E8=AF=B4=E6=98=8E;=20test=3Ddocs=5F?= =?UTF-8?q?preview?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- python/paddle/static/nn/common.py | 70 ++++++++++++++++++------------- 1 file changed, 40 insertions(+), 30 deletions(-) diff --git a/python/paddle/static/nn/common.py b/python/paddle/static/nn/common.py index c94ef112484e8..b319fdf88beef 100755 --- a/python/paddle/static/nn/common.py +++ b/python/paddle/static/nn/common.py @@ -1027,15 +1027,15 @@ def conv2d_transpose( .. math:: - Out = \sigma (W \\ast X + b) + Out = \sigma (W \ast X + b) Where: * :math:`X`: Input value, a 4-D Tensor with NCHW or NHWC format. * :math:`W`: Filter value, a 4-D Tensor with MCHW format. - * :math:`\\ast`: Convolution operation. + * :math:`\ast`: Convolution operation. * :math:`b`: Bias value, a 2-D Tensor with shape [M, 1]. - * :math:`\\sigma`: Activation function. + * :math:`\sigma`: Activation function. * :math:`Out`: Output value, a 4-D Tensor with data format 'NCHW' or 'NHWC', the shape of :math:`Out` and :math:`X` may be different. Example: @@ -1059,19 +1059,33 @@ def conv2d_transpose( H_{out} &\in [ H^\prime_{out}, H^\prime_{out} + strides[0] ] \\\\ W_{out} &\in [ W^\prime_{out}, W^\prime_{out} + strides[1] ] - Note: - The conv2d_transpose can be seen as the backward of the conv2d. For conv2d, - when stride > 1, conv2d maps multiple input shape to the same output shape, - so for conv2d_transpose, when stride > 1, input shape maps multiple output shape. - If output_size is None, :math:`H_{out} = H^\prime_{out}, W_{out} = W^\prime_{out}`; - else, the :math:`H_{out}` of the output size must between :math:`H^\prime_{out}` - and :math:`H^\prime_{out} + strides[0]`, and the :math:`W_{out}` of the output size must - between :math:`W^\prime_{out}` and :math:`W^\prime_{out} + strides[1]`, - conv2d_transpose can compute the kernel size automatically. + If `padding` = `"SAME"`: + + .. math:: + H^\prime_{out} &= \frac{(H_{in} + stride[0] - 1)}{stride[0]} \\\\ + W^\prime_{out} &= \frac{(H_{in} + stride[1] - 1)}{stride[1]} + + If `padding` = `"VALID"`: + + .. math:: + H^\prime_{out} &= (H_{in} - 1) * stride[0]} + dilations[0] * (H_f - 1) + 1 \\\\ + W^\prime_{out} &= (W_{in} − 1) * strides[1] + dilations[1] * (W_f − 1) + 1 + + If output_size is None, :math:`H_{out} = H^\prime_{out}, W_{out} = W^\prime_{out}`; + else, the :math:`H_{out}` of the output size must between :math:`H^\prime_{out}` + and :math:`H^\prime_{out} + strides[0]`, and the :math:`W_{out}` of the output size must + between :math:`W^\prime_{out}` and :math:`W^\prime_{out} + strides[1]`, + + Since transposed convolution can be treated as the inverse of convolution, and according to the input-output formula for convolution, + different sized input feature layers may correspond to the same sized output feature layer, + the size of the output feature layer for a fixed sized input feature layer is not unique to transposed convolution + + If `output_size` is specified, `conv2d_transpose` can compute the kernel size automatically. Args: - input(Tensor): 4-D Tensor with [N, C, H, W] or [N, H, W, C] format, - its data type is float32 or float64. + input(Tensor): 4-D Tensor with [N, C, H, W] or [N, H, W, C] format where N is the batch_size, + C is the input_channels, H is the input_height and W is the input_width. + Its data type is float32 or float64. num_filters(int): The number of the filter. It is as same as the output image channel. output_size(int|tuple, optional): The output image size. If output size is a @@ -1085,26 +1099,23 @@ def conv2d_transpose( Otherwise, filter_size_height = filter_size_width = filter_size. None if use output size to calculate filter_size. Default: None. filter_size and output_size should not be None at the same time. - stride(int|tuple, optional): The stride size. It means the stride in transposed convolution. - If stride is a tuple, it must contain two integers, (stride_height, stride_width). - Otherwise, stride_height = stride_width = stride. Default: stride = 1. padding(str|int|list|tuple, optional): The padding size. It means the number of zero-paddings on both sides for each dimension. If `padding` is a string, either 'VALID' or 'SAME' which is the padding algorithm. If `padding` is a tuple or list, - it could be in three forms: `[pad_height, pad_width]` or - `[pad_height_top, pad_height_bottom, pad_width_left, pad_width_right]`, - and when `data_format` is `"NCHW"`, `padding` can be in the form + it could be in three forms: + (1) Contains 4 binary groups: when `data_format` is `"NCHW"`, `padding` can be in the form `[[0,0], [0,0], [pad_height_top, pad_height_bottom], [pad_width_left, pad_width_right]]`. when `data_format` is `"NHWC"`, `padding` can be in the form `[[0,0], [pad_height_top, pad_height_bottom], [pad_width_left, pad_width_right], [0,0]]`. - Default: padding = 0. + (2) Contains 4 integer values:`[pad_height_top, pad_height_bottom, pad_width_left, pad_width_right]` + (3) Contains 2 integer values:`[pad_height, pad_width]`, in this case, `padding_height_top = padding_height_bottom = padding_height`, + `padding_width_left = padding_width_right = padding_width`. If an integer, `padding_height = padding_width = padding`. Default: padding = 0. + stride(int|tuple, optional): The stride size. It means the stride in transposed convolution. + If stride is a tuple, it must contain two integers, (stride_height, stride_width). + Otherwise, stride_height = stride_width = stride. Default: stride = 1. dilation(int|tuple, optional): The dilation size. It means the spacing between the kernel points. If dilation is a tuple, it must contain two integers, (dilation_height, dilation_width). Otherwise, dilation_height = dilation_width = dilation. Default: dilation = 1. - filter_size(int|tuple, optional): The filter size. If filter_size is a tuple, - it must contain two integers, (filter_size_height, filter_size_width). - Otherwise, filter_size_height = filter_size_width = filter_size. None if - use output size to calculate filter_size. Default: None. groups(int, optional): The groups number of the Conv2d transpose layer. Inspired by grouped convolution in Alex Krizhevsky's Deep CNN paper, in which when group=2, the first half of the filters is only connected to the @@ -1115,11 +1126,10 @@ def conv2d_transpose( of conv2d_transpose. If it is set to None or one attribute of ParamAttr, conv2d_transpose will create ParamAttr as param_attr. If the Initializer of the param_attr is not set, the parameter is initialized with Xavier. Default: None. - bias_attr (ParamAttr|bool, optional): The parameter attribute for the bias of conv2d_transpose. - If it is set to False, no bias will be added to the output units. - If it is set to None or one attribute of ParamAttr, conv2d_transpose - will create ParamAttr as bias_attr. If the Initializer of the bias_attr - is not set, the bias is initialized zero. Default: None. + bias_attr (ParamAttr|bool, optional): Specifies the object for the bias parameter attribute. + The default value is None, which means that the default bias parameter attribute is used. + For detailed information, please refer to :ref:`paramattr`. + The default bias initialisation for the conv2d_transpose operator is 0.0. use_cudnn(bool, optional): Use cudnn kernel or not, it is valid only when the cudnn library is installed. Default: True. act (str, optional): Activation type, if it is set to None, activation is not appended. From 5b92b78307befcbe05ea6929b933042fe7283200 Mon Sep 17 00:00:00 2001 From: LoneRanger <836253168@qq.com> Date: Fri, 16 Dec 2022 17:04:39 +0800 Subject: [PATCH 03/16] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E4=BA=86=201.=E8=8B=B1?= =?UTF-8?q?=E6=96=87=E7=89=88Note=E4=B8=AD=E7=9A=84api=5Ffluid=5Flayers=5F?= =?UTF-8?q?conv2d=E7=9A=84=E9=93=BE=E6=8E=A5=E5=A4=B1=E6=95=88=EF=BC=8C=20?= =?UTF-8?q?2.=20=E8=8B=B1=E6=96=87=E7=89=88=E5=8F=82=E6=95=B0=E4=B8=AD?= =?UTF-8?q?=E7=9A=84padding=5Fstart=E7=9A=84=E5=8F=82=E6=95=B0=E9=94=99?= =?UTF-8?q?=E8=AF=AF=203.=20=E5=8F=82=E6=95=B0=E4=B8=ADbias=5Fattr?= =?UTF-8?q?=E5=92=8Cparam=5Fattr=E7=9A=84=E9=93=BE=E6=8E=A5=E5=A4=B1?= =?UTF-8?q?=E6=95=88=204.=20=E5=8F=82=E6=95=B0=E7=BC=BA=E5=B0=91optional?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- python/paddle/fluid/layers/sequence_lod.py | 28 +++++++++++----------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/python/paddle/fluid/layers/sequence_lod.py b/python/paddle/fluid/layers/sequence_lod.py index 8f04a0fef9234..a09ef08daf1e9 100644 --- a/python/paddle/fluid/layers/sequence_lod.py +++ b/python/paddle/fluid/layers/sequence_lod.py @@ -63,7 +63,7 @@ def sequence_conv( r""" Note: - Only receives LoDTensor as input. If your input is Tensor, please use conv2d Op.(fluid.layers.** :ref:`api_fluid_layers_conv2d` ). + Only receives LoDTensor as input. If your input is Tensor, please use conv2d Op.(fluid.layers.** :ref:`api_paddle_nn_functional_conv2d` ). This operator receives input sequences with variable length and other convolutional configuration parameters(num_filters, filter_size) to apply the convolution operation. @@ -114,29 +114,29 @@ def sequence_conv( and K is hidden_size of input. Only lod_level of 1 is supported. The data type should be float32 or float64. num_filters (int): the number of filters. - filter_size (int): the height of filter. Specified filter width is not supported, the width is + filter_size (int, optional): the height of filter. Specified filter width is not supported, the width is hidden_size by default. Default: 3. - filter_stride (int): stride of the filter. Currently only supports :attr:`stride` = 1. - padding (bool): the parameter :attr:`padding` take no effect and will be discarded in the + filter_stride (int, optional): stride of the filter. Currently only supports :attr:`stride` = 1. + padding (bool, optional): the parameter :attr:`padding` take no effect and will be discarded in the future. Currently, it will always pad input to make sure the length of the output is the same as input whether :attr:`padding` is set true or false. Because the length of input sequence may be shorter than :attr:`filter\_size`, which will cause the convolution result to not be computed correctly. These padding data will not be trainable or updated while training. Default: True. - padding_start (int): It is used to indicate the start index for padding the input + padding_start (int, optional): It is used to indicate the start index for padding the input sequence, which can be negative. The negative number means to pad :attr:`|padding_start|` time-steps of all-zero data at the beginning of each instance. The positive number means to skip :attr:`padding_start` time-steps of each instance, and it will pad :math:`filter\_size + padding\_start - 1` time-steps of all-zero data at the end of the sequence to ensure that the output is the same length as the input. - If set None, the same length :math:`\\frac{filter\_size}{2}` of data will be filled + If set None, the same length :math:`\frac{filter\_size}{2}` of data will be filled on both sides of the sequence. If set 0, the length of :math:`filter\_size - 1` data is padded at the end of each input sequence. Default: None. - bias_attr (ParamAttr): To specify the bias parameter property. Default: None, which means the - default bias parameter property is used. See usage for details in :ref:`api_fluid_ParamAttr` . - param_attr (ParamAttr): To specify the weight parameter property. Default: None, which means the - default weight parameter property is used. See usage for details in :ref:`api_fluid_ParamAttr` . - act (str): Activation to be applied to the output of this layer, such as tanh, softmax, + bias_attr (ParamAttr, optional): To specify the bias parameter property. Default: None, which means the + default bias parameter property is used. See usage for details in :ref:`api_paddle_ParamAttr` . + param_attr (ParamAttr, optional): To specify the weight parameter property. Default: None, which means the + default weight parameter property is used. See usage for details in :ref:`api_paddle_ParamAttr` . + act (str, optional): Activation to be applied to the output of this layer, such as tanh, softmax, sigmoid, relu. For more information, please refer to :ref:`api_guide_activations_en` . Default: None. 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` . @@ -1302,9 +1302,9 @@ def sequence_enumerate(input, win_size, pad_value=0, name=None): r""" Generate a new sequence for the input index sequence with \ - shape ``[d_1, win_size]``, which enumerates all the \ - sub-sequences with length ``win_size`` of the input with \ - shape ``[d_1, 1]``, and padded by ``pad_value`` if necessary in generation. + shape ``[d_1, win_size]``, which enumerates all the \ + sub-sequences with length ``win_size`` of the input with \ + shape ``[d_1, 1]``, and padded by ``pad_value`` if necessary in generation. Please note that the `input` must be LodTensor. From 5b4f20e59f1757da98c9ca7c57c74ffe25d6b804 Mon Sep 17 00:00:00 2001 From: LoneRanger <836253168@qq.com> Date: Fri, 16 Dec 2022 20:15:14 +0800 Subject: [PATCH 04/16] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E4=BA=86paddle.static.?= =?UTF-8?q?auc=E7=9A=84=E8=8B=B1=E6=96=87=E6=96=87=E6=A1=A3=E7=9A=84Return?= =?UTF-8?q?=E6=8F=8F=E8=BF=B0=E4=BB=A5=E5=8F=8A=E5=87=BD=E6=95=B0=E7=9A=84?= =?UTF-8?q?=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- python/paddle/static/nn/metric.py | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/python/paddle/static/nn/metric.py b/python/paddle/static/nn/metric.py index 9b386c38c8e68..7406525b9df0a 100644 --- a/python/paddle/static/nn/metric.py +++ b/python/paddle/static/nn/metric.py @@ -154,19 +154,25 @@ def auc( label(Tensor): A 2D int Tensor indicating the label of the training data. The height is batch size and width is always 1. A Tensor with type int32,int64. - curve(str): Curve type, can be 'ROC' or 'PR'. Default 'ROC'. - num_thresholds(int): The number of thresholds to use when discretizing + curve(str, optional): Curve type, can be 'ROC' or 'PR'. Default 'ROC'. + num_thresholds(int, optional): The number of thresholds to use when discretizing the roc curve. Default 4095. - topk(int): only topk number of prediction output will be used for auc. - slide_steps: when calc batch auc, we can not only use step currently but the previous steps can be used. slide_steps=1 means use the current step, slide_steps=3 means use current step and the previous second steps, slide_steps=0 use all of the steps. - ins_tag_weight(Tensor): A 2D int Tensor indicating the data's tag weight, 1 means real data, 0 means fake data. Default None, and it will be assigned to a tensor of value 1. + topk(int, optional): only topk number of prediction output will be used for auc. + slide_steps(int, optional): when calc batch auc, we can not only use step currently but the previous steps can be used. slide_steps=1 means use the current step, slide_steps=3 means use current step and the previous second steps, slide_steps=0 use all of the steps. + ins_tag_weight(Tensor, optional): A 2D int Tensor indicating the data's tag weight, 1 means real data, 0 means fake data. Default None, and it will be assigned to a tensor of value 1. A Tensor with type float32,float64. Returns: - Tensor: A tuple representing the current AUC. - The return tuple is auc_out, batch_auc_out, [ - batch_stat_pos, batch_stat_neg, stat_pos, stat_neg ] - Data type is Tensor, supporting float32, float64. + Tensor: A tuple representing the current AUC. Data type is Tensor, supporting float32, float64. + The return tuple is auc_out, batch_auc_out, [batch_stat_pos, batch_stat_neg, stat_pos, stat_neg ] + + auc_out: the result of the accuracy rate + batch_auc_out: the result of the batch accuracy + batch_stat_pos: the statistic value for label=1 at the time of batch calculation + batch_stat_neg: the statistic value for label=0 at the time of batch calculation + stat_pos: the statistic for label=1 at the time of calculation + stat_neg: the statistic for label=0 at the time of calculation + Examples: .. code-block:: python From 370646ca10fb33e86d428461733374c6e57b310d Mon Sep 17 00:00:00 2001 From: LoneRanger <836253168@qq.com> Date: Fri, 16 Dec 2022 20:23:21 +0800 Subject: [PATCH 05/16] Update python/paddle/tensor/creation.py Co-authored-by: Ligoml <39876205+Ligoml@users.noreply.github.com> --- python/paddle/tensor/creation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/paddle/tensor/creation.py b/python/paddle/tensor/creation.py index 5773654e21850..ed1a7e2718808 100644 --- a/python/paddle/tensor/creation.py +++ b/python/paddle/tensor/creation.py @@ -277,7 +277,7 @@ def linspace(start, stop, num, dtype=None, name=None): Args: start(int|float|Tensor): The input :attr:`start` is start of range. It is a int, float, \ or a 0-D Tensor with data type int32, int64, float32 or float64. - stop(int|float|Tensor): The input :attr:`stop` is end variable of range. It is a int, float, \ + stop(int|float|Tensor): The input :attr:`stop` is end of range. It is a int, float, \ or a 0-D Tensor with data type int32, int64, float32 or float64. num(int|Tensor): The input :attr:`num` is given num of the sequence. It is an int, \ or a 0-D Tensor with data type int32. From 009ee8948967c2d2a144c2a3c29947d1c331816d Mon Sep 17 00:00:00 2001 From: LoneRanger <836253168@qq.com> Date: Fri, 16 Dec 2022 20:28:46 +0800 Subject: [PATCH 06/16] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E4=BA=86shard=5Findex?= =?UTF-8?q?=E7=9A=84ignore=5Fvalue=E6=8F=8F=E8=BF=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- python/paddle/tensor/manipulation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/paddle/tensor/manipulation.py b/python/paddle/tensor/manipulation.py index df478ddde460a..aa8cfb661d18e 100644 --- a/python/paddle/tensor/manipulation.py +++ b/python/paddle/tensor/manipulation.py @@ -568,7 +568,7 @@ def shard_index(input, index_num, nshards, shard_id, ignore_value=-1): index_num (int): An integer represents the integer above the maximum value of `input`. nshards (int): The number of shards. shard_id (int): The index of the current shard. - ignore_value (int): An integer value out of sharded index range. + ignore_value (int): An integer value out of sharded index range. The default value is -1. Returns: Tensor. From 0603c66cb7f9ad3ed9f84fb7150e1242e0bad4d1 Mon Sep 17 00:00:00 2001 From: LoneRanger <836253168@qq.com> Date: Fri, 16 Dec 2022 22:19:40 +0800 Subject: [PATCH 07/16] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BA=86=E8=8B=B1?= =?UTF-8?q?=E6=96=87=E6=96=87=E6=A1=A3=E7=9A=84paddle.static.nn.conv3d=5Ft?= =?UTF-8?q?ranspose=E7=9A=84=E5=85=AC=E5=BC=8F=E4=BB=8B=E7=BB=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- python/paddle/static/nn/common.py | 44 +++++++++++++++++++++---------- 1 file changed, 30 insertions(+), 14 deletions(-) diff --git a/python/paddle/static/nn/common.py b/python/paddle/static/nn/common.py index 7d688246ed44a..86d0c3a8ad870 100644 --- a/python/paddle/static/nn/common.py +++ b/python/paddle/static/nn/common.py @@ -1427,24 +1427,40 @@ def conv3d_transpose( .. math:: - D^\prime_{out} &= (D_{in} - 1) * strides[0] - 2 * paddings[0] + dilations[0] * (D_f - 1) + 1 \\ - H^\prime_{out} &= (H_{in} - 1) * strides[1] - 2 * paddings[1] + dilations[1] * (H_f - 1) + 1 \\ - W^\prime_{out} &= (W_{in} - 1) * strides[2] - 2 * paddings[2] + dilations[2] * (W_f - 1) + 1 \\ + D^\prime_{out} &= (D_{in} - 1) * strides[0] - pad_depth_front - pad_depth_back + dilations[0] * (D_f - 1) + 1 \\ + H^\prime_{out} &= (H_{in} - 1) * strides[1] - pad_depth_top - pad_depth_bottom + dilations[1] * (H_f - 1) + 1 \\ + W^\prime_{out} &= (W_{in} - 1) * strides[2] - pad_with_left - pad_width_right + dilations[2] * (W_f - 1) + 1 \\ D_{out} &\in [ D^\prime_{out}, D^\prime_{out} + strides[0] ] \\ H_{out} &\in [ H^\prime_{out}, H^\prime_{out} + strides[1] ] \\ W_{out} &\in [ W^\prime_{out}, W^\prime_{out} + strides[2] ] - Note: - The conv3d_transpose can be seen as the backward of the conv3d. For conv3d, - when stride > 1, conv3d maps multiple input shape to the same output shape, - so for conv3d_transpose, when stride > 1, input shape maps multiple output shape. - If output_size is None, :math:`H_{out} = H^\prime_{out}, :math:`H_{out} = \ - H^\prime_{out}, W_{out} = W^\prime_{out}`; else, the :math:`D_{out}` of the output - size must between :math:`D^\prime_{out}` and :math:`D^\prime_{out} + strides[0]`, - the :math:`H_{out}` of the output size must between :math:`H^\prime_{out}` - and :math:`H^\prime_{out} + strides[1]`, and the :math:`W_{out}` of the output size must - between :math:`W^\prime_{out}` and :math:`W^\prime_{out} + strides[2]`, - conv3d_transpose can compute the kernel size automatically. + If `padding` = `"SAME"`: + + .. math:: + D^\prime_{out} &= \frac{(D_{in} + stride[0] - 1)}{stride[0]} \\\\ + H^\prime_{out} &= \frac{(H_{in} + stride[1] - 1)}{stride[1]} \\\\ + W^\prime_{out} &= \frac{(H_{in} + stride[2] - 1)}{stride[2]} + + If `padding` = `"VALID"`: + + .. math:: + D^\prime_{out} &= (D_{in} - 1) * stride[0]} + dilations[0] * (D_f - 1) + 1 \\\\ + H^\prime_{out} &= (H_{in} - 1) * stride[1]} + dilations[1] * (H_f - 1) + 1 \\\\ + W^\prime_{out} &= (W_{in} − 1) * strides[2] + dilations[2] * (W_f − 1) + 1 + + If `output_size` is None, :math:`D_{out} = D^\prime_{out}, :math:`H_{out} = \ + H^\prime_{out}, W_{out} = W^\prime_{out}`; else, the specified `output_size_depth` (the depth of the ouput feature layer) :math:`D_{out}` + must between :math:`D^\prime_{out}` and :math:`D^\prime_{out} + strides[0]`(not including :math:`D^\prime_{out} + strides[0]`), + the specified `output_size_height` (the height of the ouput feature layer) :math:`H_{out}` must between :math:`H^\prime_{out}` + and :math:`H^\prime_{out} + strides[1]`(not including :math:`H^\prime_{out} + strides[1]`), + and the the specified `output_size_width` (the width of the ouput feature layer) :math:`W_{out}` must + between :math:`W^\prime_{out}` and :math:`W^\prime_{out} + strides[2]`(not including :math:`W^\prime_{out} + strides[2]`). + + Since transposed convolution can be treated as the inverse of convolution, + and since different sized input feature layers may correspond to the same sized output feature layer according to the input-output formula for convolution, + the size of the output feature layer for a fixed sized input feature layer is not unique to transposed convolution. + + If `output_size` is specified, `conv3d_transpose` can compute the kernel size automatically. Args: input(Tensor): The input is 5-D Tensor with shape [N, C, D, H, W] or [N, D, H, W, C], the data type From dc8be6d7cefe5dc2b9dbfe98a90542200fa81763 Mon Sep 17 00:00:00 2001 From: Ligoml <39876205+Ligoml@users.noreply.github.com> Date: Mon, 19 Dec 2022 15:01:43 +0800 Subject: [PATCH 08/16] add py_func COPY-FROM label; test=document_fix --- python/paddle/static/nn/common.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/python/paddle/static/nn/common.py b/python/paddle/static/nn/common.py index 86d0c3a8ad870..dca7164520bda 100644 --- a/python/paddle/static/nn/common.py +++ b/python/paddle/static/nn/common.py @@ -2757,6 +2757,7 @@ def py_func(func, x, out, backward_func=None, skip_vars_in_backward_input=None): ``x`` will be inferred automatically. This API can also be used to debug the neural network by setting the ``func`` as a function that only print variables. + Args: func (callable): The forward function of the registered OP. When the network is running, the forward output ``out`` will be calculated according to this @@ -2780,10 +2781,15 @@ def py_func(func, x, out, backward_func=None, skip_vars_in_backward_input=None): that no tensors need to be removed from ``x`` and ``out``. If it is not None, these tensors will not be the input of ``backward_func``. This parameter is only useful when ``backward_func`` is not None. + Returns: - Tensor|tuple(Tensor)|list[Tensor]: The output ``out`` of the forward function ``func``. + Tensor|tuple(Tensor)|list[Tensor], The output ``out`` of the forward function ``func``. + Examples: + .. code-block:: python + :name: code-example1 + # example 1: import paddle import numpy as np @@ -2829,7 +2835,10 @@ def simple_net(img, label): feed={'x':input1, 'y':input2}, fetch_list=[res.name]) print(out) + .. code-block:: python + :name: code-example2 + # example 2: # This example shows how to turn Tensor into numpy array and # use numpy API to register an Python OP From f25a731213217a1f847c5f846f182b6e8d134f91 Mon Sep 17 00:00:00 2001 From: LoneRanger <836253168@qq.com> Date: Mon, 19 Dec 2022 17:43:57 +0800 Subject: [PATCH 09/16] Update python/paddle/tensor/manipulation.py Co-authored-by: Ligoml <39876205+Ligoml@users.noreply.github.com> --- python/paddle/tensor/manipulation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/paddle/tensor/manipulation.py b/python/paddle/tensor/manipulation.py index aa8cfb661d18e..4bf6a9720d023 100644 --- a/python/paddle/tensor/manipulation.py +++ b/python/paddle/tensor/manipulation.py @@ -568,7 +568,7 @@ def shard_index(input, index_num, nshards, shard_id, ignore_value=-1): index_num (int): An integer represents the integer above the maximum value of `input`. nshards (int): The number of shards. shard_id (int): The index of the current shard. - ignore_value (int): An integer value out of sharded index range. The default value is -1. + ignore_value (int, optional): An integer value out of sharded index range. The default value is -1. Returns: Tensor. From 968a848602fc3ece127391ad862cb0060bc2f4c7 Mon Sep 17 00:00:00 2001 From: Ligoml <39876205+Ligoml@users.noreply.github.com> Date: Fri, 23 Dec 2022 16:25:00 +0800 Subject: [PATCH 10/16] formula; test=document_fix --- python/paddle/static/nn/common.py | 42 ++++--------------------------- 1 file changed, 5 insertions(+), 37 deletions(-) diff --git a/python/paddle/static/nn/common.py b/python/paddle/static/nn/common.py index dca7164520bda..cd15bd594b411 100644 --- a/python/paddle/static/nn/common.py +++ b/python/paddle/static/nn/common.py @@ -186,7 +186,6 @@ def instance_norm( input, epsilon=1e-05, param_attr=None, bias_attr=None, name=None ): r""" - :api_attr: Static Graph **Instance Normalization Layer** @@ -388,7 +387,6 @@ def data_norm( enable_scale_and_shift=False, ): r""" - :api_attr: Static Graph **Data Normalization Layer** @@ -587,7 +585,6 @@ def group_norm( name=None, ): """ - :api_attr: Static Graph **Group Normalization Layer** @@ -701,7 +698,6 @@ def conv3d( data_format="NCDHW", ): r""" - :api_attr: Static Graph The convolution3D layer calculates the output based on the input, filter and strides, paddings, dilations, groups parameters. Input(Input) and @@ -805,19 +801,6 @@ def conv3d( convolution result, and if act is not None, the tensor variable storing convolution and non-linearity activation result. - Raises: - ValueError: If the type of `use_cudnn` is not bool. - ValueError: If `data_format` is not "NCDHW" or "NDHWC". - ValueError: If the channel dimmention of the input is less than or equal to zero. - ValueError: If `padding` is a string, but not "SAME" or "VALID". - ValueError: If `padding` is a tuple, but the element corresponding to the input's batch size is not 0 - or the element corresponding to the input's channel is not 0. - ShapeError: If the input is not 5-D Tensor. - ShapeError: If the input's dimension size and filter's dimension size not equal. - ShapeError: If the dimension size of input minus the size of `stride` is not 2. - ShapeError: If the number of input channels is not equal to filter's channels * groups. - ShapeError: If the number of output channels is not be divided by groups. - Examples: .. code-block:: python @@ -1010,7 +993,6 @@ def conv2d_transpose( data_format='NCHW', ): r""" - :api_attr: Static Graph The convolution2D transpose layer calculates the output based on the input, filter, and dilations, strides, paddings. Input(Input) and output(Output) @@ -1055,8 +1037,8 @@ def conv2d_transpose( .. math:: - H^\prime_{out} &= (H_{in} - 1) * strides[0] - pad_height_top - pad_height_bottom + dilations[0] * (H_f - 1) + 1 \\ - W^\prime_{out} &= (W_{in} - 1) * strides[1] - pad_width_left - pad_width_right + dilations[1] * (W_f - 1) + 1 \\ + H^\prime_{out} &= (H_{in} - 1) * strides[0] - 2 * paddings[0] + dilations[0] * (H_f - 1) + 1 \\ + W^\prime_{out} &= (W_{in} - 1) * strides[1] - 2 * paddings[0] + dilations[1] * (W_f - 1) + 1 \\ H_{out} &\in [ H^\prime_{out}, H^\prime_{out} + strides[0] ] \\ W_{out} &\in [ W^\prime_{out}, W^\prime_{out} + strides[1] ] @@ -1382,7 +1364,6 @@ def conv3d_transpose( data_format='NCDHW', ): r""" - :api_attr: Static Graph The convolution3D transpose layer calculates the output based on the input, filter, and dilations, strides, paddings. Input(Input) and output(Output) @@ -1427,9 +1408,9 @@ def conv3d_transpose( .. math:: - D^\prime_{out} &= (D_{in} - 1) * strides[0] - pad_depth_front - pad_depth_back + dilations[0] * (D_f - 1) + 1 \\ - H^\prime_{out} &= (H_{in} - 1) * strides[1] - pad_depth_top - pad_depth_bottom + dilations[1] * (H_f - 1) + 1 \\ - W^\prime_{out} &= (W_{in} - 1) * strides[2] - pad_with_left - pad_width_right + dilations[2] * (W_f - 1) + 1 \\ + D^\prime_{out} &= (D_{in} - 1) * strides[0] - 2 * paddings[0] + dilations[0] * (D_f - 1) + 1 \\ + H^\prime_{out} &= (H_{in} - 1) * strides[1] - 2 * paddings[0] + dilations[1] * (H_f - 1) + 1 \\ + W^\prime_{out} &= (W_{in} - 1) * strides[2] - 2 * paddings[0] + dilations[2] * (W_f - 1) + 1 \\ D_{out} &\in [ D^\prime_{out}, D^\prime_{out} + strides[0] ] \\ H_{out} &\in [ H^\prime_{out}, H^\prime_{out} + strides[1] ] \\ W_{out} &\in [ W^\prime_{out}, W^\prime_{out} + strides[2] ] @@ -1530,19 +1511,6 @@ def conv3d_transpose( variable storing the transposed convolution result, and if act is not None, the tensor variable storing transposed convolution and non-linearity activation result. - Raises: - ValueError: If the type of `use_cudnn` is not bool. - ValueError: If `data_format` is not "NCDHW" or "NDHWC". - ValueError: If `padding` is a string, but not "SAME" or "VALID". - ValueError: If `padding` is a tuple, but the element corresponding to the input's batch size is not 0 - or the element corresponding to the input's channel is not 0. - ValueError: If `output_size` and filter_size are None at the same time. - ShapeError: If the input is not 5-D Tensor. - ShapeError: If the input's dimension size and filter's dimension size not equal. - ShapeError: If the dimension size of input minus the size of `stride` is not 2. - ShapeError: If the number of input channels is not equal to filter's channels. - ShapeError: If the size of `output_size` is not equal to that of `stride`. - Examples: .. code-block:: python From 3d1b7a966b98b00c2ed539f2fed757d6b694f643 Mon Sep 17 00:00:00 2001 From: Ligoml <39876205+Ligoml@users.noreply.github.com> Date: Fri, 23 Dec 2022 17:12:44 +0800 Subject: [PATCH 11/16] formula; test=document_fix --- python/paddle/static/nn/common.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/python/paddle/static/nn/common.py b/python/paddle/static/nn/common.py index cd15bd594b411..e8dc513ed4eea 100644 --- a/python/paddle/static/nn/common.py +++ b/python/paddle/static/nn/common.py @@ -1045,13 +1045,13 @@ def conv2d_transpose( If `padding` = `"SAME"`: .. math:: - H^\prime_{out} &= \frac{(H_{in} + stride[0] - 1)}{stride[0]} \\\\ + H^\prime_{out} &= \frac{(H_{in} + stride[0] - 1)}{stride[0]} \\ W^\prime_{out} &= \frac{(H_{in} + stride[1] - 1)}{stride[1]} If `padding` = `"VALID"`: .. math:: - H^\prime_{out} &= (H_{in} - 1) * stride[0]} + dilations[0] * (H_f - 1) + 1 \\\\ + H^\prime_{out} &= (H_{in} - 1) * stride[0]} + dilations[0] * (H_f - 1) + 1 \\ W^\prime_{out} &= (W_{in} − 1) * strides[1] + dilations[1] * (W_f − 1) + 1 If output_size is None, :math:`H_{out} = H^\prime_{out}, W_{out} = W^\prime_{out}`; @@ -1418,15 +1418,15 @@ def conv3d_transpose( If `padding` = `"SAME"`: .. math:: - D^\prime_{out} &= \frac{(D_{in} + stride[0] - 1)}{stride[0]} \\\\ - H^\prime_{out} &= \frac{(H_{in} + stride[1] - 1)}{stride[1]} \\\\ + D^\prime_{out} &= \frac{(D_{in} + stride[0] - 1)}{stride[0]} \\ + H^\prime_{out} &= \frac{(H_{in} + stride[1] - 1)}{stride[1]} \\ W^\prime_{out} &= \frac{(H_{in} + stride[2] - 1)}{stride[2]} If `padding` = `"VALID"`: .. math:: - D^\prime_{out} &= (D_{in} - 1) * stride[0]} + dilations[0] * (D_f - 1) + 1 \\\\ - H^\prime_{out} &= (H_{in} - 1) * stride[1]} + dilations[1] * (H_f - 1) + 1 \\\\ + D^\prime_{out} &= (D_{in} - 1) * stride[0]} + dilations[0] * (D_f - 1) + 1 \\ + H^\prime_{out} &= (H_{in} - 1) * stride[1]} + dilations[1] * (H_f - 1) + 1 \\ W^\prime_{out} &= (W_{in} − 1) * strides[2] + dilations[2] * (W_f − 1) + 1 If `output_size` is None, :math:`D_{out} = D^\prime_{out}, :math:`H_{out} = \ From 18a171d195d1f9c30c6e8b15309df9b238fe2d8d Mon Sep 17 00:00:00 2001 From: Ligoml <39876205+Ligoml@users.noreply.github.com> Date: Fri, 23 Dec 2022 17:19:33 +0800 Subject: [PATCH 12/16] formula; test=document_fix --- python/paddle/static/nn/common.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/python/paddle/static/nn/common.py b/python/paddle/static/nn/common.py index e8dc513ed4eea..923f78edc2502 100644 --- a/python/paddle/static/nn/common.py +++ b/python/paddle/static/nn/common.py @@ -1038,7 +1038,7 @@ def conv2d_transpose( .. math:: H^\prime_{out} &= (H_{in} - 1) * strides[0] - 2 * paddings[0] + dilations[0] * (H_f - 1) + 1 \\ - W^\prime_{out} &= (W_{in} - 1) * strides[1] - 2 * paddings[0] + dilations[1] * (W_f - 1) + 1 \\ + W^\prime_{out} &= (W_{in} - 1) * strides[1] - 2 * paddings[1] + dilations[1] * (W_f - 1) + 1 \\ H_{out} &\in [ H^\prime_{out}, H^\prime_{out} + strides[0] ] \\ W_{out} &\in [ W^\prime_{out}, W^\prime_{out} + strides[1] ] @@ -1051,7 +1051,7 @@ def conv2d_transpose( If `padding` = `"VALID"`: .. math:: - H^\prime_{out} &= (H_{in} - 1) * stride[0]} + dilations[0] * (H_f - 1) + 1 \\ + H^\prime_{out} &= (H_{in} - 1) * strides[0] + dilations[0] * (H_f - 1) + 1 \\ W^\prime_{out} &= (W_{in} − 1) * strides[1] + dilations[1] * (W_f − 1) + 1 If output_size is None, :math:`H_{out} = H^\prime_{out}, W_{out} = W^\prime_{out}`; @@ -1409,8 +1409,8 @@ def conv3d_transpose( .. math:: D^\prime_{out} &= (D_{in} - 1) * strides[0] - 2 * paddings[0] + dilations[0] * (D_f - 1) + 1 \\ - H^\prime_{out} &= (H_{in} - 1) * strides[1] - 2 * paddings[0] + dilations[1] * (H_f - 1) + 1 \\ - W^\prime_{out} &= (W_{in} - 1) * strides[2] - 2 * paddings[0] + dilations[2] * (W_f - 1) + 1 \\ + H^\prime_{out} &= (H_{in} - 1) * strides[1] - 2 * paddings[1] + dilations[1] * (H_f - 1) + 1 \\ + W^\prime_{out} &= (W_{in} - 1) * strides[2] - 2 * paddings[2] + dilations[2] * (W_f - 1) + 1 \\ D_{out} &\in [ D^\prime_{out}, D^\prime_{out} + strides[0] ] \\ H_{out} &\in [ H^\prime_{out}, H^\prime_{out} + strides[1] ] \\ W_{out} &\in [ W^\prime_{out}, W^\prime_{out} + strides[2] ] @@ -1425,8 +1425,8 @@ def conv3d_transpose( If `padding` = `"VALID"`: .. math:: - D^\prime_{out} &= (D_{in} - 1) * stride[0]} + dilations[0] * (D_f - 1) + 1 \\ - H^\prime_{out} &= (H_{in} - 1) * stride[1]} + dilations[1] * (H_f - 1) + 1 \\ + D^\prime_{out} &= (D_{in} - 1) * strides[0] + dilations[0] * (D_f - 1) + 1 \\ + H^\prime_{out} &= (H_{in} - 1) * strides[1] + dilations[1] * (H_f - 1) + 1 \\ W^\prime_{out} &= (W_{in} − 1) * strides[2] + dilations[2] * (W_f − 1) + 1 If `output_size` is None, :math:`D_{out} = D^\prime_{out}, :math:`H_{out} = \ From 5a3689bb142915e957b383e6a1fde9fd4d83f8b1 Mon Sep 17 00:00:00 2001 From: loneranger <836253168@qq.com> Date: Sun, 22 Jan 2023 23:54:18 +0800 Subject: [PATCH 13/16] =?UTF-8?q?=E4=B8=BAbilinear=5Ftensor=5Fproduct?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0x=E5=92=8Cy=E7=BB=B4=E5=BA=A6=E7=9A=84?= =?UTF-8?q?=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- python/paddle/static/nn/common.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/python/paddle/static/nn/common.py b/python/paddle/static/nn/common.py index 53954f49f343a..0714189aac6ae 100644 --- a/python/paddle/static/nn/common.py +++ b/python/paddle/static/nn/common.py @@ -2558,7 +2558,18 @@ def bilinear_tensor_product( """ helper = LayerHelper('bilinear_tensor_product', **locals()) dtype = helper.input_dtype('x') - + if len(x.shape) != 2: + raise ValueError( + "Input x should be 2D tensor, but received x with the shape of {}".format( + x.shape + ) + ) + if len(y.shape) != 2: + raise ValueError( + "Input y should be 2D tensor, but received y with the shape of {}".format( + y.shape + ) + ) param_shape = [size, x.shape[1], y.shape[1]] w = helper.create_parameter( From 33f9bc65d69d18cf6126f21b79aa8863d7636949 Mon Sep 17 00:00:00 2001 From: loneranger <836253168@qq.com> Date: Mon, 30 Jan 2023 21:46:24 +0800 Subject: [PATCH 14/16] =?UTF-8?q?=E4=B8=BAbilinear=5Ftensor=5Fproduct?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=8D=95=E6=B5=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tests/unittests/test_bilinear_tensor_product_op.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/python/paddle/fluid/tests/unittests/test_bilinear_tensor_product_op.py b/python/paddle/fluid/tests/unittests/test_bilinear_tensor_product_op.py index 77416dd9826fb..a411c202ec3b8 100644 --- a/python/paddle/fluid/tests/unittests/test_bilinear_tensor_product_op.py +++ b/python/paddle/fluid/tests/unittests/test_bilinear_tensor_product_op.py @@ -35,6 +35,12 @@ def test_errors(self): x2 = fluid.data(name='x2', shape=[-1, 4], dtype="float32") self.assertRaises(TypeError, layer, x1, x2) + with fluid.program_guard(fluid.Program(), fluid.Program()): + paddle.enable_static() + x3 = paddle.static.data("", shape=[0], dtype="float32") + x4 = paddle.static.data("", shape=[0], dtype="float32") + paddle.static.nn.bilinear_tensor_product(x3, x4, 1000) + class TestBilinearTensorProductOp(OpTest): def setUp(self): From c01848b751bea5187903c317e442ecd9dba6de09 Mon Sep 17 00:00:00 2001 From: loneranger <836253168@qq.com> Date: Sun, 5 Feb 2023 22:06:46 +0800 Subject: [PATCH 15/16] =?UTF-8?q?=E5=AE=8C=E5=96=84bilinear=5Ftensor=5Fpro?= =?UTF-8?q?duct=E7=9A=84=E5=8D=95=E6=B5=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../unittests/test_bilinear_tensor_product_op.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/python/paddle/fluid/tests/unittests/test_bilinear_tensor_product_op.py b/python/paddle/fluid/tests/unittests/test_bilinear_tensor_product_op.py index a411c202ec3b8..350b6ca72f467 100644 --- a/python/paddle/fluid/tests/unittests/test_bilinear_tensor_product_op.py +++ b/python/paddle/fluid/tests/unittests/test_bilinear_tensor_product_op.py @@ -34,12 +34,17 @@ def test_errors(self): x1 = fluid.data(name='x1', shape=[-1, 5], dtype="float16") x2 = fluid.data(name='x2', shape=[-1, 4], dtype="float32") self.assertRaises(TypeError, layer, x1, x2) - - with fluid.program_guard(fluid.Program(), fluid.Program()): + # the dimensions of x and y must be 2 paddle.enable_static() x3 = paddle.static.data("", shape=[0], dtype="float32") x4 = paddle.static.data("", shape=[0], dtype="float32") - paddle.static.nn.bilinear_tensor_product(x3, x4, 1000) + self.assertRaises( + ValueError, + paddle.static.nn.bilinear_tensor_product, + x3, + x4, + 1000, + ) class TestBilinearTensorProductOp(OpTest): From 1997d7759ef6e795c06f911bd7294744c0ad575c Mon Sep 17 00:00:00 2001 From: loneranger <836253168@qq.com> Date: Mon, 6 Feb 2023 12:36:23 +0800 Subject: [PATCH 16/16] fix bilinear_tensor_product --- python/paddle/static/nn/common.py | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/python/paddle/static/nn/common.py b/python/paddle/static/nn/common.py index 8ee73228d8cb8..07be93fb55bda 100644 --- a/python/paddle/static/nn/common.py +++ b/python/paddle/static/nn/common.py @@ -2568,16 +2568,10 @@ def bilinear_tensor_product( """ helper = LayerHelper('bilinear_tensor_product', **locals()) dtype = helper.input_dtype('x') - if len(x.shape) != 2: + if len(x.shape) != 2 or len(y.shape) != 2: raise ValueError( - "Input x should be 2D tensor, but received x with the shape of {}".format( - x.shape - ) - ) - if len(y.shape) != 2: - raise ValueError( - "Input y should be 2D tensor, but received y with the shape of {}".format( - y.shape + "Input x and y should be 2D tensor, but received x with the shape of {}, y with the shape of {}".format( + x.shape, y.shape ) ) param_shape = [size, x.shape[1], y.shape[1]]