Skip to contents

Conv_transpose2d

Usage

torch_conv_transpose2d(
  input,
  weight,
  bias = list(),
  stride = 1L,
  padding = 0L,
  output_padding = 0L,
  groups = 1L,
  dilation = 1L
)

Arguments

input

input tensor of shape \((\mbox{minibatch} , \mbox{in\_channels} , iH , iW)\)

weight

filters of shape \((\mbox{in\_channels} , \frac{\mbox{out\_channels}}{\mbox{groups}} , kH , kW)\)

bias

optional bias of shape \((\mbox{out\_channels})\). Default: NULL

stride

the stride of the convolving kernel. Can be a single number or a tuple (sH, sW). Default: 1

padding

dilation * (kernel_size - 1) - padding zero-padding will be added to both sides of each dimension in the input. Can be a single number or a tuple (padH, padW). Default: 0

output_padding

additional size added to one side of each dimension in the output shape. Can be a single number or a tuple (out_padH, out_padW). Default: 0

groups

split input into groups, \(\mbox{in\_channels}\) should be divisible by the number of groups. Default: 1

dilation

the spacing between kernel elements. Can be a single number or a tuple (dH, dW). Default: 1

conv_transpose2d(input, weight, bias=NULL, stride=1, padding=0, output_padding=0, groups=1, dilation=1) -> Tensor

Applies a 2D transposed convolution operator over an input image composed of several input planes, sometimes also called "deconvolution".

See nn_conv_transpose2d() for details and output shape.

Examples

if (torch_is_installed()) {

# With square kernels and equal stride
inputs = torch_randn(c(1, 4, 5, 5))
weights = torch_randn(c(4, 8, 3, 3))
nnf_conv_transpose2d(inputs, weights, padding=1)
}
#> torch_tensor
#> (1,1,.,.) = 
#>    1.4408   0.8382   4.9069   2.8993   6.7551
#>   -4.6352  -2.0035  -2.4074  18.6898   1.4565
#>   -3.1942   1.2563   8.6933  -3.8462  -6.3181
#>   -3.0228   0.4978  -7.3544   0.7945  -6.5071
#>   -3.7706   0.5171   7.1583  -0.8703  -4.4397
#> 
#> (1,2,.,.) = 
#>   -2.2911  13.5251   2.6689  -0.6449  -4.5406
#>    1.9914   4.6300   0.6945  -5.5953   1.6400
#>    3.6180  -0.3728   3.4228   4.9939   3.8091
#>   -5.3116   5.8967  14.4885   1.2056 -11.7310
#>   -5.4562   5.5148   1.4307  -1.9449  -1.6181
#> 
#> (1,3,.,.) = 
#>   2.7426  8.5599 -1.7288 -8.6989 -5.7267
#>  -2.8118  6.7755 -1.9225 -18.2323  3.2126
#>   7.3890  3.1476 -8.9122 -2.0824  1.3089
#>   0.4411 -6.7122 -12.3026 -1.6891 -12.3860
#>   6.1455  7.5829  8.3157  2.1556 -3.5177
#> 
#> (1,4,.,.) = 
#>  -0.7767 -4.7788 -1.1686  2.0426  1.6775
#>   1.5072 -1.8297  0.3094  0.5100 -0.8393
#>  -3.1240 -2.6774  4.9123  1.5382 -5.5920
#>  -0.2636  4.4221  7.4430 -3.4589  1.6874
#>   1.3038 -2.1575 -0.9253 -1.1700 -4.2466
#> 
#> (1,5,.,.) = 
#>    8.8429   4.8481   0.1285  -0.4408   4.9225
#> ... [the output was truncated (use n=-1 to disable)]
#> [ CPUFloatType{1,8,5,5} ]