tf.keras.layers.Conv1D

View source on GitHub

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

tf.keras.layers.Conv1D(
    filters, kernel_size, strides=1, padding='valid', data_format='channels_last',
    dilation_rate=1, activation=None, use_bias=True,
    kernel_initializer='glorot_uniform', bias_initializer='zeros',
    kernel_regularizer=None, bias_regularizer=None, activity_regularizer=None,
    kernel_constraint=None, bias_constraint=None, **kwargs
)

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.

When using this layer as the first layer in a model, provide an input_shape argument (tuple of integers or None, e.g. (10, 128) for sequences of 10 vectors of 128-dimensional vectors, or (None, 128) for variable-length sequences of 128-dimensional vectors.

Arguments:

Examples:

# Small convolutional model for 128-length vectors with 6 timesteps
# model.input_shape == (None, 6, 128)

model = Sequential()
model.add(Conv1D(32, 3, 
          activation='relu', 
          input_shape=(6, 128)))

# now: model.output_shape == (None, 4, 32)

Input shape:

3D tensor with shape: (batch_size, steps, input_dim)

Output shape:

3D tensor with shape: (batch_size, new_steps, filters) steps value might have changed due to padding or strides.