tensorflow/models · error · ValueError
Does not support relative attention for query shape: %s.
Error message
Does not support relative attention for query shape: %s.
What it means
Error "Does not support relative attention for query shape: %s." thrown in tensorflow/models.
Source
Thrown at official/projects/maxvit/modeling/layers.py:212
self.a_expr = create_expr(symbols, suffix='NST')
##### Relative attention
if self.rel_attn_type in ['2d_multi_head', '2d_single_head']:
query_shape_list = query_shape.as_list()
if query_shape.rank == 4:
height, width = query_shape_list[1:3]
elif query_shape.rank == 3:
seq_len = query_shape_list[1]
height, width = common_ops.get_shape_from_length(
seq_len, self.input_origin_height, self.input_origin_width
)
if height * width != seq_len:
raise ValueError(
'Sequence length: %s violates input size: (%s, %s).'
% (seq_len, height, width)
)
else:
raise ValueError(
'Does not support relative attention for query shape: %s.'
% query_shape_list
)
if self.scale_ratio is not None:
scale_ratio = eval(self.scale_ratio) # pylint:disable=eval-used # pyrefly: ignore[bad-argument-type]
vocab_height = 2 * int(height / scale_ratio) - 1
vocab_width = 2 * int(width / scale_ratio) - 1
else:
vocab_height = 2 * height - 1
vocab_width = 2 * width - 1
if self.rel_attn_type == '2d_multi_head':
rel_bias_shape = [self.num_heads, vocab_height, vocab_width]
elif self.rel_attn_type == '2d_single_head':
rel_bias_shape = [vocab_height, vocab_width]
else:
raise NotImplementedError(View on GitHub (pinned to e006f5f0d5)
When it happens
Trigger: Thrown at official/projects/maxvit/modeling/layers.py:212 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/12765fd776cbfdcf.
Report an issue: GitHub.