{"record":{"id":"b442af5426f9a541","repo":"tensorflow/models","slug":"epoch-end-can-only-be-called-inside-an-epoch","errorCode":null,"errorMessage":"`epoch_end` can only be called inside an epoch.","messagePattern":"`epoch_end` can only be called inside an epoch\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"orbit/utils/epoch_helper.py","lineNumber":49,"sourceCode":"    self._global_step = global_step\n    self._current_epoch = None\n    self._epoch_start_step = None\n    self._in_epoch = False\n\n  def epoch_begin(self):\n    \"\"\"Returns whether a new epoch should begin.\"\"\"\n    if self._in_epoch:\n      return False\n    current_step = self._global_step.numpy()\n    self._epoch_start_step = current_step\n    self._current_epoch = current_step // self._epoch_steps\n    self._in_epoch = True\n    return True\n\n  def epoch_end(self):\n    \"\"\"Returns whether the current epoch should end.\"\"\"\n    if not self._in_epoch:\n      raise ValueError(\"`epoch_end` can only be called inside an epoch.\")\n    current_step = self._global_step.numpy()\n    epoch = current_step // self._epoch_steps\n\n    if epoch > self._current_epoch:\n      self._in_epoch = False\n      return True\n    return False\n\n  @property\n  def batch_index(self):\n    \"\"\"Index of the next batch within the current epoch.\"\"\"\n    return self._global_step.numpy() - self._epoch_start_step\n\n  @property\n  def current_epoch(self):\n    return self._current_epoch\n","sourceCodeStart":31,"sourceCodeEnd":66,"githubUrl":"https://github.com/tensorflow/models/blob/e006f5f0d534913e49c1f1dae87364039fa607e2/orbit/utils/epoch_helper.py#L31-L66","documentation":"Error \"`epoch_end` can only be called inside an epoch.\" thrown in tensorflow/models.","triggerScenarios":"Thrown at orbit/utils/epoch_helper.py:49 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Call epoch_end only between epoch_begin and the end of the epoch.","Pair every epoch_end with a preceding epoch_begin."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e006f5f0d534913e49c1f1dae87364039fa607e2","analyzedAt":"2026-08-24T14:09:15.576Z","schemaVersion":2},"datasetVersion":"2026-08-24T17:17:21.512Z"}