tensorflow/models · error · ValueError
`batch_size` must be positive.
Error message
`batch_size` must be positive.
What it means
Error "`batch_size` must be positive." thrown in tensorflow/models.
Source
Thrown at official/projects/triviaqa/inputs.py:271
[6, 6, 6, 5, 4, 0],
]]
Args:
seq_len: The sequence length to create ids for. Must be positive. If a
Tensor, must be a scalar int.
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, seq_len] Tensor of relative position ids.
"""
with tf.name_scope(name or 'make_relative_att_ids'):
if isinstance(seq_len, int) and seq_len < 1:
raise ValueError('`seq_len` must be positive.')
if isinstance(batch_size, int) and batch_size < 1:
raise ValueError('`batch_size` must be positive.')
# We need the id_pattern to cover all tokens to the left of the last token
# and all tokens to the right of the first token at the same time.
window_size = 2 * seq_len - 1
# [window_size]
id_pattern = self._make_relative_id_pattern(window_size)
# [seq_len, window_size]
id_tensor = tf.tile(id_pattern[tf.newaxis, :], [seq_len, 1])
# [seq_len, window_size + seq_len - 1]
id_tensor = _skew_elements_right(id_tensor, -1)
# [seq_len, seq_len]
id_tensor = tf.slice(id_tensor, [0, seq_len - 1], [seq_len, seq_len])
return tf.tile(id_tensor[tf.newaxis, :, :], [batch_size, 1, 1])View on GitHub (pinned to e006f5f0d5)
When it happens
Trigger: Thrown at official/projects/triviaqa/inputs.py:271 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/a0734f6a623937f2.
Report an issue: GitHub.