Conv2d
Source:R/gen-namespace-docs.R
, R/gen-namespace-examples.R
, R/gen-namespace.R
torch_conv2d.Rd
Conv2d
Usage
torch_conv2d(
input,
weight,
bias = list(),
stride = 1L,
padding = 0L,
dilation = 1L,
groups = 1L
)
Arguments
- input
input tensor of shape \((\mbox{minibatch} , \mbox{in\_channels} , iH , iW)\)
- weight
filters of shape \((\mbox{out\_channels} , \frac{\mbox{in\_channels}}{\mbox{groups}} , kH , kW)\)
- bias
optional bias tensor 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
implicit paddings on both sides of the input. Can be a single number or a tuple
(padH, padW)
. Default: 0- dilation
the spacing between kernel elements. Can be a single number or a tuple
(dH, dW)
. Default: 1- groups
split input into groups, \(\mbox{in\_channels}\) should be divisible by the number of groups. Default: 1
conv2d(input, weight, bias=NULL, stride=1, padding=0, dilation=1, groups=1) -> Tensor
Applies a 2D convolution over an input image composed of several input planes.
See nn_conv2d()
for details and output shape.
Examples
if (torch_is_installed()) {
# With square kernels and equal stride
filters = torch_randn(c(8,4,3,3))
inputs = torch_randn(c(1,4,5,5))
nnf_conv2d(inputs, filters, padding=1)
}
#> torch_tensor
#> (1,1,.,.) =
#> 2.4975 0.7018 -4.6872 -6.0053 8.9148
#> -3.9835 -0.0577 -5.2685 4.8591 -2.4998
#> 1.0087 -3.5754 -6.7111 -4.4273 6.8516
#> -4.6899 4.3283 -1.2895 -5.7197 -0.3994
#> -10.3614 4.5721 -3.1797 -1.5449 2.2693
#>
#> (1,2,.,.) =
#> 7.6083 5.9991 -4.0038 -0.8082 -2.2552
#> 1.4880 -9.6177 2.6376 -5.2796 4.5499
#> 1.6570 -0.0920 7.3322 -10.5819 8.7521
#> 8.6734 -13.4999 2.2524 8.5251 -0.2070
#> -9.3134 -5.6651 7.4942 -5.0487 -6.8508
#>
#> (1,3,.,.) =
#> -7.2925 -1.7028 7.0622 -3.4469 -4.5846
#> 2.2165 -8.8995 -1.2713 -2.6526 -2.3976
#> -5.7185 -5.6672 -1.9402 4.6768 2.8479
#> -3.5815 -4.0945 -2.7768 2.9213 2.9248
#> -3.1693 2.9927 1.4101 2.8391 -0.4298
#>
#> (1,4,.,.) =
#> -2.3415 2.0156 -3.1422 -0.3747 -0.4778
#> -2.2533 6.8492 2.7716 -4.1783 -1.0009
#> 0.5770 1.0754 -9.5410 3.4406 -2.3913
#> -0.6745 -0.4763 2.6882 -0.2782 2.1338
#> -4.6347 -5.2201 0.3038 1.2836 -0.2038
#>
#> (1,5,.,.) =
#> -7.9878 4.6672 -5.0157 9.0481 2.7546
#> ... [the output was truncated (use n=-1 to disable)]
#> [ CPUFloatType{1,8,5,5} ]