Input 0 of layer conv1d is incompatible with the layer expected min_ndim3, found ndim2. Full shape received None, 30
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Introduction
This Keras error means a Conv1D layer received a 2D tensor, but Conv1D expects a 3D tensor. For one-dimensional convolution, the model needs data shaped like (batch, steps, channels), so an input shaped (None, 30) is missing the final feature or channel dimension.
What Conv1D Expects
A Conv1D layer slides filters across a sequence. That means it needs:
- batch dimension
- sequence length or time steps
- feature or channel dimension
A valid input shape might look like (32, 30, 1) for a batch of 32 sequences, each of length 30, with one feature per step.
Why (None, 30) Fails
The error’s None means the batch size is unspecified at model-build time. That part is normal. The problem is the remaining shape only has one axis, 30, when Conv1D needs two non-batch axes.
So Keras sees:
- batch axis
- one sequence-like axis
but no channel axis.
Fix 1: Add a Feature Dimension
If each sequence element has exactly one feature, reshape the data to add a singleton channel dimension.
That is the most common fix for tabular sequences or one-feature time series.
Fix 2: Set the Correct Input Shape in the Model
Your model definition must agree with the actual data.
If the data has shape (samples, 30, 8), then the input shape should be (30, 8) instead.
Fix 3: Use the Right Layer for the Data Type
Sometimes the error is a signal that Conv1D is the wrong layer for the problem. If the input is plain tabular data with no sequence structure, a Dense network may be more appropriate.
Do not force a fake sequence model onto data that has no meaningful local ordering just because convolution sounds powerful. If the order of the 30 values is arbitrary rather than temporal or sequential, the right fix may be a different model family rather than a reshaped tensor.
Text and Embedding Example
For token sequences, the channel dimension often comes from an embedding layer.
Here, the embedding outputs a 3D tensor automatically, so Conv1D becomes appropriate.
That is one reason text models using token embeddings can adopt Conv1D naturally, while flat feature vectors usually cannot without an explicit sequence interpretation.
Common Pitfalls
A common mistake is adding Conv1D to data shaped (samples, features) without adding or generating a channel dimension. Another is setting input_shape=(30,) for a convolution layer and assuming Keras will guess the missing axis. Developers also sometimes reshape tabular data to (samples, features, 1) mechanically without asking whether neighboring features actually have a sequence meaning.
Summary
- '
Conv1Dexpects 3D input:(batch, steps, channels).' - '
(None, 30)is only 2D, so it is missing the channel or feature axis.' - Reshape one-feature sequences to
(samples, 30, 1). - Make sure the model’s declared input shape matches the real data.
- If the data is not sequential, a dense model may be the better fix than forcing
Conv1D.

