# Conv3DTranspose¶

class paddle.fluid.dygraph.Conv3DTranspose(num_channels, num_filters, filter_size, padding=0, stride=1, dilation=1, groups=None, param_attr=None, bias_attr=None, use_cudnn=True, act=None, dtype='float32')[source]

Convlution3D transpose layer

The convolution3D transpose layer calculates the output based on the input, filter, and dilations, strides, paddings. Input(Input) and output(Output) are in NCDHW format. Where N is batch size, C is the number of channels, D is the depth of the feature, H is the height of the feature, and W is the width of the feature. Parameters(dilations, strides, paddings) are two elements. These two elements represent height and width, respectively. The details of convolution transpose layer, please refer to the following explanation and references therein. If bias attribution and activation type are provided, bias is added to the output of the convolution, and the corresponding activation function is applied to the final result.

For each input $$X$$, the equation is:

$Out = \sigma (W \ast X + b)$

In the above equation:

• $$X$$: Input value, a tensor with NCDHW format.

• $$W$$: Filter value, a tensor with MCDHW format.

• $$\ast$$: Convolution operation.

• $$b$$: Bias value, a 2-D tensor with shape [M, 1].

• $$\sigma$$: Activation function.

• $$Out$$: Output value, the shape of $$Out$$ and $$X$$ may be different.

Example

• Input:

Input shape: $$(N, C_{in}, D_{in}, H_{in}, W_{in})$$

Filter shape: $$(C_{in}, C_{out}, D_f, H_f, W_f)$$

• Output:

Output shape: $$(N, C_{out}, D_{out}, H_{out}, W_{out})$$

Where

$\begin{split}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_{out} &\in [ D^\prime_{out}, D^\prime_{out} + strides[0] ] \\ H_{out} &\in [ H^\prime_{out}, H^\prime_{out} + strides[1] ] \\\end{split}$

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, $$H_{out} = H^\prime_{out}, :math:$$; else, the $$D_{out}$$ of the output size must between $$D^\prime_{out}$$ and $$D^\prime_{out} + strides[0]$$, the $$H_{out}$$ of the output size must between $$H^\prime_{out}$$ and $$H^\prime_{out} + strides[1]$$, and the $$W_{out}$$ of the output size must between $$W^\prime_{out}$$ and $$W^\prime_{out} + strides[2]$$, conv3d_transpose can compute the kernel size automatically.

Parameters
• num_channels (int) – The number of channels in the input image.

• num_filters (int) – The number of the filter. It is as same as the output image channel.

• filter_size (int|tuple) – The filter size. If filter_size is a tuple, it must contain three integers, (filter_size_D, filter_size_H, filter_size_W). Otherwise, the filter will be a square.

adds dilation * (kernel - 1) amount of zero-padding on both sides of input. If padding is a string, either ‘VALID’ or ‘SAME’ supported, which is the padding algorithm. If padding is a tuple or list, it could be in three forms: [pad_depth, pad_height, pad_width] or

• stride (int|tuple, optional) – The stride size. It means the stride in transposed convolution. If stride is a tuple, it must contain three integers, (stride_depth, stride_height, stride_width). Otherwise, stride_depth = stride_height = stride_width = stride. The default value is 1.

• dilation (int|tuple, optional) – The dilation size. If dilation is a tuple, it must contain three integers, (dilation_D, dilation_H, dilation_W). Otherwise, the dilation_D = dilation_H = dilation_W = dilation. The default value is 1.

• groups (int, optional) – The groups number of the Conv3d 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 first half of the input channels, while the second half of the filters is only connected to the second half of the input channels. The default value is 1.

• param_attr (ParamAttr, optional) – The parameter attribute for learnable parameters/weights of conv3d_transpose. If it is set to None or one attribute of ParamAttr, conv3d_transpose will create ParamAttr as param_attr. If the Initializer of the param_attr is not set, the parameter is initialized with Xavier. The default value is None.

• bias_attr (ParamAttr|bool, optional) – The parameter attribute for the bias of conv3d_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, conv3d_transpose will create ParamAttr as bias_attr. If the Initializer of the bias_attr is not set, the bias is initialized zero. The default value is None.

• use_cudnn (bool, optional) – Use cudnn kernel or not, it is valid only when the cudnn library is installed. The default value is True.

• act (str, optional) – Activation type, if it is set to None, activation is not appended. The default value is 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 Name.

Attribute:

weight (Parameter): the learnable weights of filters of this layer.

bias (Parameter): the learnable bias of this layer.

Returns

None.

Raises

ValueError – If the shapes of input, filter_size, stride, padding and groups mismatch.

Examples

import paddle.fluid as fluid
import numpy

with fluid.dygraph.guard():
data = numpy.random.random((5, 3, 12, 32, 32)).astype('float32')
conv3dTranspose = fluid.dygraph.nn.Conv3DTranspose(
num_channels=3,
num_filters=12,
filter_size=12,
use_cudnn=False)
ret = conv3dTranspose(fluid.dygraph.base.to_variable(data))

forward(input)

Defines the computation performed at every call. Should be overridden by all subclasses.

Parameters
• *inputs (tuple) – unpacked tuple arguments

• **kwargs (dict) – unpacked dict arguments