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.

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.mint.nn.ConvTranspose2d

class mindspore.mint.nn.ConvTranspose2d(in_channels, out_channels, kernel_size, stride=1, padding=0, output_padding=0, groups=1, bias=True, dilation=1, padding_mode='zeros', dtype=None)[source]

Applies a 2D transposed convolution operator over an input image composed of several input planes.

This module can be seen as the gradient of Conv2d with respect to its input. It is also known as a fractionally-strided convolution or a deconvolution (although it is not an actual deconvolution operation as it does not compute a true inverse of convolution).

The parameters kernel_size, stride, padding, output_padding can either be:

  • a single int – in which case the same value is used for the height and width dimensions

  • a tuple of two ints – in which case, the first int is used for the height dimension, and the second int for the width dimension

Warning

  • This is an experimental API that is subject to change or deletion.

  • In the scenario where inputs are non-contiguous, output_padding must be less than stride .

  • For Atlas training products, when the dtype of input is float32, the groups only supports 1.

Parameters
  • in_channels (int) – Number of channels in the input image.

  • out_channels (int) – Number of channels produced by the convolution.

  • kernel_size (Union[int, tuple(int)]) – Size of the convolving kernel.

  • stride (Union[int, tuple(int)], optional) – Stride of the convolution. Default: 1 .

  • padding (Union[int, tuple(int)], optional) – dilation(kernel_size1)padding zero-padding will be added to both sides of each dimension in the input. Default: 0 .

  • output_padding (Union[int, tuple(int)], optional) – Additional size added to one side of each dimension in the output shape. The value of output_padding must be less than stride or dilation . Default: 0 .

  • groups (int, optional) – Number of blocked connections from input channels to output channels. Default: 1

  • bias (bool, optional) – If True, adds a learnable bias to the output. Default: True .

  • dilation (Union[int, tuple(int)], optional) – Spacing between kernel elements. Default: 1 .

  • padding_mode (str, optional) – Specifies the padding mode with a padding value. For now, it can only be set to: "zeros". Default: "zeros" .

  • dtype (mindspore.dtype, optional) – Dtype of Parameters. Default: None , when it's None , the dtype of Parameters would be mstype.float32.

Variables:
  • weigh (Parameter) - the learnable weights of the module of shape (in_channels,out_channelsgroups,kernel_size[0],kernel_size[1]) . The values of these weights are sampled from U(k,k) where k=groupsCouti=01kernel_size[i]

  • bias (Parameter) - the learnable bias of the module of shape (out_channels,) . If bias is True, then the values of these weights are sampled from U(k,k) where k=groupsCouti=01kernel_size[i] .

Inputs:
  • input (Tensor) - Tensor of shape (N,Cin,Hin,Win) or (Cin,Hin,Win) .

Outputs:

Tensor of shape (N,Cout,Hout,Wout) or (Cout,Hout,Wout), where

Hout=(Hin1)×stride[0]2×padding[0]+dilation[0]×(kernel_size[0]1)+output_padding[0]+1
Wout=(Win1)×stride[1]2×padding[1]+dilation[1]×(kernel_size[1]1)+output_padding[1]+1
Supported Platforms:

Ascend

Examples

>>> import mindspore as ms
>>> from mindspore import mint
>>> # With square kernels and equal stride
>>> m = mint.nn.ConvTranspose2d(16, 33, 3, stride=2)
>>> # non-square kernels and unequal stride and with padding
>>> m = mint.nn.ConvTranspose2d(16, 33, (3, 5), stride=(2, 1), padding=(4, 2))
>>> input = mint.randn(20, 16, 50, 100)
>>> output = m(input)
>>> # exact output size can be also specified as an argument
>>> input = mint.randn(1, 16, 12, 12)
>>> downsample = mint.nn.Conv2d(16, 16, 3, stride=2, padding=1)
>>> upsample = mint.nn.ConvTranspose2d(16, 16, 3, stride=2, padding=1)
>>> h = downsample(input)
>>> h.shape
(1, 16, 6, 6)
>>> output = upsample(h, output_size=input.shape)
>>> output.shape
(1, 16, 12, 12)