tf_agents.metrics.py_metrics.EnvironmentSteps
Stay organized with collections
Save and categorize content based on your preferences.
Counts the number of steps taken in the environment.
Inherits From: PyStepMetric
, PyMetric
tf_agents.metrics.py_metrics.EnvironmentSteps(
name: Text = 'EnvironmentSteps'
)
Used in the notebooks
Attributes |
prefix
|
Prefix for the metric.
|
summary_op
|
TF summary op for this metric.
|
summary_placeholder
|
TF placeholder to be used for the result of this metric.
|
Methods
aggregate
View source
@staticmethod
aggregate(
metrics: Sequence[tf_agents.metrics.py_metric.PyMetricType
]
) -> tf_agents.typing.types.Float
Aggregates a list of metrics.
The default behaviour is to return the average of the metrics.
Args |
metrics
|
a list of metrics, of the same class.
|
Returns |
The result of aggregating this metric.
|
call
View source
call(
trajectory: tf_agents.trajectories.Trajectory
)
Processes a trajectory to update the metric.
Args |
trajectory
|
A trajectory.Trajectory.
|
log
View source
log()
reset
View source
reset(
environment_steps: int = 0
)
Resets internal stat gathering variables used to compute the metric.
result
View source
result() -> np.int64
Evaluates the current value of the metric.
tf_summaries
View source
tf_summaries(
train_step: tf_agents.typing.types.Int
= None,
step_metrics: Sequence[tf_agents.metrics.py_metric.MetricType
] = ()
) -> tf.Operation
Build TF summary op and placeholder for this metric.
To execute the op, call py_metric.run_summaries.
Args |
train_step
|
Step counter for training iterations. If None, no metric is
generated against the global step.
|
step_metrics
|
Step values to plot as X axis in addition to global_step.
|
Raises |
RuntimeError
|
If this method has already been called (it can only be
called once).
|
ValueError
|
If any item in step_metrics is not of type PyMetric or
tf_metric.TFStepMetric.
|
__call__
View source
__call__(
*args
)
Method to update the metric contents.
To change the behavior of this function, override the call method.
Different subclasses might use this differently. For instance, the
PyStepMetric takes in a trajectory, while the CounterMetric takes no
parameters.
Args |
*args
|
See call method of subclass for specific arguments.
|
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.py_metrics.EnvironmentSteps\n\n\u003cbr /\u003e\n\n|----------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/agents/blob/v0.19.0/tf_agents/metrics/py_metrics.py#L234-L254) |\n\nCounts the number of steps taken in the environment.\n\nInherits From: [`PyStepMetric`](../../../tf_agents/metrics/py_metric/PyStepMetric), [`PyMetric`](../../../tf_agents/metrics/py_metric/PyMetric) \n\n tf_agents.metrics.py_metrics.EnvironmentSteps(\n name: Text = 'EnvironmentSteps'\n )\n\n### Used in the notebooks\n\n| Used in the tutorials |\n|------------------------------------------------------------------------------------------------------------------|\n| - [SAC minitaur with the Actor-Learner API](https://www.tensorflow.org/agents/tutorials/7_SAC_minitaur_tutorial) |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Attributes ---------- ||\n|-----------------------|----------------------------------------------------------|\n| `prefix` | Prefix for the metric. |\n| `summary_op` | TF summary op for this metric. |\n| `summary_placeholder` | TF placeholder to be used for the result of this metric. |\n\n\u003cbr /\u003e\n\nMethods\n-------\n\n### `aggregate`\n\n[View source](https://github.com/tensorflow/agents/blob/v0.19.0/tf_agents/metrics/py_metric.py#L186-L198) \n\n @staticmethod\n aggregate(\n metrics: Sequence[../../../tf_agents/metrics/py_metric#PyMetricType]\n ) -\u003e ../../../tf_agents/typing/types/Float\n\nAggregates a list of metrics.\n\nThe default behaviour is to return the average of the metrics.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ||\n|-----------|---------------------------------------|\n| `metrics` | a list of metrics, of the same class. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ||\n|---|---|\n| The result of aggregating this metric. ||\n\n\u003cbr /\u003e\n\n### `call`\n\n[View source](https://github.com/tensorflow/agents/blob/v0.19.0/tf_agents/metrics/py_metrics.py#L249-L254) \n\n call(\n trajectory: ../../../tf_agents/trajectories/Trajectory\n )\n\nProcesses a trajectory to update the metric.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ||\n|--------------|--------------------------|\n| `trajectory` | A trajectory.Trajectory. |\n\n\u003cbr /\u003e\n\n### `log`\n\n[View source](https://github.com/tensorflow/agents/blob/v0.19.0/tf_agents/metrics/py_metric.py#L103-L105) \n\n log()\n\n### `reset`\n\n[View source](https://github.com/tensorflow/agents/blob/v0.19.0/tf_agents/metrics/py_metrics.py#L243-L244) \n\n reset(\n environment_steps: int = 0\n )\n\nResets internal stat gathering variables used to compute the metric.\n\n### `result`\n\n[View source](https://github.com/tensorflow/agents/blob/v0.19.0/tf_agents/metrics/py_metrics.py#L246-L247) \n\n result() -\u003e np.int64\n\nEvaluates the current value of the metric.\n\n### `tf_summaries`\n\n[View source](https://github.com/tensorflow/agents/blob/v0.19.0/tf_agents/metrics/py_metric.py#L107-L165) \n\n tf_summaries(\n train_step: ../../../tf_agents/typing/types/Int = None,\n step_metrics: Sequence[../../../tf_agents/metrics/py_metric/MetricType] = ()\n ) -\u003e tf.Operation\n\nBuild TF summary op and placeholder for this metric.\n\nTo execute the op, call py_metric.run_summaries.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ||\n|----------------|------------------------------------------------------------------------------------------------|\n| `train_step` | Step counter for training iterations. If None, no metric is generated against the global step. |\n| `step_metrics` | Step values to plot as X axis in addition to global_step. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ||\n|---|---|\n| The summary op. ||\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Raises ||\n|----------------|--------------------------------------------------------------------------------|\n| `RuntimeError` | If this method has already been called (it can only be called once). |\n| `ValueError` | If any item in step_metrics is not of type PyMetric or tf_metric.TFStepMetric. |\n\n\u003cbr /\u003e\n\n### `__call__`\n\n[View source](https://github.com/tensorflow/agents/blob/v0.19.0/tf_agents/metrics/py_metric.py#L200-L212) \n\n __call__(\n *args\n )\n\nMethod to update the metric contents.\n\nTo change the behavior of this function, override the call method.\n\nDifferent subclasses might use this differently. For instance, the\nPyStepMetric takes in a trajectory, while the CounterMetric takes no\nparameters.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ||\n|---------|-----------------------------------------------------|\n| `*args` | See call method of subclass for specific arguments. |\n\n\u003cbr /\u003e"]]