Skip to content

DepthwiseConv1D produces incompatible shapes for channels_first inputs with dilation_rate #22534

@AGFACBNNR

Description

@AGFACBNNR

Summary

keras.layers.DepthwiseConv1D fails at runtime for data_format='channels_first' with dilation_rate > 1, and the symbolic output shape is also incorrect.

Reproduction

import keras
import tensorflow as tf
import numpy as np

x = tf.constant(np.random.rand(4, 10, 12), dtype=tf.float32)

layer = keras.layers.DepthwiseConv1D(
    kernel_size=7,
    strides=1,
    padding='valid',
    depth_multiplier=2,
    data_format='channels_first',
    dilation_rate=2,
    activation='relu',
)

# Runtime failure
try:
    y = layer(x)
    print(y.shape)
except Exception as e:
    print(type(e).__name__, e)

# Symbolic shape inference
inp = keras.Input(shape=(10, 12))
out = layer(inp)
print(out.shape)

Expected

  • The layer should either:
    • compute a valid output tensor, or
    • raise a clear validation error if the configuration is unsupported.
  • Static and dynamic shape behavior should match.

Actual

  • Eager execution raises:
    Incompatible shapes: [4,10,12] vs. [1,20,1]
  • Symbolic output shape is reported as (None, 20, 0)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions