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,.,.) =
#> -1.6762 -1.4722 -1.6436 4.5126 -2.3594
#> -6.1267 -0.6607 0.5919 9.5704 -3.9356
#> -1.7615 6.3741 -2.8814 1.8651 2.6326
#> -3.0181 6.3555 10.1203 -8.3985 -4.0173
#> 4.3111 -0.7174 2.8917 -3.1391 -8.9127
#>
#> (1,2,.,.) =
#> 8.9800 1.7654 7.7636 -6.3208 -8.4194
#> 5.8093 6.0707 9.6270 -3.9311 1.4963
#> 11.6820 -7.1384 -13.1026 0.6878 2.1252
#> -2.5556 -5.7388 4.2203 -0.1439 0.9164
#> -1.1838 -2.2137 -5.6184 -1.2443 0.6594
#>
#> (1,3,.,.) =
#> 0.7132 0.6092 -5.2210 7.3686 1.3817
#> -0.1427 3.6031 -8.0537 2.5274 -4.5634
#> 4.1523 2.8623 -1.0692 -6.0115 -5.0826
#> 3.1303 -2.6635 0.9652 -4.9996 -1.5039
#> 4.5513 -6.7425 5.8636 0.2757 -5.1578
#>
#> (1,4,.,.) =
#> -1.9208 7.2958 1.0516 2.1344 0.6837
#> 1.1177 2.2499 3.0147 -1.1611 -3.3016
#> -3.3033 13.4223 2.4072 -9.5020 0.6424
#> 5.1416 -0.7583 -7.2147 8.3988 3.6592
#> -1.6494 1.9372 -3.8303 -5.4349 -1.8648
#>
#> (1,5,.,.) =
#> 3.0466 -6.5147 2.8607 -4.0111 1.6115
#> ... [the output was truncated (use n=-1 to disable)]
#> [ CPUFloatType{1,8,5,5} ]