Deconvolution¶
Computes a 2D or 3D deconvolution of an input tensor into an output tensor.
Note
This layer is also known as ConvTranspose.
Attributes¶
kernel_size
An array of 2 or 3 elements, describing the size of the deconvolution kernel in each spatial dimension.
the size of the array(2 or 3) determines the type of the deconvolution, 2D or 3D.
padding_mode
The padding mode. The padding mode can be one of the following:
EXPLICIT_ROUND_DOWN
Use explicit padding, rounding the output size down.\(O = \lfloor\frac{M - F}{S}\rfloor + 1\)EXPLICIT_ROUND_UP
Use explicit padding, rounding the output size up.\(O = \lceil\frac{M - F}{S}\rceil + 1\)SAME_UPPER
UseSAME
padding, with \(\text{pre-padding} \leq \text{post-padding}\).\(\begin{gather}O = \lceil\frac{I}{S}\rceil \\ P = \lfloor\frac{I-1}{S}\rfloor \cdot S + F -I \\ B = \lfloor\frac{P}{2}\rfloor \\ A = P - B \end{gather}\)SAME_LOWER
UseSAME
padding, with \(\text{pre-padding} \geq \text{post-padding}\).\(\begin{gather}O = \lceil\frac{I}{S}\rceil \\ P = \lfloor\frac{I-1}{S}\rfloor \cdot S + F -I \\ A = \lfloor\frac{P}{2}\rfloor \\ B = P - A \end{gather}\)CAFFE_ROUND_DOWN
UseCAFFE
padding, rounding the output size down. It uses the pre-padding value.\(O = \lceil\frac{M-F}{S}\rceil \cdot (1-S) -S \geq I + B\)CAFFE_ROUND_UP
UseCAFFE
padding, rounding output size up. It uses the pre-padding value.\(O = \lfloor\frac{M-F}{S}\rfloor \cdot (1-S) -S \geq I + B\)
pre_padding
the amount of pre-padding to use for each spatial dimension.
post_padding
the amount of post-padding to use for each spatial dimension.
stride
the stride to use for each spatial dimension.
dilation
the dilation factor for each spatial dimension.
num_output_maps
the number of output feature maps in the layer’s output.
num_groups
the number of groups in the layer’s output. When int8
data type is used, the number of groups must be a multiply of 4 for both input and output.
kernel_weights
pointer to the layer’s weights.
bias_weights
pointer to the layer’s bias.
Inputs¶
input: tensor of type T
.
Outputs¶
output: tensor of type T
.
Data Types¶
T: int8
, float16
, float32
Shape Information¶
input is a tensor with a shape of \([a_0,...,a_n]\)
kernel_size is an array \([k_0,...,k_{m-1}], m \in [2,3]\)
output is a tensor with a shape of \([b_0,...,b_n]\), where:
Examples¶
Deconvolution
in1 = network.add_input("input1", dtype=trt.float32, shape=(1, 1, 3, 3))
layer = network.add_deconvolution_nd(
in1, num_output_maps=1, kernel_shape=(3, 3), kernel=np.ones(shape=(1, 1, 3, 3), dtype=np.float32)
)
network.mark_output(layer.get_output(0))
inputs[in1.name] = np.array([[[[-3.0, -2.0, -1.0], [0.0, 1.0, 2.0], [2.0, 5.0, 6.0]]]])
outputs[layer.get_output(0).name] = layer.get_output(0).shape
expected[layer.get_output(0).name] = np.array(
[
[
[
[-3.0, -5.0, -6.0, -3.0, -1.0],
[-3.0, -4.0, -3.0, 0.0, 1.0],
[-1.0, 3.0, 10.0, 11.0, 7.0],
[2.0, 8.0, 16.0, 14.0, 8.0],
[2.0, 7.0, 13.0, 11.0, 6.0],
]
]
]
)
C++ API¶
For more information about the C++ IDeconvolutionLayer operator, refer to the C++ IDeconvolutionLayer documentation.
Python API¶
For more information about the Python IDeconvolutionLayer operator, refer to the Python IDeconvolutionLayer documentation.