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 8   5.3091   1.6474  -8.5928  -9.1854   1.1539   1.0365   3.2029   3.2000
#>   -2.4033   1.0769   7.6355   0.9666  14.0089  -7.8355   4.7902  20.4158
#>    2.2252  -5.0655   1.1787  -1.5814  -0.9743  -5.0184  -8.6953   4.5736
#>   10.0465 -10.1242   3.8934   3.3830  -1.6990  18.2903  -1.0004   3.2715
#>   -2.1156  -5.2430   0.8227   0.4614  -6.5196  -4.3353  -3.8137 -10.3028
#>    3.9357  -5.6533  -6.7586  -7.3395  13.9449   4.5662   4.6722  -1.3070
#>   -3.6611   4.4279  -7.0320   8.6983  -6.9825  -7.7094  -1.5182  -4.0769
#>   -5.6180  -6.8333 -11.9720 -10.6127  -8.9867  -4.7977 -11.6585   0.9435
#>  -11.2728  -0.3050  -1.7377   2.2102  17.0027   0.8353  -2.8094 -12.8289
#>   -4.2451  -2.5494   2.4805  -6.7119   1.5852   2.1265   2.9400   2.9380
#>    5.8075   2.5674   6.5344   4.3939   9.5012   0.5683   3.0541   4.5666
#>   -8.5574  -6.0847  11.4207  21.7269  -7.6684   1.1783   0.2091 -14.8885
#>   15.8947   0.9798   1.5754   5.7413 -12.8788  -3.7434   9.5835  -5.3376
#>    1.8094  -0.7298  -7.5939  -8.2553  -2.5133  -3.9653  -3.0964  -0.2754
#>    2.9670   0.0847   4.7563  12.8355   7.5289   0.6380  -0.8193  -0.2097
#>   -6.7872   8.9712   0.2255  -1.8510   9.8801  -7.8462   5.7897  -7.1962
#>   19.4638  -1.9347  -9.0598  -9.2916   6.1372  14.9076   0.0937   3.4374
#>   -2.2431   5.1973   2.4891  12.6006  -9.0401   0.6933 -13.7860   0.1239
#>   -5.5764   5.0687  -5.7678  18.8690  -2.4603   1.1795  -6.2500  -7.6422
#>    3.6513  -0.7294  -8.2284  -4.5181  11.6343  -3.2471  -0.0271   2.2047
#>   -8.7015   8.0364   4.8884  -1.7910   0.1553  -7.1836  -0.2540   2.6998
#>    1.7347   0.2730  -0.8707  -1.3844   4.9136  -3.6489  -6.2753  10.9544
#>   -4.3384  -2.3918   6.3215  13.5431   8.9800  -1.1426   2.1216   5.6288
#>    0.7760  -3.2082   0.8259  -5.7443  -7.2542 -15.0525   1.9777  -2.6702
#>   -9.1423   0.9958  -3.9096  -9.7653  -8.1029  -5.1045 -13.8743  -0.3156
#>   -1.6779  -0.9812  -0.3721  -6.7095 -10.8731   6.4269  -4.2481   2.1253
#>    5.5286  -7.1578   2.6841  11.5914 -10.3884   7.1804  -3.8635  -3.3625
#>   -1.9944   1.2487   0.9406   1.2301   0.5804   6.4594   3.7814   2.8177
#>    0.1376  -2.8645  -4.3845   6.7084   9.2125  12.8587  -6.4231   1.4120
#> ... [the output was truncated (use n=-1 to disable)]
#> [ CPUFloatType{20,33,48} ]