Document feedback

Question document fragment

When a question document fragment contains a formula, it is displayed as a space.

Submission type
issue

It's a little complicated...

I'd like to ask someone.

PR

Just a small problem.

I can fix it online!

Please select the submission type

Problem type
Specifications and Common Mistakes

- Specifications and Common Mistakes:

- Misspellings or punctuation mistakes,incorrect formulas, abnormal display.

- Incorrect links, empty cells, or wrong formats.

- Chinese characters in English context.

- Minor inconsistencies between the UI and descriptions.

- Low writing fluency that does not affect understanding.

- Incorrect version numbers, including software package names and version numbers on the UI.

Usability

- Usability:

- Incorrect or missing key steps.

- Missing main function descriptions, keyword explanation, necessary prerequisites, or precautions.

- Ambiguous descriptions, unclear reference, or contradictory context.

- Unclear logic, such as missing classifications, items, and steps.

Correctness

- Correctness:

- Technical principles, function descriptions, supported platforms, parameter types, or exceptions inconsistent with that of software implementation.

- Incorrect schematic or architecture diagrams.

- Incorrect commands or command parameters.

- Incorrect code.

- Commands inconsistent with the functions.

- Wrong screenshots.

- Sample code running error, or running results inconsistent with the expectation.

Risk Warnings

- Risk Warnings:

- Lack of risk warnings for operations that may damage the system or important data.

Content Compliance

- Content Compliance:

- Contents that may violate applicable laws and regulations or geo-cultural context-sensitive words and expressions.

- Copyright infringement.

Please select the type of question

Problem description

Describe the bug so that we can quickly locate the problem.

mindspore.ops.Conv2DTranspose

View Source On Gitee
class mindspore.ops.Conv2DTranspose(out_channel, kernel_size, pad_mode='valid', pad=0, pad_list=None, mode=1, stride=1, dilation=1, group=1, data_format='NCHW')[source]

Calculates a 2D transposed convolution, which can be regarded as Conv2d for the gradient of the input, also called deconvolution, although it is not an actual deconvolution. Because it cannot restore the original input data completely, but it can restore the shape of the original input.

Parameters
  • out_channel (int) – The dimensionality of the output space.

  • kernel_size (Union[int, tuple[int]]) – The size of the convolution window.

  • pad_mode (str, optional) –

    Specifies the padding mode with a padding value of 0. It can be set to: "same" , "valid" or "pad" . Default: "valid" .

    • "same": Pad the input around its edges so that the shape of input and output are the same when stride is set to 1. The amount of padding to is calculated by the operator internally, If the amount is even, it is uniformly distributed around the input, if it is odd, the excess amount goes to the right/bottom side. If this mode is set, pad must be 0.

    • "valid": No padding is applied to the input, and the output returns the maximum possible height and width. Extra pixels that could not complete a full stride will be discarded. If this mode is set, pad must be 0.

    • "pad": Pad the input with a specified amount. In this mode, the amount of padding in the height and width directions is determined by the pad parameter. If this mode is set, pad must be greater than or equal to 0.

    Please refer to mindspore.nn.Conv2dTranspose for more specifications about pad_mode.

  • pad (Union[int, tuple[int]], optional) – The pad value to be filled. Default: 0 . If pad is an integer, the paddings of top, bottom, left and right are the same, equal to pad. If pad is a tuple of four integers, the padding of top, bottom, left and right equal to pad[0], pad[1], pad[2], and pad[3] correspondingly.

  • pad_list (Union[str, None], optional) – The pad list like (top, bottom, left, right). Default: None .

  • mode (int, optional) – Modes for different convolutions. The value is currently not used. Default: 1 .

  • stride (Union[int, tuple[int]], optional) – The stride to be applied to the convolution filter. Default: 1 .

  • dilation (Union[int, tuple[int]], optional) – Specifies the dilation rate to be used for the dilated convolution. Default: 1 .

  • group (int, optional) – Splits input into groups. Default: 1 .

  • data_format (str, optional) – The format of input and output data. It should be 'NHWC' or 'NCHW' . Default is 'NCHW' .

Inputs:
  • dout (Tensor) - the gradients with respect to the output of the convolution. The shape conforms to the default data_format (N,Cout,Hout,Wout).

  • weight (Tensor) - Set size of kernel is (K1,K2), then the shape is (Cout,Cin,K1,K2).

  • input_size (Tensor) - A tuple describes the shape of the input which conforms to the format (N,Cin,Hin,Win).

Outputs:

Tensor, the gradients with respect to the input of convolution. It has the same shape as the input.

Raises
  • TypeError – If kernel_size, stride, pad or dilation is neither an int nor a tuple.

  • TypeError – If out_channel or group is not an int.

  • ValueError – If kernel_size, stride or dilation is less than 1.

  • ValueError – If pad_mode is not one of 'same', 'valid' or 'pad'.

  • ValueError – If padding is a tuple whose length is not equal to 4.

  • ValueError – If pad_mode it not equal to 'pad' and pad is not equal to (0, 0, 0, 0).

  • ValueError – If data_format is neither 'NCHW' nor 'NHWC'.

Supported Platforms:

Ascend GPU CPU

Examples

>>> import mindspore
>>> import numpy as np
>>> from mindspore import Tensor, ops
>>> dout = Tensor(np.ones([10, 32, 30, 30]), mindspore.float32)
>>> weight = Tensor(np.ones([32, 32, 3, 3]), mindspore.float32)
>>> x = Tensor(np.ones([10, 32, 32, 32]))
>>> conv2d_transpose_input = ops.Conv2DTranspose(out_channel=32, kernel_size=3)
>>> output = conv2d_transpose_input(dout, weight, ops.shape(x))
>>> print(output.shape)
(10, 32, 32, 32)