keras-team/keras · error · ValueError
`strides > 1` not supported in conjunction with `dilation_ra
Error message
`strides > 1` not supported in conjunction with `dilation_rate > 1`. Received: strides={self.strides} and dilation_rate={self.dilation_rate} What it means
Keras transpose-convolution layers (Conv2DTranspose etc.) reject any configuration where both strides and dilation_rate exceed 1. The backend algorithms for transposed convolutions cannot combine strided upsampling with dilated kernels, so the constructor fails fast at layer creation.
Source
Thrown at keras/src/layers/convolutional/base_conv_transpose.py:159
if not all(self.strides):
raise ValueError(
"The argument `strides` cannot contains 0. Received "
f"strides={self.strides}."
)
if self.output_padding is not None:
for i, (op, s) in enumerate(zip(self.output_padding, self.strides)):
if op >= s:
raise ValueError(
"`output_padding` must be strictly less than "
f"`strides` for all dimensions. At dimension {i}, "
f"`output_padding` is {op} but `strides` is {s}. "
f"Received: output_padding={self.output_padding}, "
f"strides={self.strides}"
)
if max(self.strides) > 1 and max(self.dilation_rate) > 1:
raise ValueError(
"`strides > 1` not supported in conjunction with "
f"`dilation_rate > 1`. Received: strides={self.strides} and "
f"dilation_rate={self.dilation_rate}"
)
if self.output_padding is not None:
for i, (op, s) in enumerate(zip(self.output_padding, self.strides)):
if op >= s:
raise ValueError(
"Invalid `output_padding` argument. "
"Each value in `output_padding` must be strictly "
"less than the corresponding `strides` value.\n"
f"At index {i}, `output_padding` is {op} and `strides` "
f"is {s}.\n"
f"Received: output_padding={self.output_padding}, "
f"strides={self.strides}."
)
View on GitHub (pinned to 7a34a03db6)
Solutions
- Set dilation_rate back to 1 and keep the stride, growing receptive field via kernel_size instead.
- Replace the transpose conv with UpSampling2D followed by a dilated Conv2D, which supports the combination.
- Assert the combo in your model factory so invalid configs fail at config time.
Example fix
# before layer = keras.layers.Conv2DTranspose(64, 3, strides=2, dilation_rate=2) # after layer = keras.layers.Conv2DTranspose(64, 3, strides=2) # or: UpSampling2D(size=2) + Conv2D(64, 3, dilation_rate=2)
Defensive patterns
Strategy: validation
Validate before calling
assert valid_transpose_cfg(strides, dilation_rate), 'strides>1 with dilation>1 unsupported'
Type guard
def valid_transpose_cfg(strides, dilation_rate) -> bool:
s = strides if isinstance(strides, (tuple, list)) else (strides,)
d = dilation_rate if isinstance(dilation_rate, (tuple, list)) else (dilation_rate,)
return not (max(s) > 1 and max(d) > 1) Prevention
- Validate stride/dilation combos at config time
- Use UpSampling + dilated Conv for dilated upsampling
When it happens
Trigger: Constructing keras.layers.Conv2DTranspose (or Conv1DTranspose/Conv3DTranspose) with e.g. strides=2 and dilation_rate=2: max of any stride dim >1 AND max of any dilation dim >1 triggers it.
Common situations: Copying a regular Conv2D config into a Conv*DTranspose; attempting dilated upsampling architectures (generator networks) without knowing transposed conv limits.
Related errors
- Invalid `output_padding` argument. Each value in `output_pad
- Invalid value for argument `depth_multiplier`. Expected a st
- The argument `kernel_size` cannot contain 0. Received kernel
- The argument `strides` cannot contains 0. Received strides={
- Invalid value for argument `depth_multiplier`. Expected a st
AI-assisted analysis of keras-team/keras@7a34a03db6 (2026-08-25).
Data as JSON: /api/errors/a46b3e91da27125f.
Report an issue: GitHub.