r"""Applies a 1D convolution over an input tensor. For instance, given an input of the size :math:`(N, C_{\text{in}}, H)`, this layer generates an output of the size :math:`(N, C_{\text{out}}, H_{\text{out}})` through the process described as below: .. math:: \text{out}
| 93 | |
| 94 | |
| 95 | class Conv1d(_ConvNd): |
| 96 | |
| 97 | r"""Applies a 1D convolution over an input tensor. |
| 98 | |
| 99 | For instance, given an input of the size :math:`(N, C_{\text{in}}, H)`, |
| 100 | this layer generates an output of the size |
| 101 | :math:`(N, C_{\text{out}}, H_{\text{out}})` through the |
| 102 | process described as below: |
| 103 | |
| 104 | .. math:: |
| 105 | \text{out}(N_i, C_{\text{out}_j}) = \text{bias}(C_{\text{out}_j}) + |
| 106 | \sum_{k = 0}^{C_{\text{in}} - 1} \text{weight}(C_{\text{out}_j}, k) \star \text{input}(N_i, k) |
| 107 | |
| 108 | where :math:`\star` is the valid 1D cross-correlation operator, |
| 109 | :math:`N` is batch size, :math:`C` denotes number of channels, and |
| 110 | :math:`H` is length of 1D data element. |
| 111 | |
| 112 | When `groups == in_channels` and `out_channels == K * in_channels`, |
| 113 | where K is a positive integer, this operation is also known as depthwise |
| 114 | convolution. |
| 115 | |
| 116 | In other words, for an input of size :math:`(N, C_{\text{in}}, H_{\text{in}})`, |
| 117 | a depthwise convolution with a depthwise multiplier `K`, can be constructed |
| 118 | by arguments :math:`(in\_channels=C_{\text{in}}, out\_channels=C_{\text{in}} \times K, ..., groups=C_{\text{in}})`. |
| 119 | |
| 120 | Args: |
| 121 | in_channels(int): number of input channels. |
| 122 | out_channels(int): number of output channels. |
| 123 | kernel_size(int): size of weight on spatial dimensions. |
| 124 | stride(int): stride of the 1D convolution operation. Default: 1. |
| 125 | padding(int): size of the paddings added to the input on both sides of its |
| 126 | spatial dimensions. Default: 0. |
| 127 | dilation(int): dilation of the 1D convolution operation. Default: 1. |
| 128 | groups(int): number of groups to divide input and output channels into, |
| 129 | so as to perform a "grouped convolution". When ``groups`` is not 1, |
| 130 | ``in_channels`` and ``out_channels`` must be divisible by ``groups``, |
| 131 | and the shape of weight should be ``(groups, out_channel // groups, |
| 132 | in_channels // groups, kernel_size)``. Default: 1. |
| 133 | bias(bool): whether to add a bias onto the result of convolution. Default: True. |
| 134 | conv_mode(str): supports `cross_correlation`. Default: `cross_correlation`. |
| 135 | compute_mode(str): when set to "default", no special requirements will be |
| 136 | placed on the precision of intermediate results. When set to "float32", |
| 137 | "float32" would be used for accumulator and intermediate result, but only |
| 138 | effective when input and output are of float16 dtype. Default: `default`. |
| 139 | padding_mode(str): "zeros", "reflect" or "replicate". Default: "zeros". |
| 140 | Refer to :class:`~.module.padding.Pad` for more information. |
| 141 | |
| 142 | Shape: |
| 143 | ``input``: :math:`(N, C_{\text{in}}, H_{\text{in}})`. |
| 144 | ``output``: :math:`(N, C_{\text{out}}, H_{\text{out}})`. |
| 145 | |
| 146 | Note: |
| 147 | * ``weight`` usually has shape ``(out_channels, in_channels, kernel_size)`` , |
| 148 | if groups is not 1, shape will be ``(groups, out_channels // groups, in_channels // groups, kernel_size)`` |
| 149 | * ``bias`` usually has shape ``(1, out_channels, 1)`` |
| 150 | |
| 151 | Returns: |
| 152 | Return type: module. The instance of the ``Conv1d`` module. |
no outgoing calls