Example #1
0
def run_experiment(hparams):
    """Train the model then export it for tf.model_analysis evaluation.

  Args:
    hparams: Holds hyperparameters used to train the model as name/value pairs.
  """
    estimator = train_and_maybe_evaluate(hparams)

    schema = taxi.read_schema(hparams.schema_file)

    # Save a model for tfma eval
    eval_model_dir = os.path.join(hparams.output_dir, EVAL_MODEL_DIR)

    receiver_fn = lambda: model.eval_input_receiver_fn(  # pylint: disable=g-long-lambda
        hparams.tf_transform_dir, schema)

    tfma.export.export_eval_savedmodel(estimator=estimator,
                                       export_dir_base=eval_model_dir,
                                       eval_input_receiver_fn=receiver_fn)
Example #2
0
def run_experiment(hparams):
  """Train the model then export it for tf.model_analysis evaluation.

  Args:
    hparams: Holds hyperparameters used to train the model as name/value pairs.
  """
  estimator = train_and_maybe_evaluate(hparams)

  schema = taxi.read_schema(hparams.schema_file)

  # Save a model for tfma eval
  eval_model_dir = os.path.join(hparams.output_dir, EVAL_MODEL_DIR)

  receiver_fn = lambda: model.eval_input_receiver_fn(  # pylint: disable=g-long-lambda
      hparams.tf_transform_dir, schema)

  tfma.export.export_eval_savedmodel(
      estimator=estimator,
      export_dir_base=eval_model_dir,
      eval_input_receiver_fn=receiver_fn)
Example #3
0
 def eval_input_receiver_fn():
     return model.eval_input_receiver_fn(tf_transform_output)