Skip to contents

Conv1d

Usage

torch_conv1d(
  input,
  weight,
  bias = list(),
  stride = 1L,
  padding = 0L,
  dilation = 1L,
  groups = 1L
)

Arguments

input

input tensor of shape \((\mbox{minibatch} , \mbox{in\_channels} , iW)\)

weight

filters of shape \((\mbox{out\_channels} , \frac{\mbox{in\_channels}}{\mbox{groups}} , kW)\)

bias

optional bias of shape \((\mbox{out\_channels})\). Default: NULL

stride

the stride of the convolving kernel. Can be a single number or a one-element tuple (sW,). Default: 1

padding

implicit paddings on both sides of the input. Can be a single number or a one-element tuple (padW,). Default: 0

dilation

the spacing between kernel elements. Can be a single number or a one-element tuple (dW,). Default: 1

groups

split input into groups, \(\mbox{in\_channels}\) should be divisible by the number of groups. Default: 1

conv1d(input, weight, bias=NULL, stride=1, padding=0, dilation=1, groups=1) -> Tensor

Applies a 1D convolution over an input signal composed of several input planes.

See nn_conv1d() for details and output shape.

Examples

if (torch_is_installed()) {

filters = torch_randn(c(33, 16, 3))
inputs = torch_randn(c(20, 16, 50))
nnf_conv1d(inputs, filters)
}
#> torch_tensor
#> (1,.,.) = 
#>  Columns 1 to 6 -7.6300e+00 -1.3585e+00 -3.1643e+00  3.3415e+00 -3.5581e+00  7.2428e+00
#>  -5.2401e-01  6.5767e-01 -1.0477e+01  4.0122e+00  7.6638e-01  4.6045e+00
#>   1.4166e+00  9.5717e+00 -5.2018e-01 -7.7267e+00  1.2873e+00 -8.6838e+00
#>   1.0061e+00  6.2838e+00  4.2919e+00  1.0921e+00  1.2625e+01  4.4649e+00
#>   2.3416e-01 -3.3182e-01 -2.3053e-01 -1.2939e+01  8.9212e+00  2.5906e+00
#>  -2.3818e+00 -1.1870e+01 -1.6421e+00 -3.4941e+00  1.1204e+01  1.2993e+01
#>  -1.3894e+01  2.2251e+00 -6.1084e-01  7.6547e+00  9.9298e+00  7.4196e+00
#>   6.3769e-01 -3.1934e+00 -6.4780e+00  4.5578e-01 -1.2425e+01 -2.4923e-01
#>   6.9175e+00 -3.9134e+00  5.1277e+00  1.5918e+00 -1.4201e+01 -3.6999e+00
#>   8.7734e+00 -3.2359e+00  8.7718e+00  4.9934e-01  1.0709e+01  4.5730e+00
#>  -6.8355e+00  2.8346e+00 -7.1111e+00 -9.7834e+00  1.1589e+00 -3.5177e+00
#>   5.7896e+00 -7.4164e-01  1.1781e+01  4.1452e+00 -7.3474e+00  9.5850e+00
#>   4.9037e+00 -2.8005e+00  5.6207e-01  1.0762e+01 -8.5670e+00 -3.6310e+00
#>   2.7419e+00  4.8202e-01  1.6581e+00  3.0009e-01 -1.8480e+00 -3.9726e-01
#>   6.0024e+00 -2.0720e+00  3.6992e+00 -7.8596e+00 -5.5947e+00 -9.3042e+00
#>   1.1852e+00 -1.4299e+00  7.6922e+00  3.6214e+00 -5.2615e+00 -3.0108e+00
#>   3.2865e+00  1.4782e+00  3.3309e+00  1.3141e+01  5.5439e+00  9.8467e+00
#>  -1.6810e+00 -2.2276e+00  6.5694e+00  6.1285e+00 -2.4090e+00  5.9491e-01
#>  -3.0169e+00  6.0753e+00  1.0108e+01 -5.6399e+00 -6.1327e+00  2.4715e+00
#>   3.0414e+00 -5.1283e+00 -2.3013e+00  1.3995e+01  7.4323e+00  1.3514e+01
#>  -9.6343e+00  1.4717e+00 -6.2687e+00 -4.1786e+00  3.9113e+00  2.4174e+00
#>  -3.7199e+00  4.1180e+00 -6.7664e+00  7.8996e-02  3.8984e+00  5.3923e+00
#>  -9.1347e-01  5.2097e-01  2.5081e+00  2.7902e+00 -3.5013e+00  4.9551e+00
#>   3.2554e+00 -3.3475e+00  9.8589e+00  5.3145e+00 -8.8504e+00 -7.9860e+00
#>   9.6049e+00  3.7402e+00 -2.4565e+00  2.5863e+00 -5.7386e+00 -9.0553e+00
#>  -3.1641e+00  4.4166e+00  9.4419e+00  1.5043e+01  6.2037e+00  1.5404e+01
#>   2.6345e+00  9.8827e-01  1.1774e+01  3.5380e+00 -8.2268e+00 -1.7612e+00
#>  -1.5381e+00 -3.3915e+00  8.8268e-01 -4.2406e+00 -4.7781e+00  2.1441e+00
#>  -5.1637e+00 -1.0505e+00  1.2550e+00 -5.4375e+00 -4.6202e+00  4.3786e+00
#> ... [the output was truncated (use n=-1 to disable)]
#> [ CPUFloatType{20,33,48} ]