Google I/O returns May 18-20! Reserve space and build your schedule Register now


Wraps a python metric as a TF metric.

Inherits From: TFStepMetric

py_metric A batched python metric to wrap.
name Name of the metric.
dtype Data type of the metric.



View source

Update the value of the metric using trajectory.

The trajectory can be either batched or un-batched depending on the expected inputs for the py_metric being wrapped.

trajectory A tf_agents.trajectory.Trajectory.

The arguments, for easy chaining.


View source

Initializes this Metric's variables.

Should be called after variables are created in the first execution of __call__(). If using graph execution, the return value should be run() in a session before running the op returned by __call__(). (See example above.)

If using graph execution, this returns an op to perform the initialization. Under eager execution, the variables are reset to their initial values as a side effect and this function returns None.


View source

Resets the values being tracked by the metric.


View source

Computes and returns a final value for the metric.


View source

Generates summaries against train_step and all step_metrics.

train_step (Optional) Step counter for training iterations. If None, no metric is generated against the global step.
step_metrics (Optional) Iterable of step metrics to generate summaries against.

A list of summaries.


View source

Returns op to execute to update this metric for these inputs.

Returns None if eager execution is enabled. Returns a graph-mode function if graph execution is enabled.


**kwargs A mini-batch of inputs to the Metric, passed on to call().