tensorflow/models · error · ValueError
`local_radius` must be positive.
Error message
`local_radius` must be positive.
What it means
Error "`local_radius` must be positive." thrown in tensorflow/models.
Source
Thrown at official/projects/triviaqa/inputs.py:330
Args:
seq_len: The sequence length to create ids for. Must be positive. If a
Tensor, must be a scalar int.
local_radius: The local radius as expected by
`layers.RelativeLocalSelfAttention`. Must be positive.
batch_size: The batch size of the result (default 1). Must be positive. If
a Tensor, must be a scalar int. All examples in the batch will have the
same id pattern.
name: A name for the operation (optional).
Returns:
<int32>[batch_size, seq_len, 2*local_radius + 1] Tensor of relative
position ids.
"""
with tf.name_scope(name or 'make_local_relative_att_ids'):
if isinstance(seq_len, int) and seq_len < 1:
raise ValueError('`seq_len` must be positive.')
if local_radius < 1:
raise ValueError('`local_radius` must be positive.')
if isinstance(batch_size, int) and batch_size < 1:
raise ValueError('`batch_size` must be positive.')
window_size = 2 * local_radius + 1
# [window_size]
id_pattern = self._make_relative_id_pattern(window_size)
return tf.tile(id_pattern[tf.newaxis, tf.newaxis, :],
[batch_size, seq_len, 1])
def _make_relative_id_pattern(
self, window_size: Union[int, tf.Tensor]) -> tf.Tensor:
"""Helper for making the relative id pattern for a particular window size.
For example, if `max_distance` is 3, `ignore_direction` is False, and
`window_size` is 11, the result is the following:
[6, 6, 6, 5, 4, 0, 1, 2, 3, 3, 3].View on GitHub (pinned to e006f5f0d5)
When it happens
Trigger: Thrown at official/projects/triviaqa/inputs.py:330 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/adfce21e84db0d59.
Report an issue: GitHub.