tensorflow/models · error · ValueError
User positives ( ) is different from item positives ( )
Error message
User positives ({}) is different from item positives ({}) What it means
Constructor sanity check in the data constructor: the train_pos_users and train_pos_items arrays (positive user/item pairs) must have identical shape; differing shapes mean the pairing of users to items is corrupted or mismatched.
Solutions
- Verify train_pos_users and train_pos_items come from the same preprocessing run and hold one entry per positive interaction
- Re-run data preprocessing to regenerate consistent positive-pair arrays
- Check that neither array was truncated or filtered independently of the other
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at official/recommendation/data_pipeline.py:413 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/6f42e64a9f5feb5a.
Report an issue: GitHub.
Appendix: source
Thrown at official/recommendation/data_pipeline.py:413
self._maximum_number_epochs = maximum_number_epochs
self._num_users = num_users
self._num_items = num_items
self.user_map = user_map
self.item_map = item_map
self._train_pos_users = train_pos_users
self._train_pos_items = train_pos_items
self.train_batch_size = train_batch_size
self._num_train_negatives = num_train_negatives
self._batches_per_train_step = batches_per_train_step
self._eval_pos_users = eval_pos_users
self._eval_pos_items = eval_pos_items
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)View on GitHub (pinned to e006f5f0d5)