tensorflow/models · error · ValueError
The lengths of strides and axes need to match.
Error message
The lengths of strides and axes need to match.
What it means
Error "The lengths of strides and axes need to match." thrown in tensorflow/models.
Source
Thrown at official/nlp/modeling/networks/funnel_transformer.py:78
It also skips first unpool_length elements.
Args:
mask: Tensor to be pooled.
unpool_length: Leading elements to be skipped.
strides: Strides for the given axes.
axes: Axes to pool the Tensor.
Returns:
Pooled and concatenated Tensor.
"""
# Wraps the axes as a list.
if isinstance(axes, int):
axes = [axes]
if isinstance(strides, int):
strides = [strides] * len(axes)
else:
if len(strides) != len(axes):
raise ValueError('The lengths of strides and axes need to match.')
# Bypass no pooling cases.
if np.all(np.array(strides) == 1):
return mask
for axis, stride in zip(axes, strides):
# Skips first `unpool_length` tokens.
unpool_tensor_shape = [slice(None)] * axis + [slice(None, unpool_length)]
unpool_tensor = mask[unpool_tensor_shape]
# Pools the second half.
pool_tensor_shape = [slice(None)] * axis + [
slice(unpool_length, None, stride)
]
pool_tensor = mask[pool_tensor_shape]
mask = tf.concat((unpool_tensor, pool_tensor), axis=axis)
return mask
def _create_fractional_pool_transform(sl: int, pool_factor: float):View on GitHub (pinned to e006f5f0d5)
When it happens
Trigger: Thrown at official/nlp/modeling/networks/funnel_transformer.py:78 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of tensorflow/models@e006f5f0d5 (2026-08-24).
Data as JSON: /api/errors/4684ee7abfef6b40.
Report an issue: GitHub.