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
- weight
filters of shape
- bias
optional bias tensor of shape
. 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,
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,.,.) =
#> 0.0189 4.9447 0.6224 0.7597 -4.5645
#> 5.9175 7.0085 5.9416 -5.2371 8.0103
#> -0.9964 -7.0508 -0.9801 -5.0388 4.4114
#> 5.4303 -5.1018 3.9502 16.1350 -3.8399
#> 0.9899 -3.3628 -6.8478 0.9403 3.0106
#>
#> (1,2,.,.) =
#> -0.4150 1.9061 4.7993 4.0147 -2.4514
#> -2.1454 -16.8381 -3.7747 6.1538 -3.3264
#> 2.5807 -12.0448 5.3367 -3.1636 -7.9218
#> 2.5600 -4.3728 8.6374 0.6756 -2.6467
#> -3.3193 -8.9347 4.0515 2.1577 1.3617
#>
#> (1,3,.,.) =
#> -7.2225 2.0309 5.5763 -5.5566 -4.7529
#> 0.1236 2.6598 -6.3783 7.5947 -4.1330
#> 6.4922 -1.9247 1.0046 -0.3332 10.4420
#> 6.7431 -0.1652 9.3561 -12.9978 1.6157
#> 1.6747 -8.7162 1.9752 5.6119 -7.2847
#>
#> (1,4,.,.) =
#> 7.6439 -2.1554 -2.2380 1.6979 5.8495
#> 8.1608 9.1738 -9.0112 1.5795 2.2012
#> -3.5933 -0.0972 -7.7132 -6.2405 -4.9428
#> -10.1969 10.3241 2.3233 2.7456 5.4896
#> -1.1503 -5.4917 -0.2620 -1.1470 -4.7064
#>
#> (1,5,.,.) =
#> -3.6470 2.4733 3.6185 -5.0308 -0.5395
#> ... [the output was truncated (use n=-1 to disable)]
#> [ CPUFloatType{1,8,5,5} ]