{"record":{"id":"1de16db7c1a9c922","repo":"tensorflow/models","slug":"if-eval-metric-fn-is-specified-eval-metric-fn-m","errorCode":null,"errorMessage":"if `eval_metric_fn` is specified, eval_metric_fn must be a callable.","messagePattern":"if `eval_metric_fn` is specified, eval_metric_fn must be a callable\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"official/legacy/detection/executor/distributed_executor.py","lineNumber":371,"sourceCode":"      summary_writer_fn: function to create summary writer.\n      init_checkpoint: function to load checkpoint.\n      custom_callbacks: A list of Keras Callbacks objects to run during\n        training. More specifically, `on_batch_begin()`, `on_batch_end()`,\n        methods are invoked during training.\n      continuous_eval: If `True`, will continously run evaluation on every\n        available checkpoints. If `False`, will do the evaluation once after the\n        final step.\n      save_config: bool. Whether to save params to model_dir.\n\n    Returns:\n      The training loss and eval metrics.\n    \"\"\"\n    assert train_input_fn is not None\n    if train_metric_fn and not callable(train_metric_fn):\n      raise ValueError('if `train_metric_fn` is specified, '\n                       'train_metric_fn must be a callable.')\n    if eval_metric_fn and not callable(eval_metric_fn):\n      raise ValueError('if `eval_metric_fn` is specified, '\n                       'eval_metric_fn must be a callable.')\n    train_metric_fn = train_metric_fn or _no_metric\n    eval_metric_fn = eval_metric_fn or _no_metric\n\n    if custom_callbacks and iterations_per_loop != 1:\n      logging.warning(\n          'It is sematically wrong to run callbacks when '\n          'iterations_per_loop is not one (%s)', iterations_per_loop)\n\n    custom_callbacks = custom_callbacks or []\n\n    def _run_callbacks_on_batch_begin(batch):\n      \"\"\"Runs custom callbacks at the start of every step.\"\"\"\n      if not custom_callbacks:\n        return\n      for callback in custom_callbacks:\n        if callback:\n          callback.on_batch_begin(batch)","sourceCodeStart":353,"sourceCodeEnd":389,"githubUrl":"https://github.com/tensorflow/models/blob/e006f5f0d534913e49c1f1dae87364039fa607e2/official/legacy/detection/executor/distributed_executor.py#L353-L389","documentation":"Error \"if `eval_metric_fn` is specified, eval_metric_fn must be a callable.\" thrown in tensorflow/models.","triggerScenarios":"Thrown at official/legacy/detection/executor/distributed_executor.py:371 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"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"}