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,.,.) =
#> 0.3928 -4.3969 -2.3146 7.7619 5.4566
#> 2.8590 -1.3547 3.4482 0.3780 9.6762
#> -2.0638 6.4916 -2.3878 0.5365 1.3308
#> 6.3936 7.2366 -4.6264 10.7481 -6.6758
#> -0.3444 -7.9977 2.1000 7.4754 1.2675
#>
#> (1,2,.,.) =
#> 5.6546 -1.1660 -5.4485 7.0526 -1.5640
#> -0.3930 2.6439 -4.3852 -0.9276 -3.5268
#> -2.4788 -2.0740 2.4324 -1.9888 -1.8247
#> -9.5550 0.0146 2.6103 2.4464 6.0080
#> -1.2036 -0.3968 -8.2409 -5.0677 0.6947
#>
#> (1,3,.,.) =
#> -0.8294 1.6107 -4.4979 1.0547 -1.8074
#> -4.6571 -0.3706 4.8720 14.9730 -7.3230
#> 9.7994 2.8858 -6.0449 3.7432 -1.6568
#> -3.1815 -1.1242 -2.3441 -10.9135 3.1649
#> -7.2575 -0.1519 6.5451 5.3078 7.1776
#>
#> (1,4,.,.) =
#> -0.8931 -0.2716 6.5106 -3.1991 -3.2743
#> -1.6721 -5.8525 2.8246 -2.0895 -0.9239
#> -6.7006 -1.4318 0.9618 6.6474 1.4570
#> 8.0434 -0.3249 -13.5622 6.5173 -8.2603
#> 9.8050 13.0547 -2.8967 0.6291 -0.1371
#>
#> (1,5,.,.) =
#> -0.7943 4.2281 1.8168 -1.4556 -3.7774
#> ... [the output was truncated (use n=-1 to disable)]
#> [ CPUFloatType{1,8,5,5} ]