tf_agents.metrics.tf_py_metric.TFPyMetric
Stay organized with collections
Save and categorize content based on your preferences.
Wraps a python metric as a TF metric.
Inherits From: TFStepMetric
tf_agents.metrics.tf_py_metric.TFPyMetric(
py_metric, name=None, dtype=tf.float32
)
Args |
py_metric
|
A batched python metric to wrap.
|
name
|
Name of the metric.
|
dtype
|
Data type of the metric.
|
Methods
call
View source
call(
trajectory
)
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.
Args |
trajectory
|
A tf_agents.trajectory.Trajectory.
|
Returns |
The arguments, for easy chaining.
|
init_variables
View source
init_variables()
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.)
Returns |
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.
|
reset
View source
reset()
Resets the values being tracked by the metric.
result
View source
result()
Computes and returns a final value for the metric.
tf_summaries
View source
tf_summaries(
train_step=None, step_metrics=()
)
Generates summaries against train_step and all step_metrics.
Args |
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.
|
Returns |
A list of summaries.
|
__call__
View source
__call__(
*args, **kwargs
)
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.
Args |
*args
|
|
**kwargs
|
A mini-batch of inputs to the Metric, passed on to call() .
|
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-04-26 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-04-26 UTC."],[],[],null,["# tf_agents.metrics.tf_py_metric.TFPyMetric\n\n\u003cbr /\u003e\n\n|-----------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/agents/blob/v0.19.0/tf_agents/metrics/tf_py_metric.py#L40-L103) |\n\nWraps a python metric as a TF metric.\n\nInherits From: [`TFStepMetric`](../../../tf_agents/metrics/tf_metric/TFStepMetric) \n\n tf_agents.metrics.tf_py_metric.TFPyMetric(\n py_metric, name=None, dtype=tf.float32\n )\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|-------------|----------------------------------|\n| `py_metric` | A batched python metric to wrap. |\n| `name` | Name of the metric. |\n| `dtype` | Data type of the metric. |\n\n\u003cbr /\u003e\n\nMethods\n-------\n\n### `call`\n\n[View source](https://github.com/tensorflow/agents/blob/v0.19.0/tf_agents/metrics/tf_py_metric.py#L57-L84) \n\n call(\n trajectory\n )\n\nUpdate the value of the metric using trajectory.\n\nThe trajectory can be either batched or un-batched depending on\nthe expected inputs for the py_metric being wrapped.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ||\n|--------------|------------------------------------|\n| `trajectory` | A tf_agents.trajectory.Trajectory. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ||\n|---|---|\n| The arguments, for easy chaining. ||\n\n\u003cbr /\u003e\n\n### `init_variables`\n\n[View source](https://github.com/tensorflow/agents/blob/v0.19.0/tf_agents/metrics/tf_metric.py#L61-L75) \n\n init_variables()\n\nInitializes this Metric's variables.\n\nShould be called after variables are created in the first execution\nof `__call__()`. If using graph execution, the return value should be\n`run()` in a session before running the op returned by `__call__()`.\n(See example above.)\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ||\n|---|---|\n| 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. ||\n\n\u003cbr /\u003e\n\n### `reset`\n\n[View source](https://github.com/tensorflow/agents/blob/v0.19.0/tf_agents/metrics/tf_py_metric.py#L98-L103) \n\n reset()\n\nResets the values being tracked by the metric.\n\n### `result`\n\n[View source](https://github.com/tensorflow/agents/blob/v0.19.0/tf_agents/metrics/tf_py_metric.py#L86-L96) \n\n result()\n\nComputes and returns a final value for the metric.\n\n### `tf_summaries`\n\n[View source](https://github.com/tensorflow/agents/blob/v0.19.0/tf_agents/metrics/tf_metric.py#L94-L126) \n\n tf_summaries(\n train_step=None, step_metrics=()\n )\n\nGenerates summaries against train_step and all step_metrics.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ||\n|----------------|-----------------------------------------------------------------------------------------------------------|\n| `train_step` | (Optional) Step counter for training iterations. If None, no metric is generated against the global step. |\n| `step_metrics` | (Optional) Iterable of step metrics to generate summaries against. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ||\n|---|---|\n| A list of summaries. ||\n\n\u003cbr /\u003e\n\n### `__call__`\n\n[View source](https://github.com/tensorflow/agents/blob/v0.19.0/tf_agents/metrics/tf_metric.py#L82-L92) \n\n __call__(\n *args, **kwargs\n )\n\nReturns op to execute to update this metric for these inputs.\n\nReturns None if eager execution is enabled.\nReturns a graph-mode function if graph execution is enabled.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ||\n|------------|--------------------------------------------------------------|\n| `*args` | \u003cbr /\u003e \u003cbr /\u003e |\n| `**kwargs` | A mini-batch of inputs to the Metric, passed on to `call()`. |\n\n\u003cbr /\u003e"]]