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,.,.) =
#> 5.1597 3.9603 -2.4935 -0.0889 0.7977
#> -1.6765 7.7421 13.2688 -1.5230 8.0365
#> 3.6046 -1.0772 11.6349 5.6885 -0.5709
#> -1.1548 -3.8150 -10.1069 -0.4077 -2.5187
#> -7.5372 -0.4844 0.2251 2.6514 -0.7511
#>
#> (1,2,.,.) =
#> -0.8449 -14.8820 -8.0421 -9.8562 4.9472
#> -4.2979 -2.9638 6.7024 14.1146 1.8427
#> -3.7069 7.4507 -10.9364 -0.8396 -7.4850
#> -5.3940 2.9988 -5.6019 2.4148 -2.3016
#> 6.6855 4.0635 4.6500 1.1979 3.1503
#>
#> (1,3,.,.) =
#> -0.6765 -7.8094 3.1173 -3.2594 -3.4862
#> -0.6563 -8.1427 -7.3896 -8.6645 0.2167
#> 8.1900 0.5001 16.1295 1.7405 1.8729
#> -3.3775 6.8973 -2.4682 10.3839 0.7046
#> -2.5128 4.3628 -2.2759 1.0886 -1.9905
#>
#> (1,4,.,.) =
#> -3.8900 -6.4439 1.6001 0.2653 0.7250
#> -2.3296 -8.5687 -6.6549 -3.0899 -3.3301
#> 6.1453 3.4250 -0.9796 5.5812 2.3349
#> 2.3370 0.9344 -4.7569 -6.3572 2.1482
#> 5.9125 -0.7927 -0.5621 0.3140 -2.7526
#>
#> (1,5,.,.) =
#> -1.0798 0.9808 -12.1057 -4.0144 -3.4264
#> ... [the output was truncated (use n=-1 to disable)]
#> [ CPUFloatType{1,8,5,5} ]