{"record":{"id":"50617bdc84366ff0","repo":"tensorflow/models","slug":"expected-to-find-items-but-found","errorCode":null,"errorMessage":"Expected to find {} items, but found {}","messagePattern":"Expected to find (.+?) items, but found (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"official/recommendation/data_preprocessing.py","lineNumber":237,"sourceCode":"    epoch_dir: Directory in which to store the training epochs.\n    generate_data_offline: Boolean, whether current pipeline is done offline or\n      while training.\n  \"\"\"\n  logging.info(\"Beginning data preprocessing.\")\n\n  st = timeit.default_timer()\n  raw_rating_path = os.path.join(data_dir, dataset, movielens.RATINGS_FILE)\n  cache_path = os.path.join(data_dir, dataset, rconst.RAW_CACHE_FILE)\n\n  raw_data, _ = _filter_index_sort(raw_rating_path, cache_path)\n  user_map, item_map = raw_data[\"user_map\"], raw_data[\"item_map\"]\n  num_users, num_items = movielens.DATASET_TO_NUM_USERS_AND_ITEMS[dataset]\n\n  if num_users != len(user_map):\n    raise ValueError(\"Expected to find {} users, but found {}\".format(\n        num_users, len(user_map)))\n  if num_items != len(item_map):\n    raise ValueError(\"Expected to find {} items, but found {}\".format(\n        num_items, len(item_map)))\n\n  producer = data_pipeline.get_constructor(constructor_type or \"materialized\")(\n      maximum_number_epochs=params[\"train_epochs\"],\n      num_users=num_users,\n      num_items=num_items,\n      user_map=user_map,\n      item_map=item_map,\n      train_pos_users=raw_data[rconst.TRAIN_USER_KEY],\n      train_pos_items=raw_data[rconst.TRAIN_ITEM_KEY],\n      train_batch_size=params[\"batch_size\"],\n      batches_per_train_step=params[\"batches_per_step\"],\n      num_train_negatives=params[\"num_neg\"],\n      eval_pos_users=raw_data[rconst.EVAL_USER_KEY],\n      eval_pos_items=raw_data[rconst.EVAL_ITEM_KEY],\n      eval_batch_size=params[\"eval_batch_size\"],\n      batches_per_eval_step=params[\"batches_per_step\"],\n      stream_files=params[\"stream_files\"],","sourceCodeStart":219,"sourceCodeEnd":255,"githubUrl":"https://github.com/tensorflow/models/blob/e006f5f0d534913e49c1f1dae87364039fa607e2/official/recommendation/data_preprocessing.py#L219-L255","documentation":"Integrity check in instantiate_pipeline: the number of distinct items found in the preprocessed ratings data does not match the expected count for the chosen MovieLens dataset, indicating corrupted, partial, or mislabeled data.","triggerScenarios":"Thrown at official/recommendation/data_preprocessing.py:237 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Delete the raw cache file and regenerate preprocessing artifacts","Confirm the correct dataset (ml-1m vs ml-20m) is configured so the expected item count matches","Re-download the dataset if the ratings file appears incomplete"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e006f5f0d534913e49c1f1dae87364039fa607e2","analyzedAt":"2026-08-24T14:09:15.576Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}