tensorflow/models · error · ValueError
`window_size` must be positive.
Error message
`window_size` must be positive.
What it means
Error "`window_size` must be positive." thrown in tensorflow/models.
Source
Thrown at official/projects/triviaqa/inputs.py:360
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].
Args:
window_size: Window size to return relative ids for. Must be positive and
odd since ids will be relative to the center of the window. If a Tensor,
must be a scalar int.
Returns:
<int32>[window_size] Tensor of relative position ids.
"""
if isinstance(window_size, int):
if window_size < 1:
raise ValueError('`window_size` must be positive.')
if window_size % 2 != 1:
raise ValueError('`window_size` must be odd.')
x = tf.range(self.max_distance + 1, dtype=tf.int32)
x = tf.pad(x, [[self.max_distance, 0]], mode='REFLECT')
if not self.ignore_direction:
direction_adder = tf.concat([
tf.fill([self.max_distance], self.max_distance),
tf.zeros([self.max_distance + 1], dtype=tf.int32)
], 0)
x += direction_adder
len_x = x.shape.as_list()[0]
if len_x > window_size:
trim_amount = (len_x - window_size) // 2
return x[trim_amount:-trim_amount]
pad_amount = (window_size - len_x) // 2View on GitHub (pinned to e006f5f0d5)
When it happens
Trigger: Thrown at official/projects/triviaqa/inputs.py:360 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/cc5cc5e2760294ce.
Report an issue: GitHub.