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,.,.) = 
#>  -16.4915  -7.1084   2.2552  -5.5098  -1.9551
#>   -0.0960  -4.6960   0.3408   5.5424  -6.6240
#>   -4.6362   6.1942  -3.9790 -12.1864 -10.5656
#>    1.0288  -1.2155   2.6384  -5.0723 -17.1100
#>   -1.4404  -2.5701   3.7745  -2.0833   1.3002
#> 
#> (1,2,.,.) = 
#>  -5.1453  1.6284 -2.1693 -5.0362 -4.8813
#>  -4.8790 -10.5559 -1.4654  1.2554 -2.5333
#>   2.9571 -3.7017  9.2761 -8.1789 -0.4773
#>  -2.7921  7.7110  2.5923 -6.8664  6.9055
#>  -4.5503  4.2681  4.6297 -3.0151  0.2031
#> 
#> (1,3,.,.) = 
#>    1.0281  -9.6812  16.3552   6.3669  -4.6126
#>    0.5148   1.2316 -15.6037  -6.6426   3.6358
#>    5.3912  -0.1138  17.5092   5.3323  -3.8475
#>    6.1143  10.5162 -14.1057  -5.6480  -4.1088
#>    3.8699   3.1543   0.5277  -7.4548  -8.1097
#> 
#> (1,4,.,.) = 
#>    4.1664  -5.9036  -0.3487  -2.9725  -4.5606
#>   -4.1471   5.6767  13.3075 -19.9812  -3.1175
#>    2.0599  -2.7947   8.5322  -8.9522  -1.2739
#>   -2.3672   4.9684   8.6299 -12.7486  -4.0735
#>   -5.3846  -1.7668   6.3076  -1.4303   6.1592
#> 
#> (1,5,.,.) = 
#>  -0.5800  9.3276 -2.5061 -0.1393  8.5250
#> ... [the output was truncated (use n=-1 to disable)]
#> [ CPUFloatType{1,8,5,5} ]