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,.,.) =
#> -6.2293 3.6368 -6.9950 -3.2092 4.0164
#> 4.4499 5.6002 5.9233 0.9858 4.2309
#> -5.9799 -12.2515 -1.1408 5.2784 4.7481
#> 3.5944 0.3573 1.3755 -0.4545 -0.4302
#> 4.4743 3.5464 2.9807 3.5504 3.6378
#>
#> (1,2,.,.) =
#> -14.1458 -2.4284 -1.6412 -4.7466 -0.5833
#> -2.7556 -2.9063 -13.3437 -1.0216 0.0556
#> 8.1979 -9.5774 -2.3079 -9.8105 -6.1516
#> -3.3297 1.0058 3.2910 -4.9661 -10.2056
#> -2.9389 7.1504 -4.6618 3.7112 0.9689
#>
#> (1,3,.,.) =
#> 2.0213 4.8348 -0.0753 -5.5559 2.1641
#> 7.3397 5.3186 -0.5203 -10.4046 -2.4127
#> -2.8926 -5.7183 7.3088 1.4437 -0.2859
#> -0.1150 1.8809 -4.1334 4.5544 1.0229
#> -4.4993 0.7790 -2.1356 1.6472 -3.0782
#>
#> (1,4,.,.) =
#> -8.0488 0.3474 9.3235 -1.6900 -3.2958
#> -8.0323 -9.7287 -6.8925 4.5854 10.4326
#> 10.2315 -12.7851 -6.9631 -11.5428 -1.7736
#> 1.9657 0.0843 -5.3749 -8.2050 -2.8523
#> -1.6009 3.4971 2.5930 0.7100 5.0198
#>
#> (1,5,.,.) =
#> -3.1366 2.1507 -1.2642 1.5051 -3.3853
#> ... [the output was truncated (use n=-1 to disable)]
#> [ CPUFloatType{1,8,5,5} ]