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.0231 -5.6029 -11.5761 1.7143 5.9216
#> -8.6533 -3.1235 15.7295 -6.0593 9.2511
#> 8.4979 -13.4046 -13.9410 -9.4461 9.4648
#> -4.4897 3.7682 0.3209 8.7378 -6.1204
#> -0.3647 0.9731 -0.7515 3.4601 1.6865
#>
#> (1,2,.,.) =
#> 7.0896 -5.5982 -7.6702 -3.5603 -1.2482
#> -8.6291 1.6284 0.6596 12.8297 7.0360
#> 0.4704 -0.7088 1.9296 0.7521 3.7638
#> 2.5873 13.8303 -1.0990 -1.3369 -6.8281
#> 1.7741 0.4981 3.9623 -2.9872 -0.7715
#>
#> (1,3,.,.) =
#> 1.9486 4.2593 3.4958 -4.3602 -11.2844
#> -4.6424 -2.3620 -7.5738 -0.2210 4.9159
#> 2.8113 13.1138 13.1928 -3.5597 5.6266
#> -4.2096 -6.5700 -8.8867 1.5816 -5.5888
#> -0.2709 -1.5333 0.1801 0.7487 -5.4131
#>
#> (1,4,.,.) =
#> 2.9319 -1.7305 -3.5251 3.4202 1.0916
#> -6.4199 -6.5232 -3.4441 3.7061 -4.2515
#> 3.5935 4.0829 0.3279 -6.4848 5.5157
#> -3.1565 -12.9017 8.0733 -7.9554 13.5600
#> -0.2963 2.9512 2.8726 0.0982 -0.0403
#>
#> (1,5,.,.) =
#> -4.7585 10.8287 8.5631 3.2067 0.8199
#> ... [the output was truncated (use n=-1 to disable)]
#> [ CPUFloatType{1,8,5,5} ]