Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

Keras · Class

layers.Conv1D

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.

How it works

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.

Syntax

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)

Parameters

NameTypeDescription
filtersintNumber of output filters, defining the output channel dimension.
kernel_sizeint or tuple/list of 1 integerLength of the one-dimensional convolution window.
stridesint or tuple/list of 1 integerStep size of the convolution window; default 1.
paddingstringPadding mode, such as "valid" or "same".
data_formatstring or NoneInput/output channel layout; defaults to the backend data format.
dilation_rateint or tuple/list of 1 integerDilation factor for the convolution window; default 1.
groupsintNumber of groups for channel-wise partitioning; default 1.
activationstring, callable, or NoneOptional activation function.
use_biasboolWhether to include a bias vector; default True.
kernel_initializerinitializerInitializer for the kernel weights.
bias_initializerinitializerInitializer for the bias vector.
kernel_regularizerregularizer or NoneRegularizer applied to kernel weights.

Returns

A rank-3 tensor representing activation(conv1d(inputs, kernel) + bias), with layout determined by data_format.

Key points

  • Use Conv1D for learned local patterns along sequences or another single spatial axis.
  • The kernel operates over one spatial or temporal dimension rather than across a 2D image grid.
  • The optional bias is added after convolution when use_bias is enabled.
  • An activation function can be applied to the convolution-plus-bias result.
  • With channels_last, inputs are rank-3 tensors ordered as batch, steps, and channels.
  • With channels_last, the layer returns batch, output steps, and filter channels.
  • kernel_size specifies the length of the one-dimensional convolution window.

Common mistakes

  • Do not combine a stride greater than 1 with a dilation rate greater than 1.

Example: Temporal convolution

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.

When to use it

Sequence feature extraction

Classifying or labeling sequences such as sensor streams, audio features, or token representations.

Local temporal pattern detection

Detecting short-lived motifs distributed along a temporal axis.

Strided temporal downsampling

Reducing sequence resolution while learning representations.

Grouped convolution

Using sparse channel connectivity to reduce parameter interaction between channel groups.

Interview questions

QWhat input and output shapes does Conv1D use?

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).

QHow does Conv1D compute its output?

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.

QWhat does the groups argument control?

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.Conv2D
  • keras.layers.Conv3D
  • keras.layers.SeparableConv1D
  • keras.layers.DepthwiseConv1D
  • keras.layers.Conv1DTranspose

Source: Conv1D layer. Checked 2026-10-15.