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  -4.2799  -4.4055  -7.6185  -3.6413  -7.5131   4.4503  12.4302  -0.6246
#>    1.7820  11.2815  15.3058   2.5497   7.3234   0.0027 -10.2557   6.1521
#>    6.7319  -7.6383   0.4122  -3.1282   0.5867 -13.2591  -3.8448  -5.2541
#>   -4.5234   5.8615   5.2040   2.6400   1.5504  -5.1288   7.8689   9.1657
#>    1.5921  -9.1527  -7.8412   6.6396   4.7601  -1.1723  -6.4607  -3.6257
#>    5.3255  -7.3895   0.9591  -0.0180  -4.1197   6.3202   6.3130   8.4903
#>   -3.0993   6.3749   8.7024  12.7569   6.9660  -6.5842   3.9414   0.4054
#>    7.9684   7.1598  -9.6735  -0.4639  -6.5569   2.3603   9.3425   2.4212
#>   -7.4006  -0.8673 -11.1602   3.0148   5.2737   1.9895  18.0035  -7.5815
#>    4.1510   0.0882  -0.8894   2.7853  -6.1612  -4.3666  15.8519   6.8035
#>    0.0551  -5.5998  -5.5718  -5.0208  -2.6086  -1.5798   3.4159   3.6958
#>    4.9326   3.3454   4.7694 -20.7927  -4.5259  -8.8677  -6.1775   0.2884
#>   -9.2756 -11.0536  10.1570  -8.5320   7.1997   7.5796 -13.5387   9.1202
#>    7.6942   2.6654   7.1931  -2.1197  -5.2211 -10.6524   1.2795  -2.3806
#>    6.9804   1.1636 -11.7477  -0.4564   5.4912   4.7557   7.8871  -5.5879
#>    1.3042  -0.0151  -3.8278  -9.6159 -13.3710  -5.5168   3.3523   4.1783
#>    6.7552 -10.0832  -3.2173   2.9196   7.2266   9.8423   1.2781  -2.5732
#>    6.1371  -0.0244   7.5641  -0.5036   4.0956  -6.5192  -2.8360   7.7989
#>    2.2528   9.6603  10.6675   8.4282  -6.9757 -14.2541  -8.1621  -6.9910
#>    8.8926  -2.7399 -10.1791   0.7602   0.3328  -1.9903   2.8115  -7.6494
#>    6.0896   0.4523  -3.8656  -1.9457  -2.5374  -2.1337   6.4756   1.8318
#>   -5.5806  -7.6214  -0.0251 -15.2107   0.9737  -5.4552  -1.9320   3.1738
#>   -0.2481   0.0856   7.8390   9.7375  -8.8718  -7.1358  -5.8276  -3.8133
#>   -3.9938 -11.1520   2.7522   5.5041  -8.3037  -6.4006  -7.6681  -6.7562
#>  -11.1665   5.2830  -4.3023  -1.4715   0.5730  -2.5748  -8.8762   6.7086
#>   -5.3044  -1.7767   2.1370   0.3335  -4.1531  -8.9707 -10.8596  -5.2838
#>    4.3987  -4.4244  -1.9234  -7.0934   2.9753   3.3248   1.1382   3.2683
#>   14.1857   9.1710   8.3437 -10.4215  -4.2963 -12.3506   5.2811   5.7495
#>    8.5927   4.8413  -5.3993 -11.4106 -12.2129  -2.8460   5.5478   3.4733
#> ... [the output was truncated (use n=-1 to disable)]
#> [ CPUFloatType{20,33,48} ]