keras-team/keras · error · ValueError

The convolution operation resulted in an empty output. This…

Error message

The convolution operation resulted in an empty output. This can happen if the input is too small for the given kernel size, strides, dilation rate, and padding mode. Please check the input shape and convolution parameters.

What it means

Error "The convolution operation resulted in an empty output. This can happen if the input is too small for the given kernel size, strides, dilation rate, and padding mode. Please check the input shape and convolution parameters." thrown in keras-team/keras.

Solutions

  1. Reduce kernel size, strides, or dilation_rate so at least one output position fits the input.
  2. Use padding='same' to preserve spatial size where possible.
  3. Increase the input spatial dims (e.g. larger crops or less aggressive downsampling upstream).
  4. Check for an accidental extra stride/downsample applied twice in the model.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at keras/src/backend/jax/nn.py:774 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/6a4eaa20ed50db76. Report an issue: GitHub.

Appendix: source

Thrown at keras/src/backend/jax/nn.py:774

        raise ValueError(
            "The number of input channels must be evenly divisible by "
            f"kernel's in_channels. Received input channels {channels} and "
            f"kernel in_channels {kernel_in_channels}. "
        )
    feature_group_count = channels // kernel_in_channels
    kernel = convert_to_tensor(kernel)
    inputs = convert_to_tensor(inputs, dtype=kernel.dtype)
    result = jax.lax.conv_general_dilated(
        inputs,
        kernel,
        strides,
        padding,
        rhs_dilation=dilation_rate,
        dimension_numbers=dimension_numbers,
        feature_group_count=feature_group_count,
    )
    if result.size == 0 and inputs.size != 0:
        raise ValueError(
            "The convolution operation resulted in an empty output. "
            "This can happen if the input is too small for the given "
            "kernel size, strides, dilation rate, and padding mode. "
            "Please check the input shape and convolution parameters."
        )
    return result


def depthwise_conv(
    inputs,
    kernel,
    strides=1,
    padding="valid",
    data_format=None,
    dilation_rate=1,
):
    data_format = backend.standardize_data_format(data_format)
    inputs = convert_to_tensor(inputs)

View on GitHub (pinned to 7a34a03db6)