View source on GitHub
|
Computes the regret with respect to a baseline.
Inherits From: TFStepMetric
tf_agents.bandits.metrics.tf_metrics.RegretMetric(
baseline_reward_fn: Callable[[tf_agents.typing.types.Tensor], tf_agents.typing.types.Tensor],
name: Optional[Text] = 'RegretMetric',
dtype: float = tf.float32
)
Used in the notebooks
| Used in the tutorials |
|---|
Args | |
|---|---|
baseline_reward_fn
|
function that computes the reward used as a baseline for computing the regret. |
name
|
(str) name of the metric |
dtype
|
dtype of the metric value. |
Methods
call
call(
trajectory
)
Update the regret value.
| Args | |
|---|---|
trajectory
|
A tf_agents.trajectory.Trajectory |
| Returns | |
|---|---|
| The arguments, for easy chaining. |
init_variables
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
reset()
Resets the values being tracked by the metric.
result
result()
Computes and returns a final value for the metric.
tf_summaries
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__
__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().
|
View source on GitHub