tfma.types.EvalSharedModel

Class EvalSharedModel

Aliases:

  • Class tfma.EvalSharedModel
  • Class tfma.types.EvalSharedModel

Defined in types.py.

Shared model used during extraction and evaluation.

Attributes:

  • model_path: Path to EvalSavedModel (containing the saved_model.pb file).
  • add_metrics_callbacks: Optional list of callbacks for adding additional metrics to the graph. The names of the metrics added by the callbacks should not conflict with existing metrics. See below for more details about what each callback should do. The callbacks are only used during evaluation.
  • include_default_metrics: True to include the default metrics that are part of the saved model graph during evaluation.
  • example_weight_key: Deprecated.
  • additional_fetches: Prefixes of additional tensors stored in signature_def.inputs that should be fetched at prediction time. The "features" and "labels" tensors are handled automatically and should not be included in this list.
  • shared_handle: Optional handle to a shared.Shared object for sharing the in-memory model within / between stages.
  • construct_fn: A callable which creates a construct function to set up the tensorflow graph. Callable takes a beam.metrics distribution to track graph construction time.

More details on add_metrics_callbacks:

Each add_metrics_callback should have the following prototype: def add_metrics_callback(features_dict, predictions_dict, labels_dict):

Note that features_dict, predictions_dict and labels_dict are not necessarily dictionaries - they might also be Tensors, depending on what the model's eval_input_receiver_fn returns.

It should create and return a metric_ops dictionary, such that metric_ops['metric_name'] = (value_op, update_op), just as in the Trainer.

Short example:

def add_metrics_callback(features_dict, predictions_dict, labels): metrics_ops = {} metric_ops['mean_label'] = tf.metrics.mean(labels) metric_ops['mean_probability'] = tf.metrics.mean(tf.slice( predictions_dict['probabilities'], [0, 1], [2, 1])) return metric_ops

__new__

@staticmethod
__new__(
    cls,
    model_path=None,
    add_metrics_callbacks=None,
    include_default_metrics=True,
    example_weight_key=None,
    additional_fetches=None,
    shared_handle=None,
    construct_fn=None
)

Create new instance of EvalSharedModel(model_path, add_metrics_callbacks, include_default_metrics, example_weight_key, additional_fetches, shared_handle, construct_fn)

Properties

model_path

add_metrics_callbacks

include_default_metrics

example_weight_key

additional_fetches

shared_handle

construct_fn