(module_spec, checkpoints, task_manager, run_config,
              use_tpu, num_averaging_runs)
Evaluates the given checkpoints and add results to a result writer.

  Args:
    module_spec: `ModuleSpec` of the model.
    checkpoints: Generator for for checkpoint paths.
    task_manager: `TaskManager`. init_eval() will be called before adding
      results.
    run_config: `RunConfig` to use. Values for master and tpu_config are
      currently ignored.
    use_tpu: Whether to use TPU for evaluation.
    num_averaging_runs: Determines how many times each metric is computed.
Evaluates the given checkpoints and add results to a result writer.
Evaluates the given checkpoints and add results to a result writer .
def _run_eval(module_spec, checkpoints, task_manager, run_config,
              use_tpu, num_averaging_runs):
  """Evaluates the given checkpoints and add results to a result writer.

  Args:
    module_spec: `ModuleSpec` of the model.
    checkpoints: Generator for for checkpoint paths.
    task_manager: `TaskManager`. init_eval() will be called before adding
      results.
    run_config: `RunConfig` to use. Values for master and tpu_config are
      currently ignored.
    use_tpu: Whether to use TPU for evaluation.
    num_averaging_runs: Determines how many times each metric is computed.
  """
  # By default, we compute FID and Inception scores. Other tasks defined in
  # the metrics folder (such as the one in metrics/kid_score.py) can be added
  # to this list if desired.
  eval_tasks = [
      inception_score_lib.InceptionScoreTask(),
      fid_score_lib.FIDScoreTask()
  ]
  logging.info("eval_tasks: %s", eval_tasks)

  for checkpoint_path in checkpoints:
    step = os.path.basename(checkpoint_path).split("-")[-1]
    if step == 0:
      continue
    export_path = os.path.join(run_config.model_dir, "tfhub", str(step))
    if not tf.gfile.Exists(export_path):
      module_spec.export(export_path, checkpoint_path=checkpoint_path)
    default_value = -1.0
    try:
      result_dict = eval_gan_lib.evaluate_tfhub_module(
          export_path, eval_tasks, use_tpu=use_tpu,
          num_averaging_runs=num_averaging_runs)
    except ValueError as nan_found_error:
      result_dict = {}
      logging.exception(nan_found_error)
      default_value = eval_gan_lib.NAN_DETECTED

    logging.info("Evaluation result for checkpoint %s: %s (default value: %s)",
                 checkpoint_path, result_dict, default_value)
    task_manager.add_eval_result(checkpoint_path, result_dict, default_value)
def _run_eval ( module_spec , checkpoints , task_manager , run_config , use_tpu , num_averaging_runs ) : # By default, we compute FID and Inception scores. Other tasks defined in # the metrics folder (such as the one in metrics/kid_score.py) can be added # to this list if desired. eval_tasks = [ inception_score_lib . InceptionScoreTask ( ) , fid_score_lib . FIDScoreTask ( ) ] logging . info ( "eval_tasks: %s" , eval_tasks ) for checkpoint_path in checkpoints : step = os . path . basename ( checkpoint_path ) . split ( "-" ) [ - 1 ] if step == 0 : continue export_path = os . path . join ( run_config . model_dir , "tfhub" , str ( step ) ) if not tf . gfile . Exists ( export_path ) : module_spec . export ( export_path , checkpoint_path = checkpoint_path ) default_value = - 1.0 try : result_dict = eval_gan_lib . evaluate_tfhub_module ( export_path , eval_tasks , use_tpu = use_tpu , num_averaging_runs = num_averaging_runs ) except ValueError as nan_found_error : result_dict = { } logging . exception ( nan_found_error ) default_value = eval_gan_lib . NAN_DETECTED logging . info ( "Evaluation result for checkpoint %s: %s (default value: %s)" , checkpoint_path , result_dict , default_value ) task_manager . add_eval_result ( checkpoint_path , result_dict , default_value )