ray.rllib.utils.metrics.metrics_logger.MetricsLogger.log_value#
- MetricsLogger.log_value(key: str | Tuple[str, ...], value: Any, *, reduce: str | None = None, window: int | float | None = None, ema_coeff: float | None = None, percentiles: List[int] | bool | None = None, clear_on_reduce: bool | None = -1, with_throughput: bool | None = None, throughput_ema_coeff: float | None = -1, reduce_per_index_on_aggregate: bool | None = -1, **kwargs: Dict[str, Any]) None[source]#
Logs a new value or item under a (possibly nested) key to the logger.
- Parameters:
key – The key (or nested key-tuple) to log the
valueunder.value – A numeric value, an item to log or a StatsObject containing multiple values to log.
reduce – The reduction method to apply when compiling metrics at the root logger. By default, the reduction methods to choose from here are the keys of rllib.utils.metrics.metrics_logger.DEFAULT_STATS_CLS_LOOKUP. You can provide your own reduce methods by extending rllib.utils.metrics.metrics_logger.DEFAULT_STATS_CLS_LOOKUP and passing it to AlgorithmConfig.logging()).
window – An optional window size to reduce over. If not None, then the reduction operation is only applied to the most recent
windowitems, and - after reduction - the internal values list underkeyis shortened to hold at mostwindowitems (the most recent ones). Must be None ifema_coeffis provided. If None (andema_coeffis None), reduction must not be “mean”.ema_coeff – An optional EMA coefficient to use if
reduceis “mean” and nowindowis provided. Note that if bothwindowandema_coeffare provided, an error is thrown. Also, ifema_coeffis provided,reducemust be “mean”. The reduction formula for EMA is: EMA(t1) = (1.0 - ema_coeff) * EMA(t0) + ema_coeff * new_value Defaults to 0.01.percentiles – If reduce is
None, we can compute the percentiles of the values list given bypercentiles. Defaults to [0, 0.5, 0.75, 0.9, 0.95, 0.99, 1] if set to True. When using percentiles, a window must be provided. This window should be chosen carefully. RLlib computes exact percentiles and the computational complexity is O(m*n*log(n/m)) where n is the window size and m is the number of parallel metrics loggers involved (for example, m EnvRunners).clear_on_reduce – Deprecated. Use reduce=”lifetime_sum” instead. If True, all values under
keywill be cleared afterself.reduce()is called. Setting this to True is useful for cases, in which the internal values list would otherwise grow indefinitely, for example if reduce is None and there is nowindowprovided.with_throughput – Whether to track a throughput estimate together with this metric. This is supported by default only for
reduce=sumandreduce=lifetime_sum.throughput_ema_coeff – Deprecated argument. Throughput is not smoothed with ema anymore but calculate once per MetricsLogger.reduce() call.
reduce_per_index_on_aggregate – Deprecated argument. Aggregation now happens over all values of incoming stats objects once per MetricsLogger.reduce() call, treating each incoming value with equal weight.