Sequence feature extraction
Classifying or labeling sequences such as sensor streams, audio features, or token representations.
Keras · Class
Conv1D applies a learnable one-dimensional convolution across a sequence or single spatial axis. It produces the requested number of output filters and can optionally add bias and activation.
Conv1D slides a learnable window across one spatial or temporal axis of a rank-3 input. It combines each local window into the requested number of filters, optionally adds a bias, and then applies the selected activation.
keras.layers.Conv1D(filters, kernel_size, strides=1, padding="valid", data_format=None, dilation_rate=1, groups=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)| Name | Type | Description |
|---|---|---|
filters | int | Number of output filters, defining the output channel dimension. |
kernel_size | int or tuple/list of 1 integer | Length of the one-dimensional convolution window. |
strides | int or tuple/list of 1 integer | Step size of the convolution window; default 1. |
padding | string | Padding mode, such as "valid" or "same". |
data_format | string or None | Input/output channel layout; defaults to the backend data format. |
dilation_rate | int or tuple/list of 1 integer | Dilation factor for the convolution window; default 1. |
groups | int | Number of groups for channel-wise partitioning; default 1. |
activation | string, callable, or None | Optional activation function. |
use_bias | bool | Whether to include a bias vector; default True. |
kernel_initializer | initializer | Initializer for the kernel weights. |
bias_initializer | initializer | Initializer for the bias vector. |
kernel_regularizer | regularizer or None | Regularizer applied to kernel weights. |
A rank-3 tensor representing activation(conv1d(inputs, kernel) + bias), with layout determined by data_format.
import keras
from keras import layers
inputs = keras.Input(shape=(100, 8))
x = layers.Conv1D(filters=16, kernel_size=3, padding="same", activation="relu")(inputs)
model = keras.Model(inputs, x)
print(model.output_shape) # (None, 100, 16)Applies a 3-step temporal convolution to sequences with 8 channels and produces 16 output channels while preserving sequence length.
Classifying or labeling sequences such as sensor streams, audio features, or token representations.
Detecting short-lived motifs distributed along a temporal axis.
Reducing sequence resolution while learning representations.
Using sparse channel connectivity to reduce parameter interaction between channel groups.
Conv1D expects a rank-3 tensor. With channels_last, its shape is (batch, steps, channels), and the output is (batch, new_steps, filters).
Follow-up: How does channels_first change the layout? The input becomes (batch, channels, steps), and the output becomes (batch, filters, new_steps).
The kernel moves along the single spatial or temporal dimension and generates one output channel per filter. Padding and stride determine the resulting number of steps.
Follow-up: What does padding="same" do with stride 1? It preserves the steps dimension, assuming the layer's usual valid input conditions.
Groups split the input and filters into separate channel groups, reducing connectivity between them. The input channels and filter count must both be divisible by groups.
Follow-up: What constraint applies when groups is greater than 1? Each group processes a corresponding subset of channels independently before the outputs are combined.
keras.layers.Conv2Dkeras.layers.Conv3Dkeras.layers.SeparableConv1Dkeras.layers.DepthwiseConv1Dkeras.layers.Conv1DTranspose