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 -8.3169e+00 -2.1014e+00 -5.1744e+00  4.7219e+00 -7.2245e+00 -3.7793e+00
#>  -2.3550e+00  3.5967e-01 -5.9571e+00  1.9716e+00 -2.8001e+00  9.2921e+00
#>  -2.9458e+00  7.0693e+00 -2.3263e+00 -4.4576e+00 -3.0706e+00 -3.6137e+00
#>   7.6318e+00  7.6674e+00  6.7905e-01 -1.0191e+00  2.8939e+00  3.7213e+00
#>   3.5952e+00 -1.5817e+01  9.1722e+00  8.3184e-01  1.4853e+00 -1.3252e+00
#>   4.0351e+00  4.5588e-01  4.6643e+00 -5.1794e+00  2.4778e+00 -3.6634e+00
#>  -7.6635e+00  2.3136e+00  1.3166e+00  1.3124e+00 -3.7686e+00 -1.1524e+01
#>  -4.7977e+00  3.8666e+00  7.2739e+00 -1.3060e+01 -1.6958e+00  9.6115e+00
#>  -1.3698e+01 -6.0547e+00  1.0270e+01  1.7839e+01 -4.4191e+00 -5.6308e+00
#>   1.7233e+00 -2.1186e+00 -1.1272e+00 -4.6070e+00 -1.3363e+00  1.4993e+01
#>   4.1939e+00 -1.2392e+01  3.6945e+00  7.5041e+00  7.6516e+00 -7.6661e+00
#>   4.6416e+00 -8.4228e+00 -2.2767e+00  1.5158e+00  6.5058e+00 -7.3223e-01
#>   1.9778e+00 -2.0790e+00  1.6602e+00  9.3931e+00  2.3396e+00  1.5080e+01
#>   5.6369e+00 -4.9868e+00  8.2276e+00 -1.1036e+01  3.5321e+00  2.3121e+00
#>   1.8445e+00 -9.2048e-01 -4.2860e+00 -5.7858e+00 -2.1423e+00  1.3416e+01
#>  -8.5335e-01 -9.2716e+00 -4.5451e+00 -5.0947e+00  3.1179e-01  5.0687e-01
#>   2.1218e+00  3.3808e+00  6.7575e-02  1.9638e+00 -6.4383e-02  4.6061e+00
#>  -9.4345e+00 -1.2909e+01  4.5463e+00  5.7057e+00  7.9532e+00  1.0342e+00
#>   2.0564e+01  3.4541e+00  5.7038e-01 -1.0550e+01  6.2890e+00  2.9685e+00
#>   8.4836e+00  1.0381e+01 -4.9445e+00 -6.4267e-01 -8.5755e+00  3.4221e+00
#>   7.6088e-01  8.3236e+00 -9.5267e+00  4.5688e-01 -2.2607e+00  7.8716e+00
#>   7.3898e+00 -4.1470e+00  1.9449e+00 -1.8083e+00  1.9612e-01  1.6873e+00
#>  -4.0546e+00  3.4497e+00 -3.6739e+00  3.2975e+00 -4.9923e+00  6.4785e+00
#>   1.0131e+01  1.1753e+00 -9.1447e+00 -6.6979e+00  2.5119e+00  3.9920e+00
#>   2.9422e+00  1.0326e+01 -1.5198e+00 -1.6618e+00 -1.2997e+01 -1.6538e+01
#>  -4.5410e+00  1.7281e+00  2.8887e+00  7.1734e+00 -1.5699e-02  1.3118e+00
#>  -1.5259e+00 -5.7793e+00  1.5204e+00 -4.8937e-04 -1.0205e+00 -4.2960e+00
#>   2.3303e+00  6.4505e+00 -5.2870e+00  6.7430e-01 -1.5892e+00  1.6843e+01
#>   4.7452e+00 -3.9635e+00 -6.0927e+00  4.8368e+00 -1.0148e+00 -1.2588e+01
#> ... [the output was truncated (use n=-1 to disable)]
#> [ CPUFloatType{20,33,48} ]