Convolutional 1D (Conv1D)#

API#

class warp_nn.modules.layers.Conv1D(
in_channels: int,
out_channels: int,
kernel_size: int,
*,
stride: int = 1,
padding: int = 0,
dilation: int = 1,
groups: int = 1,
bias: bool = True,
)[source]#

Bases: Module

Apply a 1D convolution.

\[\text{Conv1D}(x) = TODO\]


Learnable parameters:

Name

Shape

Description

\(W\)

weight

(out_channels, in_channels / groups, kernel_size)

Weights

\(b\)

bias

(out_channels, 1)

Bias. Only if bias is true

The parameters are initialized from the uniform distribution \(u(-k, k)\) where \(k = \sqrt{\frac{groups}{\text{in\_channels * kernel\_size}}}\)


Parameters:
  • in_channels – The number of input channels.

  • out_channels – The number of output channels.

  • kernel_size – The size of the kernel.

  • stride – The stride of the convolution.

  • padding – The padding of the convolution.

  • dilation – The dilation of the convolution.

  • groups – The number of groups. Both, the in_channels and the out_channels arguments must be divisible by groups.

  • bias – Whether to include a bias term.

__call__(
input: array,
) array[source]#

Forward pass of the module.

Parameters:

input – The input array, with shape (batch_size, in_channels, in_signal_length).

Returns:

The output array, with shape (batch_size, out_channels, out_signal_length) where:

\[L_{out} = \left\lfloor \frac{L_{in} + 2 \, \text{padding} - \text{dilation} \, (\text{kernel\_size} - 1) - 1}{\text{stride}} \right\rfloor + 1\]