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,.,.) = 
#>  -0.9863 -2.1015 -0.7686  4.6569  4.3497
#>  -4.9922  3.4184  0.0460 -0.6890  7.4952
#>   5.5314 -1.1805 -0.0253  5.8615 -2.7114
#>   2.1113  3.0726  7.1237 -2.0755 -3.5216
#>   4.6665 -5.3079 -2.6928 -0.7921  1.6514
#> 
#> (1,2,.,.) = 
#>  -5.4506 -14.0902  0.0557  9.6182  1.5526
#>   0.7919  0.8676  4.5834  4.1394 -0.5979
#>  -2.8559  2.2970  4.3644 -14.7250 -1.2473
#>  -5.2405 -2.2707 -2.3420  0.0843  3.2389
#>   1.5088 -0.2471  2.9301  6.5253  4.5815
#> 
#> (1,3,.,.) = 
#>   -8.1272  -3.7910   1.7024  10.5755   1.1526
#>    5.3352   0.1813   7.7843   1.7031   2.8132
#>    5.1791  -4.5619   4.4660  -2.8693   7.4604
#>    2.2076   1.4190  -2.2263  -2.5487  -3.6389
#>    2.8728  -2.9609   4.4764  -3.8207   4.7798
#> 
#> (1,4,.,.) = 
#>    7.5384   5.1471   3.5030  -6.6308   2.5658
#>   -3.0810  -7.5815  -5.2492   8.1604  -2.4829
#>    4.6761  -3.1848   3.4074   0.4728  -0.2657
#>   -5.8688  13.5493   3.0594 -13.3597   0.1405
#>   -2.6346  -4.1050   1.9900   6.8615   1.5911
#> 
#> (1,5,.,.) = 
#>  -1.4595 -6.9167 -9.4588  4.4856  3.8772
#> ... [the output was truncated (use n=-1 to disable)]
#> [ CPUFloatType{1,8,5,5} ]