Conv1D

class Conv1D(channels, kernel_size, strides=1, padding=0, dilation=1, groups=1, layout='NCW', activation=None, use_bias=True, weight_initializer=None, bias_initializer='zeros', in_channels=0, **kwargs)

1D convolution layer (e.g. temporal convolution).

This layer creates a convolution kernel that is convolved with the layer input over a single spatial (or temporal) dimension to produce a tensor of outputs. If use_bias is True, a bias vector is created and added to the outputs. Finally, if activation is not None, it is applied to the outputs as well.

If in_channels is not specified, Parameter initialization will be deferred to the first time forward is called and in_channels will be inferred from the shape of input data.

Parameters:
channels : int

The dimensionality of the output space, i.e. the number of output channels (filters) in the convolution.

kernel_size :int or tuple/list of 1 int

Specifies the dimensions of the convolution window.

strides : int or tuple/list of 1 int,

Specify the strides of the convolution.

padding : int or a tuple/list of 1 int,

If padding is non-zero, then the input is implicitly zero-padded on both sides for padding number of points

dilation : int or tuple/list of 1 int

Specifies the dilation rate to use for dilated convolution.

groups : int

Controls the connections between inputs and outputs. At groups=1, all inputs are convolved to all outputs. At groups=2, the operation becomes equivalent to having two conv layers side by side, each seeing half the input channels, and producing half the output channels, and both subsequently concatenated.

layout: str, default ‘NCW’

Dimension ordering of data and weight. Only supports ‘NCW’ layout for now. ‘N’, ‘C’, ‘W’ stands for batch, channel, and width (time) dimensions respectively. Convolution is applied on the ‘W’ dimension.

in_channels : int, default 0

The number of input channels to this layer. If not specified, initialization will be deferred to the first time forward is called and in_channels will be inferred from the shape of input data.

activation : str

Activation function to use. See Activation(). If you don’t specify anything, no activation is applied (ie. “linear” activation: a(x) = x).

use_bias : bool

Whether the layer uses a bias vector.

weight_initializer : str or Initializer

Initializer for the weight weights matrix.

bias_initializer : str or Initializer

Initializer for the bias vector.

Inputs:
  • data: 3D input tensor with shape (batch_size, in_channels, width) when layout is NCW. For other layouts shape is permuted accordingly.
Outputs:
  • out: 3D output tensor with shape (batch_size, channels, out_width) when layout is NCW. out_width is calculated as:

    out_width = floor((width+2*padding-dilation*(kernel_size-1)-1)/stride)+1