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  -6.5423   5.8292   2.1301   9.8757   5.0527   2.9301  -7.8724  -9.9589
#>   -8.4360  -5.5698   3.8586   0.4653  -2.0081   3.6169  -5.9865  -7.0142
#>   -4.9530  -0.0715  -1.5879 -15.2245   4.4054  -2.4457  16.9565  -0.5127
#>   -1.4222   5.5428   4.8601  -9.0962   8.4197 -12.0085  15.2258  -0.0257
#>    1.5579   8.4882   1.5763   4.2697  10.7162 -13.5989   4.2508   1.3128
#>   -4.9069   4.4334  -7.1795   0.2593  -1.9644  -7.8766  -2.5244   7.9853
#>   -2.6823  -0.0387  -3.0720  -7.6783   8.9129 -16.7570   3.4913  -8.1394
#>   -2.9913  -3.9623  -4.3750   8.7784   2.6321   8.3151   0.6707  -8.3441
#>   -3.7127 -16.0610   5.2007   0.9932  -5.5197  -0.1969 -11.5819  -8.6211
#>   -6.9922 -11.3149 -11.1871  -7.3527   0.4165  -4.7087   2.1307  17.4993
#>    1.1608  -4.7244  -4.4014  16.1602  -6.7607  10.8913   0.3380  -0.2487
#>   -4.8985  -5.2659   4.4458   4.9943  -3.9965   0.8129  -0.4502   2.1250
#>    6.2574  -4.3700  -1.4915   9.4067  -8.6351   2.6245  -9.3461  -8.3367
#>   -1.9540  -3.3729  -7.2350   6.0237  -0.3011   6.9989  -0.7064  -6.2871
#>   -1.7192   1.2123  -1.2035   0.8997 -17.6134  -7.1392  -3.7051  16.3590
#>   -1.2008  -9.5683  13.8626  -1.7313   5.0631  -8.7309   5.1955   5.7694
#>    5.6794   3.8339  -7.5278  -4.8827 -14.2746  -5.7771  -6.7245   0.7738
#>    3.3087  -7.5384   2.8028   1.7923   9.2609   0.3526  -4.6701  -1.2176
#>   -2.9484   1.8263  -6.2848   7.9557  12.3277 -12.3458  13.1852  -7.8474
#>    5.6359   3.7645   4.1574   2.4562   5.0812  10.9621  -6.3501  11.2769
#>   -8.9129   5.0768  -4.3795  -8.9234  11.0471 -18.8720   6.1349   9.9895
#>   -8.2568 -12.3392  -5.6785  -5.8478  -2.1199  11.3817 -13.9812  13.7217
#>    6.1360   7.4402   2.0855  -1.3762   1.1808 -12.5978  -6.4557   0.3239
#>  -10.9461  -4.4320  -4.9298 -10.0698  10.0514  -6.2777  10.5519   4.6538
#>   -0.6784   5.8729  -3.7604  -2.8887   0.8702   0.6454 -14.3181  -0.7408
#>    2.3048  17.1698   7.8892  -4.6586  -1.5689   8.5414  -6.1121   6.0690
#>    4.5289 -13.5405  -3.7432   7.6128  12.7659   4.0483  -3.4360  -4.8060
#>   -5.6532   2.3120   2.9335 -12.8453   5.6602 -17.6635   0.2414  -1.8911
#>    7.1887   0.5034  -5.6625   0.7569 -10.7164  13.1485  -5.1950  -0.9280
#> ... [the output was truncated (use n=-1 to disable)]
#> [ CPUFloatType{20,33,48} ]