{"record":{"id":"f57c5a460081889f","repo":"tensorflow/models","slug":"wrong-train-dataset-size-r","errorCode":null,"errorMessage":"Wrong train dataset size {!r}","messagePattern":"Wrong train dataset size (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"official/projects/yt8m/configs/yt8m.py","lineNumber":228,"sourceCode":"      default_factory=lambda: Evaluation(  # pylint: disable=g-long-lambda\n          average_precision=AveragePrecisionConfig()\n      )\n  )\n  gradient_clip_norm: float = 1.0\n\n\ndef add_trainer(\n    experiment: cfg.ExperimentConfig,\n    train_batch_size: int,\n    eval_batch_size: int,\n    learning_rate: float = 0.0001,\n    train_epochs: int = 50,\n    num_train_examples: int = YT8M_TRAIN_EXAMPLES,\n    num_val_examples: int = YT8M_VAL_EXAMPLES,\n) -> cfg.ExperimentConfig:\n  \"\"\"Adds and config a trainer to the experiment config.\"\"\"\n  if num_train_examples <= 0:\n    raise ValueError('Wrong train dataset size {!r}'.format(\n        experiment.task.train_data))\n  if num_val_examples <= 0:\n    raise ValueError('Wrong validation dataset size {!r}'.format(\n        experiment.task.validation_data))\n  experiment.task.train_data.global_batch_size = train_batch_size\n  experiment.task.validation_data.global_batch_size = eval_batch_size\n  steps_per_epoch = num_train_examples // train_batch_size\n  steps_per_loop = 500\n  experiment.trainer = cfg.TrainerConfig(\n      steps_per_loop=steps_per_loop,\n      summary_interval=steps_per_loop,\n      checkpoint_interval=steps_per_loop,\n      train_steps=train_epochs * steps_per_epoch,\n      validation_steps=num_val_examples // eval_batch_size,\n      validation_interval=steps_per_loop,\n      optimizer_config=optimization.OptimizationConfig({\n          'optimizer': {\n              'type': 'adam',","sourceCodeStart":210,"sourceCodeEnd":246,"githubUrl":"https://github.com/tensorflow/models/blob/e006f5f0d534913e49c1f1dae87364039fa607e2/official/projects/yt8m/configs/yt8m.py#L210-L246","documentation":"Sanity check in the yt8m experiment helper add_trainer: num_train_examples must be positive because the trainer divides by it to compute steps per epoch; zero or negative would yield zero or negative train steps. Note the message interpolates the repr of experiment.task.train_data rather than the offending number — a formatting quirk that can mislead diagnosis. Reached from yt8m_experiment when a bad count is passed.","triggerScenarios":"Thrown at official/projects/yt8m/configs/yt8m.py:228 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass a positive num_train_examples matching your dataset size (default YT8M_TRAIN_EXAMPLES)","Do not explicitly set num_train_examples=0 in yt8m_experiment","For custom datasets, count training records and pass that count"],"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"}