tensorflow/models · error · ValueError
Eval batch size {} is not divisible by {}
Error message
Eval batch size {} is not divisible by {} What it means
Error "Eval batch size {} is not divisible by {}" thrown in tensorflow/models.
Source
Thrown at official/recommendation/data_pipeline.py:425
self.eval_batch_size = eval_batch_size
self.num_train_epochs = num_train_epochs
self.create_data_offline = create_data_offline
# Training
if self._train_pos_users.shape != self._train_pos_items.shape:
raise ValueError(
"User positives ({}) is different from item positives ({})".format(
self._train_pos_users.shape, self._train_pos_items.shape))
(self._train_pos_count,) = self._train_pos_users.shape
self._elements_in_epoch = (1 + num_train_negatives) * self._train_pos_count
self.train_batches_per_epoch = self._count_batches(self._elements_in_epoch,
train_batch_size,
batches_per_train_step)
# Evaluation
if eval_batch_size % (1 + rconst.NUM_EVAL_NEGATIVES):
raise ValueError("Eval batch size {} is not divisible by {}".format(
eval_batch_size, 1 + rconst.NUM_EVAL_NEGATIVES))
self._eval_users_per_batch = int(eval_batch_size //
(1 + rconst.NUM_EVAL_NEGATIVES))
self._eval_elements_in_epoch = num_users * (1 + rconst.NUM_EVAL_NEGATIVES)
self.eval_batches_per_epoch = self._count_batches(
self._eval_elements_in_epoch, eval_batch_size, batches_per_eval_step)
# Intermediate artifacts
self._current_epoch_order = np.empty(shape=(0,))
self._shuffle_iterator = None
self._shuffle_with_forkpool = not stream_files
if stream_files:
self._shard_root = epoch_dir or tempfile.mkdtemp(prefix="ncf_")
if not create_data_offline:
atexit.register(tf.io.gfile.rmtree, self._shard_root)
else:
self._shard_root = NoneView on GitHub (pinned to e006f5f0d5)
When it happens
Trigger: Thrown at official/recommendation/data_pipeline.py:425 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/2e6ebb808de534dd.
Report an issue: GitHub.