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  -1.8641  -6.6524   8.0712   1.7574  -0.5660   5.0709   3.4057   2.5800
#>   -5.6113  -5.8589   4.8754  -6.2561  -6.4587  -2.8910   2.5593   2.1116
#>    5.7170   2.9407  -7.4782   5.0608   2.9909  -3.4642  -4.9597  -6.2477
#>    5.5986   3.8181  -2.7312   5.6109   0.8328   9.0121  -1.0862  -3.5937
#>    1.5127  -7.1788  -2.5440  -9.2190   8.3417  -0.5399   7.6451   4.5990
#>   -1.8021  -7.8513   9.0152   3.0945  -2.4432   3.4107  13.3500  -2.1323
#>   -0.1558   9.4404 -12.9771  -4.2166   1.3729  -5.1833  13.8807  11.7492
#>    2.4973   9.6618  -0.0129  -3.1894  -4.8106   3.7974   0.1796   1.8961
#>   -2.4628   1.9612   6.6957   8.2243   0.6170  -9.1448   5.2311  -6.0113
#>    9.6524  -0.9482  -5.5829  -2.6563  10.8457   2.5799  -7.5784   2.2872
#>   -1.9645  -0.7056  -3.0134  -1.2535   5.6326  -0.0120  11.7309  -9.3089
#>   -0.2826  -5.2709  -5.2773  -5.1004  -1.0218   8.2822  17.4279   3.2184
#>    4.9536  -4.7880   1.1786  -7.5880  -1.3963   9.0198  -7.1197  -0.4095
#>    4.3486  -4.6031   3.4140  -1.8617   3.2617  -6.4705   1.7058   0.2821
#>   -4.3148  -4.5690  -1.1054   2.1007 -11.8271  -5.2499  -7.9635  -7.6768
#>  -10.7719   6.5053  -0.8688   3.5775  -3.2013  -1.8998 -13.6238   0.4372
#>   -2.9024   0.4214   6.1257  -4.7374  -7.1609   1.2166   3.8942  14.8569
#>    4.4457  -1.8345   0.5690  -7.7897   8.0356  -5.2015   7.5272  -8.5157
#>  -12.8855  -0.6889  -5.1558  11.7154   0.2254  -1.0668  -5.7417  -3.2186
#>    3.8954  -0.7314 -14.0361 -13.6528   3.2276   0.1599   4.7790  -1.6393
#>   -3.4260  -2.7345  -2.0796  -4.3465   7.8942  -0.6273  -5.0692  -9.8773
#>    0.9460  -4.1219   3.9453   5.5029  -1.2588  -8.1771  -6.9217  -7.0764
#>   -1.2089   1.6221   3.6694   6.5862  -8.4518  -4.1257   3.8832  -2.3519
#>    7.4026   3.6683  -3.7818   4.9101   7.7949   4.7245   8.5875  -0.1877
#>   -1.8057   5.6143  -0.8837   8.9282   1.2911   0.0444  -7.4376  -1.4959
#>   -1.3902  -4.0130   9.7309   3.1879  10.9578  -3.4027   3.8745  -7.0696
#>    5.4274  -7.8449  -8.1336  -9.3733  -2.7188   6.1163  -5.7320  -8.1033
#>    4.8099   3.9079   8.9011  -3.1479   5.9867   4.2950  22.0404   9.4418
#>   -4.5599 -15.1182  -5.2385   4.7854  -7.9836  -8.5419  -3.0353  -6.2807
#> ... [the output was truncated (use n=-1 to disable)]
#> [ CPUFloatType{20,33,48} ]