keras-team/keras · error · ValueError

ConvLSTM layers only support static input shapes for the…

Error message

ConvLSTM layers only support static input shapes for the spatial dimension. Received invalid input shape: input_shape={inputs_shape}

What it means

Raised by ConvLSTM.build when any of the spatial dimensions extracted from inputs_shape is None. The layer must know static spatial sizes (and channel count) to create its convolution kernels, so fully dynamic spatial shapes are unsupported.

Solutions

  1. Specify static spatial dimensions in your Input, e.g. Input(shape=(timesteps, 32, 32, channels)) instead of None entries
  2. Avoid dynamic-shape-producing ops directly before the ConvLSTM, or materialize a fixed shape first
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at keras/src/layers/rnn/conv_lstm.py:172 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of keras-team/keras@7a34a03db6 (2026-08-25). Data as JSON: /api/errors/10148de7c612e78a. Report an issue: GitHub.

Appendix: source

Thrown at keras/src/layers/rnn/conv_lstm.py:172

        self.kernel_constraint = constraints.get(kernel_constraint)
        self.recurrent_constraint = constraints.get(recurrent_constraint)
        self.bias_constraint = constraints.get(bias_constraint)

        self.dropout = min(1.0, max(0.0, dropout))
        self.recurrent_dropout = min(1.0, max(0.0, recurrent_dropout))
        self.dropout_mask_count = 4
        self.input_spec = InputSpec(ndim=rank + 2)
        self.state_size = -1  # Custom, defined in methods

    def build(self, inputs_shape, states_shape=None):
        if self.data_format == "channels_first":
            channel_axis = 1
            self.spatial_dims = inputs_shape[2:]
        else:
            channel_axis = -1
            self.spatial_dims = inputs_shape[1:-1]
        if None in self.spatial_dims:
            raise ValueError(
                "ConvLSTM layers only support static "
                "input shapes for the spatial dimension. "
                f"Received invalid input shape: input_shape={inputs_shape}"
            )
        if inputs_shape[channel_axis] is None:
            raise ValueError(
                "The channel dimension of the inputs (last axis) should be "
                "defined. Found None. Full input shape received: "
                f"input_shape={inputs_shape}"
            )
        self.input_spec = InputSpec(
            ndim=self.rank + 3, shape=(None,) + inputs_shape[1:]
        )

        input_dim = inputs_shape[channel_axis]
        self.input_dim = input_dim
        self.kernel_shape = self.kernel_size + (input_dim, self.filters * 4)
        recurrent_kernel_shape = self.kernel_size + (

View on GitHub (pinned to 7a34a03db6)