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)
Summary
keras.layers.DepthwiseConv1Dfails at runtime fordata_format='channels_first'withdilation_rate > 1, and the symbolic output shape is also incorrect.Reproduction
Expected
Actual
Incompatible shapes: [4,10,12] vs. [1,20,1](None, 20, 0)