tf_agents.bandits.metrics.tf_metrics.SuboptimalArmsMetric
Stay organized with collections
Save and categorize content based on your preferences.
Computes the number of suboptimal arms with respect to a baseline.
Inherits From: TFStepMetric
tf_agents.bandits.metrics.tf_metrics.SuboptimalArmsMetric(
baseline_action_fn: Callable[[tf_agents.typing.types.Tensor
], tf_agents.typing.types.Tensor
],
name: Optional[Text] = 'SuboptimalArmsMetric',
dtype: float = tf.float32
)
Args |
baseline_action_fn
|
function that computes the action used as a baseline
for computing the metric.
|
name
|
(str) name of the metric
|
dtype
|
dtype of the metric value.
|
Methods
call
View source
call(
trajectory
)
Update the metric value.
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.
[null,null,["Last updated 2024-04-26 UTC."],[],[],null,["# tf_agents.bandits.metrics.tf_metrics.SuboptimalArmsMetric\n\n\u003cbr /\u003e\n\n|-----------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/agents/blob/v0.19.0/tf_agents/bandits/metrics/tf_metrics.py#L84-L126) |\n\nComputes the number of suboptimal arms with respect to a baseline.\n\nInherits From: [`TFStepMetric`](../../../../tf_agents/metrics/tf_metric/TFStepMetric) \n\n tf_agents.bandits.metrics.tf_metrics.SuboptimalArmsMetric(\n baseline_action_fn: Callable[[../../../../tf_agents/typing/types/Tensor], ../../../../tf_agents/typing/types/Tensor],\n name: Optional[Text] = 'SuboptimalArmsMetric',\n dtype: float = tf.float32\n )\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|----------------------|--------------------------------------------------------------------------------|\n| `baseline_action_fn` | function that computes the action used as a baseline for computing the metric. |\n| `name` | (str) name of the metric |\n| `dtype` | dtype of the metric value. |\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/bandits/metrics/tf_metrics.py#L109-L123) \n\n call(\n trajectory\n )\n\nUpdate the metric value.\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_metric.py#L53-L55) \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/bandits/metrics/tf_metrics.py#L125-L126) \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"]]